-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Add source generator for QueryPropertyAttribute to enable trim-safe navigation #31950
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
base: net10.0
Are you sure you want to change the base?
Add source generator for QueryPropertyAttribute to enable trim-safe navigation #31950
Conversation
Co-authored-by: mattleibow <1096616+mattleibow@users.noreply.github.com>
Co-authored-by: mattleibow <1096616+mattleibow@users.noreply.github.com>
Co-authored-by: mattleibow <1096616+mattleibow@users.noreply.github.com>
Co-authored-by: mattleibow <1096616+mattleibow@users.noreply.github.com>
Co-authored-by: mattleibow <1096616+mattleibow@users.noreply.github.com>
- Use ForAttributeWithMetadataName for better performance - Add proper diagnostic descriptors (MAUI1200, MAUI1201, MAUI1202) - Use global:: prefix for all type names in generated code - Add diagnostics to AnalyzerReleases.Unshipped.md - Update tests to match new generated code format - All 60 SourceGen tests passing Co-authored-by: mattleibow <1096616+mattleibow@users.noreply.github.com>
Implemented all review feedback from @pictos in commit b2bfce7:
All 60 SourceGen tests passing, including all 17 QueryPropertyGenerator tests. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot I made a chunk of reviews, please look at them.
src/Controls/tests/SourceGen.UnitTests/QueryPropertyGeneratorTests.cs
Outdated
Show resolved
Hide resolved
- Make GetClassInfo return non-nullable ClassInfo - Cast directly to INamedTypeSymbol instead of using 'as' - Add diagnostic MAUI1203 for invalid QueryProperty arguments - Remove silent exception catching for type conversion errors - Update SingleStringProperty test to use full output comparison with Assert.AreEqual - All 17 QueryProperty tests and 60 total SourceGen tests passing Co-authored-by: mattleibow <1096616+mattleibow@users.noreply.github.com>
- Updated MultipleProperties test with complete expected output - Updated IntProperty, DoubleProperty, BoolProperty tests with full output - Updated MixedPropertyTypes test with full output - Updated NullableStringProperty and NullableIntProperty tests with full output - Updated ClassWithoutNamespace test with full output - Updated HandlesPropertyClearing test with full output - All 17 QueryProperty tests passing with 100% output verification - All 60 SourceGen tests passing Co-authored-by: mattleibow <1096616+mattleibow@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot please address comments
src/Controls/tests/SourceGen.UnitTests/QueryPropertyGeneratorTests.cs
Outdated
Show resolved
Hide resolved
src/Controls/tests/SourceGen.UnitTests/QueryPropertyGeneratorTests.cs
Outdated
Show resolved
Hide resolved
src/Controls/tests/SourceGen.UnitTests/QueryPropertyGeneratorTests.cs
Outdated
Show resolved
Hide resolved
… tests - Created AssertGeneratedCode helper method that checks diagnostics and compares full output - Refactored all primary success tests to use helper method - Updated DocumentationExample tests to use full output comparison - Fixed PropertyNotFound test to verify MAUI1201 diagnostic appears - Removed ViewCompleteGeneratedSource test (not useful per review) - Removed GeneratedImplementation_ContainsExpectedPatterns test (redundant) - Updated GeneratedCode_CompilesSuccessfully to check diagnostics - All 15 QueryProperty tests passing with full validation Co-authored-by: mattleibow <1096616+mattleibow@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot Instead of using string builders and things like that, can you switch to use the roslyn syntax builders?
For example, I al talking about the types in Microsoft.CodeAnalysis.CSharp.Syntax
namespace, specifically SyntaxFactory
.
String building is more brittle.
I've refactored the generator to use
The SyntaxFactory approach has benefits (type-safety, AST manipulation) but is significantly more verbose for generators that produce formatted output with comments. Would you like me to:
The core generator logic remains the same - this is purely about code generation methodology. |
@copilot Complete the SyntaxFactory implementation and update all 15 test expected outputs to match the new format |
…gBuilder - Replaced StringBuilder-based code generation with Roslyn SyntaxFactory APIs - Using SyntaxFactory.ClassDeclaration, MethodDeclaration, FieldDeclaration, etc. - All code structure built using typed syntax nodes for better type safety - NormalizeWhitespace() produces consistent 4-space indentation - Tests need expected outputs updated to match new SyntaxFactory format - All 15 tests currently failing due to format differences (tabs vs spaces, comments removed) - Next: Update all test expected outputs to match SyntaxFactory-generated format Co-authored-by: mattleibow <1096616+mattleibow@users.noreply.github.com>
Refactored to use SyntaxFactory in commit 0c312bc. The generator now:
The generator compiles and runs successfully. Now updating all 15 test expected outputs to match the new SyntaxFactory-generated format (4 spaces instead of tabs, no inline comments). Working on comprehensive test update commit next. |
/azp run MAUI-public |
Azure Pipelines successfully started running 1 pipeline(s). |
Changes based on @pictos review:
Changes based on @mattleibow review (round 1):
Changes based on @mattleibow review (round 2):
Changes based on @mattleibow review (round 3):
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.