diff --git a/src/DemoApp/Services/IntermediateCaGenerator.cs b/src/DemoApp/Services/IntermediateCaGenerator.cs index 7a4dbf0..a2b4ec6 100644 --- a/src/DemoApp/Services/IntermediateCaGenerator.cs +++ b/src/DemoApp/Services/IntermediateCaGenerator.cs @@ -12,7 +12,7 @@ public IntermediateCaGenerator(ISerialNumberProvider serialNumberProvider) _serialNumberProvider = serialNumberProvider; } - [Command(name:"intermediate")] + [Handler(name:"intermediate")] public async Task GenerateCaAsync( string commonName, string issuerFilePath, diff --git a/src/DemoApp/Services/RootCaGenerator.cs b/src/DemoApp/Services/RootCaGenerator.cs index b4810fa..b3146e5 100644 --- a/src/DemoApp/Services/RootCaGenerator.cs +++ b/src/DemoApp/Services/RootCaGenerator.cs @@ -6,7 +6,7 @@ namespace DemoApp.Services; public class RootCaGenerator { - [Command("root")] + [Handler("root")] public static async Task GenerateRootCaAsync( [FromServices] ISerialNumberProvider serialNumberProvider, string commonName, diff --git a/src/DemoApp/Services/SSLCertificateGenerator.cs b/src/DemoApp/Services/SSLCertificateGenerator.cs index 324f4cb..a63a9eb 100644 --- a/src/DemoApp/Services/SSLCertificateGenerator.cs +++ b/src/DemoApp/Services/SSLCertificateGenerator.cs @@ -13,7 +13,7 @@ public SSLCertificateGenerator(ISerialNumberProvider serialNumberProvider) _serialNumberProvider = serialNumberProvider; } - [Command("ssl")] + [Handler("ssl")] public async Task GenerateSslCertAsync( string commonName, string issuerFilePath2, diff --git a/src/HelloWorld/HelloWorldClass.cs b/src/HelloWorld/HelloWorldClass.cs index a48fdf4..d9c0a79 100644 --- a/src/HelloWorld/HelloWorldClass.cs +++ b/src/HelloWorld/HelloWorldClass.cs @@ -5,7 +5,7 @@ namespace Hello; public class HelloWorldClass { - [Command("hello-world")] + [Handler("hello-world")] public void Execute( string message, string option1 = "opt 1 default value", diff --git a/src/System.CommandLine.Minimal.Core/CommandAttribute.cs b/src/System.CommandLine.Minimal.Core/HandlerAttribute.cs similarity index 53% rename from src/System.CommandLine.Minimal.Core/CommandAttribute.cs rename to src/System.CommandLine.Minimal.Core/HandlerAttribute.cs index f19ded0..6c59ba2 100644 --- a/src/System.CommandLine.Minimal.Core/CommandAttribute.cs +++ b/src/System.CommandLine.Minimal.Core/HandlerAttribute.cs @@ -1,8 +1,8 @@ namespace System.CommandLine.Minimal; [AttributeUsage(AttributeTargets.Method)] -public sealed class CommandAttribute : Attribute +public sealed class HandlerAttribute : Attribute { public string Name { get; } - public CommandAttribute(string name) => Name = name; + public HandlerAttribute(string name) => Name = name; } diff --git a/src/System.CommandLine.Minimal.SourceGenerator/CommandSourceGenerator.cs b/src/System.CommandLine.Minimal.SourceGenerator/CommandSourceGenerator.cs index a223eb4..c28514e 100644 --- a/src/System.CommandLine.Minimal.SourceGenerator/CommandSourceGenerator.cs +++ b/src/System.CommandLine.Minimal.SourceGenerator/CommandSourceGenerator.cs @@ -16,7 +16,7 @@ public void Initialize(IncrementalGeneratorInitializationContext context) // attributes IncrementalValueProvider> bindersProvider = context.SyntaxProvider .ForAttributeWithMetadataName( - "System.CommandLine.Minimal.CommandAttribute", + "System.CommandLine.Minimal.HandlerAttribute", predicate: MethodDeclPredicate, transform: GeneratorBindingsProvider.Transform ).Collect(); diff --git a/src/System.CommandLine.Minimal.SourceGenerator/GeneratorBindingsProvider.cs b/src/System.CommandLine.Minimal.SourceGenerator/GeneratorBindingsProvider.cs index 71a649a..37a6902 100644 --- a/src/System.CommandLine.Minimal.SourceGenerator/GeneratorBindingsProvider.cs +++ b/src/System.CommandLine.Minimal.SourceGenerator/GeneratorBindingsProvider.cs @@ -21,9 +21,9 @@ public static GeneratingCommandBinder Transform(GeneratorAttributeSyntaxContext if (ctx.TargetSymbol is not IMethodSymbol methodSymbol) return null!; - AttributeData? commandAttribute = ctx.Attributes.FirstOrDefault(a => a.AttributeClass is not null - && a.AttributeClass.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat) == "global::System.CommandLine.Minimal.CommandAttribute"); - string? commandName = commandAttribute?.ConstructorArguments.FirstOrDefault().Value as string; + AttributeData? handlerAttribute = ctx.Attributes.FirstOrDefault(a => a.AttributeClass is not null + && a.AttributeClass.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat) == "global::System.CommandLine.Minimal.HandlerAttribute"); + string? commandName = handlerAttribute?.ConstructorArguments.FirstOrDefault().Value as string; string classNamespace = methodSymbol.ContainingNamespace.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat); string className = methodSymbol.ContainingType.Name;