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

Commit ad2d99e

Browse files
author
Lakshmi Priya Sekar
committed
Add comments for readability
1 parent 24a13cf commit ad2d99e

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

src/Microsoft.DotNet.CodeFormatting/Rules/HasPrivateAccessorOnFieldNames.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,14 @@ public async Task<Document> ProcessAsync(Document document, CancellationToken ca
3535
var privateKeyword = SyntaxFactory.Token(SyntaxKind.PrivateKeyword);
3636
if (field.Modifiers.Any())
3737
{
38+
// There is trivia associated with the first modifier token
3839
privateKeyword = privateKeyword.WithLeadingTrivia(field.Modifiers.First().LeadingTrivia);
3940
var nextTrivia = field.Modifiers.First().WithLeadingTrivia();
4041
tokenList = tokenList.Concat(new[] { privateKeyword, nextTrivia}).Concat(field.Modifiers.Skip(1));
4142
}
4243
else if (field.ChildNodes().OfType<VariableDeclarationSyntax>().First().GetFirstToken().HasLeadingTrivia)
4344
{
45+
// There is trivia association with the first token - not a modifier token
4446
var firstToken = field.ChildNodes().OfType<VariableDeclarationSyntax>().First().GetFirstToken();
4547
privateKeyword = privateKeyword.WithLeadingTrivia(firstToken.LeadingTrivia);
4648
field = field.ReplaceToken(firstToken, firstToken.WithLeadingTrivia());

0 commit comments

Comments
 (0)