Skip to content

A source generator for the INotifyPropertyChanged interface using the Uno.SourceGeneration framework

Notifications You must be signed in to change notification settings

jeromelaban/fonderie

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Fonderie source generators

This repository is the home of Fonderie set of Roslyn generators.

These generators need at least Visual Studio 16.8 Preview 2.1 or .NET 5 Preview 8 to work properly.

Fonderie.INPC

This is repository for the INotifyPropertyChanged generator based on field discovery, using C# 9.0 source generators.

Find out more about it in this article.

How to use it

Add the following attribute in your source:

namespace Fonderie
{
    public class GeneratedPropertyAttribute : Attribute { }
}

Add a reference to Fonderie.INPC.Generator, the add the following class :

    public partial class MyClass
    {
        [GeneratedProperty]
        private string _stringProperty;

        [GeneratedProperty]
        private int _intProperty;

        private bool _otherField;

        partial void OnIntPropertyChanged(int previous, int value)
            => Console.WriteLine($"OnIntPropertyChanged({previous},{value})");

        partial void OnStringPropertyChanged(string previous, string value) 
            => Console.WriteLine($"OnIntPropertyChanged({previous},{value})");
    }

The INotifyPropertyChanged interface is automatically implemented, and XXPropertyChanged methods are generated to be notified inside the class if a property changed.

Fonderie.Resw.Generator

This generator is a sample to demonstrate the ability for Roslyn generators to use MSBuild properties and items.

Find out more in the article describing this sample.

About

A source generator for the INotifyPropertyChanged interface using the Uno.SourceGeneration framework

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages