Git Product home page Git Product logo

notifypropertychangedgenerator's Introduction

NotifyPropertyChangedGenerator

Roslyn Analyzer/Generator for avoid boring boilerplate INotifyPropertyChanged implementation.

Installation

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.

What is this?

  • 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.

Configuration

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) { }
}

What is different with Code Snippet?

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.

What is different with PostSharp or Fody?

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.

notifypropertychangedgenerator's People

Contributors

neuecc avatar ufcpp avatar ciniml avatar

Watchers

James Cloos avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.