From 47ed95f5829ad3904198704aa10016737975ea5a Mon Sep 17 00:00:00 2001 From: Nikolche Kolev Date: Fri, 24 Jan 2025 08:38:04 -0800 Subject: [PATCH 1/4] Test out pruning --- global.json | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/global.json b/global.json index f0a083e23ce2..f6d01fd69693 100644 --- a/global.json +++ b/global.json @@ -1,9 +1,11 @@ { "sdk": { - "version": "9.0.101" + "version": "9.0.300-preview.0.25073.14", + "allowPrerelease": false, + "rollForward": "patch" }, "tools": { - "dotnet": "9.0.101", + "dotnet": "9.0.300-preview.0.25073.14", "runtimes": { "dotnet/x86": [ "$(MicrosoftNETCoreBrowserDebugHostTransportVersion)" From 80d86a56dd6acfb9722bce22ddaaae648ba5cce5 Mon Sep 17 00:00:00 2001 From: Nikolche Kolev Date: Fri, 24 Jan 2025 08:39:28 -0800 Subject: [PATCH 2/4] Enable pruning --- Directory.Build.props | 1 + 1 file changed, 1 insertion(+) diff --git a/Directory.Build.props b/Directory.Build.props index 499cf17df265..a6ea4276a388 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -3,6 +3,7 @@ true + true From ec17e0740c16f1678fabc3c6966c0175d093dc64 Mon Sep 17 00:00:00 2001 From: Nikolche Kolev Date: Fri, 24 Jan 2025 08:54:22 -0800 Subject: [PATCH 3/4] shut up analyzer --- .editorconfig | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/.editorconfig b/.editorconfig index 536c212ea709..4fc821124191 100644 --- a/.editorconfig +++ b/.editorconfig @@ -276,68 +276,68 @@ dotnet_diagnostic.CA2246.severity = warning dotnet_diagnostic.CA2249.severity = warning # IDE0005: Remove unnecessary usings -dotnet_diagnostic.IDE0005.severity = warning +dotnet_diagnostic.IDE0005.severity = none # IDE0011: Curly braces to surround blocks of code -dotnet_diagnostic.IDE0011.severity = warning +dotnet_diagnostic.IDE0011.severity = none # IDE0020: Use pattern matching to avoid is check followed by a cast (with variable) -dotnet_diagnostic.IDE0020.severity = warning +dotnet_diagnostic.IDE0020.severity = none # IDE0029: Use coalesce expression (non-nullable types) -dotnet_diagnostic.IDE0029.severity = warning +dotnet_diagnostic.IDE0029.severity = none # IDE0030: Use coalesce expression (nullable types) -dotnet_diagnostic.IDE0030.severity = warning +dotnet_diagnostic.IDE0030.severity = none # IDE0031: Use null propagation -dotnet_diagnostic.IDE0031.severity = warning +dotnet_diagnostic.IDE0031.severity = none # IDE0035: Remove unreachable code -dotnet_diagnostic.IDE0035.severity = warning +dotnet_diagnostic.IDE0035.severity = none # IDE0036: Order modifiers csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async:suggestion -dotnet_diagnostic.IDE0036.severity = warning +dotnet_diagnostic.IDE0036.severity = none # IDE0038: Use pattern matching to avoid is check followed by a cast (without variable) -dotnet_diagnostic.IDE0038.severity = warning +dotnet_diagnostic.IDE0038.severity = none # IDE0043: Format string contains invalid placeholder -dotnet_diagnostic.IDE0043.severity = warning +dotnet_diagnostic.IDE0043.severity = none # IDE0044: Make field readonly -dotnet_diagnostic.IDE0044.severity = warning +dotnet_diagnostic.IDE0044.severity = none # IDE0051: Remove unused private members -dotnet_diagnostic.IDE0051.severity = warning +dotnet_diagnostic.IDE0051.severity = none # IDE0055: All formatting rules -dotnet_diagnostic.IDE0055.severity = suggestion +dotnet_diagnostic.IDE0055.severity = none # IDE0059: Unnecessary assignment to a value -dotnet_diagnostic.IDE0059.severity = warning +dotnet_diagnostic.IDE0059.severity = none # IDE0060: Remove unused parameter dotnet_code_quality_unused_parameters = non_public -dotnet_diagnostic.IDE0060.severity = warning +dotnet_diagnostic.IDE0060.severity = none # IDE0062: Make local function static -dotnet_diagnostic.IDE0062.severity = warning +dotnet_diagnostic.IDE0062.severity = none # IDE0073: File header -dotnet_diagnostic.IDE0073.severity = warning +dotnet_diagnostic.IDE0073.severity = none file_header_template = Licensed to the .NET Foundation under one or more agreements.\nThe .NET Foundation licenses this file to you under the MIT license. # IDE0161: Convert to file-scoped namespace -dotnet_diagnostic.IDE0161.severity = warning +dotnet_diagnostic.IDE0161.severity = none # IDE0200: Lambda expression can be removed -dotnet_diagnostic.IDE0200.severity = warning +dotnet_diagnostic.IDE0200.severity = none # IDE2000: Disallow multiple blank lines dotnet_style_allow_multiple_blank_lines_experimental = false -dotnet_diagnostic.IDE2000.severity = warning +dotnet_diagnostic.IDE2000.severity = none [{eng/tools/**.cs,**/{test,testassets,samples,Samples,perf,benchmarkapps,scripts,stress}/**.cs,src/Hosting/Server.IntegrationTesting/**.cs,src/Servers/IIS/IntegrationTesting.IIS/**.cs,src/Shared/Http2cat/**.cs,src/Testing/**.cs}] # CA1018: Mark attributes with AttributeUsageAttribute From 5922f0ce006db5d313df85746d76fc6414e2a064 Mon Sep 17 00:00:00 2001 From: Adeel Mujahid <3840695+am11@users.noreply.github.com> Date: Sun, 3 Nov 2024 11:58:38 +0200 Subject: [PATCH 4/4] Fix compilation with latest roslyn (#58769) * Fix compilation with latest roslyn * . --- .../test/Circuits/ServerComponentDeserializerTest.cs | 2 +- .../DataProtection/src/Internal/ContainerUtils.cs | 2 +- .../App.Runtime/src/CompatibilitySuppressions.xml | 2 +- .../Infrastructure/SyntaxNodeExtensions.cs | 3 ++- .../RouteHandlers/DetectMisplacedLambdaAttribute.cs | 2 +- .../src/Shared/Server/MethodOptions.cs | 2 +- .../Hosting/src/GenericHost/GenericWebHostService.cs | 2 +- src/Hosting/Hosting/src/Internal/StartupLoader.cs | 2 +- src/Hosting/Hosting/src/Internal/WebHost.cs | 2 +- .../Routing/test/UnitTests/Tree/TreeRouterTest.cs | 11 ++++++----- .../WebUtilities/test/FileBufferingReadStreamTests.cs | 2 +- .../DeveloperExceptionPageMiddlewareImpl.cs | 6 +++--- .../src/Extensions/JsonNodeSchemaExtensions.cs | 2 +- .../Connections.Abstractions/src/ConnectionBuilder.cs | 2 +- .../src/MultiplexedConnectionBuilder.cs | 2 +- .../Kestrel/Core/src/Internal/KestrelServerImpl.cs | 4 ++-- src/Testing/src/xunit/DockerOnlyAttribute.cs | 2 +- 17 files changed, 26 insertions(+), 24 deletions(-) diff --git a/src/Components/Server/test/Circuits/ServerComponentDeserializerTest.cs b/src/Components/Server/test/Circuits/ServerComponentDeserializerTest.cs index d9adcd29ba33..b07bdb5e6b1c 100644 --- a/src/Components/Server/test/Circuits/ServerComponentDeserializerTest.cs +++ b/src/Components/Server/test/Circuits/ServerComponentDeserializerTest.cs @@ -156,7 +156,7 @@ public void CanParseMultipleMarkersWithAndWithoutParameters() public void DoesNotParseOutOfOrderMarkers() { // Arrange - var markers = SerializeMarkers(CreateMarkers(typeof(TestComponent), typeof(TestComponent)).Reverse().ToArray()); + var markers = SerializeMarkers(Enumerable.Reverse(CreateMarkers(typeof(TestComponent), typeof(TestComponent))).ToArray()); var serverComponentDeserializer = CreateServerComponentDeserializer(); // Act & assert diff --git a/src/DataProtection/DataProtection/src/Internal/ContainerUtils.cs b/src/DataProtection/DataProtection/src/Internal/ContainerUtils.cs index 5ae6c60ca89b..3e49202877a8 100644 --- a/src/DataProtection/DataProtection/src/Internal/ContainerUtils.cs +++ b/src/DataProtection/DataProtection/src/Internal/ContainerUtils.cs @@ -103,7 +103,7 @@ private static bool IsProcessRunningInContainer() var lines = File.ReadAllLines(procFile); // typically the last line in the file is "1:name=openrc:/docker" - return lines.Reverse().Any(l => l.EndsWith("name=openrc:/docker", StringComparison.Ordinal)); + return Enumerable.Reverse(lines).Any(l => l.EndsWith("name=openrc:/docker", StringComparison.Ordinal)); } private static bool GetBooleanEnvVar(string envVarName) diff --git a/src/Framework/App.Runtime/src/CompatibilitySuppressions.xml b/src/Framework/App.Runtime/src/CompatibilitySuppressions.xml index 044b90f8b6da..addf7e253000 100644 --- a/src/Framework/App.Runtime/src/CompatibilitySuppressions.xml +++ b/src/Framework/App.Runtime/src/CompatibilitySuppressions.xml @@ -1,5 +1,5 @@  - + PKV0001 diff --git a/src/Framework/AspNetCoreAnalyzers/src/Analyzers/RouteEmbeddedLanguage/Infrastructure/SyntaxNodeExtensions.cs b/src/Framework/AspNetCoreAnalyzers/src/Analyzers/RouteEmbeddedLanguage/Infrastructure/SyntaxNodeExtensions.cs index 3eba331a5ffb..ca244de30c0b 100644 --- a/src/Framework/AspNetCoreAnalyzers/src/Analyzers/RouteEmbeddedLanguage/Infrastructure/SyntaxNodeExtensions.cs +++ b/src/Framework/AspNetCoreAnalyzers/src/Analyzers/RouteEmbeddedLanguage/Infrastructure/SyntaxNodeExtensions.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System; +using System.Linq; using System.Diagnostics.CodeAnalysis; using Microsoft.CodeAnalysis; using Microsoft.CodeAnalysis.CSharp; @@ -126,7 +127,7 @@ private static SyntaxToken GetInitialToken( /// private static SyntaxToken FindSkippedTokenBackward(SyntaxTriviaList triviaList, int position) { - foreach (var trivia in triviaList.Reverse()) + foreach (var trivia in Enumerable.Reverse(triviaList)) { if (trivia.HasStructure) { diff --git a/src/Framework/AspNetCoreAnalyzers/src/Analyzers/RouteHandlers/DetectMisplacedLambdaAttribute.cs b/src/Framework/AspNetCoreAnalyzers/src/Analyzers/RouteHandlers/DetectMisplacedLambdaAttribute.cs index c6025fe0431f..ef6f1131d769 100644 --- a/src/Framework/AspNetCoreAnalyzers/src/Analyzers/RouteHandlers/DetectMisplacedLambdaAttribute.cs +++ b/src/Framework/AspNetCoreAnalyzers/src/Analyzers/RouteHandlers/DetectMisplacedLambdaAttribute.cs @@ -70,7 +70,7 @@ static bool IsInValidNamespace(INamespaceSymbol? @namespace) static IMethodSymbol? GetReturnedInvocation(IBlockOperation blockOperation) { - foreach (var op in blockOperation.ChildOperations.Reverse()) + foreach (var op in Enumerable.Reverse(blockOperation.ChildOperations)) { if (op is IReturnOperation returnStatement) { diff --git a/src/Grpc/JsonTranscoding/src/Shared/Server/MethodOptions.cs b/src/Grpc/JsonTranscoding/src/Shared/Server/MethodOptions.cs index 1ed83b6ea24b..1fdf601659e7 100644 --- a/src/Grpc/JsonTranscoding/src/Shared/Server/MethodOptions.cs +++ b/src/Grpc/JsonTranscoding/src/Shared/Server/MethodOptions.cs @@ -116,7 +116,7 @@ public static MethodOptions Create(IEnumerable serviceOption string? responseCompressionAlgorithm = null; CompressionLevel? responseCompressionLevel = null; - foreach (var options in serviceOptions.Reverse()) + foreach (var options in Enumerable.Reverse(serviceOptions)) { AddCompressionProviders(resolvedCompressionProviders, options.CompressionProviders); tempInterceptors.InsertRange(0, options.Interceptors); diff --git a/src/Hosting/Hosting/src/GenericHost/GenericWebHostService.cs b/src/Hosting/Hosting/src/GenericHost/GenericWebHostService.cs index 9ac3001c9b0f..c5dc58cd8251 100644 --- a/src/Hosting/Hosting/src/GenericHost/GenericWebHostService.cs +++ b/src/Hosting/Hosting/src/GenericHost/GenericWebHostService.cs @@ -132,7 +132,7 @@ static string ExpandPorts(string ports, string scheme) var builder = ApplicationBuilderFactory.CreateBuilder(Server.Features); - foreach (var filter in StartupFilters.Reverse()) + foreach (var filter in Enumerable.Reverse(StartupFilters)) { configure = filter.Configure(configure); } diff --git a/src/Hosting/Hosting/src/Internal/StartupLoader.cs b/src/Hosting/Hosting/src/Internal/StartupLoader.cs index 6124347cebc3..3989a7786bcc 100644 --- a/src/Hosting/Hosting/src/Internal/StartupLoader.cs +++ b/src/Hosting/Hosting/src/Internal/StartupLoader.cs @@ -222,7 +222,7 @@ void RunPipeline(TContainerBuilder containerBuilder) #pragma warning restore CS0612 // Type or member is obsolete Action pipeline = InvokeConfigureContainer; - foreach (var filter in filters.Reverse()) + foreach (var filter in Enumerable.Reverse(filters)) { pipeline = filter.ConfigureContainer(pipeline); } diff --git a/src/Hosting/Hosting/src/Internal/WebHost.cs b/src/Hosting/Hosting/src/Internal/WebHost.cs index 404ba7107c90..6626cdda9889 100644 --- a/src/Hosting/Hosting/src/Internal/WebHost.cs +++ b/src/Hosting/Hosting/src/Internal/WebHost.cs @@ -214,7 +214,7 @@ private RequestDelegate BuildApplication() Action configure = _startup!.Configure; if (startupFilters != null) { - foreach (var filter in startupFilters.Reverse()) + foreach (var filter in Enumerable.Reverse(startupFilters)) { configure = filter.Configure(configure); } diff --git a/src/Http/Routing/test/UnitTests/Tree/TreeRouterTest.cs b/src/Http/Routing/test/UnitTests/Tree/TreeRouterTest.cs index 951ebc1fd4c5..ad97a08408b0 100644 --- a/src/Http/Routing/test/UnitTests/Tree/TreeRouterTest.cs +++ b/src/Http/Routing/test/UnitTests/Tree/TreeRouterTest.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using System.Globalization; +using System.Linq; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Routing.Constraints; using Microsoft.AspNetCore.Routing.Template; @@ -100,7 +101,7 @@ public async Task TreeRouter_RouteAsync_MatchesRouteWithTheRightLength(string ur // We setup the route entries in reverse order of precedence to ensure that when we // try to route the request, the route with a higher precedence gets tried first. - foreach (var template in routes.Reverse()) + foreach (var template in Enumerable.Reverse(routes)) { MapInboundEntry(builder, template); } @@ -147,7 +148,7 @@ public async Task TreeRouter_RouteAsync_MatchesRoutesWithDefaults(string url, ob // We setup the route entries in reverse order of precedence to ensure that when we // try to route the request, the route with a higher precedence gets tried first. - foreach (var template in routes.Reverse()) + foreach (var template in Enumerable.Reverse(routes)) { MapInboundEntry(builder, template); } @@ -199,7 +200,7 @@ public async Task TreeRouter_RouteAsync_MatchesConstrainedRoutesWithDefaults(str // We setup the route entries in reverse order of precedence to ensure that when we // try to route the request, the route with a higher precedence gets tried first. - foreach (var template in routes.Reverse()) + foreach (var template in Enumerable.Reverse(routes)) { MapInboundEntry(builder, template); } @@ -242,7 +243,7 @@ public async Task TreeRouter_RouteAsync_MatchesCatchAllRoutesWithDefaults() // We setup the route entries in reverse order of precedence to ensure that when we // try to route the request, the route with a higher precedence gets tried first. - foreach (var template in routes.Reverse()) + foreach (var template in Enumerable.Reverse(routes)) { MapInboundEntry(builder, template); } @@ -340,7 +341,7 @@ public async Task TreeRouter_RouteAsync_DoesNotMatchShorterUrl() // We setup the route entries in reverse order of precedence to ensure that when we // try to route the request, the route with a higher precedence gets tried first. - foreach (var template in routes.Reverse()) + foreach (var template in Enumerable.Reverse(routes)) { MapInboundEntry(builder, template); } diff --git a/src/Http/WebUtilities/test/FileBufferingReadStreamTests.cs b/src/Http/WebUtilities/test/FileBufferingReadStreamTests.cs index c38dcbd2df91..51ec5de92648 100644 --- a/src/Http/WebUtilities/test/FileBufferingReadStreamTests.cs +++ b/src/Http/WebUtilities/test/FileBufferingReadStreamTests.cs @@ -488,7 +488,7 @@ public async Task CopyToAsyncWorksWithFileThreshold() // 4K is the lower bound on buffer sizes var bufferSize = 4096; var mostExpectedWrites = 8; - var data = Enumerable.Range(0, bufferSize * mostExpectedWrites).Select(b => (byte)b).Reverse().ToArray(); + var data = Enumerable.Reverse(Enumerable.Range(0, bufferSize * mostExpectedWrites).Select(b => (byte)b)).ToArray(); var inner = new MemoryStream(data); using var stream = new FileBufferingReadStream(inner, 100, bufferLimit: null, GetCurrentDirectory()); diff --git a/src/Middleware/Diagnostics/src/DeveloperExceptionPage/DeveloperExceptionPageMiddlewareImpl.cs b/src/Middleware/Diagnostics/src/DeveloperExceptionPage/DeveloperExceptionPageMiddlewareImpl.cs index cfc26131c1a1..41a2f849f94c 100644 --- a/src/Middleware/Diagnostics/src/DeveloperExceptionPage/DeveloperExceptionPageMiddlewareImpl.cs +++ b/src/Middleware/Diagnostics/src/DeveloperExceptionPage/DeveloperExceptionPageMiddlewareImpl.cs @@ -67,7 +67,7 @@ public DeveloperExceptionPageMiddlewareImpl( _exceptionHandler = DisplayException; _serializationContext = CreateSerializationContext(jsonOptions?.Value); _problemDetailsService = problemDetailsService; - foreach (var filter in filters.Reverse()) + foreach (var filter in Enumerable.Reverse(filters)) { var nextFilter = _exceptionHandler; _exceptionHandler = errorContext => filter.HandleExceptionAsync(errorContext, nextFilter); @@ -208,8 +208,8 @@ private async Task DisplayExceptionContent(ErrorContext errorContext) if (_problemDetailsService == null || !await _problemDetailsService.TryWriteAsync(new() { HttpContext = httpContext, - ProblemDetails = CreateProblemDetails(errorContext, httpContext), - Exception = errorContext.Exception + ProblemDetails = CreateProblemDetails(errorContext, httpContext), + Exception = errorContext.Exception })) { httpContext.Response.ContentType = "text/plain; charset=utf-8"; diff --git a/src/OpenApi/src/Extensions/JsonNodeSchemaExtensions.cs b/src/OpenApi/src/Extensions/JsonNodeSchemaExtensions.cs index 7e456214cfb9..a569a81daea4 100644 --- a/src/OpenApi/src/Extensions/JsonNodeSchemaExtensions.cs +++ b/src/OpenApi/src/Extensions/JsonNodeSchemaExtensions.cs @@ -211,7 +211,7 @@ internal static void ApplyRouteConstraints(this JsonNode schema, IEnumerable l.EndsWith("name=openrc:/docker", StringComparison.Ordinal)); + return Enumerable.Reverse(lines).Any(l => l.EndsWith("name=openrc:/docker", StringComparison.Ordinal)); } } }