Skip to content

Commit 9d8eeb9

Browse files
committed
Fixed incorrect placment of XML comments on properties in classes
1 parent ab5fdf6 commit 9d8eeb9

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

src/CodeGeneration/CSharpClass.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ protected override IEnumerable<MemberDeclarationSyntax> GetMemberDeclarations()
7272
if (BaseClass != null && BaseClass.Parameters.Count != 0)
7373
yield return BaseClass.ToDeclarationSyntax(Identifier.Name);
7474

75-
foreach (var member in base.GetMemberDeclarations())
76-
yield return member.WithModifiers(TokenList(Token(SyntaxKind.PublicKeyword)));
75+
foreach (var member in Properties.Select(property => property.ToSyntax(makePublic: true)))
76+
yield return member;
7777
}
7878
}
7979
}

src/CodeGeneration/CSharpProperty.cs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,18 @@ internal IEnumerable<string> GetNamespaces()
8080
/// <summary>
8181
/// Returns a Roslyn syntax for the property.
8282
/// </summary>
83-
internal PropertyDeclarationSyntax ToSyntax()
83+
/// <param name="makePublic">Controls whether to make the property public or not.</param>
84+
internal PropertyDeclarationSyntax ToSyntax(bool makePublic = false)
8485
{
8586
var propertyDeclaration =
86-
PropertyDeclaration(Type.ToSyntax(), Identifier(Name))
87-
.WithAttributeLists(List(Attributes.Select(x => x.ToSyntax())))
88-
.WithDocumentation(Summary);
87+
PropertyDeclaration(Type.ToSyntax(), Identifier(Name));
88+
89+
if (makePublic)
90+
propertyDeclaration = propertyDeclaration.AddModifiers(Token(SyntaxKind.PublicKeyword));
91+
92+
propertyDeclaration = propertyDeclaration
93+
.WithAttributeLists(List(Attributes.Select(x => x.ToSyntax())))
94+
.WithDocumentation(Summary);
8995

9096
return (GetterExpression == null)
9197
? propertyDeclaration.WithAccessorList(AccessorList(List(GetAccessors())))

src/UnitTests/CSharpClassFacts.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ public void GeneratesCorrectCode()
3737
new CSharpProperty(myInterface, "MyProperty")
3838
{
3939
Summary = "My property",
40-
Attributes = {dummyAttribute},
4140
GetterExpression = new CSharpConstructor(otherClass)
4241
{
4342
Parameters =
@@ -69,7 +68,6 @@ public MyClass(IEndpoint referrer): base(referrer, relativeUri: ""./sample"")
6968
/// <summary>
7069
/// My property
7170
/// </summary>
72-
[Dummy(""myValue"", Extra = ""extra"")]
7371
public MyInterface<MyModel> MyProperty => new OtherClass<MyModel>(this, arg2: ""value"");
7472
}
7573
}");

0 commit comments

Comments
 (0)