-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[XSG][BindingSourceGen] Add support for CommunityToolkit.Mvvm ObservablePropertyAttribute source generator #32955
Copy link
Copy link
Closed
Description
Similar to #32597
Related to #32953
The CommunityToolkit.Mvvm package contains a source generator which generates bindable property bolierplate code based on the [ObservableProperty] attribute: https://learn.microsoft.com/en-us/dotnet/communitytoolkit/mvvm/generators/observableproperty
Scenarios:
// applied to a field
[ObservableProperty]
private string? name;
// generated code:
/// <inheritdoc cref="_tags"/>
[global::System.CodeDom.Compiler.GeneratedCode("CommunityToolkit.Mvvm.SourceGenerators.ObservablePropertyGenerator", "8.3.0.0")]
[global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]
public global::System.Collections.ObjectModel.ObservableCollection<global::TestSampleContentBindings.Models.Tag> Tags
{
get => _tags;
[global::System.Diagnostics.CodeAnalysis.MemberNotNull("_tags")]
set
{
if (!global::System.Collections.Generic.EqualityComparer<global::System.Collections.ObjectModel.ObservableCollection<global::TestSampleContentBindings.Models.Tag>>.Default.Equals(_tags, value))
{
OnTagsChanging(value);
OnTagsChanging(default, value);
OnPropertyChanging(global::CommunityToolkit.Mvvm.ComponentModel.__Internals.__KnownINotifyPropertyChangingArgs.Tags);
_tags = value;
OnTagsChanged(value);
OnTagsChanged(default, value);
OnPropertyChanged(global::CommunityToolkit.Mvvm.ComponentModel.__Internals.__KnownINotifyPropertyChangedArgs.Tags);
}
}
}Our source generators cannot see properties generated by other source generators, so the binding compilation will fail.
Our sample content template uses this source generator and we are currently failing over to reflection-based bindings.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
xsgXaml sourceGenXaml sourceGen
Type
Projects
Status
Done