Skip to content

Commit e3230e5

Browse files
authored
Re-enable CA1305 (dotnet#35867)
* Re-enable CA1305 Fixes dotnet#34361
1 parent d7acbfb commit e3230e5

26 files changed

Lines changed: 66 additions & 61 deletions

File tree

.editorconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ dotnet_diagnostic.CA1018.severity = warning
7777
dotnet_diagnostic.CA1047.severity = warning
7878

7979
# CA1305: Specify IFormatProvider
80-
dotnet_diagnostic.CA1305.severity = suggestion
80+
dotnet_diagnostic.CA1305.severity = warning
8181

8282
# CA1507: Use nameof to express symbol names
8383
dotnet_diagnostic.CA1507.severity = warning

src/Components/Web.JS/dist/Release/blazor.server.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Components/Web.JS/dist/Release/blazor.webview.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Components/test/E2ETest/Tests/RoutingTest.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Licensed to the .NET Foundation under one or more agreements.
22
// The .NET Foundation licenses this file to you under the MIT license.
33

4+
using System.Globalization;
45
using System.Runtime.InteropServices;
56
using BasicTestApp;
67
using BasicTestApp.RouterTest;
@@ -810,9 +811,9 @@ public void CanArriveAtQueryStringPageWithDateTimeQuery()
810811
var app = Browser.MountTestComponent<TestRouter>();
811812
Assert.Equal("Hello Abc .", app.FindElement(By.Id("test-info")).Text);
812813
Assert.Equal("0", app.FindElement(By.Id("value-QueryInt")).Text);
813-
Assert.Equal(dateTime.ToString("hh:mm:ss on yyyy-MM-dd"), app.FindElement(By.Id("value-NullableDateTimeValue")).Text);
814-
Assert.Equal(dateOnly.ToString("yyyy-MM-dd"), app.FindElement(By.Id("value-NullableDateOnlyValue")).Text);
815-
Assert.Equal(timeOnly.ToString("hh:mm:ss"), app.FindElement(By.Id("value-NullableTimeOnlyValue")).Text);
814+
Assert.Equal(dateTime.ToString("hh:mm:ss on yyyy-MM-dd", CultureInfo.InvariantCulture), app.FindElement(By.Id("value-NullableDateTimeValue")).Text);
815+
Assert.Equal(dateOnly.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture), app.FindElement(By.Id("value-NullableDateOnlyValue")).Text);
816+
Assert.Equal(timeOnly.ToString("hh:mm:ss", CultureInfo.InvariantCulture), app.FindElement(By.Id("value-NullableTimeOnlyValue")).Text);
816817
Assert.Equal(string.Empty, app.FindElement(By.Id("value-StringValue")).Text);
817818
Assert.Equal("0 values ()", app.FindElement(By.Id("value-LongValues")).Text);
818819

src/Components/test/testassets/TestServer/Controllers/PersonController.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public string Delete()
5454
var result = new StringBuilder();
5555
foreach (var header in Request.Headers)
5656
{
57-
result.AppendLine($"{header.Key}: {string.Join(",", header.Value.ToArray())}");
57+
result.AppendLine(FormattableString.Invariant($"{header.Key}: {string.Join(",", header.Value.ToArray())}"));
5858
}
5959
return "REQUEST HEADERS:\n" + result.ToString();
6060
}

src/HealthChecks/HealthChecks/src/DefaultHealthCheckService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ public override string ToString()
313313
if (_formatted == null)
314314
{
315315
var builder = new StringBuilder();
316-
builder.AppendLine($"Health check data for {_name}:");
316+
builder.AppendLine(FormattableString.Invariant($"Health check data for {_name}:"));
317317

318318
var values = _values;
319319
for (var i = 0; i < values.Count; i++)

src/Hosting/Server.IntegrationTesting/src/Deployers/RemoteWindowsDeployer/RemoteWindowsDeployer.cs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -214,29 +214,29 @@ private async Task RunScriptAsync(string serverAction)
214214
}
215215

