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

Commit 9a136fb

Browse files
committed
Rule rename
Shorten the rule names to be more about the scenario than the specific action they are taking.
1 parent 445a69b commit 9a136fb

File tree

6 files changed

+26
-7
lines changed

6 files changed

+26
-7
lines changed

src/CodeFormatter.sln

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{34034F
1414
.nuget\packages.config = .nuget\packages.config
1515
EndProjectSection
1616
EndProject
17+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{297488BF-08A5-4D06-A0C3-B1623F49162A}"
18+
ProjectSection(SolutionItems) = preProject
19+
Performance1.psess = Performance1.psess
20+
EndProjectSection
21+
EndProject
1722
Global
1823
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1924
Debug|Any CPU = Debug|Any CPU
@@ -36,4 +41,7 @@ Global
3641
GlobalSection(SolutionProperties) = preSolution
3742
HideSolutionNode = FALSE
3843
EndGlobalSection
44+
GlobalSection(Performance) = preSolution
45+
HasPerformanceSessions = true
46+
EndGlobalSection
3947
EndGlobal

src/Microsoft.DotNet.CodeFormatting.Tests/Microsoft.DotNet.CodeFormatting.Tests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@
112112
<Compile Include="Rules\HasNewLineBeforeFirstUsingFormattingRuleTests.cs" />
113113
<Compile Include="Rules\HasNoNewLineAfterOpenBraceFormattingRuleTests.cs" />
114114
<Compile Include="Rules\HasNoNewLineBeforeEndBraceFormattingRuleTests.cs" />
115-
<Compile Include="Rules\HasUnderScoreInPrivateFieldNamesFormattingRuleTests.cs" />
115+
<Compile Include="Rules\PrivateFieldNamingRuleTests.cs" />
116116
<Compile Include="Rules\NonAsciiCharactersAreEscapedInLiteralsRuleTests.cs" />
117117
<Compile Include="Rules\UsesXunitForTestsFormattingRuleTests.cs" />
118118
</ItemGroup>
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
namespace Microsoft.DotNet.CodeFormatting.Tests
77
{
8-
public class HasUnderScoreInPrivateFieldNamesFormattingRuleTests : CodeFormattingTestBase
8+
public class PrivateFieldNamingRuleTests : CodeFormattingTestBase
99
{
1010
[Fact]
1111
public void TestUnderScoreInPrivateFields()
@@ -45,7 +45,7 @@ class T
4545

4646
internal override IFormattingRule GetFormattingRule()
4747
{
48-
return new Rules.HasUnderScoreInPrivateFieldNamesFormattingRule();
48+
return new Rules.PrivateFieldNamingRule();
4949
}
5050
}
5151
}

src/Microsoft.DotNet.CodeFormatting/Microsoft.DotNet.CodeFormatting.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989
<Compile Include="Rules\HasNoNewLineAfterOpenBraceFormattingRule.cs" />
9090
<Compile Include="Rules\HasNoNewLineBeforeEndBraceFormattingRule.cs" />
9191
<Compile Include="Rules\HasNoCustomCopyrightHeaderFormattingRule.cs" />
92-
<Compile Include="Rules\HasUnderScoreInPrivateFieldNamesFormattingRule.cs" />
92+
<Compile Include="Rules\PrivateFieldNamingRule.cs" />
9393
<Compile Include="Rules\HasUsingsOutsideOfNamespaceFormattingRule.cs" />
9494
<Compile Include="Rules\IsFormattedFormattingRule.cs" />
9595
<Compile Include="Rules\IsSimplifiedFormattingRule.cs" />
Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,23 @@
1717

1818
namespace Microsoft.DotNet.CodeFormatting.Rules
1919
{
20-
[RuleOrder(RuleOrder.HasUnderScoreInPrivateFieldNamesFormattingRule)]
20+
[RuleOrder(RuleOrder.PrivateFieldNamingRule)]
2121
// TODO Bug 1086632: Deactivated due to active bug in Roslyn.
2222
// There is a hack to run this rule, but it's slow.
2323
// If needed, enable the rule and enable the hack at the code below in RenameFields.
24-
internal sealed class HasUnderScoreInPrivateFieldNamesFormattingRule : IFormattingRule
24+
internal sealed class PrivateFieldNamingRule : IFormattingRule
2525
{
26+
/// <summary>
27+
/// This rewriter exists to work around DevDiv 1086632 in Roslyn. The Rename action is
28+
/// leaving a set of annotations in the tree. These annotations slow down further processing
29+
/// and eventually make the rename operation unusable. As a temporary work around we manually
30+
/// remove these from the tree.
31+
/// </summary>
32+
private sealed class RemoveRenameAnnotationsRewriter : CSharpSyntaxRewriter
33+
{
34+
35+
}
36+
2637
private static string[] s_keywordsToIgnore = { "public", "internal", "protected", "const" };
2738
private static readonly SyntaxAnnotation s_annotationMarker = new SyntaxAnnotation();
2839
private static readonly Regex s_regex = new Regex("^._");

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ internal static class RuleOrder
2121
public const int HasNoNewLineBeforeEndBraceFormattingRule = 7;
2222
public const int HasNoNewLineAfterOpenBraceFormattingRule = 8;
2323
public const int ExplicitVisibilityRule = 9;
24-
public const int HasUnderScoreInPrivateFieldNamesFormattingRule = 10;
24+
public const int PrivateFieldNamingRule = 10;
2525
public const int IsFormattedFormattingRule = 11;
2626
public const int UsesXunitForTestsFormattingRule = 12;
2727
public const int NonAsciiChractersAreEscapedInLiterals = 13;

0 commit comments

Comments
 (0)