Skip to content

Commit 46b979f

Browse files
committed
Enable string analyzers
1 parent d02dcf5 commit 46b979f

File tree

5 files changed

+39
-3
lines changed

5 files changed

+39
-3
lines changed

.editorconfig

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,6 @@ dotnet_style_qualification_for_property = false:error
4848
dotnet_style_qualification_for_method = false:error
4949
dotnet_style_qualification_for_event = false:error
5050

51-
# CA1062: Validate arguments of public methods
52-
dotnet_diagnostic.CA1062.severity = error
5351

5452
## Naming Conventions
5553
[*.{cs,vb}]

analysis/idisposable.editorconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
is_global = true
22

3+
#
34
# Rules
45

56
# IDISP001: Dispose created

analysis/sdk.editorconfig

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
is_global = true
2+
3+
#
4+
# Rules
5+
6+
# CA1062: Validate arguments of public methods
7+
dotnet_diagnostic.CA1062.severity = error
8+
9+
# CA1303: Do not pass literals as localized parameters
10+
dotnet_diagnostic.CA1303.severity = error
11+
12+
# CA1304: Specify CultureInfo
13+
dotnet_diagnostic.CA1304.severity = error
14+
15+
# CA1305: Specify IFormatProvider
16+
dotnet_diagnostic.CA1305.severity = error
17+
18+
# CA1307: Specify StringComparison for clarity
19+
dotnet_diagnostic.CA1307.severity = error
20+
21+
# CA1308: Normalize strings to uppercase
22+
dotnet_diagnostic.CA1308.severity = error
23+
24+
# CA1309: Use ordinal StringComparison
25+
dotnet_diagnostic.CA1309.severity = error
26+
27+
# CA1310: Specify StringComparison for correctness
28+
dotnet_diagnostic.CA1310.severity = error
29+
30+
# CA1838: Avoid StringBuilder parameters for P/Invokes
31+
dotnet_diagnostic.CA1838.severity = error
32+
33+
# CA2101: Specify marshalling for P/Invoke string arguments
34+
dotnet_diagnostic.CA2101.severity = error

src/ConsoleWriter.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ namespace RunScript;
33
using System;
44
using System.CommandLine;
55
using System.CommandLine.Rendering;
6+
using System.Globalization;
67

78
internal class ConsoleWriter
89
{
@@ -28,7 +29,7 @@ private void WriteLine(AnsiControlCode textColor, bool verbose, string? message
2829

2930
if (args?.Length > 0)
3031
{
31-
_console.Out.Write(string.Format(message, args));
32+
_console.Out.Write(string.Format(CultureInfo.CurrentCulture, message, args));
3233
}
3334
else
3435
{

src/Serialization/CaseInsensitiveDictionaryConverter.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@ public override Dictionary<string, TValue> Read(
1313
var dict = (Dictionary<string, TValue>)JsonSerializer
1414
.Deserialize(ref reader, typeToConvert, options)!;
1515

16+
#pragma warning disable CA1308 // Normalize strings to uppercase
1617
return dict.ToDictionary(
1718
i => i.Key.ToLowerInvariant(),
1819
i => i.Value,
1920
StringComparer.OrdinalIgnoreCase);
21+
#pragma warning restore CA1308 // Normalize strings to uppercase
2022
}
2123

2224
public override void Write(

0 commit comments

Comments
 (0)