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

Commit fdfc103

Browse files
dotnet-botjaredpar
authored andcommitted
Formatted the formatter source using the formatter.
1 parent 5b33f8a commit fdfc103

File tree

7 files changed

+30
-24
lines changed

7 files changed

+30
-24
lines changed

src/CodeFormatter/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ private static int Main(string[] args)
3535
List<string> ruleTypes = new List<string>();
3636
List<string> filenames = new List<string>();
3737

38-
for (int i=1; i<args.Length; i++)
38+
for (int i = 1; i < args.Length; i++)
3939
{
4040
string arg = args[i];
4141
if (arg.Equals("/file", StringComparison.InvariantCultureIgnoreCase))

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
using System;
1+
// Copyright (c) Microsoft. All rights reserved.
2+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
3+
4+
using System;
25
using System.Collections.Generic;
36
using System.Linq;
47
using System.Text;
@@ -8,7 +11,7 @@
811

912
namespace Microsoft.DotNet.CodeFormatting.Tests
1013
{
11-
14+
1215
public class UsesXunitForTestsFormattingRuleTests : CodeFormattingTestBase
1316
{
1417
[Fact]

src/Microsoft.DotNet.CodeFormatting/Filters/FilenameFilter.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
using System;
1+
// Copyright (c) Microsoft. All rights reserved.
2+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
3+
4+
using System;
25
using System.Collections.Generic;
36
using System.ComponentModel.Composition;
47
using System.IO;
@@ -11,7 +14,7 @@ namespace Microsoft.DotNet.CodeFormatting.Filters
1114
{
1215
internal sealed class FilenameFilter : IFormattingFilter
1316
{
14-
IEnumerable<string> _filenames;
17+
private IEnumerable<string> _filenames;
1518

1619
public FilenameFilter(IEnumerable<string> filenames)
1720
{

src/Microsoft.DotNet.CodeFormatting/RuleTypeConstants.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
using System;
1+
// Copyright (c) Microsoft. All rights reserved.
2+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
3+
4+
using System;
25
using System.Collections.Generic;
36
using System.ComponentModel.Composition;
47
using System.Linq;
@@ -10,6 +13,6 @@ namespace Microsoft.DotNet.CodeFormatting
1013
static class RuleTypeConstants
1114
{
1215
public const string PartMetadataKey = "RuleType";
13-
public const string ConvertTestsRuleType = "ConvertTests";
16+
public const string ConvertTestsRuleType = "ConvertTests";
1417
}
1518
}

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ private string[] GetIllegalHeaders(Document document)
9494
illegalHeaders.Remove(FileNameIllegalHeader);
9595
illegalHeaders.Add(document.Name);
9696
}
97-
97+
9898
return illegalHeaders.ToArray();
9999
}
100100

@@ -159,7 +159,7 @@ private static bool CommentLineContainsMeaningfulIInformation(string line)
159159
string newLine = line;
160160
for (int i = 0; i < CommentFormattingCharacters.Length; i++)
161161
{
162-
newLine = newLine.Replace(CommentFormattingCharacters[i],' ');
162+
newLine = newLine.Replace(CommentFormattingCharacters[i], ' ');
163163
}
164164
if (newLine.Trim() == string.Empty)
165165
return false;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ internal sealed class HasUnderScoreInPrivateFieldNamesFormattingRule : IFormatti
2525
{
2626
private static string[] s_keywordsToIgnore = { "public", "internal", "protected", "const" };
2727
private static readonly SyntaxAnnotation s_annotationMarker = new SyntaxAnnotation();
28-
private static readonly Regex regex = new Regex("^._");
28+
private static readonly Regex s_regex = new Regex("^._");
2929

3030
public async Task<Document> ProcessAsync(Document document, CancellationToken cancellationToken)
3131
{
@@ -88,7 +88,7 @@ private async Task<Solution> RenameFields(Solution solution, DocumentId document
8888
private static string GetNewSymbolName(ISymbol symbol)
8989
{
9090
var symbolName = symbol.Name.TrimStart('_');
91-
if (regex.IsMatch(symbolName)) symbolName = symbolName.Remove(0, 2);
91+
if (s_regex.IsMatch(symbolName)) symbolName = symbolName.Remove(0, 2);
9292
if (symbol.IsStatic)
9393
{
9494
// Check for ThreadStatic private fields.

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

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
using System;
1+
// Copyright (c) Microsoft. All rights reserved.
2+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
3+
4+
using System;
25
using System.Collections.Generic;
36
using System.Linq;
47
using System.Text;
@@ -94,7 +97,7 @@ public async Task<Document> ProcessAsync(Document document, CancellationToken ca
9497
root = root.ReplaceNode(firstMember, firstMember.WithLeadingTrivia(newLeadingTrivia));
9598
}
9699
}
97-
100+
98101
var xUnitUsing = SyntaxFactory.UsingDirective(SyntaxFactory.ParseName("Xunit")).NormalizeWhitespace();
99102
newUsings.Add(xUnitUsing);
100103

@@ -123,7 +126,6 @@ private void RemoveTestClassAttributes(CompilationUnitSyntax root, SemanticModel
123126
if (IsTestNamespaceType(attributeTypeDocID, "TestClassAttribute"))
124127
{
125128
return true;
126-
127129
}
128130
}
129131
return false;
@@ -149,7 +151,6 @@ private void RemoveTestClassAttributes(CompilationUnitSyntax root, SemanticModel
149151
}
150152
return transformationRoot;
151153
});
152-
153154
}
154155
private void ChangeTestMethodAttributesToFact(CompilationUnitSyntax root, SemanticModel semanticModel, TransformationTracker transformationTracker)
155156
{
@@ -190,7 +191,6 @@ private void ChangeAssertCalls(CompilationUnitSyntax root, SemanticModel semanti
190191
{ "IsTrue", "True" },
191192
{ "IsFalse", "False" },
192193
{ "IsInstanceOfType", "IsAssignableFrom" },
193-
194194
};
195195

196196
Dictionary<SimpleNameSyntax, string> nameReplacementsForNodes = new Dictionary<SimpleNameSyntax, string>();
@@ -240,7 +240,7 @@ private void ChangeAssertCalls(CompilationUnitSyntax root, SemanticModel semanti
240240
var oldArguments = invocationExpression.ArgumentList.Arguments;
241241
var newArguments = new SeparatedSyntaxList<ArgumentSyntax>().AddRange(new[] { oldArguments[1], oldArguments[0] });
242242

243-
return invocationExpression.WithArgumentList(invocationExpression.ArgumentList.WithArguments(newArguments));
243+
return invocationExpression.WithArgumentList(invocationExpression.ArgumentList.WithArguments(newArguments));
244244
});
245245
});
246246
}
@@ -288,7 +288,7 @@ private static bool IsTestNamespaceType(string docID, string simpleTypeName)
288288

289289
private static bool LoadMSTestNamespaces()
290290
{
291-
lock(_lockObject)
291+
lock (_lockObject)
292292
{
293293
if (_mstestNamespaces != null)
294294
{
@@ -310,16 +310,13 @@ private static bool LoadMSTestNamespaces()
310310
return true;
311311
}
312312

313-
314-
315-
316313
}
317314

318315
class TransformationTracker
319316
{
320-
Dictionary<SyntaxAnnotation, Func<CompilationUnitSyntax, IEnumerable<SyntaxNode>, Dictionary<SyntaxNode, SyntaxNode>, CompilationUnitSyntax>> _annotationToTransformation = new Dictionary<SyntaxAnnotation, Func<CompilationUnitSyntax, IEnumerable<SyntaxNode>, Dictionary<SyntaxNode, SyntaxNode>, CompilationUnitSyntax>>();
321-
Dictionary<SyntaxNode, List<SyntaxAnnotation>> _nodeToAnnotations = new Dictionary<SyntaxNode, List<SyntaxAnnotation>>();
322-
Dictionary<SyntaxAnnotation, SyntaxNode> _originalNodeLookup = new Dictionary<SyntaxAnnotation, SyntaxNode>();
317+
private Dictionary<SyntaxAnnotation, Func<CompilationUnitSyntax, IEnumerable<SyntaxNode>, Dictionary<SyntaxNode, SyntaxNode>, CompilationUnitSyntax>> _annotationToTransformation = new Dictionary<SyntaxAnnotation, Func<CompilationUnitSyntax, IEnumerable<SyntaxNode>, Dictionary<SyntaxNode, SyntaxNode>, CompilationUnitSyntax>>();
318+
private Dictionary<SyntaxNode, List<SyntaxAnnotation>> _nodeToAnnotations = new Dictionary<SyntaxNode, List<SyntaxAnnotation>>();
319+
private Dictionary<SyntaxAnnotation, SyntaxNode> _originalNodeLookup = new Dictionary<SyntaxAnnotation, SyntaxNode>();
323320

324321
public void AddTransformation(IEnumerable<SyntaxNode> nodesToTransform, Func<CompilationUnitSyntax, IEnumerable<SyntaxNode>, Dictionary<SyntaxNode, SyntaxNode>, CompilationUnitSyntax> transformerFunc)
325322
{

0 commit comments

Comments
 (0)