Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Try pruning #60025

Draft
wants to merge 4 commits into
base: release/9.0
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 20 additions & 20 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

<PropertyGroup>
<AccelerateBuildsInVisualStudio>true</AccelerateBuildsInVisualStudio>
<RestoreEnablePackagePruning>true</RestoreEnablePackagePruning>
</PropertyGroup>

<PropertyGroup>
Expand Down
6 changes: 4 additions & 2 deletions global.json
Original file line number Diff line number Diff line change
@@ -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)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- https://learn.microsoft.com/en-us/dotnet/fundamentals/package-validation/diagnostic-ids -->
<!-- https://learn.microsoft.com/dotnet/fundamentals/package-validation/diagnostic-ids -->
<Suppressions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<Suppression>
<DiagnosticId>PKV0001</DiagnosticId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -126,7 +127,7 @@ private static SyntaxToken GetInitialToken(
/// </summary>
private static SyntaxToken FindSkippedTokenBackward(SyntaxTriviaList triviaList, int position)
{
foreach (var trivia in triviaList.Reverse())
foreach (var trivia in Enumerable.Reverse(triviaList))
{
if (trivia.HasStructure)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public static MethodOptions Create(IEnumerable<GrpcServiceOptions> 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Hosting/Hosting/src/Internal/StartupLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ void RunPipeline(TContainerBuilder containerBuilder)
#pragma warning restore CS0612 // Type or member is obsolete

Action<TContainerBuilder> pipeline = InvokeConfigureContainer;
foreach (var filter in filters.Reverse())
foreach (var filter in Enumerable.Reverse(filters))
{
pipeline = filter.ConfigureContainer(pipeline);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Hosting/Hosting/src/Internal/WebHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ private RequestDelegate BuildApplication()
Action<IApplicationBuilder> configure = _startup!.Configure;
if (startupFilters != null)
{
foreach (var filter in startupFilters.Reverse())
foreach (var filter in Enumerable.Reverse(startupFilters))
{
configure = filter.Configure(configure);
}
Expand Down
11 changes: 6 additions & 5 deletions src/Http/Routing/test/UnitTests/Tree/TreeRouterTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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";
Expand Down
2 changes: 1 addition & 1 deletion src/OpenApi/src/Extensions/JsonNodeSchemaExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ internal static void ApplyRouteConstraints(this JsonNode schema, IEnumerable<IRo
{
// Apply constraints in reverse order because when it comes to the routing
// layer the first constraint that is violated causes routing to short circuit.
foreach (var constraint in constraints.Reverse())
foreach (var constraint in Enumerable.Reverse(constraints))
{
if (constraint is MinRouteConstraint minRouteConstraint)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public ConnectionDelegate Build()
return Task.CompletedTask;
};

foreach (var component in _components.Reverse())
foreach (var component in Enumerable.Reverse(_components))
{
app = component(app);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public MultiplexedConnectionDelegate Build()
return Task.CompletedTask;
};

foreach (var component in _components.Reverse())
foreach (var component in Enumerable.Reverse(_components))
{
app = component(app);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Servers/Kestrel/Core/src/Internal/KestrelServerImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ internal KestrelServerImpl(
{
ArgumentNullException.ThrowIfNull(transportFactories);

_transportFactories = transportFactories.Reverse().ToList();
_multiplexedTransportFactories = multiplexedFactories.Reverse().ToList();
_transportFactories = Enumerable.Reverse(transportFactories).ToList();
_multiplexedTransportFactories = Enumerable.Reverse(multiplexedFactories).ToList();
_httpsConfigurationService = httpsConfigurationService;

if (_transportFactories.Count == 0 && _multiplexedTransportFactories.Count == 0)
Expand Down
2 changes: 1 addition & 1 deletion src/Testing/src/xunit/DockerOnlyAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public bool IsMet

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));
}
}
}
Loading