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

Commit fd51d25

Browse files
author
Lakshmi Priya Sekar
committed
Add a constant for rename
1 parent e52f950 commit fd51d25

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,31 +110,31 @@ private static string GetNewSymbolName(ISymbol symbol)
110110
private async Task<Solution> CleanSolutionAsync(Solution solution, CancellationToken cancellationToken)
111111
{
112112
var documentIdsToProcess = solution.Projects.SelectMany(p => p.DocumentIds).ToList();
113-
113+
const string rename = "Rename";
114114
foreach (var documentId in documentIdsToProcess)
115115
{
116116
var root = await solution.GetDocument(documentId).GetSyntaxRootAsync(cancellationToken).ConfigureAwait(false);
117117

118118
while (true)
119119
{
120-
var renameNodes = root.DescendantNodes(descendIntoTrivia: true).Where(s => s.GetAnnotations("Rename").Any());
120+
var renameNodes = root.DescendantNodes(descendIntoTrivia: true).Where(s => s.GetAnnotations(rename).Any());
121121
if (!renameNodes.Any())
122122
{
123123
break;
124124
}
125125

126-
root = root.ReplaceNode(renameNodes.First(), renameNodes.First().WithoutAnnotations("Rename"));
126+
root = root.ReplaceNode(renameNodes.First(), renameNodes.First().WithoutAnnotations(rename));
127127
}
128128

129129
while (true)
130130
{
131-
var renameTokens = root.DescendantTokens(descendIntoTrivia: true).Where(s => s.GetAnnotations("Rename").Any());
131+
var renameTokens = root.DescendantTokens(descendIntoTrivia: true).Where(s => s.GetAnnotations(rename).Any());
132132
if (!renameTokens.Any())
133133
{
134134
break;
135135
}
136136

137-
root = root.ReplaceToken(renameTokens.First(), renameTokens.First().WithoutAnnotations("Rename"));
137+
root = root.ReplaceToken(renameTokens.First(), renameTokens.First().WithoutAnnotations(rename));
138138
}
139139

140140
solution = solution.WithDocumentSyntaxRoot(documentId, root);

0 commit comments

Comments
 (0)