NuExt.Minimal.Mvvm.SourceGenerator
0.2.4
dotnet add package NuExt.Minimal.Mvvm.SourceGenerator --version 0.2.4
NuGet\Install-Package NuExt.Minimal.Mvvm.SourceGenerator -Version 0.2.4
<PackageReference Include="NuExt.Minimal.Mvvm.SourceGenerator" Version="0.2.4" />
paket add NuExt.Minimal.Mvvm.SourceGenerator --version 0.2.4
#r "nuget: NuExt.Minimal.Mvvm.SourceGenerator, 0.2.4"
// Install NuExt.Minimal.Mvvm.SourceGenerator as a Cake Addin #addin nuget:?package=NuExt.Minimal.Mvvm.SourceGenerator&version=0.2.4 // Install NuExt.Minimal.Mvvm.SourceGenerator as a Cake Tool #tool nuget:?package=NuExt.Minimal.Mvvm.SourceGenerator&version=0.2.4
NuExt.Minimal.Mvvm.SourceGenerator
NuExt.Minimal.Mvvm.SourceGenerator
is an extension for the lightweight MVVM framework NuExt.Minimal.Mvvm. This package includes a source generator that produces boilerplate code for your ViewModels at compile time, simplifying development and reducing routine work. By automating repetitive tasks, it helps you focus on implementing application-specific logic.
Features
- Automatically generates boilerplate code for ViewModels:
- Generates properties with notification change support.
- Creates command properties for appropriate methods.
- Generates static localization classes from JSON files.
- Simplifies the development process by reducing repetitive coding tasks.
- Seamlessly integrates with the NuExt.Minimal.Mvvm framework.
- Enhances maintainability and readability of your codebase.
Installation
You can install NuExt.Minimal.Mvvm.SourceGenerator
via NuGet:
dotnet add package NuExt.Minimal.Mvvm.SourceGenerator
Or through the Visual Studio package manager:
- Go to
Tools -> NuGet Package Manager -> Manage NuGet Packages for Solution...
. - Search for
NuExt.Minimal.Mvvm.SourceGenerator
. - Click "Install".
Dependencies
To use this source generator effectively, you need to have any of these packages installed in your project: NuExt.Minimal.Mvvm
, NuExt.Minimal.Mvvm.Windows
, or NuExt.Minimal.Mvvm.MahApps.Metro
. You can add them via NuGet as well:
For the base MVVM framework:
dotnet add package NuExt.Minimal.Mvvm
For Windows-specific extensions:
dotnet add package NuExt.Minimal.Mvvm.Windows
For MahApps.Metro integration:
dotnet add package NuExt.Minimal.Mvvm.MahApps.Metro
Usage Examples
Example using auto-generated property notifications
Given a user class such as:
using Minimal.Mvvm;
using System.Threading.Tasks;
public partial class MyModel : BindableBase
{
[Notify]
private string? _description;
[Notify(Setter = AccessModifier.Private)]
private string _name;
/// <summary>
/// Opens file.
/// </summary>
[Notify("OpenFileCommand", Setter = AccessModifier.Private)]
[CustomAttribute("System.Text.Json.Serialization.JsonIgnore")]
private async Task OpenAsync(string filePath)
{
await Task.Delay(1000);
}
}
The generator could produce the following:
partial class MyModel
{
public string? Description
{
get => _description;
set => SetProperty(ref _description, value);
}
public string Name
{
get => _name;
private set => SetProperty(ref _name, value);
}
private IAsyncCommand<string>? _openFileCommand;
/// <summary>
/// Opens file.
/// </summary>
[System.Text.Json.Serialization.JsonIgnore]
public IAsyncCommand<string>? OpenFileCommand
{
get => _openFileCommand;
private set => SetProperty(ref _openFileCommand, value);
}
}
This example demonstrates how the source generator automatically creates properties with notification changes for fields and methods marked with the [Notify]
attribute, thereby reducing boilerplate code.
Contributing
Contributions are welcome! Feel free to submit issues, fork the repository, and send pull requests. Your feedback and suggestions for improvement are highly appreciated.
License
Licensed under the MIT License. See the LICENSE file for details.
Learn more about Target Frameworks and .NET Standard.
This package has no dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
0.2.4 | 39 | 11/22/2024 |