Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ufcpp/ValueChangedGenerator
Roslyn Code Fix / Source Generator for generating PropertyChanged from inner struct members.
https://github.com/ufcpp/ValueChangedGenerator
csharp-sourcegenerator
Last synced: about 1 month ago
JSON representation
Roslyn Code Fix / Source Generator for generating PropertyChanged from inner struct members.
- Host: GitHub
- URL: https://github.com/ufcpp/ValueChangedGenerator
- Owner: ufcpp
- License: mit
- Created: 2015-06-12T11:03:10.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2023-07-07T04:42:54.000Z (over 1 year ago)
- Last Synced: 2024-05-28T12:21:53.622Z (7 months ago)
- Topics: csharp-sourcegenerator
- Language: C#
- Homepage:
- Size: 216 KB
- Stars: 12
- Watchers: 4
- Forks: 4
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- csharp-source-generators - ValueChangedGenerator - ![stars](https://img.shields.io/github/stars/ufcpp/ValueChangedGenerator?style=flat-square&cacheSeconds=604800) ![last commit](https://img.shields.io/github/last-commit/ufcpp/ValueChangedGenerator?style=flat-square&cacheSeconds=86400) for generating PropertyChanged from inner struct members. (Source Generators / XAML / WPF / Avalonia)
- RSCG_Examples - ValueChangedGenerator
README
# ValueChangedGenerator
A Roslyn Code Fix provider for generating PropertyChanged from inner struct members.
This inlcudes VSIX and NuGet packages of an analyzer created by using .NET Compiler Platform (Roslyn).
Code Fix version (C# 6.0)
- VSIX: https://visualstudiogallery.msdn.microsoft.com/bf5dbce2-b73d-4f5f-8e1c-0e1de386b7ce
- NuGet: https://www.nuget.org/packages/ValueChangedGenerator/Source Generator version (C# 9.0)
- NuGet: https://www.nuget.org/packages/ValueChangedGenerator.SourceGenerator/
## Usage
- Insert an inner struct named `NotifyRecord` into a class that you want to generete its properties.
- Use 'Quick Action' (Lightbulb) to fix the code![screenshot](https://github.com/ufcpp/ValueChangedGenerator/blob/master/ValueChangedGenerator/ValueChangedGenerator/ValueChangedGenerator.Vsix/Screenshot.png)
## Sample
original source:
```cs
class Point : BindableBase
{
struct NotifyRecord
{
public int X;
public int Y;
public int Z => X * Y;///
/// Name.
///
public string Name;
}
}
```fixed result of the original source (`partial` modifier added):
```cs
partial class Point : BindableBase
{
struct NotifyRecord
{
public int X;
public int Y;
public int Z => X * Y;///
/// Name.
///
public string Name;
}
}
```the generetated source code:
```cs
using System.ComponentModel;partial class Point
{
private NotifyRecord _value;public int X { get { return _value.X; } set { SetProperty(ref _value.X, value, XProperty); OnPropertyChanged(ZProperty); } }
private static readonly PropertyChangedEventArgs XProperty = new PropertyChangedEventArgs(nameof(X));
public int Y { get { return _value.Y; } set { SetProperty(ref _value.Y, value, YProperty); OnPropertyChanged(ZProperty); } }
private static readonly PropertyChangedEventArgs YProperty = new PropertyChangedEventArgs(nameof(Y));///
/// Name.
///
public string Name { get { return _value.Name; } set { SetProperty(ref _value.Name, value, NameProperty); } }
private static readonly PropertyChangedEventArgs NameProperty = new PropertyChangedEventArgs(nameof(Name));
public int Z => _value.Z;
private static readonly PropertyChangedEventArgs ZProperty = new PropertyChangedEventArgs(nameof(Z));
}
```