AutoSettingUI.Generator
1.1.0
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package AutoSettingUI.Generator --version 1.1.0
NuGet\Install-Package AutoSettingUI.Generator -Version 1.1.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="AutoSettingUI.Generator" Version="1.1.0"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="AutoSettingUI.Generator" Version="1.1.0" />
<PackageReference Include="AutoSettingUI.Generator"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference>
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add AutoSettingUI.Generator --version 1.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: AutoSettingUI.Generator, 1.1.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package AutoSettingUI.Generator@1.1.0
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=AutoSettingUI.Generator&version=1.1.0
#tool nuget:?package=AutoSettingUI.Generator&version=1.1.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
AutoSettingUI.Generator
Roslyn Incremental Source Generator for AutoSettingUI - Generates AOT-compatible setting descriptors at compile time.
Installation
<PackageReference Include="AutoSettingUI.Generator" Version="1.0.0" />
What It Does
This source generator automatically generates:
GeneratedSettingProvider- ImplementsISettingDescriptorProviderGeneratedPropertyAccessor- ImplementsIPropertyValueAccessor
These generated classes enable full Native AOT and trimming support by eliminating runtime reflection.
How It Works
- At compile time, the generator scans for classes decorated with
[SettingUI] - It generates strongly-typed descriptor and accessor classes
- No runtime reflection is needed to access property metadata or values
Generated Code Example
For a settings class like:
[SettingUI]
public class AppSettings
{
[Title("Volume")]
public int Volume { get; set; } = 50;
}
The generator produces (simplified):
public partial class GeneratedSettingProvider : ISettingDescriptorProvider, IPropertyValueAccessor
{
public SettingClassDescriptor? GetDescriptor(Type type)
{
if (type == typeof(AppSettings))
return GetAppSettingsDescriptor();
// ... other types
}
private SettingClassDescriptor GetAppSettingsDescriptor()
{
return new SettingClassDescriptor
{
TargetType = typeof(AppSettings),
Properties = new[]
{
new PropertyDescriptor
{
PropertyName = "Volume",
PropertyType = typeof(int),
// ... metadata from attributes
}
}
};
}
public object? GetValue(object target, string propertyName)
{
if (target is AppSettings settings)
{
return propertyName switch
{
"Volume" => settings.Volume,
// ... other properties
};
}
return null;
}
}
Usage
// The generated class is in the AutoSettingUI.Generated namespace
panel.DescriptorProvider = new AutoSettingUI.Generated.GeneratedSettingProvider();
panel.PropertyAccessor = new AutoSettingUI.Generated.GeneratedSettingProvider();
Requirements
- .NET Standard 2.0+ compatible projects
- C# 9.0+ (for source generators support)
Related Packages
- AutoSettingUI.Core - Core attributes and interfaces
- AutoSettingUI.Avalonia - Avalonia UI panel
- AutoSettingUI.Ursa - Ursa-themed Avalonia panel
- AutoSettingUI.WPF - WPF panel
Documentation
License
MIT
There are no supported framework assets in this package.
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.0
- 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.