Skip to content

Commit 94f1088

Browse files
eerhardtBrennanConroyradical
authored
Update SDK to 8.0.100-rc.1.23381.2 (#49761)
* Update SDK to 8.0.100-rc.1.23381.2 * Respond to new code analysis warnings. - CA2208: Instantiate argument exceptions correctly - CA2249: Use 'string.Contains' instead of 'string.IndexOf' to improve readability * WasmLinkerTest: Workaround incorrect settings in the project file Issue when updating to build with rc1: ``` /Users/runner/work/1/s/.dotnet/sdk/8.0.100-rc.1.23381.2/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.ImportWorkloads.targets(38,5): error NETSDK1147: To build this project, the following workloads must be installed: wasm-tools [/Users/runner/work/1/s/src/Components/WebAssembly/testassets/WasmLinkerTest/WasmLinkerTest.csproj] /Users/runner/work/1/s/.dotnet/sdk/8.0.100-rc.1.23381.2/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.Sdk.ImportWorkloads.targets(38,5): error NETSDK1147: To install these workloads, run the following command: dotnet workload restore [/Users/runner/work/1/s/src/Components/WebAssembly/testassets/WasmLinkerTest/WasmLinkerTest.csproj] ``` Explanation: 1. This project has `RuntimeIdentifier=browser-wasm`, which triggers the workload manifests for wasm 2. But the project is *not* using blazor sdk, or the wasm-sdk. 3. The condition at https://github.com/dotnet/emsdk/blob/5466de081d350d3214c1ae68b7fca6295109d5cf/eng/nuget/Microsoft.NET.Workload.Emscripten.Current.Manifest/WorkloadManifest.targets#L12 ```xml <UsingBrowserRuntimeWorkload Condition="'$(RunAOTCompilation)' == 'true' or '$(UsingMicrosoftNETSdkBlazorWebAssembly)' != 'true' or '$(UsingMicrosoftNETSdkWebAssembly)' != 'true'" >true</UsingBrowserRuntimeWorkload> ``` .. means that if a `rid=browser-wasm` project is not using blazor sdk, or the wasm sdk, then it depends on the targets in the workload. And hence requires the workload. Solution: As a workaround set `UsingMicrosoftNETSdkWebAssembly=true` also (`UsingMicrosoftNETSdkBlazorWebAssembly` is already set to true). --------- Co-authored-by: Brennan <[email protected]> Co-authored-by: Ankit Jain <[email protected]>
1 parent cf006b0 commit 94f1088

File tree

11 files changed

+27
-15
lines changed

11 files changed

+27
-15
lines changed

global.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
22
"sdk": {
3-
"version": "8.0.100-preview.7.23360.1"
3+
"version": "8.0.100-rc.1.23381.2"
44
},
55
"tools": {
6-
"dotnet": "8.0.100-preview.7.23360.1",
6+
"dotnet": "8.0.100-rc.1.23381.2",
77
"runtimes": {
88
"dotnet/x86": [
99
"$(MicrosoftNETCoreBrowserDebugHostTransportVersion)"

src/Caching/SqlServer/src/SqlServerCache.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,12 @@ public SqlServerCache(IOptions<SqlServerCacheOptions> options)
5959
}
6060
if (cacheOptions.DefaultSlidingExpiration <= TimeSpan.Zero)
6161
{
62+
#pragma warning disable CA2208 // Instantiate argument exceptions correctly
6263
throw new ArgumentOutOfRangeException(
6364
nameof(cacheOptions.DefaultSlidingExpiration),
6465
cacheOptions.DefaultSlidingExpiration,
6566
"The sliding expiration value must be positive.");
67+
#pragma warning restore CA2208 // Instantiate argument exceptions correctly
6668
}
6769

6870
_systemClock = cacheOptions.SystemClock ?? new SystemClock();

src/Caching/StackExchangeRedis/src/RedisCache.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -573,10 +573,12 @@ private async Task RefreshAsync(IDatabase cache, string key, DateTimeOffset? abs
573573
{
574574
if (options.AbsoluteExpiration.HasValue && options.AbsoluteExpiration <= creationTime)
575575
{
576+
#pragma warning disable CA2208 // Instantiate argument exceptions correctly
576577
throw new ArgumentOutOfRangeException(
577578
nameof(DistributedCacheEntryOptions.AbsoluteExpiration),
578579
options.AbsoluteExpiration.Value,
579580
"The absolute expiration value must be in the future.");
581+
#pragma warning restore CA2208 // Instantiate argument exceptions correctly
580582
}
581583

582584
if (options.AbsoluteExpirationRelativeToNow.HasValue)

src/Components/Components/src/Routing/TemplateSegment.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ public TemplateSegment(string template, string segment, bool isParameter)
2323
Value = segment[1..];
2424
}
2525

26-
var invalidCharacterIndex = Value.IndexOf('*');
27-
if (invalidCharacterIndex != -1)
26+
if (Value.Contains('*'))
2827
{
2928
throw new InvalidOperationException($"Invalid template '{template}'. A catch-all parameter may only have '*' or '**' at the beginning of the segment.");
3029
}
@@ -93,7 +92,7 @@ public TemplateSegment(string template, string segment, bool isParameter)
9392

9493
// Moving the check for this here instead of TemplateParser so we can allow catch-all.
9594
// We checked for '*' up above specifically for catch-all segments, this one checks for all others
96-
if (Value.IndexOf('*') != -1)
95+
if (Value.Contains('*'))
9796
{
9897
throw new InvalidOperationException($"Invalid template '{template}'. The character '*' in parameter segment '{{{segment}}}' is not allowed.");
9998
}

src/Components/WebAssembly/testassets/WasmLinkerTest/WasmLinkerTest.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<SelfContained>true</SelfContained>
66
<UseMonoRuntime>true</UseMonoRuntime>
77
<UsingMicrosoftNETSdkBlazorWebAssembly>true</UsingMicrosoftNETSdkBlazorWebAssembly>
8+
<UsingMicrosoftNETSdkWebAssembly>true</UsingMicrosoftNETSdkWebAssembly>
89
<PublishTrimmed>true</PublishTrimmed>
910
</PropertyGroup>
1011
<ItemGroup>

src/Http/Http/src/Internal/ResponseCookies.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,20 +122,20 @@ public void Delete(string key, CookieOptions options)
122122
{
123123
rejectPredicate = (value, encKeyPlusEquals, opts) =>
124124
value.StartsWith(encKeyPlusEquals, StringComparison.OrdinalIgnoreCase) &&
125-
value.IndexOf($"domain={opts.Domain}", StringComparison.OrdinalIgnoreCase) != -1 &&
126-
value.IndexOf($"path={opts.Path}", StringComparison.OrdinalIgnoreCase) != -1;
125+
value.Contains($"domain={opts.Domain}", StringComparison.OrdinalIgnoreCase) &&
126+
value.Contains($"path={opts.Path}", StringComparison.OrdinalIgnoreCase);
127127
}
128128
else if (domainHasValue)
129129
{
130130
rejectPredicate = (value, encKeyPlusEquals, opts) =>
131131
value.StartsWith(encKeyPlusEquals, StringComparison.OrdinalIgnoreCase) &&
132-
value.IndexOf($"domain={opts.Domain}", StringComparison.OrdinalIgnoreCase) != -1;
132+
value.Contains($"domain={opts.Domain}", StringComparison.OrdinalIgnoreCase);
133133
}
134134
else if (pathHasValue)
135135
{
136136
rejectPredicate = (value, encKeyPlusEquals, opts) =>
137137
value.StartsWith(encKeyPlusEquals, StringComparison.OrdinalIgnoreCase) &&
138-
value.IndexOf($"path={opts.Path}", StringComparison.OrdinalIgnoreCase) != -1;
138+
value.Contains($"path={opts.Path}", StringComparison.OrdinalIgnoreCase);
139139
}
140140
else
141141
{

src/Http/Routing/src/Patterns/RoutePatternParser.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ private static bool IsValidLiteral(Context context, string literal)
441441
Debug.Assert(context != null);
442442
Debug.Assert(literal != null);
443443

444-
if (literal.IndexOf(QuestionMark) != -1)
444+
if (literal.Contains(QuestionMark))
445445
{
446446
context.Error = Resources.FormatTemplateRoute_InvalidLiteral(literal);
447447
return false;

src/Logging.AzureAppServices/src/BatchingLoggerProvider.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,15 @@ internal BatchingLoggerProvider(IOptionsMonitor<BatchingLoggerOptions> options)
3939
var loggerOptions = options.CurrentValue;
4040
if (loggerOptions.BatchSize <= 0)
4141
{
42+
#pragma warning disable CA2208 // Instantiate argument exceptions correctly
4243
throw new ArgumentOutOfRangeException(nameof(loggerOptions.BatchSize), $"{nameof(loggerOptions.BatchSize)} must be a positive number.");
44+
#pragma warning restore CA2208 // Instantiate argument exceptions correctly
4345
}
4446
if (loggerOptions.FlushPeriod <= TimeSpan.Zero)
4547
{
48+
#pragma warning disable CA2208 // Instantiate argument exceptions correctly
4649
throw new ArgumentOutOfRangeException(nameof(loggerOptions.FlushPeriod), $"{nameof(loggerOptions.FlushPeriod)} must be longer than zero.");
50+
#pragma warning restore CA2208 // Instantiate argument exceptions correctly
4751
}
4852

4953
_interval = loggerOptions.FlushPeriod;

src/Mvc/Mvc.Razor/src/ViewPath.cs

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

44
namespace Microsoft.AspNetCore.Mvc.Razor;
@@ -8,7 +8,7 @@ internal static class ViewPath
88
public static string NormalizePath(string path)
99
{
1010
var addLeadingSlash = path[0] != '\\' && path[0] != '/';
11-
var transformSlashes = path.IndexOf('\\') != -1;
11+
var transformSlashes = path.Contains('\\');
1212

1313
if (!addLeadingSlash && !transformSlashes)
1414
{

src/Shared/ChunkingCookieManager/ChunkingCookieManager.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,11 +243,11 @@ public void DeleteCookie(HttpContext context, string key, CookieOptions options)
243243
Func<string, bool> predicate = value => keys.Any(k => value.StartsWith(k, StringComparison.OrdinalIgnoreCase));
244244
if (domainHasValue)
245245
{
246-
rejectPredicate = value => predicate(value) && value.IndexOf("domain=" + options.Domain, StringComparison.OrdinalIgnoreCase) != -1;
246+
rejectPredicate = value => predicate(value) && value.Contains("domain=" + options.Domain, StringComparison.OrdinalIgnoreCase);
247247
}
248248
else if (pathHasValue)
249249
{
250-
rejectPredicate = value => predicate(value) && value.IndexOf("path=" + options.Path, StringComparison.OrdinalIgnoreCase) != -1;
250+
rejectPredicate = value => predicate(value) && value.Contains("path=" + options.Path, StringComparison.OrdinalIgnoreCase);
251251
}
252252
else
253253
{

src/Tools/Shared/CommandLine/CommandLineApplicationExtensions.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,11 @@ public static CommandOption Option(this CommandLineApplication command, string t
2626
=> command.Option(
2727
template,
2828
description,
29-
template.IndexOf("<", StringComparison.Ordinal) != -1
29+
#if NETCOREAPP
30+
template.Contains('<')
31+
#else
32+
template.IndexOf('<') != -1
33+
#endif
3034
? template.EndsWith(">...", StringComparison.Ordinal) ? CommandOptionType.MultipleValue : CommandOptionType.SingleValue
3135
: CommandOptionType.NoValue);
3236

0 commit comments

Comments
 (0)