Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.

Commit 87a8938

Browse files
committed
inherit case bug fixed.
1 parent fe39ac0 commit 87a8938

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

src/PlasticCommand.UnitTests/TestCommands/AttributesCommandSpec.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
namespace PlasticCommand.UnitTests.TestCommands;
55

66
[PlasticCommand(GeneratedCommandName = "AAACommand", GroupName = "AGroupCommands")]
7-
public class AttributesCommandSpec : ICommandSpecification<int, int>
7+
internal class AttributesCommandSpec : ICommandSpecification<int, int>
88
{
99
public Task<int> ExecuteAsync(int param, CancellationToken token = default)
1010
{

src/PlasticCommand.UnitTests/TestCommands/InheritCommandSpec.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ public Task<int> ExecuteAsync(int param, CancellationToken token = default)
1414
protected abstract Task<int> Execute();
1515
}
1616

17+
[PlasticCommand(GroupName = "AGroupCommands")]
1718
public class InheritCommandSpec : InheritCommandSpecBase
1819
{
1920
/// <summary>

src/PlasticCommand/Generator/Analysis/PlasticCommandAttributeAnalyzer.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
using Microsoft.CodeAnalysis;
2+
using System.Collections.Generic;
3+
using System.Collections.Immutable;
24
using System.Linq;
35

46
namespace PlasticCommand.Generator.Analysis;
@@ -17,10 +19,11 @@ public static (string? CommandName, string? GroupName) Analyze(
1719

1820
string commandNameArg = nameof(PlasticCommandAttribute.GeneratedCommandName);
1921
string groupNameArg = nameof(PlasticCommandAttribute.GroupName);
22+
ImmutableArray<KeyValuePair<string, TypedConstant>>? attributeArgs = commandNameAtt?.NamedArguments;
2023

2124
return (
22-
(string?)commandNameAtt?.NamedArguments.Single(q => q.Key == commandNameArg).Value.Value,
23-
(string?)commandNameAtt?.NamedArguments.Single(q => q.Key == groupNameArg).Value.Value
25+
(string?)attributeArgs?.SingleOrDefault(q => q.Key == commandNameArg).Value.Value,
26+
(string?)attributeArgs?.SingleOrDefault(q => q.Key == groupNameArg).Value.Value
2427
);
2528
}
2629
}

0 commit comments

Comments
 (0)