Skip to content

Commit 0a31f40

Browse files
authored
Rename the CommandAttribute to HandlerAttribute #54 (#55)
1 parent f8585da commit 0a31f40

File tree

7 files changed

+10
-10
lines changed

7 files changed

+10
-10
lines changed

src/DemoApp/Services/IntermediateCaGenerator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public IntermediateCaGenerator(ISerialNumberProvider serialNumberProvider)
1212
_serialNumberProvider = serialNumberProvider;
1313
}
1414

15-
[Command(name:"intermediate")]
15+
[Handler(name:"intermediate")]
1616
public async Task GenerateCaAsync(
1717
string commonName,
1818
string issuerFilePath,

src/DemoApp/Services/RootCaGenerator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ namespace DemoApp.Services;
66

77
public class RootCaGenerator
88
{
9-
[Command("root")]
9+
[Handler("root")]
1010
public static async Task GenerateRootCaAsync(
1111
[FromServices] ISerialNumberProvider serialNumberProvider,
1212
string commonName,

src/DemoApp/Services/SSLCertificateGenerator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public SSLCertificateGenerator(ISerialNumberProvider serialNumberProvider)
1313
_serialNumberProvider = serialNumberProvider;
1414
}
1515

16-
[Command("ssl")]
16+
[Handler("ssl")]
1717
public async Task GenerateSslCertAsync(
1818
string commonName,
1919
string issuerFilePath2,

src/HelloWorld/HelloWorldClass.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ namespace Hello;
55

66
public class HelloWorldClass
77
{
8-
[Command("hello-world")]
8+
[Handler("hello-world")]
99
public void Execute(
1010
string message,
1111
string option1 = "opt 1 default value",

src/System.CommandLine.Minimal.Core/CommandAttribute.cs renamed to src/System.CommandLine.Minimal.Core/HandlerAttribute.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
namespace System.CommandLine.Minimal;
22

33
[AttributeUsage(AttributeTargets.Method)]
4-
public sealed class CommandAttribute : Attribute
4+
public sealed class HandlerAttribute : Attribute
55
{
66
public string Name { get; }
7-
public CommandAttribute(string name) => Name = name;
7+
public HandlerAttribute(string name) => Name = name;
88
}

src/System.CommandLine.Minimal.SourceGenerator/CommandSourceGenerator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public void Initialize(IncrementalGeneratorInitializationContext context)
1616
// attributes
1717
IncrementalValueProvider<ImmutableArray<GeneratingCommandBinder>> bindersProvider = context.SyntaxProvider
1818
.ForAttributeWithMetadataName(
19-
"System.CommandLine.Minimal.CommandAttribute",
19+
"System.CommandLine.Minimal.HandlerAttribute",
2020
predicate: MethodDeclPredicate,
2121
transform: GeneratorBindingsProvider.Transform
2222
).Collect();

src/System.CommandLine.Minimal.SourceGenerator/GeneratorBindingsProvider.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ public static GeneratingCommandBinder Transform(GeneratorAttributeSyntaxContext
2121
if (ctx.TargetSymbol is not IMethodSymbol methodSymbol)
2222
return null!;
2323

24-
AttributeData? commandAttribute = ctx.Attributes.FirstOrDefault(a => a.AttributeClass is not null
25-
&& a.AttributeClass.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat) == "global::System.CommandLine.Minimal.CommandAttribute");
26-
string? commandName = commandAttribute?.ConstructorArguments.FirstOrDefault().Value as string;
24+
AttributeData? handlerAttribute = ctx.Attributes.FirstOrDefault(a => a.AttributeClass is not null
25+
&& a.AttributeClass.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat) == "global::System.CommandLine.Minimal.HandlerAttribute");
26+
string? commandName = handlerAttribute?.ConstructorArguments.FirstOrDefault().Value as string;
2727

2828
string classNamespace = methodSymbol.ContainingNamespace.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat);
2929
string className = methodSymbol.ContainingType.Name;

0 commit comments

Comments
 (0)