You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This issue tracks adding support for partial properties to the [ObservableProperty] generator. This is blocked on dotnet/csharplang#6420, so support for this will have to wait for that first (hopefully in the C# 12 timeframe).
API breakdown
The changes are pretty straightforward: properties will also be allowed on [ObservableProperty]:
/// <inheritdoc cref="_itemsSource"/>[global::System.CodeDom.Compiler.GeneratedCode("CommunityToolkit.Mvvm.SourceGenerators.ObservablePropertyGenerator","8.1.0.0")][global::System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage]publicpartialstringName{get=> field;set{if(!global::System.Collections.Generic.EqualityComparer<string>.Default.Equals(field,value)){OnNameChanging(value);OnPropertyChanging(global::CommunityToolkit.Mvvm.ComponentModel.__Internals.__KnownINotifyPropertyChangingArgs.Name);field=value;OnItemsSourceChanged(value);OnNameChanged(global::CommunityToolkit.Mvvm.ComponentModel.__Internals.__KnownINotifyPropertyChangedArgs.Name);}}}/// <summary>Executes the logic for when <see cref="Name"/> is changing.</summary>[global::System.CodeDom.Compiler.GeneratedCode("CommunityToolkit.Mvvm.SourceGenerators.ObservablePropertyGenerator","8.1.0.0")]partialvoidOnNameChanging(stringvalue);/// <summary>Executes the logic for when <see cref="Name"/> just changed.</summary>[global::System.CodeDom.Compiler.GeneratedCode("CommunityToolkit.Mvvm.SourceGenerators.ObservablePropertyGenerator","8.1.0.0")]partialvoidOnNameChanged(stringvalue);
This will also enable support for declaring custom accessibility modifiers for property accessors.
Progress tracking
Initial code generation support
Add analyzer for C# preview
Add analyzer to use partial properties instead of fields
Add code fixer to convert fields to partial properties
Add analyzer for partial property declarations
Add analyzer for unsupported Roslyn version for properties
Update all titles/descriptions of existing shared diagnostics
Overview
This issue tracks adding support for partial properties to the
[ObservableProperty]generator. This is blocked on dotnet/csharplang#6420, so support for this will have to wait for that first (hopefully in the C# 12 timeframe).API breakdown
The changes are pretty straightforward: properties will also be allowed on
[ObservableProperty]:Analyzers will also need to be added to ensure that the annotated properties are partial and valid.
Usage example
Code like this:
Will generate the following:
This will also enable support for declaring custom accessibility modifiers for property accessors.
Progress tracking