Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/DemoApp/Services/IntermediateCaGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public IntermediateCaGenerator(ISerialNumberProvider serialNumberProvider)
_serialNumberProvider = serialNumberProvider;
}

[Command(name:"intermediate")]
[Handler(name:"intermediate")]
public async Task GenerateCaAsync(
string commonName,
string issuerFilePath,
Expand Down
2 changes: 1 addition & 1 deletion src/DemoApp/Services/RootCaGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace DemoApp.Services;

public class RootCaGenerator
{
[Command("root")]
[Handler("root")]
public static async Task GenerateRootCaAsync(
[FromServices] ISerialNumberProvider serialNumberProvider,
string commonName,
Expand Down
2 changes: 1 addition & 1 deletion src/DemoApp/Services/SSLCertificateGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public SSLCertificateGenerator(ISerialNumberProvider serialNumberProvider)
_serialNumberProvider = serialNumberProvider;
}

[Command("ssl")]
[Handler("ssl")]
public async Task GenerateSslCertAsync(
string commonName,
string issuerFilePath2,
Expand Down
2 changes: 1 addition & 1 deletion src/HelloWorld/HelloWorldClass.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public void Initialize(IncrementalGeneratorInitializationContext context)
// attributes
IncrementalValueProvider<ImmutableArray<GeneratingCommandBinder>> bindersProvider = context.SyntaxProvider
.ForAttributeWithMetadataName(
"System.CommandLine.Minimal.CommandAttribute",
"System.CommandLine.Minimal.HandlerAttribute",
predicate: MethodDeclPredicate,
transform: GeneratorBindingsProvider.Transform
).Collect();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down