216216
var parameterBuilder = new StringBuilder();
217-
parameterBuilder.Append($"\"{remotePSSessionHelperScript}\"");
218-
parameterBuilder.Append($" -serverName {_deploymentParameters.ServerName}");
219-
parameterBuilder.Append($" -accountName {_deploymentParameters.ServerAccountName}");
220-
parameterBuilder.Append($" -accountPassword {_deploymentParameters.ServerAccountPassword}");
221-
parameterBuilder.Append($" -deployedFolderPath {_deployedFolderPathInFileShare}");
217+
parameterBuilder.Append(FormattableString.Invariant($"\"{remotePSSessionHelperScript}\""));
218+
parameterBuilder.Append(FormattableString.Invariant($" -serverName {_deploymentParameters.ServerName}"));
219+
parameterBuilder.Append(FormattableString.Invariant($" -accountName {_deploymentParameters.ServerAccountName}"));
220+
parameterBuilder.Append(FormattableString.Invariant($" -accountPassword {_deploymentParameters.ServerAccountPassword}"));
221+
parameterBuilder.Append(FormattableString.Invariant($" -deployedFolderPath {_deployedFolderPathInFileShare}"));
222222

223223
if (!string.IsNullOrEmpty(_deploymentParameters.DotnetRuntimePath))
224224
{
225-
parameterBuilder.Append($" -dotnetRuntimePath \"{_deploymentParameters.DotnetRuntimePath}\"");
225+
parameterBuilder.Append(FormattableString.Invariant($" -dotnetRuntimePath \"{_deploymentParameters.DotnetRuntimePath}\""));
226226
}
227227

228-
parameterBuilder.Append($" -executablePath \"{executablePath}\"");
228+
parameterBuilder.Append(FormattableString.Invariant($" -executablePath \"{executablePath}\""));
229229

230230
if (!string.IsNullOrEmpty(executableParameters))
231231
{
232-
parameterBuilder.Append($" -executableParameters \"{executableParameters}\"");
232+
parameterBuilder.Append(FormattableString.Invariant($" -executableParameters \"{executableParameters}\""));
233233
}
234234

235-
parameterBuilder.Append($" -serverType {_deploymentParameters.ServerType}");
236-
parameterBuilder.Append($" -serverAction {serverAction}");
237-
parameterBuilder.Append($" -applicationBaseUrl {_deploymentParameters.ApplicationBaseUriHint}");
235+
parameterBuilder.Append(FormattableString.Invariant($" -serverType {_deploymentParameters.ServerType}"));
236+
parameterBuilder.Append(FormattableString.Invariant($" -serverAction {serverAction}"));
237+
parameterBuilder.Append(FormattableString.Invariant($" -applicationBaseUrl {_deploymentParameters.ApplicationBaseUriHint}"));
238238
var environmentVariables = string.Join("`,", _deploymentParameters.EnvironmentVariables.Select(envVariable => $"{envVariable.Key}={envVariable.Value}"));
239-
parameterBuilder.Append($" -environmentVariables \"{environmentVariables}\"");
239+
parameterBuilder.Append(FormattableString.Invariant($" -environmentVariables \"{environmentVariables}\""));
240240

241241
var startInfo = new ProcessStartInfo
242242
{

src/Http/Http.Extensions/src/RequestDelegateFactory.cs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1211,17 +1211,19 @@ private static void SetPlaintextContentType(HttpContext httpContext)
12111211
private static string BuildErrorMessageForMultipleBodyParameters(FactoryContext factoryContext)
12121212
{
12131213
var errorMessage = new StringBuilder();
1214-
errorMessage.Append($"Failure to infer one or more parameters.\n");
1215-
errorMessage.Append("Below is the list of parameters that we found: \n\n");
1216-
errorMessage.Append($"{"Parameter",-20}|{"Source",-30} \n");
1217-
errorMessage.Append("---------------------------------------------------------------------------------\n");
1214+
errorMessage.AppendLine("Failure to infer one or more parameters.");
1215+
errorMessage.AppendLine("Below is the list of parameters that we found: ");
1216+
errorMessage.AppendLine();
1217+
errorMessage.AppendLine(FormattableString.Invariant($"{"Parameter",-20}|{"Source",-30}"));
1218+
errorMessage.AppendLine("---------------------------------------------------------------------------------");
12181219

12191220
foreach (var kv in factoryContext.TrackedParameters)
12201221
{
1221-
errorMessage.Append($"{kv.Key,-19} | {kv.Value,-15}\n");
1222+
errorMessage.AppendLine(FormattableString.Invariant($"{kv.Key,-19} | {kv.Value,-15}"));
12221223
}
1223-
errorMessage.Append("\n\n");
1224-
errorMessage.Append("Did you mean to register the \"UNKNOWN\" parameters as a Service?\n\n");
1224+
errorMessage.AppendLine().AppendLine();
1225+
errorMessage.AppendLine("Did you mean to register the \"UNKNOWN\" parameters as a Service?")
1226+
.AppendLine();
12251227
return errorMessage.ToString();
12261228
}
12271229
}

