diff --git a/Build.ps1 b/Build.ps1
index c4e8d771..16fbe863 100644
--- a/Build.ps1
+++ b/Build.ps1
@@ -33,7 +33,7 @@ exec { & dotnet test $solution -c Release --no-build -l trx --verbosity=normal }
# Core
exec { & dotnet pack .\src\EasilyNET.Core\EasilyNET.Core.csproj -c Release -o $artifacts --include-symbols -p:SymbolPackageFormat=snupkg --no-build }
-exec { & dotnet pack .\src\EasilyNET.Core.SourceGenerator\EasilyNET.Core.SourceGenerator.csproj -c Release -o $artifacts --no-build }
+# exec { & dotnet pack .\src\EasilyNET.Core.SourceGenerator\EasilyNET.Core.SourceGenerator.csproj -c Release -o $artifacts --no-build }
exec { & dotnet pack .\src\EasilyNET.WebCore\EasilyNET.WebCore.csproj -c Release -o $artifacts --include-symbols -p:SymbolPackageFormat=snupkg --no-build }
exec { & dotnet pack .\src\EasilyNET.WebCore.Swagger\EasilyNET.WebCore.Swagger.csproj -c Release -o $artifacts --include-symbols -p:SymbolPackageFormat=snupkg --no-build }
diff --git a/EasilyNET.sln b/EasilyNET.sln
index bdbc363a..2567c82e 100644
--- a/EasilyNET.sln
+++ b/EasilyNET.sln
@@ -68,7 +68,7 @@ Project("{E53339B2-1760-4266-BCC7-CA923CBCF16C}") = "docker-compose", "docker-co
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WebApi.SourceGenerator.Test", "sample\WebApi.SourceGenerator.Test\WebApi.SourceGenerator.Test.csproj", "{4A011ECD-3C24-4818-8C42-A9361BF4119A}"
EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EasilyNET.Core.SourceGenerator", "src\EasilyNET.Core.SourceGenerator\EasilyNET.Core.SourceGenerator.csproj", "{7B1CB9C6-F4EB-4FAA-A17D-345946F6DD7C}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EasilyNET.Core.SourceGenerator", "src\EasilyNET.Core.SourceGenerator\EasilyNET.Core.SourceGenerator.csproj", "{64D128C1-919B-4A60-A715-5910D5204251}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -151,10 +151,10 @@ Global
{4A011ECD-3C24-4818-8C42-A9361BF4119A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4A011ECD-3C24-4818-8C42-A9361BF4119A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4A011ECD-3C24-4818-8C42-A9361BF4119A}.Release|Any CPU.Build.0 = Release|Any CPU
- {7B1CB9C6-F4EB-4FAA-A17D-345946F6DD7C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {7B1CB9C6-F4EB-4FAA-A17D-345946F6DD7C}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {7B1CB9C6-F4EB-4FAA-A17D-345946F6DD7C}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {7B1CB9C6-F4EB-4FAA-A17D-345946F6DD7C}.Release|Any CPU.Build.0 = Release|Any CPU
+ {64D128C1-919B-4A60-A715-5910D5204251}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {64D128C1-919B-4A60-A715-5910D5204251}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {64D128C1-919B-4A60-A715-5910D5204251}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {64D128C1-919B-4A60-A715-5910D5204251}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -181,7 +181,7 @@ Global
{8F9C18F9-A526-DCA0-597F-90D64AE5C6C2} = {8D626EA8-CB54-BC41-363A-217881BEBA6E}
{9B426136-DC85-603B-94FB-F3C0B2E72713} = {4F9DEAE5-078F-E77A-2E4A-FEB6FFE226FF}
{4A011ECD-3C24-4818-8C42-A9361BF4119A} = {4F9DEAE5-078F-E77A-2E4A-FEB6FFE226FF}
- {7B1CB9C6-F4EB-4FAA-A17D-345946F6DD7C} = {8D626EA8-CB54-BC41-363A-217881BEBA6E}
+ {64D128C1-919B-4A60-A715-5910D5204251} = {8D626EA8-CB54-BC41-363A-217881BEBA6E}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {BF2C0069-ED43-44A1-A66C-2CC1B62E3EA3}
diff --git a/sample/WebApi.SourceGenerator.Test/Controllers/WeatherForecastController.cs b/sample/WebApi.SourceGenerator.Test/Controllers/WeatherForecastController.cs
index d52fa90b..f112c885 100644
--- a/sample/WebApi.SourceGenerator.Test/Controllers/WeatherForecastController.cs
+++ b/sample/WebApi.SourceGenerator.Test/Controllers/WeatherForecastController.cs
@@ -1,4 +1,3 @@
-using System.ComponentModel;
using Microsoft.AspNetCore.Mvc;
namespace WebApi.SourceGenerator.Test.Controllers;
@@ -14,34 +13,4 @@ public class WeatherForecastController(WeatherForecastService wfs) : ControllerB
///
[HttpGet("GetWeatherForecast")]
public IEnumerable Get() => wfs.Get();
-
- ///
- ///
- ///
- [HttpGet("GetEnumDescription")]
- public string GetEnumDescription() => ETestEnumDescription.A.ToDescription();
-}
-
-///
-/// öԴ
-///
-public enum ETestEnumDescription
-{
- ///
- /// A
- ///
- [Description("ADES")]
- A,
-
- ///
- /// B
- ///
- [Description("BDES")]
- B,
-
- ///
- /// C
- ///
- [Description("CDES")]
- C
}
\ No newline at end of file
diff --git a/sample/WebApi.SourceGenerator.Test/WebApi.SourceGenerator.Test.csproj b/sample/WebApi.SourceGenerator.Test/WebApi.SourceGenerator.Test.csproj
index db8beeff..8058ec20 100644
--- a/sample/WebApi.SourceGenerator.Test/WebApi.SourceGenerator.Test.csproj
+++ b/sample/WebApi.SourceGenerator.Test/WebApi.SourceGenerator.Test.csproj
@@ -7,12 +7,11 @@
-
+
-
diff --git a/sample/WebApi.Test.Unit/WebApi.Test.Unit.csproj b/sample/WebApi.Test.Unit/WebApi.Test.Unit.csproj
index d712b16b..8c49d380 100644
--- a/sample/WebApi.Test.Unit/WebApi.Test.Unit.csproj
+++ b/sample/WebApi.Test.Unit/WebApi.Test.Unit.csproj
@@ -39,7 +39,7 @@
-
+
diff --git a/src/Directory.Packages.props b/src/Directory.Packages.props
index 715f024f..2161f18f 100644
--- a/src/Directory.Packages.props
+++ b/src/Directory.Packages.props
@@ -23,9 +23,9 @@
-
-
-
+
+
+
diff --git a/src/EasilyNET.Core.SourceGenerator/EnumDescriptionGenerator.cs b/src/EasilyNET.Core.SourceGenerator/EnumDescriptionGenerator.cs
index 98b48a79..1e903376 100644
--- a/src/EasilyNET.Core.SourceGenerator/EnumDescriptionGenerator.cs
+++ b/src/EasilyNET.Core.SourceGenerator/EnumDescriptionGenerator.cs
@@ -1,126 +1,127 @@
-using System.Collections.Immutable;
-using System.ComponentModel;
-using System.Text;
-using Microsoft.CodeAnalysis;
-using Microsoft.CodeAnalysis.CSharp;
-using Microsoft.CodeAnalysis.CSharp.Syntax;
-using Microsoft.CodeAnalysis.Text;
+//using System.Collections.Immutable;
+//using System.ComponentModel;
+//using System.Text;
+//using Microsoft.CodeAnalysis;
+//using Microsoft.CodeAnalysis.CSharp;
+//using Microsoft.CodeAnalysis.CSharp.Syntax;
+//using Microsoft.CodeAnalysis.Text;
-namespace EasilyNET.Core.SourceGenerator;
+//namespace EasilyNET.Core.SourceGenerator;
-///
-/// 用于对枚举类型添加描述信息的源代码生成器
-///
-[Generator(LanguageNames.CSharp)]
-public class EnumDescriptionGenerator : IIncrementalGenerator
-{
- ///
- public void Initialize(IncrementalGeneratorInitializationContext context)
- {
- // 注册一个语法接收器,用于在编译期间收集枚举信息
- var enumDeclarations = context.SyntaxProvider
- .CreateSyntaxProvider(static (s, _) => s is EnumDeclarationSyntax,
- static (ctx, _) => (EnumDeclarationSyntax)ctx.Node)
- .Where(static m => m is not null)
- .Collect();
- var compilationAndEnums = context.CompilationProvider.Combine(enumDeclarations);
- context.RegisterSourceOutput(compilationAndEnums, (spc, source) => Execute(source.Left, source.Right, spc));
- }
+/////
+///// 用于对枚举类型添加描述信息的源代码生成器
+/////
+//[Generator(LanguageNames.CSharp)]
+//public class EnumDescriptionGenerator : IIncrementalGenerator
+//{
+// ///
+// public void Initialize(IncrementalGeneratorInitializationContext context)
+// {
+// // 注册一个语法接收器,用于在编译期间收集枚举信息
+// var enumDeclarations = context.SyntaxProvider
+// .CreateSyntaxProvider(static (s, _) => s is EnumDeclarationSyntax,
+// static (ctx, _) => (EnumDeclarationSyntax)ctx.Node)
+// .Where(static m => m is not null)
+// .Collect();
+// var compilationAndEnums = context.CompilationProvider.Combine(enumDeclarations);
+// context.RegisterSourceOutput(compilationAndEnums, (spc, source) => Execute(source.Left, source.Right, spc));
+// }
- private static void Execute(Compilation compilation, ImmutableArray enums, SourceProductionContext context)
- {
- foreach (var enumDeclaration in enums)
- {
- if (enumDeclaration is null) continue;
- var semanticModel = compilation.GetSemanticModel(enumDeclaration.SyntaxTree);
- var enumSymbol = semanticModel.GetDeclaredSymbol(enumDeclaration);
- if (enumSymbol is null) continue;
- // 仅处理 public 的枚举类型
- if (enumSymbol.DeclaredAccessibility != Accessibility.Public) continue;
- var enumName = enumSymbol.Name;
- var namespaceName = enumSymbol.ContainingNamespace.ToDisplayString();
- var compilationUnit = SyntaxFactory.CompilationUnit()
- .AddUsings(SyntaxFactory.UsingDirective(SyntaxFactory.ParseName("System")))
- .AddUsings(SyntaxFactory.UsingDirective(SyntaxFactory.ParseName("System.Collections.Generic")))
- .AddMembers(SyntaxFactory.NamespaceDeclaration(SyntaxFactory.ParseName(namespaceName))
- .AddMembers(SyntaxFactory.ClassDeclaration($"{enumName}Extensions")
- .AddModifiers(SyntaxFactory.Token(SyntaxKind.PublicKeyword), SyntaxFactory.Token(SyntaxKind.StaticKeyword))
- .WithLeadingTrivia(SyntaxFactory.Comment("""
- ///
- /// 提供扩展方法以获取枚举值的描述。
- ///
- """))
- .AddMembers(GenerateDescriptionCacheField(enumName, enumSymbol),
- GenerateToDescriptionMethod(enumName))));
- var code = compilationUnit.NormalizeWhitespace().ToFullString();
- // 在文件开头添加注释,以便标识该文件是由源代码生成器生成的
- code = $"""
- //
+// private static void Execute(Compilation compilation, ImmutableArray enums, SourceProductionContext context)
+// {
+// foreach (var enumDeclaration in enums)
+// {
+// if (enumDeclaration is null) continue;
+// var semanticModel = compilation.GetSemanticModel(enumDeclaration.SyntaxTree);
+// var enumSymbol = semanticModel.GetDeclaredSymbol(enumDeclaration);
+// if (enumSymbol is null) continue;
+// // 仅处理 public 的枚举类型
+// if (enumSymbol.DeclaredAccessibility != Accessibility.Public) continue;
+// var enumName = enumSymbol.Name;
+// var namespaceName = enumSymbol.ContainingNamespace.ToDisplayString();
+// var compilationUnit = SyntaxFactory.CompilationUnit()
+// .AddUsings(SyntaxFactory.UsingDirective(SyntaxFactory.ParseName("System")))
+// .AddUsings(SyntaxFactory.UsingDirective(SyntaxFactory.ParseName("System.Collections.Generic")))
+// .AddMembers(SyntaxFactory.NamespaceDeclaration(SyntaxFactory.ParseName(namespaceName))
+// .AddMembers(SyntaxFactory.ClassDeclaration($"{enumName}Extensions")
+// .AddModifiers(SyntaxFactory.Token(SyntaxKind.PublicKeyword), SyntaxFactory.Token(SyntaxKind.StaticKeyword))
+// .WithLeadingTrivia(SyntaxFactory.Comment("""
+// ///
+// /// 提供扩展方法以获取枚举值的描述。
+// ///
+// """))
+// .AddMembers(GenerateDescriptionCacheField(enumName, enumSymbol),
+// GenerateToDescriptionMethod(enumName))));
+// var code = compilationUnit.NormalizeWhitespace().ToFullString();
+// // 在文件开头添加注释,以便标识该文件是由源代码生成器生成的
+// code = $"""
+// //
- {code}
- """;
- context.AddSource($"{enumName}Extensions.g.cs", SourceText.From(code, Encoding.UTF8));
- }
- }
+// {code}
+// """;
+// context.AddSource($"{enumName}Extensions.g.cs", SourceText.From(code, Encoding.UTF8));
+// }
+// }
- private static FieldDeclarationSyntax GenerateDescriptionCacheField(string enumName, INamedTypeSymbol enumSymbol)
- {
- var initializer = SyntaxFactory.InitializerExpression(SyntaxKind.CollectionInitializerExpression,
- SyntaxFactory.SeparatedList(enumSymbol.GetMembers().OfType().Select(member =>
- {
- var descriptionAttribute = member.GetAttributes().FirstOrDefault(attr => attr.AttributeClass?.ToDisplayString() == nameof(DescriptionAttribute));
- var description = descriptionAttribute?.ConstructorArguments.FirstOrDefault().Value?.ToString() ?? member.Name;
- return SyntaxFactory.InitializerExpression(SyntaxKind.ComplexElementInitializerExpression,
- SyntaxFactory.SeparatedList(new ExpressionSyntax[]
- {
- SyntaxFactory.MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression,
- SyntaxFactory.IdentifierName(enumName),
- SyntaxFactory.IdentifierName(member.Name)),
- SyntaxFactory.LiteralExpression(SyntaxKind.StringLiteralExpression, SyntaxFactory.Literal(description))
- }));
- })));
- return SyntaxFactory.FieldDeclaration(SyntaxFactory.VariableDeclaration(SyntaxFactory.GenericName(SyntaxFactory.Identifier("Dictionary"))
- .WithTypeArgumentList(SyntaxFactory.TypeArgumentList(SyntaxFactory.SeparatedList(new SyntaxNodeOrToken[]
- {
- SyntaxFactory.IdentifierName(enumName),
- SyntaxFactory.Token(SyntaxKind.CommaToken),
- SyntaxFactory.PredefinedType(SyntaxFactory.Token(SyntaxKind.StringKeyword))
- }))))
- .AddVariables(SyntaxFactory.VariableDeclarator("DescriptionCache")
- .WithInitializer(SyntaxFactory.EqualsValueClause(SyntaxFactory.ObjectCreationExpression(SyntaxFactory.GenericName(SyntaxFactory.Identifier("Dictionary"))
- .WithTypeArgumentList(SyntaxFactory.TypeArgumentList(SyntaxFactory.SeparatedList(new SyntaxNodeOrToken[]
- {
- SyntaxFactory.IdentifierName(enumName),
- SyntaxFactory.Token(SyntaxKind.CommaToken),
- SyntaxFactory.PredefinedType(SyntaxFactory.Token(SyntaxKind.StringKeyword))
- }))))
- .WithInitializer(initializer)))))
- .AddModifiers(SyntaxFactory.Token(SyntaxKind.PrivateKeyword), SyntaxFactory.Token(SyntaxKind.StaticKeyword), SyntaxFactory.Token(SyntaxKind.ReadOnlyKeyword));
- }
+// private static FieldDeclarationSyntax GenerateDescriptionCacheField(string enumName, INamedTypeSymbol enumSymbol)
+// {
+// var initializer = SyntaxFactory.InitializerExpression(SyntaxKind.CollectionInitializerExpression,
+// SyntaxFactory.SeparatedList(enumSymbol.GetMembers().OfType().Select(member =>
+// {
+// var descriptionAttribute = member.GetAttributes().FirstOrDefault(attr => attr.AttributeClass?.ToDisplayString() == nameof(DescriptionAttribute));
+// var description = descriptionAttribute?.ConstructorArguments.FirstOrDefault().Value?.ToString() ?? member.Name;
+// return SyntaxFactory.InitializerExpression(SyntaxKind.ComplexElementInitializerExpression,
+// SyntaxFactory.SeparatedList(new ExpressionSyntax[]
+// {
+// SyntaxFactory.MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression,
+// SyntaxFactory.IdentifierName(enumName),
+// SyntaxFactory.IdentifierName(member.Name)),
+// SyntaxFactory.LiteralExpression(SyntaxKind.StringLiteralExpression, SyntaxFactory.Literal(description))
+// }));
+// })));
+// return SyntaxFactory.FieldDeclaration(SyntaxFactory.VariableDeclaration(SyntaxFactory.GenericName(SyntaxFactory.Identifier("Dictionary"))
+// .WithTypeArgumentList(SyntaxFactory.TypeArgumentList(SyntaxFactory.SeparatedList(new SyntaxNodeOrToken[]
+// {
+// SyntaxFactory.IdentifierName(enumName),
+// SyntaxFactory.Token(SyntaxKind.CommaToken),
+// SyntaxFactory.PredefinedType(SyntaxFactory.Token(SyntaxKind.StringKeyword))
+// }))))
+// .AddVariables(SyntaxFactory.VariableDeclarator("DescriptionCache")
+// .WithInitializer(SyntaxFactory.EqualsValueClause(SyntaxFactory.ObjectCreationExpression(SyntaxFactory.GenericName(SyntaxFactory.Identifier("Dictionary"))
+// .WithTypeArgumentList(SyntaxFactory.TypeArgumentList(SyntaxFactory.SeparatedList(new SyntaxNodeOrToken[]
+// {
+// SyntaxFactory.IdentifierName(enumName),
+// SyntaxFactory.Token(SyntaxKind.CommaToken),
+// SyntaxFactory.PredefinedType(SyntaxFactory.Token(SyntaxKind.StringKeyword))
+// }))))
+// .WithInitializer(initializer)))))
+// .AddModifiers(SyntaxFactory.Token(SyntaxKind.PrivateKeyword), SyntaxFactory.Token(SyntaxKind.StaticKeyword), SyntaxFactory.Token(SyntaxKind.ReadOnlyKeyword));
+// }
+
+// private static MethodDeclarationSyntax GenerateToDescriptionMethod(string enumName) =>
+// SyntaxFactory.MethodDeclaration(SyntaxFactory.PredefinedType(SyntaxFactory.Token(SyntaxKind.StringKeyword).WithTrailingTrivia(SyntaxFactory.TriviaList(SyntaxFactory.Space))),
+// SyntaxFactory.Identifier("ToDescription"))
+// .AddModifiers(SyntaxFactory.Token(SyntaxKind.PublicKeyword), SyntaxFactory.Token(SyntaxKind.StaticKeyword))
+// .AddParameterListParameters(SyntaxFactory.Parameter(SyntaxFactory.Identifier("value"))
+// .WithType(SyntaxFactory.IdentifierName(enumName))
+// .WithModifiers(SyntaxFactory.TokenList(SyntaxFactory.Token(SyntaxKind.ThisKeyword))))
+// .WithLeadingTrivia(SyntaxFactory.Comment("""
+// ///
+// /// 获取枚举值的描述。
+// ///
+// /// 枚举值。
+// /// 枚举值的描述。
+// """))
+// .WithBody(SyntaxFactory.Block(SyntaxFactory.ReturnStatement(SyntaxFactory.ConditionalExpression(SyntaxFactory.InvocationExpression(SyntaxFactory.MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression,
+// SyntaxFactory.IdentifierName("DescriptionCache"),
+// SyntaxFactory.IdentifierName("TryGetValue")))
+// .AddArgumentListArguments(SyntaxFactory.Argument(SyntaxFactory.IdentifierName("value")),
+// SyntaxFactory.Argument(SyntaxFactory.DeclarationExpression(SyntaxFactory.IdentifierName("var"),
+// SyntaxFactory.SingleVariableDesignation(SyntaxFactory.Identifier("description"))))
+// .WithRefOrOutKeyword(SyntaxFactory.Token(SyntaxKind.OutKeyword))),
+// SyntaxFactory.IdentifierName("description"),
+// SyntaxFactory.InvocationExpression(SyntaxFactory.MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression,
+// SyntaxFactory.IdentifierName("value"),
+// SyntaxFactory.IdentifierName("ToString")))))));
+//}
- private static MethodDeclarationSyntax GenerateToDescriptionMethod(string enumName) =>
- SyntaxFactory.MethodDeclaration(SyntaxFactory.PredefinedType(SyntaxFactory.Token(SyntaxKind.StringKeyword).WithTrailingTrivia(SyntaxFactory.TriviaList(SyntaxFactory.Space))),
- SyntaxFactory.Identifier("ToDescription"))
- .AddModifiers(SyntaxFactory.Token(SyntaxKind.PublicKeyword), SyntaxFactory.Token(SyntaxKind.StaticKeyword))
- .AddParameterListParameters(SyntaxFactory.Parameter(SyntaxFactory.Identifier("value"))
- .WithType(SyntaxFactory.IdentifierName(enumName))
- .WithModifiers(SyntaxFactory.TokenList(SyntaxFactory.Token(SyntaxKind.ThisKeyword))))
- .WithLeadingTrivia(SyntaxFactory.Comment("""
- ///
- /// 获取枚举值的描述。
- ///
- /// 枚举值。
- /// 枚举值的描述。
- """))
- .WithBody(SyntaxFactory.Block(SyntaxFactory.ReturnStatement(SyntaxFactory.ConditionalExpression(SyntaxFactory.InvocationExpression(SyntaxFactory.MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression,
- SyntaxFactory.IdentifierName("DescriptionCache"),
- SyntaxFactory.IdentifierName("TryGetValue")))
- .AddArgumentListArguments(SyntaxFactory.Argument(SyntaxFactory.IdentifierName("value")),
- SyntaxFactory.Argument(SyntaxFactory.DeclarationExpression(SyntaxFactory.IdentifierName("var"),
- SyntaxFactory.SingleVariableDesignation(SyntaxFactory.Identifier("description"))))
- .WithRefOrOutKeyword(SyntaxFactory.Token(SyntaxKind.OutKeyword))),
- SyntaxFactory.IdentifierName("description"),
- SyntaxFactory.InvocationExpression(SyntaxFactory.MemberAccessExpression(SyntaxKind.SimpleMemberAccessExpression,
- SyntaxFactory.IdentifierName("value"),
- SyntaxFactory.IdentifierName("ToString")))))));
-}
\ No newline at end of file
diff --git a/src/EasilyNET.Core/EasilyNET.Core.csproj b/src/EasilyNET.Core/EasilyNET.Core.csproj
index 5c41056b..a2f62a52 100644
--- a/src/EasilyNET.Core/EasilyNET.Core.csproj
+++ b/src/EasilyNET.Core/EasilyNET.Core.csproj
@@ -23,8 +23,4 @@
-
-
-
-
\ No newline at end of file
diff --git a/src/EasilyNET.Core/Misc/EnumExtensions.cs b/src/EasilyNET.Core/Misc/EnumExtensions.cs
new file mode 100644
index 00000000..9069cd66
--- /dev/null
+++ b/src/EasilyNET.Core/Misc/EnumExtensions.cs
@@ -0,0 +1,23 @@
+// ReSharper disable UnusedMember.Global
+// ReSharper disable UnusedType.Global
+
+using System.ComponentModel;
+
+namespace EasilyNET.Core.Misc;
+
+///
+/// 扩展枚举
+///
+public static class EnumExtensions
+{
+ ///
+ /// 转成显示名字
+ ///
+ ///
+ ///
+ public static string ToDescription(this Enum value)
+ {
+ var fieldInfo = value.GetType().GetField(value.ToString())?.GetCustomAttributes(typeof(DescriptionAttribute), false).FirstOrDefault();
+ return fieldInfo is DescriptionAttribute descriptionAttribute ? descriptionAttribute.Description : value.ToString();
+ }
+}
\ No newline at end of file
diff --git a/src/EasilyNET.RabbitBus.Core/EasilyNET.RabbitBus.Core.csproj b/src/EasilyNET.RabbitBus.Core/EasilyNET.RabbitBus.Core.csproj
index bafcc02c..dd8250b1 100644
--- a/src/EasilyNET.RabbitBus.Core/EasilyNET.RabbitBus.Core.csproj
+++ b/src/EasilyNET.RabbitBus.Core/EasilyNET.RabbitBus.Core.csproj
@@ -16,7 +16,6 @@
-