GwWuYou 50a71deaa7 feat(generator): 添加枚举扩展方法生成器及相关属性
- 新增 EnumExtensionsGenerator 源生成器
- 实现 GenerateEnumExtensionsAttribute 特性标注
- 为标记的枚举自动生成 IsXXX 和 IsIn 扩展方法
- 配置项目引用及 Analyzer 打包设置
- 更新解决方案文件包含新增项目
- 调整主项目配置排除生成器相关文件编译
2025-12-10 08:39:27 +08:00

22 lines
701 B
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System;
namespace GFramework.Generator.Attributes
{
/// <summary>
/// 标注在 enum 上Source Generator 会为该 enum 生成扩展方法。
/// </summary>
[AttributeUsage(AttributeTargets.Enum)]
public sealed class GenerateEnumExtensionsAttribute : Attribute
{
/// <summary>
/// 是否为每个枚举项生成单独的 IsXXX 方法(默认 true
/// </summary>
public bool GenerateIsMethods { get; set; } = true;
/// <summary>
/// 是否生成一个 IsIn(params T[]) 方法以简化多值判断(默认 true
/// </summary>
public bool GenerateIsInMethod { get; set; } = true;
}
}