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

Fix compilation with latest roslyn #58769

Merged
merged 2 commits into from
Nov 3, 2024
Merged
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
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 @@ -228,8 +228,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 @@ -196,7 +196,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