EasyStyledProperty 1.0.3

dotnet add package EasyStyledProperty --version 1.0.3
                    
NuGet\Install-Package EasyStyledProperty -Version 1.0.3
                    
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="EasyStyledProperty" Version="1.0.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="EasyStyledProperty" Version="1.0.3" />
                    
Directory.Packages.props
<PackageReference Include="EasyStyledProperty" />
                    
Project file
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 EasyStyledProperty --version 1.0.3
                    
#r "nuget: EasyStyledProperty, 1.0.3"
                    
#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 EasyStyledProperty@1.0.3
                    
#: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=EasyStyledProperty&version=1.0.3
                    
Install as a Cake Addin
#tool nuget:?package=EasyStyledProperty&version=1.0.3
                    
Install as a Cake Tool

EasyStyledProperty# Roslyn Source Generators Sample

用于 Avalonia 的 StyledProperty 源生成器,让您通过简单的特性标注自动生成 StyledProperty 和属性代码。A set of three projects that illustrates Roslyn source generators. Enjoy this template to learn from and modify source generators for your own needs.

安装## Content

SourceGenerators


dotnet add package EasyStyledProperty**You must build this project to see the result (generated code) in the IDE.**

  • SampleSourceGenerator.cs: A source generator that creates C# classes based on a text file (in this case, Domain Driven Design ubiquitous language registry).

使用方法- SampleIncrementalSourceGenerator.cs: A source generator that creates a custom report based on class properties. The target class should be annotated with the Generators.ReportAttribute attribute.

1. 在您的 Avalonia 控件类上添加特性### SourceGenerators.Sample

A project that references source generators. Note the parameters of ProjectReference in SourceGenerators.Sample.csproj, they make sure that the project is referenced as a set of source generators.


using EasyStyledProperty;### SourceGenerators.Tests

Unit tests for source generators. The easiest way to develop language-related features is to start with unit tests.

[StyledProperty("Text", typeof(string), "默认文本")]

[StyledProperty("IsEnabled", typeof(bool), true)]## How To?

[StyledProperty("FontSize", typeof(double), 14.0)]### How to debug?

public partial class MyControl : AvaloniaObject- Use the [launchSettings.json](Properties/launchSettings.json) profile.

{- Debug tests.

    // 源生成器会自动生成:

    // - public static readonly StyledProperty<string> TextProperty### How can I determine which syntax nodes I should expect?

    // - public string Text { get; set; }Consider using the Roslyn Visualizer toolwindow, witch allow you to observe syntax tree.

    // - public static readonly StyledProperty<bool> IsEnabledProperty

    // - public bool IsEnabled { get; set; }### How to learn more about wiring source generators?

    // - public static readonly StyledProperty<double> FontSizePropertyWatch the walkthrough video: [Let’s Build an Incremental Source Generator With Roslyn, by Stefan Pölz](https://youtu.be/azJm_Y2nbAI)

    // - public double FontSize { get; set; }The complete set of information is available in [Source Generators Cookbook](https://github.com/dotnet/roslyn/blob/main/docs/features/source-generators.cookbook.md).
}

2. 高级选项

[StyledProperty("Command", typeof(ICommand), null, 
    BindsTwoWayByDefault = true,
    PropertyChangedCallback = "OnCommandChanged",
    CoerceCallback = "CoerceCommand")]
public partial class MyButton : Button
{
    private static void OnCommandChanged(AvaloniaObject obj, AvaloniaPropertyChangedEventArgs args)
    {
        // 属性变更回调
    }

    private static object CoerceCommand(AvaloniaObject obj, object value)
    {
        // 值强制转换
        return value;
    }
}

特性参数

  • PropertyName: 属性名称
  • PropertyType: 属性类型
  • DefaultValue: 默认值(可选)
  • BindsTwoWayByDefault: 是否默认双向绑定(可选,默认 false)
  • PropertyChangedCallback: 属性变更回调方法名(可选)
  • CoerceCallback: 值强制转换回调方法名(可选)

依赖

需要在您的项目中安装:

  • Avalonia >= 11.0.0
  • FluentIcons.Avalonia >= 1.1.0

许可证

MIT License

作者

HU

There are no supported framework assets in this package.

Learn more about Target Frameworks and .NET Standard.

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
1.0.3 290 11/13/2025
1.0.1 305 11/13/2025
1.0.0 287 11/13/2025