Roslyn Analyzer/Generator for avoid boring boilerplate INotifyPropertyChanged implementation.
You can donwload from NuGet, NotifyPropertyChangedGenerator.
- PM> Install-Package NotifyPropertyChangedGenerator
Supports platforms are all and all .NET Framework(3.5 supports!) but requires Visual Studio 2015.
- Super lightweight to write INotifyPropertyChanged
- Keeping code clean in view
- Being strong in a change
- POMO(Plain Old MVVM Object), you don't need inherit base class
Static analyzed. NotifyAttribute
to class or NotifyAttribute
to property, Roslyn Analyzer checks are all target properties implemented(generated) Notify property. If not, output compiler error.
If set NotifyAttribute
to class, target properties are all property. You can ignore set NonNotifyAttribute
to nontarget property. If set NotifyAttribute
only to property, its target property is opt-in.
Press Ctrl+.
(Lightbulb QuickFix), preview the change.
The modified class is clean, noisy boilerplate codes are lower in the code, not around a property.
Default naming rule of backing field is plain lowerCase. If you want to change _lowerCase, configure NotifyAttribute.cs
's interface for example to LeadingUnserscore is here.
[Conditional("NEVER_USED_AT_RUNTIME")]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property, AllowMultiple = false, Inherited = false)]
internal sealed class NotifyAttribute : Attribute,
// option, you can customize naming convention rule
NotifyAttribute.ILeadingUnderscore
{
// naming convention markers
internal interface IPlain { }
internal interface ILeadingUnderscore { }
internal interface ITrailingUnderscore { }
/// <summary>
/// No option.
/// </summary>
public NotifyAttribute() { }
/// <summary>
/// Specify options.
/// </summary>
/// <param name="compareMethod">Comppare kind for raise property changed.</param>
public NotifyAttribute(NotifyCompareMethod compareMethod) { }
}
Code snippet is easy to write but difficult to read. Generated code is very noisy because code snippet does not support that generate to separating.
There are easy to write and easy to read but difficult to build and debug. NotifyPropertyChangedGenerator is only simple compile time analyze/generator and fully Visual Studio integrated.