src/Http/Http.Extensions/test/RequestDelegateFactoryTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -918,7 +918,7 @@ public async Task BindAsyncWithBodyArgument()
918918
httpContext.Request.Body = stream;
919919

920920
httpContext.Request.Headers["Content-Type"] = "application/json";
921-
httpContext.Request.Headers["Content-Length"] = stream.Length.ToString();
921+
httpContext.Request.Headers["Content-Length"] = stream.Length.ToString(CultureInfo.InvariantCulture);
922922
httpContext.Features.Set<IHttpRequestBodyDetectionFeature>(new RequestBodyDetectionFeature(true));
923923

924924
var jsonOptions = new JsonOptions();
@@ -974,7 +974,7 @@ public async Task BindAsyncRunsBeforeBodyBinding()
974974
httpContext.Request.Body = stream;
975975

976976
httpContext.Request.Headers["Content-Type"] = "application/json";
977-
httpContext.Request.Headers["Content-Length"] = stream.Length.ToString();
977+
httpContext.Request.Headers["Content-Length"] = stream.Length.ToString(CultureInfo.InvariantCulture);
978978
httpContext.Features.Set<IHttpRequestBodyDetectionFeature>(new RequestBodyDetectionFeature(true));
979979

980980
var jsonOptions = new JsonOptions();
@@ -1118,7 +1118,7 @@ public async Task RequestDelegatePopulatesFromBodyParameter(Delegate action)
11181118
httpContext.Request.Body = stream;
11191119

11201120
httpContext.Request.Headers["Content-Type"] = "application/json";
1121-
httpContext.Request.Headers["Content-Length"] = stream.Length.ToString();
1121+
httpContext.Request.Headers["Content-Length"] = stream.Length.ToString(CultureInfo.InvariantCulture);
11221122
httpContext.Features.Set<IHttpRequestBodyDetectionFeature>(new RequestBodyDetectionFeature(true));
11231123

11241124
var jsonOptions = new JsonOptions();
@@ -2558,7 +2558,7 @@ internal static class TestExtensionResults
25582558
{
25592559
public static IResult TestResult(this IResultExtensions resultExtensions, string name)
25602560
{
2561-
return Results.Ok($"Hello {name}. This is from an extension method.");
2561+
return Results.Ok(FormattableString.Invariant($"Hello {name}. This is from an extension method."));
25622562
}
25632563
}
25642564
}

src/Http/Routing/perf/Microbenchmarks/EndpointRoutingBenchmarkBase.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,10 @@ private protected void Validate(HttpContext httpContext, Endpoint expected, Endp
7373
if (!object.ReferenceEquals(expected, actual))
7474
{
7575
var message = new StringBuilder();
76-
message.AppendLine($"Validation failed for request {Array.IndexOf(Requests, httpContext)}");
77-
message.AppendLine($"{httpContext.Request.Method} {httpContext.Request.Path}");
78-
message.AppendLine($"expected: '{((RouteEndpoint)expected)?.DisplayName ?? "null"}'");
79-
message.AppendLine($"actual: '{((RouteEndpoint)actual)?.DisplayName ?? "null"}'");
76+
message.AppendLine(FormattableString.Invariant($"Validation failed for request {Array.IndexOf(Requests, httpContext)}"));
77+
message.AppendLine(FormattableString.Invariant($"{httpContext.Request.Method} {httpContext.Request.Path}"));
78+
message.AppendLine(FormattableString.Invariant($"expected: '{((RouteEndpoint)expected)?.DisplayName ?? "null"}'"));
79+
message.AppendLine(FormattableString.Invariant($"actual: '{((RouteEndpoint)actual)?.DisplayName ?? "null"}'"));
8080
throw new InvalidOperationException(message.ToString());
8181
}
8282
}

0 commit comments

Comments
 (0)