-
-
Notifications
You must be signed in to change notification settings - Fork 95
Fix PropertyInjection emitting invalid source code #2767
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Claude finished @thomhurst's task —— View job PR Review: Fix PropertyInjection emitting invalid source code ✅Todo List:
SummaryThis PR addresses property injection source code generation issues, specifically fixing problems with init-only properties and data source property initialization. The changes span across multiple source generators and core runtime components. Code Review Findings✅ Strengths
|
… API verification files
|
Claude finished @thomhurst's task —— View job PR Review: Fix PropertyInjection emitting invalid source codeTodo List:
SummaryThis PR fixes a PropertyInjection issue where invalid source code was being emitted. The main fix involves preventing premature object initialization during property injection and enhancing the source generation capabilities for AOT compatibility. Core Changes Analysis1. Main Fix - PropertyInjector.cs:462- await ObjectInitializer.InitializeAsync(value);
+ // Don't initialize here - it will be initialized later after all properties are set✅ Excellent Fix: This prevents premature initialization of injected objects, allowing all properties to be set before initialization occurs. This is handled later in the pipeline with proper depth ordering. 2. Enhanced DataSourceHelpersGenerator.cs (+152/-7)✅ Strong Architecture:
Minor Concerns:
3. DataSourceHelpers.cs (+34 new methods)✅ Well-designed API: New Code Quality AssessmentStrengths ✅
Best Practices ✅
Potential Issues & RecommendationsSecurity
|
… tests for abstract base class property injection
|
Claude finished @thomhurst's task —— View job PR Review: Fix PropertyInjection emitting invalid source code ✅Todo List:
SummaryThis PR successfully addresses a PropertyInjection issue where invalid source code was being emitted, particularly focusing on init-only properties and AOT compatibility. The main fix prevents premature object initialization during property injection, with enhanced source generation capabilities. Core Changes Analysis1. Main Fix - PropertyInjector.cs:140- await ObjectInitializer.InitializeAsync(value);
+ // Don't initialize here - it will be initialized later after all properties are set✅ Excellent Strategy: This prevents premature initialization, allowing all properties to be set before object initialization occurs through proper depth-based ordering (lines 155-178). 2. Enhanced DataSourceHelpersGenerator.cs (+176/-12)✅ Robust Architecture:
Key Improvements:
3. DataSourceHelpers.cs (+57 new methods)✅ Clean API Design:
4. ClassDataSources.cs Enhancement✅ Seamless Integration: Lines 128-134 show how the new type creation integrates cleanly with existing data source infrastructure. Code Quality AssessmentStrengths ✅
Architecture ✅
Technical ObservationsExcellent Patterns ✅
Performance Considerations
|
|
Claude finished @thomhurst's task —— View job PR Review: Fix PropertyInjection emitting invalid source code ✅Todo List:
SummaryThis PR successfully addresses a PropertyInjection issue where invalid source code was being emitted, particularly focusing on init-only properties and AOT compatibility. The main fix prevents premature object initialization during property injection, with enhanced source generation capabilities. Core Changes Analysis1. Main Fix - PropertyInjector.cs:140- await ObjectInitializer.InitializeAsync(value);
+ // Don't initialize here - it will be initialized later after all properties are set✅ Excellent Strategy: This prevents premature initialization, allowing all properties to be set before object initialization occurs through proper depth-based ordering (lines 155-178). 2. Enhanced DataSourceHelpersGenerator.cs (+176/-12)✅ Robust Architecture:
Key Improvements:
3. DataSourceHelpers.cs (+57 new methods)✅ Clean API Design:
4. ClassDataSources.cs Enhancement✅ Seamless Integration: Lines 128-134 show how the new type creation integrates cleanly with existing data source infrastructure. Code Quality AssessmentStrengths ✅
Architecture ✅
Technical ObservationsExcellent Patterns ✅
Performance Considerations
|
Added DynamicallyAccessedMemberTypes.PublicFields and NonPublicFields to prevent AOT compilation from trimming backing fields needed for init-only properties with data source attributes. This resolves "Could not find backing field" errors in AOT scenarios while maintaining compatibility with reflection and source generation. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
|
Claude finished @thomhurst's task —— View job PR Review: Fix PropertyInjection emitting invalid source code ✅Todo List:
SummaryThis PR successfully addresses a PropertyInjection issue where invalid source code was being emitted, particularly focusing on init-only properties and AOT compatibility. The main fix prevents premature object initialization during property injection, with enhanced source generation capabilities. Core Changes Analysis1. Main Fix - PropertyInjector.cs:140- await ObjectInitializer.InitializeAsync(value);
+ // Don't initialize here - it will be initialized later after all properties are set✅ Excellent Strategy: This prevents premature initialization, allowing all properties to be set before object initialization occurs through proper depth-based ordering (lines 155-178). 2. Enhanced DataSourceHelpersGenerator.cs (+176/-12)✅ Robust Architecture:
Key Improvements:
3. DataSourceHelpers.cs (+57 new methods)✅ Clean API Design:
4. ClassDataSources.cs Enhancement✅ Seamless Integration: Lines 128-134 show how the new type creation integrates cleanly with existing data source infrastructure. Code Quality AssessmentStrengths ✅
Architecture ✅
Technical ObservationsExcellent Patterns ✅
Performance Considerations
|
- Unified PropertySourceRegistry to serve both metadata and array-based needs - Enhanced PropertyInjectionService to handle all PropertyInjector use cases - Removed obsolete PropertyInjector and DataSourcePropertyInjectionRegistry - Fixed nested property injection in AOT mode - now works recursively - Updated all call sites to use unified PropertyInjectionService - Added proper DynamicallyAccessedMembers annotations for AOT safety The property injection system is now fully unified with a single registry and injection service that handles both source-generated (AOT) and reflection-based scenarios. Nested property injection now works correctly in AOT mode with any IDataSourceAttribute implementation. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
|
Claude finished @thomhurst's task —— View job PR Review: Fix PropertyInjection emitting invalid source code ✅Todo List:
SummaryThis PR successfully addresses a critical PropertyInjection issue where invalid source code was being emitted, particularly focusing on init-only properties and AOT compatibility. The solution represents a significant architectural improvement that unifies property injection handling while maintaining backward compatibility. Core Changes Analysis1. Architectural TransformationThe PR transforms the property injection system from a fragmented approach to a unified, source-generation-first architecture:
2. Key Technical ImprovementsEnhanced DataSourceHelpersGenerator (+176/-12 lines): // Lines 135-154: Module initializer registration ensures proper initialization order
[ModuleInitializer]
public static void Initialize()
{
// Registers both property initializers and type creators
DataSourceHelpers.RegisterPropertyInitializer<T>(InitializePropertiesAsync_T);
DataSourceHelpers.RegisterTypeCreator<T>(CreateAndInitializeAsync_T);
}Init-Only Property Support (Lines 322-430):
Runtime Registry System ( // Lines 415-429: Type creation with init-only property support
public static bool TryCreateWithInitializer(Type type, MethodMetadata testInformation, string testSessionId, out object createdInstance)Code Quality AssessmentStrengths ✅
Technical Implementation ✅
Potential Issues & RecommendationsMinor Code Quality Issues
|
Fixes #2754