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

Commit 8c5a4b7

Browse files
committed
Merge pull request #16 from dotnet/add-rule-order-class
Add Rule Order Class
2 parents 0da03d6 + 6660aab commit 8c5a4b7

17 files changed

+67
-40
lines changed

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,21 @@ class Test
4848
Verify(text, expected);
4949
}
5050

51+
[Fact]
52+
public void NonAsciiRewriterHandlesNonStringLiterals()
53+
{
54+
var text = @"
55+
using System;
56+
57+
class Test
58+
{
59+
public const int OkayInt = 12345;
60+
}
61+
";
62+
63+
Verify(text, text);
64+
}
65+
5166
internal override IFormattingRule GetFormattingRule()
5267
{
5368
return new Rules.NonAsciiChractersAreEscapedInLiterals();

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@
101101
<Compile Include="Rules\IsSimplifiedFormattingRule.cs" />
102102
<Compile Include="Rules\NonAsciiCharactersAreEscapedInLiteralsRule.cs" />
103103
<Compile Include="Rules\RuleExtensions.cs" />
104+
<Compile Include="Rules\RuleOrder.cs" />
104105
<Compile Include="Rules\UsesXunitForTestsFormattingRule.cs" />
105106
<Compile Include="RuleTypeConstants.cs" />
106107
</ItemGroup>

src/Microsoft.DotNet.CodeFormatting/Properties/AssemblyInfo.cs

Lines changed: 8 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -5,36 +5,17 @@
55
using System.Runtime.CompilerServices;
66
using System.Runtime.InteropServices;
77

8-
// General Information about an assembly is controlled through the following
9-
// set of attributes. Change these attribute values to modify the information
10-
// associated with an assembly.
8+
[assembly: AssemblyCopyright("\x00a9 Microsoft Corporation. All rights reserved.")]
9+
[assembly: AssemblyCompany("Microsoft Corporation")]
10+
[assembly: AssemblyFileVersion("1.0.0.0")]
11+
[assembly: AssemblyInformationalVersion("1.0.0.0")]
12+
[assembly: AssemblyVersion("1.0.0.0")]
13+
1114
[assembly: AssemblyTitle("Microsoft.DotNet.CodeFormatting")]
15+
[assembly: AssemblyProduct("Microsoft.DotNet.CodeFormatting")]
1216
[assembly: AssemblyDescription("")]
1317
[assembly: AssemblyConfiguration("")]
14-
[assembly: AssemblyCompany("")]
15-
[assembly: AssemblyProduct("Microsoft.DotNet.CodeFormatting")]
16-
[assembly: AssemblyCopyright("Copyright © 2014")]
1718
[assembly: AssemblyTrademark("")]
1819
[assembly: AssemblyCulture("")]
19-
[assembly: InternalsVisibleTo("Microsoft.DotNet.CodeFormatting.Tests")]
2020

21-
// Setting ComVisible to false makes the types in this assembly not visible
22-
// to COM components. If you need to access a type in this assembly from
23-
// COM, set the ComVisible attribute to true on that type.
24-
[assembly: ComVisible(false)]
25-
26-
// The following GUID is for the ID of the typelib if this project is exposed to COM
27-
[assembly: Guid("c950a4bd-7014-4d1f-a1e0-9945016cf07f")]
28-
29-
// Version information for an assembly consists of the following four values:
30-
//
31-
// Major Version
32-
// Minor Version
33-
// Build Number
34-
// Revision
35-
//
36-
// You can specify all the values or you can default the Build and Revision Numbers
37-
// by using the '*' as shown below:
38-
// [assembly: AssemblyVersion("1.0.*")]
39-
[assembly: AssemblyVersion("1.0.0.0")]
40-
[assembly: AssemblyFileVersion("1.0.0.0")]
21+
[assembly: InternalsVisibleTo("Microsoft.DotNet.CodeFormatting.Tests")]

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
namespace Microsoft.DotNet.CodeFormatting.Rules
1616
{
17-
[RuleOrder(9)]
17+
[RuleOrder(RuleOrder.ExplicitVisibilityRule)]
1818
internal sealed class ExplicitVisibilityRule : IFormattingRule
1919
{
2020
private sealed class VisibilityRewriter : CSharpSyntaxRewriter

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
namespace Microsoft.DotNet.CodeFormatting.Rules
1515
{
16-
[RuleOrder(3)]
16+
[RuleOrder(RuleOrder.HasCopyrightHeaderFormattingRule)]
1717
internal sealed class HasCopyrightHeaderFormattingRule : IFormattingRule
1818
{
1919
private static readonly string[] s_copyrightHeader =

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
namespace Microsoft.DotNet.CodeFormatting.Rules
1616
{
17-
[RuleOrder(6)]
17+
[RuleOrder(RuleOrder.HasNewLineBeforeFirstNamespaceFormattingRule)]
1818
internal sealed class HasNewLineBeforeFirstNamespaceFormattingRule : IFormattingRule
1919
{
2020
public async Task<Document> ProcessAsync(Document document, CancellationToken cancellationToken)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
namespace Microsoft.DotNet.CodeFormatting.Rules
1717
{
18-
[RuleOrder(5)]
18+
[RuleOrder(RuleOrder.HasNewLineBeforeFirstUsingFormattingRule)]
1919
internal sealed class HasNewLineBeforeFirstUsingFormattingRule : IFormattingRule
2020
{
2121
private const string FormatError = "Could not format using";

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
namespace Microsoft.DotNet.CodeFormatting.Rules
1717
{
18-
[RuleOrder(1)]
18+
[RuleOrder(RuleOrder.HasNoCustomCopyrightHeaderFormattingRule)]
1919
internal sealed class HasNoCustomCopyrightHeaderFormattingRule : IFormattingRule
2020
{
2121
private static string RulerMarker { get; set; }

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
namespace Microsoft.DotNet.CodeFormatting.Rules
1717
{
18-
[RuleOrder(2)]
18+
[RuleOrder(RuleOrder.HasNoIllegalHeadersFormattingRule)]
1919
internal sealed class HasNoIllegalHeadersFormattingRule : IFormattingRule
2020
{
2121
// We are going to replace this header with the actual filename of the document being processed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
namespace Microsoft.DotNet.CodeFormatting.Rules
1515
{
16-
[RuleOrder(8)]
16+
[RuleOrder(RuleOrder.HasNoNewLineAfterOpenBraceFormattingRule)]
1717
internal sealed class HasNoNewLineAfterOpenBraceFormattingRule : IFormattingRule
1818
{
1919
public async Task<Document> ProcessAsync(Document document, CancellationToken cancellationToken)

0 commit comments

Comments
 (0)