diff --git a/global.json b/global.json index a3f08ea3cd45..7bb9d2d03876 100644 --- a/global.json +++ b/global.json @@ -1,9 +1,9 @@ { "sdk": { - "version": "8.0.100-preview.7.23360.1" + "version": "8.0.100-rc.1.23381.2" }, "tools": { - "dotnet": "8.0.100-preview.7.23360.1", + "dotnet": "8.0.100-rc.1.23381.2", "runtimes": { "dotnet/x86": [ "$(MicrosoftNETCoreBrowserDebugHostTransportVersion)" diff --git a/src/Caching/SqlServer/src/SqlServerCache.cs b/src/Caching/SqlServer/src/SqlServerCache.cs index e24192b6d1f5..5e5e96546163 100644 --- a/src/Caching/SqlServer/src/SqlServerCache.cs +++ b/src/Caching/SqlServer/src/SqlServerCache.cs @@ -59,10 +59,12 @@ public SqlServerCache(IOptions options) } if (cacheOptions.DefaultSlidingExpiration <= TimeSpan.Zero) { +#pragma warning disable CA2208 // Instantiate argument exceptions correctly throw new ArgumentOutOfRangeException( nameof(cacheOptions.DefaultSlidingExpiration), cacheOptions.DefaultSlidingExpiration, "The sliding expiration value must be positive."); +#pragma warning restore CA2208 // Instantiate argument exceptions correctly } _systemClock = cacheOptions.SystemClock ?? new SystemClock(); diff --git a/src/Caching/StackExchangeRedis/src/RedisCache.cs b/src/Caching/StackExchangeRedis/src/RedisCache.cs index 102bcae32c78..9a896e0e5a7c 100644 --- a/src/Caching/StackExchangeRedis/src/RedisCache.cs +++ b/src/Caching/StackExchangeRedis/src/RedisCache.cs @@ -573,10 +573,12 @@ private async Task RefreshAsync(IDatabase cache, string key, DateTimeOffset? abs { if (options.AbsoluteExpiration.HasValue && options.AbsoluteExpiration <= creationTime) { +#pragma warning disable CA2208 // Instantiate argument exceptions correctly throw new ArgumentOutOfRangeException( nameof(DistributedCacheEntryOptions.AbsoluteExpiration), options.AbsoluteExpiration.Value, "The absolute expiration value must be in the future."); +#pragma warning restore CA2208 // Instantiate argument exceptions correctly } if (options.AbsoluteExpirationRelativeToNow.HasValue) diff --git a/src/Components/Components/src/Routing/TemplateSegment.cs b/src/Components/Components/src/Routing/TemplateSegment.cs index 5e61935634ee..111622185ab8 100644 --- a/src/Components/Components/src/Routing/TemplateSegment.cs +++ b/src/Components/Components/src/Routing/TemplateSegment.cs @@ -23,8 +23,7 @@ public TemplateSegment(string template, string segment, bool isParameter) Value = segment[1..]; } - var invalidCharacterIndex = Value.IndexOf('*'); - if (invalidCharacterIndex != -1) + if (Value.Contains('*')) { throw new InvalidOperationException($"Invalid template '{template}'. A catch-all parameter may only have '*' or '**' at the beginning of the segment."); } @@ -93,7 +92,7 @@ public TemplateSegment(string template, string segment, bool isParameter) // Moving the check for this here instead of TemplateParser so we can allow catch-all. // We checked for '*' up above specifically for catch-all segments, this one checks for all others - if (Value.IndexOf('*') != -1) + if (Value.Contains('*')) { throw new InvalidOperationException($"Invalid template '{template}'. The character '*' in parameter segment '{{{segment}}}' is not allowed."); } diff --git a/src/Components/WebAssembly/testassets/WasmLinkerTest/WasmLinkerTest.csproj b/src/Components/WebAssembly/testassets/WasmLinkerTest/WasmLinkerTest.csproj index 99e41f9663fa..f33a0a1d0d26 100644 --- a/src/Components/WebAssembly/testassets/WasmLinkerTest/WasmLinkerTest.csproj +++ b/src/Components/WebAssembly/testassets/WasmLinkerTest/WasmLinkerTest.csproj @@ -5,6 +5,7 @@ true true true + true true diff --git a/src/Http/Http/src/Internal/ResponseCookies.cs b/src/Http/Http/src/Internal/ResponseCookies.cs index 8d57ef2a1316..f2a198b9eec3 100644 --- a/src/Http/Http/src/Internal/ResponseCookies.cs +++ b/src/Http/Http/src/Internal/ResponseCookies.cs @@ -122,20 +122,20 @@ public void Delete(string key, CookieOptions options) { rejectPredicate = (value, encKeyPlusEquals, opts) => value.StartsWith(encKeyPlusEquals, StringComparison.OrdinalIgnoreCase) && - value.IndexOf($"domain={opts.Domain}", StringComparison.OrdinalIgnoreCase) != -1 && - value.IndexOf($"path={opts.Path}", StringComparison.OrdinalIgnoreCase) != -1; + value.Contains($"domain={opts.Domain}", StringComparison.OrdinalIgnoreCase) && + value.Contains($"path={opts.Path}", StringComparison.OrdinalIgnoreCase); } else if (domainHasValue) { rejectPredicate = (value, encKeyPlusEquals, opts) => value.StartsWith(encKeyPlusEquals, StringComparison.OrdinalIgnoreCase) && - value.IndexOf($"domain={opts.Domain}", StringComparison.OrdinalIgnoreCase) != -1; + value.Contains($"domain={opts.Domain}", StringComparison.OrdinalIgnoreCase); } else if (pathHasValue) { rejectPredicate = (value, encKeyPlusEquals, opts) => value.StartsWith(encKeyPlusEquals, StringComparison.OrdinalIgnoreCase) && - value.IndexOf($"path={opts.Path}", StringComparison.OrdinalIgnoreCase) != -1; + value.Contains($"path={opts.Path}", StringComparison.OrdinalIgnoreCase); } else { diff --git a/src/Http/Routing/src/Patterns/RoutePatternParser.cs b/src/Http/Routing/src/Patterns/RoutePatternParser.cs index 268aee537973..77bbdb43d656 100644 --- a/src/Http/Routing/src/Patterns/RoutePatternParser.cs +++ b/src/Http/Routing/src/Patterns/RoutePatternParser.cs @@ -441,7 +441,7 @@ private static bool IsValidLiteral(Context context, string literal) Debug.Assert(context != null); Debug.Assert(literal != null); - if (literal.IndexOf(QuestionMark) != -1) + if (literal.Contains(QuestionMark)) { context.Error = Resources.FormatTemplateRoute_InvalidLiteral(literal); return false; diff --git a/src/Logging.AzureAppServices/src/BatchingLoggerProvider.cs b/src/Logging.AzureAppServices/src/BatchingLoggerProvider.cs index b2b0cb2d2927..40fcc93e3904 100644 --- a/src/Logging.AzureAppServices/src/BatchingLoggerProvider.cs +++ b/src/Logging.AzureAppServices/src/BatchingLoggerProvider.cs @@ -39,11 +39,15 @@ internal BatchingLoggerProvider(IOptionsMonitor options) var loggerOptions = options.CurrentValue; if (loggerOptions.BatchSize <= 0) { +#pragma warning disable CA2208 // Instantiate argument exceptions correctly throw new ArgumentOutOfRangeException(nameof(loggerOptions.BatchSize), $"{nameof(loggerOptions.BatchSize)} must be a positive number."); +#pragma warning restore CA2208 // Instantiate argument exceptions correctly } if (loggerOptions.FlushPeriod <= TimeSpan.Zero) { +#pragma warning disable CA2208 // Instantiate argument exceptions correctly throw new ArgumentOutOfRangeException(nameof(loggerOptions.FlushPeriod), $"{nameof(loggerOptions.FlushPeriod)} must be longer than zero."); +#pragma warning restore CA2208 // Instantiate argument exceptions correctly } _interval = loggerOptions.FlushPeriod; diff --git a/src/Mvc/Mvc.Razor/src/ViewPath.cs b/src/Mvc/Mvc.Razor/src/ViewPath.cs index d522cbb71575..5166ccb032c6 100644 --- a/src/Mvc/Mvc.Razor/src/ViewPath.cs +++ b/src/Mvc/Mvc.Razor/src/ViewPath.cs @@ -1,4 +1,4 @@ -// Licensed to the .NET Foundation under one or more agreements. +// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. namespace Microsoft.AspNetCore.Mvc.Razor; @@ -8,7 +8,7 @@ internal static class ViewPath public static string NormalizePath(string path) { var addLeadingSlash = path[0] != '\\' && path[0] != '/'; - var transformSlashes = path.IndexOf('\\') != -1; + var transformSlashes = path.Contains('\\'); if (!addLeadingSlash && !transformSlashes) { diff --git a/src/Shared/ChunkingCookieManager/ChunkingCookieManager.cs b/src/Shared/ChunkingCookieManager/ChunkingCookieManager.cs index 182981b78036..e67666749dbb 100644 --- a/src/Shared/ChunkingCookieManager/ChunkingCookieManager.cs +++ b/src/Shared/ChunkingCookieManager/ChunkingCookieManager.cs @@ -243,11 +243,11 @@ public void DeleteCookie(HttpContext context, string key, CookieOptions options) Func predicate = value => keys.Any(k => value.StartsWith(k, StringComparison.OrdinalIgnoreCase)); if (domainHasValue) { - rejectPredicate = value => predicate(value) && value.IndexOf("domain=" + options.Domain, StringComparison.OrdinalIgnoreCase) != -1; + rejectPredicate = value => predicate(value) && value.Contains("domain=" + options.Domain, StringComparison.OrdinalIgnoreCase); } else if (pathHasValue) { - rejectPredicate = value => predicate(value) && value.IndexOf("path=" + options.Path, StringComparison.OrdinalIgnoreCase) != -1; + rejectPredicate = value => predicate(value) && value.Contains("path=" + options.Path, StringComparison.OrdinalIgnoreCase); } else { diff --git a/src/Tools/Shared/CommandLine/CommandLineApplicationExtensions.cs b/src/Tools/Shared/CommandLine/CommandLineApplicationExtensions.cs index 4316db65c139..54bc7fe122ed 100644 --- a/src/Tools/Shared/CommandLine/CommandLineApplicationExtensions.cs +++ b/src/Tools/Shared/CommandLine/CommandLineApplicationExtensions.cs @@ -26,7 +26,11 @@ public static CommandOption Option(this CommandLineApplication command, string t => command.Option( template, description, - template.IndexOf("<", StringComparison.Ordinal) != -1 +#if NETCOREAPP + template.Contains('<') +#else + template.IndexOf('<') != -1 +#endif ? template.EndsWith(">...", StringComparison.Ordinal) ? CommandOptionType.MultipleValue : CommandOptionType.SingleValue : CommandOptionType.NoValue);