The PR adds a new package, TinyLittleMvvm.Analyzers.
This package provides a new attribute TinyLittleMvvm.AutoNotifyAttribute. When applied to a private field, it will automatically generate a public property, raising the PropertyChanged event in the setter. It is based on the source generator sample AutoNotifyGenerator. However, in this implementation the setter first checks if the new value is different (using EqualityComparer<TField>.Default). Additionally it will call the partial method On{PropertyName}Changed(oldValue, newValue).
What's missing is an analyzer, which warns when you set the field directly instead of through the property.
When consuming the analyzer package in a WPF application with .NET Core SDK < 5.0.2xx, you have to set the IncludePackageReferencesDuringMarkupCompilation property on your csproj:
The PR adds a new package, TinyLittleMvvm.Analyzers.
This package provides a new attribute
TinyLittleMvvm.AutoNotifyAttribute
. When applied to a private field, it will automatically generate a public property, raising thePropertyChanged
event in the setter. It is based on the source generator sample AutoNotifyGenerator. However, in this implementation the setter first checks if the new value is different (usingEqualityComparer<TField>.Default
). Additionally it will call the partial methodOn{PropertyName}Changed(oldValue, newValue)
.What's missing is an analyzer, which warns when you set the field directly instead of through the property.
When consuming the analyzer package in a WPF application with .NET Core SDK < 5.0.2xx, you have to set the
IncludePackageReferencesDuringMarkupCompilation
property on your csproj:See https://github.com/dotnet/wpf/issues/3404 and https://github.com/dotnet/sdk/issues/15395 for details.