Skip to content

Commit 525f159

Browse files
committed
Fixed namespace handling for attributes on enum values
1 parent 5ced73e commit 525f159

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/CodeGeneration/CSharpEnum.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,16 @@ public CSharpEnum(CSharpIdentifier identifier)
3030
protected override MemberDeclarationSyntax GetMemberDeclaration()
3131
=> EnumDeclaration(Identifier.Name)
3232
.WithMembers(SeparatedList(Values.Select(value => value.ToSyntax())));
33+
34+
/// <inheritdoc/>
35+
protected override ISet<string> GetNamespaces()
36+
{
37+
var namespaces = base.GetNamespaces();
38+
39+
foreach (string ns in Values.SelectMany(x => x.GetNamespaces()))
40+
namespaces.Add(ns);
41+
42+
return namespaces;
43+
}
3344
}
3445
}

src/UnitTests/CSharpEnumFacts.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ public void GeneratesCorrectCode()
1717
Assert(new CSharpEnum(myEnum)
1818
{
1919
Summary = "My enum\nDetails",
20-
Attributes = {dummyAttribute},
2120
Values =
2221
{
2322
new CSharpEnumValue("Value1")
@@ -39,7 +38,6 @@ namespace Namespace1
3938
/// My enum
4039
/// Details
4140
/// </summary>
42-
[Dummy(""myValue"", Extra = ""extra"")]
4341
public partial enum MyEnum
4442
{
4543
/// <summary>

0 commit comments

Comments
 (0)