百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
E

Enum.Source.Generator

> AI 编程
开源

一个 C# 源生成器, 用于从 enum 类型创建一个计数类 。 有了这个软件包,你可以非常,非常快地在enums上工作而不使用反射.

198 stars0 点赞0 次浏览
访问官网GitHub

工具介绍

一个 C# 源生成器, 用于从 enum 类型创建一个计数类 。 有了这个软件包,你可以非常,非常快地在enums上工作而不使用反射.

Supernova.Enum.Generators

The best Source Generator for working with enums in C#

A C# source generator to create an enumeration class from an enum type. With this package, you can work on enums very, very fast without using reflection.

Package - Supernova.Enum.Generators

Add the package to your application using

bash
dotnet add package Supernova.Enum.Generators

Adding the package will automatically add a marker attribute, [EnumGenerator], to your project.

To use the generator, add the [EnumGenerator] attribute to an enum. For example:

csharp
[EnumGenerator]
public enum UserTypeTest
{
    [Display(Name = "مرد", Description = "Descمرد")] Men = 3,

    [Display(Name = "زن", Description = "Descزن")] Women = 4,

    //[Display(Name = "نامشخص")]
    None
}

This will generate a class called EnumNameEnumExtensions (UserTypeTest + EnumExtensions), which contains a number of helper methods. For example:

…

You do not see this file inside the project. But you can use it.

Usage

csharp
var stringEnum = UserTypeTest.Men.ToStringFast(); //Men;

var isDefined = UserTypeTestEnumExtensions.IsDefinedFast(UserType.Men); //true;

var displayEnum = UserTypeTest.Men.ToDisplayFast(); //مرد

var descriptionEnum = UserTypeTest.Men.ToDescriptionFast(); //Descمرد

var names = UserTypeTestEnumExtensions.GetNamesFast(); //string[]

var values = UserTypeTestEnumExtensions.GetValuesFast(); //UserType[]

var length = UserTypeTestEnumExtensions.GetLengthFast(); //3

var menString = "Men";
var result = UserTypeTestEnumExtensions.TryParseFast(menString, out var enumValue);

If you had trouble using UserTypeTestEnumExtensions and the IDE did not recognize it. This is an IDE problem and you need to restart the IDE once.

Benchmark

Contributing

Create an issue if you find a BUG or have a Suggestion or Question. If you want to develop this project :

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request

Give a Star! ⭐️

If you find this repository useful, please give it a star. Thanks!

License

Supernova.Enum.Generators is Copyright © 2022 Mohsen Rajabi under the MIT License.

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

C#codegenerationcodegeneratorcsharp-sourcegeneratordotnet

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类AI 编程
定价开源

> 相关工具

G
GitHub Copilot
GitHub 官方 AI 编程助手,覆盖补全、Chat 与 Agent 模式。
C
Cursor
AI 原生代码编辑器,对话改代码、多文件 Agent 与规则体系是其核心。
S
skills
Skills for Real Engineers. Straight from my .agents directory.