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

Commit 24a13cf

Browse files
author
Lakshmi Priya Sekar
committed
Minor improvements
1. Making modifier list readonly 2. Using hash set and case insensitive search for illegal headers
1 parent 940c145 commit 24a13cf

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,18 +42,18 @@ public async Task<Document> ProcessAsync(Document document, CancellationToken ca
4242
return document.WithSyntaxRoot(syntaxNode.WithLeadingTrivia(newTrivia));
4343
}
4444

45-
public static string[] GetIllegalHeaders()
45+
public static HashSet<string> GetIllegalHeaders()
4646
{
4747
var filePath = Path.Combine(
4848
Path.GetDirectoryName(Uri.UnescapeDataString(new UriBuilder(Assembly.GetExecutingAssembly().CodeBase).Path)),
4949
"IllegalHeaders.md");
5050

5151
if (!File.Exists(filePath))
5252
{
53-
return new string[] { };
53+
return new HashSet<string>();
5454
}
5555

56-
return File.ReadAllLines(filePath).Where(l => !l.StartsWith("##") && !l.Equals("")).ToArray();
56+
return new HashSet<string>(File.ReadAllLines(filePath).Where(l => !l.StartsWith("##") && !l.Equals("")), StringComparer.OrdinalIgnoreCase);
5757
}
5858
}
5959
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ namespace Microsoft.DotNet.CodeFormatting.Rules
1717
[RuleOrder(9)]
1818
internal sealed class HasPrivateAccessorOnFieldNames : IFormattingRule
1919
{
20-
private static string[] AccessorModifiers = {"public", "private", "internal", "protected"};
20+
private static readonly string[] AccessorModifiers = {"public", "private", "internal", "protected"};
2121
public async Task<Document> ProcessAsync(Document document, CancellationToken cancellationToken)
2222
{
2323
var syntaxRoot = await document.GetSyntaxRootAsync(cancellationToken) as CSharpSyntaxNode;

0 commit comments

Comments
 (0)