Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jeromelaban/fonderie
A source generator for the INotifyPropertyChanged interface using the Uno.SourceGeneration framework
https://github.com/jeromelaban/fonderie
csharp dotnet roslyn source-generation
Last synced: 2 months ago
JSON representation
A source generator for the INotifyPropertyChanged interface using the Uno.SourceGeneration framework
- Host: GitHub
- URL: https://github.com/jeromelaban/fonderie
- Owner: jeromelaban
- Created: 2019-12-09T02:34:08.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2020-09-17T23:41:26.000Z (about 4 years ago)
- Last Synced: 2024-09-14T22:02:05.047Z (3 months ago)
- Topics: csharp, dotnet, roslyn, source-generation
- Language: C#
- Homepage:
- Size: 28.3 KB
- Stars: 16
- Watchers: 3
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
Awesome Lists containing this project
- RSCG_Examples - fonderie
README
## 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](https://jaylee.org/archive/2019/12/08/roslyn-sourcegeneration-reborn-replace-inotifypropertychanged.html).
### How to use it
Add the following attribute in your source:
```csharp
namespace Fonderie
{
public class GeneratedPropertyAttribute : Attribute { }
}
```Add a reference to [`Fonderie.INPC.Generator`](https://www.nuget.org/packages/Fonderie.INPC.Generator), the add the following class :
```csharp
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](https://jaylee.org/archive/2020/09/13/msbuild-items-and-properties-in-csharp9-sourcegenerators.html).