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

Commit 2a41e29

Browse files
committed
Added additional comments
1 parent acdab71 commit 2a41e29

File tree

2 files changed

+42
-3
lines changed

2 files changed

+42
-3
lines changed

src/Microsoft.DotNet.CodeFormatting.Tests/Rules/ExplicitVisibilityRuleTests.cs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,41 @@ private static void M2() { }
454454

455455
}
456456

457+
[Fact]
458+
public void CommentAttributeAndMethod2()
459+
{
460+
var text = @"
461+
class C
462+
{
463+
// Hello
464+
[Attr]
465+
// World
466+
void M1() { }
467+
468+
// Hello
469+
[Attr]
470+
// World
471+
override void M2() { }
472+
};";
473+
474+
var expected = @"
475+
internal class C
476+
{
477+
// Hello
478+
[Attr]
479+
// World
480+
private void M1() { }
481+
482+
// Hello
483+
[Attr]
484+
// World
485+
private override void M2() { }
486+
};";
487+
488+
Verify(text, expected);
489+
490+
}
491+
457492
[Fact]
458493
public void CommentAttributeAndProperty()
459494
{

src/Microsoft.DotNet.CodeFormatting/Rules/ExplicitVisibilityRule.CSharp.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ private static bool IsNestedDeclaration(SyntaxNode node)
233233
}
234234

235235
/// <summary>
236-
/// Ensure a visibility modifier is specified on the given type node.
236+
/// Ensure a visibility modifier is specified on the given type node.
237237
/// </summary>
238238
private static T EnsureTypeVisibility<T>(T originalNode, Func<T, SyntaxToken, T> withKeyword, Func<T, SyntaxTokenList, T> withModifiers, Func<SyntaxKind> getDefaultVisibility) where T : TypeDeclarationSyntax
239239
{
@@ -247,8 +247,8 @@ private static T EnsureTypeVisibility<T>(T originalNode, Func<T, SyntaxToken, T>
247247
}
248248

249249
/// <summary>
250-
/// Ensure a visibility modifier is specified on the given node where first modifier is
251-
/// inserted before a keyword token.
250+
/// Ensure a visibility modifier is specified. If this is the first modifier it will be
251+
/// inserted directly before the returned token.
252252
/// </summary>
253253
private static T EnsureVisibilityBeforeToken<T>(T originalNode, SyntaxTokenList originalModifierList, Func<T, SyntaxToken> getToken, Func<T, SyntaxToken, T> withToken, Func<T, SyntaxTokenList, T> withModifiers, Func<SyntaxKind> getDefaultVisibility) where T : CSharpSyntaxNode
254254
{
@@ -269,6 +269,10 @@ private static T EnsureVisibilityBeforeToken<T>(T originalNode, SyntaxTokenList
269269
getDefaultVisibility);
270270
}
271271

272+
/// <summary>
273+
/// Ensure a visibility modifier is specified. If this is the first modifier it will be
274+
/// inserted directly before the specified type node.
275+
/// </summary>
272276
private static T EnsureVisibilityBeforeType<T>(T originalNode, SyntaxTokenList originalModifierList, Func<T, TypeSyntax> getTypeSyntax, Func<T, TypeSyntax, T> withTypeSyntax, Func<T, SyntaxTokenList, T> withModifiers, Func<SyntaxKind> getDefaultVisibility) where T : CSharpSyntaxNode
273277
{
274278
Func<T, SyntaxKind, T> withFirstModifier = (node, visibilityKind) =>

0 commit comments

Comments
 (0)