Skip to content

Commit

Permalink
Use invariant culture (#1430)
Browse files Browse the repository at this point in the history
  • Loading branch information
josefpihrt committed Apr 7, 2024
1 parent ba7f9e2 commit 7505ae8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
11 changes: 6 additions & 5 deletions src/Tools/CodeGeneration/CSharp/CodeGenerator.cs
@@ -1,5 +1,6 @@
// Copyright (c) .NET Foundation and Contributors. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
Expand All @@ -25,7 +26,7 @@ public static CompilationUnitSyntax GenerateConfigOptions(IEnumerable<AnalyzerOp
Modifiers.Public_Static_Partial(),
"ConfigOptions",
options
.OrderBy(f => f.Id)
.OrderBy(f => f.Id, StringComparer.InvariantCulture)
.Select(f =>
{
return FieldDeclaration(
Expand All @@ -51,7 +52,7 @@ public static CompilationUnitSyntax GenerateConfigOptions(IEnumerable<AnalyzerOp
Block(
analyzers
.Where(f => f.ConfigOptions.Any(f => f.IsRequired))
.OrderBy(f => f.Id)
.OrderBy(f => f.Id, StringComparer.InvariantCulture)
.Select(f => (id: f.Id, keys: f.ConfigOptions.Where(f => f.IsRequired)))
.Select(f =>
{
Expand Down Expand Up @@ -88,7 +89,7 @@ public static CompilationUnitSyntax GenerateLegacyConfigOptions(IEnumerable<Anal
analyzers
.SelectMany(f => f.LegacyOptions)
.Where(f => f.Status != AnalyzerStatus.Disabled)
.OrderBy(f => f.Identifier)
.OrderBy(f => f.Identifier, StringComparer.InvariantCulture)
.Select(f =>
{
return FieldDeclaration(
Expand Down Expand Up @@ -116,7 +117,7 @@ public static CompilationUnitSyntax GenerateConfigOptionKeys(IEnumerable<Analyze
Modifiers.Internal_Static_Partial(),
"ConfigOptionKeys",
options
.OrderBy(f => f.Id)
.OrderBy(f => f.Id, StringComparer.InvariantCulture)
.Select(f =>
{
return FieldDeclaration(
Expand Down Expand Up @@ -144,7 +145,7 @@ public static CompilationUnitSyntax GenerateConfigOptionValues(IEnumerable<Analy
Modifiers.Internal_Static_Partial(),
"ConfigOptionValues",
options
.OrderBy(option => option.Id)
.OrderBy(option => option.Id, StringComparer.InvariantCulture)
.SelectMany(option =>
{
return option.Values.Select(v =>
Expand Down
12 changes: 6 additions & 6 deletions src/Tools/CodeGeneration/EditorConfig/EditorConfigGenerator.cs
Expand Up @@ -38,7 +38,7 @@ public static string GenerateEditorConfig(RoslynatorMetadata metadata, bool comm

foreach (AnalyzerOptionMetadata option in metadata.ConfigOptions
.Where(f => !f.IsObsolete)
.OrderBy(f => f.Key))
.OrderBy(f => f.Key, StringComparer.InvariantCulture))
{
if (optionMap.TryGetValue(option.Key, out HashSet<AnalyzerMetadata> analyzers)
&& !isSeparatedWithNewLine)
Expand All @@ -56,7 +56,7 @@ public static string GenerateEditorConfig(RoslynatorMetadata metadata, bool comm

if (analyzers?.Count > 0)
{
w.WriteLine("# Applicable to: " + string.Join(", ", analyzers.OrderBy(f => f.Id).Select(f => f.Id.ToLowerInvariant())));
w.WriteLine("# Applicable to: " + string.Join(", ", analyzers.OrderBy(f => f.Id, StringComparer.InvariantCulture).Select(f => f.Id.ToLowerInvariant())));
w.WriteLine();
isSeparatedWithNewLine = true;
}
Expand All @@ -72,7 +72,7 @@ public static string GenerateEditorConfig(RoslynatorMetadata metadata, bool comm

foreach (AnalyzerMetadata analyzer in metadata.Analyzers
.Where(f => f.Status == AnalyzerStatus.Enabled && !f.Tags.Contains("HideFromConfiguration"))
.OrderBy(f => f.Id))
.OrderBy(f => f.Id, StringComparer.InvariantCulture))
{
w.WriteLine($"# {analyzer.Title.TrimEnd('.')}");
w.WriteCommentCharIf(commentOut);
Expand All @@ -89,7 +89,7 @@ public static string GenerateEditorConfig(RoslynatorMetadata metadata, bool comm
", ",
analyzer.ConfigOptions
.Where(f => metadata.ConfigOptions.FirstOrDefault(ff => ff.Key == f.Key)?.IsObsolete != true)
.OrderBy(f => f.Key)
.OrderBy(f => f.Key, StringComparer.InvariantCulture)
.Select(f2 => metadata.ConfigOptions.First(f => f.Key == f2.Key).Key)));
}

Expand All @@ -102,7 +102,7 @@ public static string GenerateEditorConfig(RoslynatorMetadata metadata, bool comm

foreach (RefactoringMetadata refactoring in metadata.Refactorings
.Where(f => !f.IsObsolete)
.OrderBy(f => f.OptionKey))
.OrderBy(f => f.OptionKey, StringComparer.InvariantCulture))
{
w.WriteCommentCharIf(commentOut);
w.WriteRefactoring(refactoring.OptionKey, refactoring.IsEnabledByDefault);
Expand All @@ -113,7 +113,7 @@ public static string GenerateEditorConfig(RoslynatorMetadata metadata, bool comm
w.WriteLine();

foreach (CompilerDiagnosticMetadata compilerDiagnostic in metadata.CompilerDiagnostics
.OrderBy(f => f.Id))
.OrderBy(f => f.Id, StringComparer.InvariantCulture))
{
w.WriteCommentCharIf(commentOut);
w.WriteCompilerDiagnosticFix(compilerDiagnostic.Id.ToLowerInvariant(), true);
Expand Down

0 comments on commit 7505ae8

Please sign in to comment.