-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[XSG][BindingSourceGen] Add support for CommunityToolkit.Mvvm ObservablePropertyAttribute #33028
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: inflight/current
Are you sure you want to change the base?
Conversation
|
/azp run |
|
Azure Pipelines could not run because the pipeline triggers exclude this branch/path. |
045818b to
8af82a8
Compare
Co-authored-by: simonrozsival <[email protected]>
Co-authored-by: simonrozsival <[email protected]>
Co-authored-by: simonrozsival <[email protected]>
6c9d40b to
c039c1f
Compare
|
/azp run |
|
Azure Pipelines could not run because the pipeline triggers exclude this branch/path. |
simonrozsival
left a comment
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 add also a test case in Xaml.UnitTest
Co-authored-by: simonrozsival <[email protected]>
Added XAML unit tests in commit 5a2eadd. The tests cover bindings to ObservableProperty-generated properties from camelCase fields ( |
Note
Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!
Description of Change
Binding source generators now support properties generated by CommunityToolkit.Mvvm's
[ObservableProperty]attribute. Previously, bindings failed because MAUI generators cannot see properties generated by other source generators.Implementation (following PR #32954 pattern for RelayCommand):
BindingSourceGen/ITypeSymbolExtensions.cs: Added
TryGetObservablePropertyType()to detect fields with[ObservableProperty]and infer property types. Supports bothcamelCaseand_camelCasefield naming patterns.BindingSourceGen/PathParser.cs: Enhanced
TryHandleSpecialCases()to handle ObservableProperty patterns as fallback when symbol resolution fails.BindingSourceGen/BindingSourceGenerator.cs: Updated
GetLambdaReturnType()to infer types from ObservableProperty fields, enabling C# lambda bindings.SourceGen/ITypeSymbolExtensions.cs: Updated
TryGetProperty()to check ObservableProperty-inferred properties, enabling XAML string-based bindings.Tests: Added comprehensive unit tests in both
BindingSourceGen.UnitTests(7 tests) andXaml.UnitTests(3 tests) to validate ObservableProperty binding support across all scenarios and XamlInflator modes.Works for both XAML and C# bindings:
Issues Fixed
Fixes #32597
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.