Skip to content

Commit

Permalink
Fix #10066
Browse files Browse the repository at this point in the history
  • Loading branch information
rynowak committed May 9, 2019
1 parent 9c32660 commit 24784d0
Show file tree
Hide file tree
Showing 50 changed files with 19 additions and 65 deletions.
Expand Up @@ -147,6 +147,11 @@ public partial class Endpoint
public Microsoft.AspNetCore.Http.RequestDelegate RequestDelegate { [System.Runtime.CompilerServices.CompilerGeneratedAttribute]get { throw null; } }
public override string ToString() { throw null; }
}
public static partial class EndpointHttpContextExtensions
{
public static Microsoft.AspNetCore.Http.Endpoint GetEndpoint(this Microsoft.AspNetCore.Http.HttpContext context) { throw null; }
public static void SetEndpoint(this Microsoft.AspNetCore.Http.HttpContext context, Microsoft.AspNetCore.Http.Endpoint endpoint) { }
}
public sealed partial class EndpointMetadataCollection : System.Collections.Generic.IEnumerable<object>, System.Collections.Generic.IReadOnlyCollection<object>, System.Collections.Generic.IReadOnlyList<object>, System.Collections.IEnumerable
{
public static readonly Microsoft.AspNetCore.Http.EndpointMetadataCollection Empty;
Expand Down Expand Up @@ -463,14 +468,6 @@ public abstract partial class WebSocketManager
public abstract System.Threading.Tasks.Task<System.Net.WebSockets.WebSocket> AcceptWebSocketAsync(string subProtocol);
}
}
namespace Microsoft.AspNetCore.Http.Endpoints
{
public static partial class EndpointHttpContextExtensions
{
public static Microsoft.AspNetCore.Http.Endpoint GetEndpoint(this Microsoft.AspNetCore.Http.HttpContext context) { throw null; }
public static void SetEndpoint(this Microsoft.AspNetCore.Http.HttpContext context, Microsoft.AspNetCore.Http.Endpoint endpoint) { }
}
}
namespace Microsoft.AspNetCore.Http.Features
{
public partial interface IEndpointFeature
Expand Down
Expand Up @@ -4,7 +4,7 @@
using System;
using Microsoft.AspNetCore.Http.Features;

namespace Microsoft.AspNetCore.Http.Endpoints
namespace Microsoft.AspNetCore.Http
{
/// <summary>
/// Extension methods to expose Endpoint on HttpContext.
Expand Down
Expand Up @@ -5,7 +5,6 @@
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http.Endpoints;
using Microsoft.AspNetCore.Http.Features;
using Xunit;

Expand Down
1 change: 0 additions & 1 deletion src/Http/Http/src/Internal/ApplicationBuilder.cs
Expand Up @@ -6,7 +6,6 @@
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Endpoints;
using Microsoft.AspNetCore.Http.Features;
using Microsoft.AspNetCore.Http.Internal;
using Microsoft.Extensions.Internal;
Expand Down
1 change: 0 additions & 1 deletion src/Http/Http/test/Internal/ApplicationBuilderTests.cs
Expand Up @@ -4,7 +4,6 @@
using System;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Endpoints;
using Xunit;

namespace Microsoft.AspNetCore.Builder.Internal
Expand Down
2 changes: 1 addition & 1 deletion src/Http/Routing/perf/Matching/MatcherAzureBenchmark.cs
Expand Up @@ -3,7 +3,7 @@

using System.Threading.Tasks;
using BenchmarkDotNet.Attributes;
using Microsoft.AspNetCore.Http.Endpoints;
using Microsoft.AspNetCore.Http;

namespace Microsoft.AspNetCore.Routing.Matching
{
Expand Down
2 changes: 1 addition & 1 deletion src/Http/Routing/perf/Matching/MatcherGithubBenchmark.cs
Expand Up @@ -3,7 +3,7 @@

using System.Threading.Tasks;
using BenchmarkDotNet.Attributes;
using Microsoft.AspNetCore.Http.Endpoints;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Features;

namespace Microsoft.AspNetCore.Routing.Matching
Expand Down
Expand Up @@ -4,7 +4,6 @@
using System.Threading.Tasks;
using BenchmarkDotNet.Attributes;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Endpoints;
using Microsoft.AspNetCore.Http.Features;

namespace Microsoft.AspNetCore.Routing.Matching
Expand Down
1 change: 0 additions & 1 deletion src/Http/Routing/perf/Matching/TrivialMatcher.cs
Expand Up @@ -4,7 +4,6 @@
using System;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Endpoints;
using Microsoft.AspNetCore.Http.Features;

namespace Microsoft.AspNetCore.Routing.Matching
Expand Down
1 change: 0 additions & 1 deletion src/Http/Routing/src/EndpointRoutingMiddleware.cs
Expand Up @@ -6,7 +6,6 @@
using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Endpoints;
using Microsoft.AspNetCore.Routing.Matching;
using Microsoft.Extensions.Logging;

Expand Down
1 change: 0 additions & 1 deletion src/Http/Routing/src/Matching/DefaultEndpointSelector.cs
Expand Up @@ -6,7 +6,6 @@
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Endpoints;

namespace Microsoft.AspNetCore.Routing.Matching
{
Expand Down
3 changes: 1 addition & 2 deletions src/Http/Routing/src/Matching/DfaMatcher.cs
Expand Up @@ -5,7 +5,6 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Endpoints;
using Microsoft.AspNetCore.Routing.Patterns;
using Microsoft.Extensions.Logging;

Expand Down Expand Up @@ -230,7 +229,7 @@ public sealed override Task MatchAsync(HttpContext httpContext)
for (var i = 0; i < captures.Length; i++)
{
(var parameterName, var segmentIndex, var slotIndex) = captures[i];

if ((uint)segmentIndex < (uint)segments.Length)
{
var segment = segments[segmentIndex];
Expand Down
1 change: 0 additions & 1 deletion src/Http/Routing/src/Matching/EndpointSelector.cs
Expand Up @@ -3,7 +3,6 @@

using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Endpoints;

namespace Microsoft.AspNetCore.Routing.Matching
{
Expand Down
1 change: 0 additions & 1 deletion src/Http/Routing/src/Matching/HttpMethodMatcherPolicy.cs
Expand Up @@ -6,7 +6,6 @@
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Endpoints;
using Microsoft.Extensions.Internal;
using Microsoft.Extensions.Primitives;
using Microsoft.Net.Http.Headers;
Expand Down
1 change: 0 additions & 1 deletion src/Http/Routing/src/Matching/IEndpointSelectorPolicy.cs
Expand Up @@ -2,7 +2,6 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Endpoints;
using System.Collections.Generic;
using System.Threading.Tasks;

Expand Down
Expand Up @@ -6,7 +6,6 @@
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder.Internal;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Endpoints;
using Microsoft.AspNetCore.Http.Features;
using Microsoft.AspNetCore.Routing;
using Microsoft.AspNetCore.Routing.Matching;
Expand Down
5 changes: 2 additions & 3 deletions src/Http/Routing/test/UnitTests/EndpointMiddlewareTest.cs
Expand Up @@ -6,7 +6,6 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Cors.Infrastructure;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Endpoints;
using Microsoft.AspNetCore.Http.Features;
using Microsoft.Extensions.Logging.Abstractions;
using Microsoft.Extensions.Options;
Expand Down Expand Up @@ -46,7 +45,7 @@ public async Task Invoke_NoEndpoint_NoOps()
var httpContext = new DefaultHttpContext();
httpContext.RequestServices = new ServiceProvider();
httpContext.SetEndpoint(null);

RequestDelegate next = (c) =>
{
return Task.CompletedTask;
Expand Down Expand Up @@ -75,7 +74,7 @@ public async Task Invoke_WithEndpoint_InvokesDelegate()
};

httpContext.SetEndpoint(new Endpoint(endpointFunc, EndpointMetadataCollection.Empty, "Test"));

RequestDelegate next = (c) =>
{
return Task.CompletedTask;
Expand Down
Expand Up @@ -5,7 +5,6 @@
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Endpoints;
using Microsoft.AspNetCore.Http.Features;
using Microsoft.AspNetCore.Routing.Matching;
using Microsoft.AspNetCore.Routing.TestObjects;
Expand Down
Expand Up @@ -4,7 +4,6 @@
using System;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Endpoints;
using Microsoft.AspNetCore.Http.Features;

namespace Microsoft.AspNetCore.Routing.Matching
Expand Down
Expand Up @@ -4,7 +4,6 @@
using System;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Endpoints;
using Microsoft.AspNetCore.Http.Features;
using Microsoft.AspNetCore.Routing.Patterns;
using Moq;
Expand Down
1 change: 0 additions & 1 deletion src/Http/Routing/test/UnitTests/Matching/DfaMatcherTest.cs
Expand Up @@ -6,7 +6,6 @@
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Endpoints;
using Microsoft.AspNetCore.Http.Features;
using Microsoft.AspNetCore.Routing.Constraints;
using Microsoft.AspNetCore.Routing.Patterns;
Expand Down
Expand Up @@ -5,7 +5,6 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Endpoints;
using Microsoft.AspNetCore.Http.Features;
using Microsoft.AspNetCore.Routing.Patterns;
using Microsoft.Extensions.DependencyInjection;
Expand Down
1 change: 0 additions & 1 deletion src/Http/Routing/test/UnitTests/Matching/MatcherAssert.cs
Expand Up @@ -5,7 +5,6 @@
using System.Collections.Generic;
using System.Linq;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Endpoints;
using Microsoft.AspNetCore.Http.Features;
using Xunit.Sdk;

Expand Down
Expand Up @@ -6,7 +6,6 @@
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Endpoints;
using Microsoft.AspNetCore.Http.Features;
using Microsoft.AspNetCore.Routing.Patterns;
using Microsoft.AspNetCore.Routing.TestObjects;
Expand Down
Expand Up @@ -5,7 +5,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http.Endpoints;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Features;
using Microsoft.AspNetCore.Routing.Internal;
using Microsoft.AspNetCore.Routing.Template;
Expand Down
1 change: 0 additions & 1 deletion src/Http/Routing/test/UnitTests/TestObjects/TestMatcher.cs
Expand Up @@ -3,7 +3,6 @@

using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Endpoints;
using Microsoft.AspNetCore.Http.Features;
using Microsoft.AspNetCore.Routing.Matching;

Expand Down
Expand Up @@ -8,7 +8,6 @@
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Endpoints;
using Microsoft.AspNetCore.Http.Features;
using Microsoft.AspNetCore.Internal;
using Microsoft.AspNetCore.Routing;
Expand Down
1 change: 0 additions & 1 deletion src/Middleware/CORS/src/Infrastructure/CorsMiddleware.cs
Expand Up @@ -5,7 +5,6 @@
using System.Threading.Tasks;
using Microsoft.AspNetCore.Cors.Internal;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Endpoints;
using Microsoft.Extensions.Logging;

namespace Microsoft.AspNetCore.Cors.Infrastructure
Expand Down
1 change: 0 additions & 1 deletion src/Middleware/CORS/test/UnitTests/CorsMiddlewareTests.cs
Expand Up @@ -8,7 +8,6 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Endpoints;
using Microsoft.AspNetCore.TestHost;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging.Abstractions;
Expand Down
Expand Up @@ -6,7 +6,6 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Endpoints;
using Microsoft.AspNetCore.Routing;
using Microsoft.AspNetCore.Routing.Patterns;

Expand Down
Expand Up @@ -3,7 +3,7 @@

using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http.Endpoints;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using System;
Expand Down
Expand Up @@ -2,7 +2,6 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.

using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http.Endpoints;
using Microsoft.AspNetCore.SpaServices.StaticFiles;
using Microsoft.Extensions.FileProviders;
using Microsoft.Extensions.Options;
Expand Down
3 changes: 1 addition & 2 deletions src/Middleware/StaticFiles/src/DefaultFilesMiddleware.cs
Expand Up @@ -6,7 +6,6 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Endpoints;
using Microsoft.Extensions.FileProviders;
using Microsoft.Extensions.Options;
using Microsoft.Net.Http.Headers;
Expand Down Expand Up @@ -47,7 +46,7 @@ public DefaultFilesMiddleware(RequestDelegate next, IWebHostEnvironment hostingE
{
throw new ArgumentNullException(nameof(options));
}

_next = next;
_options = options.Value;
_fileProvider = _options.FileProvider ?? Helpers.ResolveFileProvider(hostingEnv);
Expand Down
3 changes: 1 addition & 2 deletions src/Middleware/StaticFiles/src/DirectoryBrowserMiddleware.cs
Expand Up @@ -7,7 +7,6 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Endpoints;
using Microsoft.Extensions.FileProviders;
using Microsoft.Extensions.Options;
using Microsoft.Net.Http.Headers;
Expand All @@ -31,7 +30,7 @@ public class DirectoryBrowserMiddleware
/// <param name="next">The next middleware in the pipeline.</param>
/// <param name="hostingEnv">The <see cref="IWebHostEnvironment"/> used by this middleware.</param>
/// <param name="options">The configuration for this middleware.</param>
public DirectoryBrowserMiddleware(RequestDelegate next, IWebHostEnvironment hostingEnv, IOptions<DirectoryBrowserOptions> options)
public DirectoryBrowserMiddleware(RequestDelegate next, IWebHostEnvironment hostingEnv, IOptions<DirectoryBrowserOptions> options)
: this(next, hostingEnv, HtmlEncoder.Default, options)
{
}
Expand Down
1 change: 0 additions & 1 deletion src/Middleware/StaticFiles/src/StaticFileMiddleware.cs
Expand Up @@ -6,7 +6,6 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Endpoints;
using Microsoft.Extensions.FileProviders;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
Expand Down
Expand Up @@ -3,7 +3,6 @@

using System;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Endpoints;
using Microsoft.AspNetCore.Routing;
using Microsoft.AspNetCore.StaticFiles;

Expand Down
Expand Up @@ -14,7 +14,6 @@
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Endpoints;
using Microsoft.AspNetCore.Server.IntegrationTesting;
using Microsoft.AspNetCore.Server.IntegrationTesting.Common;
using Microsoft.AspNetCore.Testing;
Expand Down
Expand Up @@ -9,7 +9,6 @@
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Endpoints;
using Microsoft.AspNetCore.Http.Extensions;
using Microsoft.AspNetCore.TestHost;
using Microsoft.AspNetCore.Testing.xunit;
Expand Down
Expand Up @@ -9,7 +9,6 @@
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Endpoints;
using Microsoft.AspNetCore.Http.Features;
using Microsoft.AspNetCore.TestHost;
using Microsoft.AspNetCore.Testing.xunit;
Expand Down
4 changes: 2 additions & 2 deletions src/Mvc/Mvc.Core/src/Authorization/AuthorizeFilter.cs
Expand Up @@ -8,7 +8,7 @@
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Authorization.Policy;
using Microsoft.AspNetCore.Http.Endpoints;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc.ApplicationModels;
using Microsoft.AspNetCore.Mvc.Core;
using Microsoft.AspNetCore.Mvc.Filters;
Expand Down Expand Up @@ -230,7 +230,7 @@ private static bool HasAllowAnonymous(AuthorizationFilterContext context)
}

// When doing endpoint routing, MVC does not add AllowAnonymousFilters for AllowAnonymousAttributes that
// were discovered on controllers and actions. To maintain compat with 2.x,
// were discovered on controllers and actions. To maintain compat with 2.x,
// we'll check for the presence of IAllowAnonymous in endpoint metadata.
var endpoint = context.HttpContext.GetEndpoint();
if (endpoint?.Metadata?.GetMetadata<IAllowAnonymous>() != null)
Expand Down

0 comments on commit 24784d0

Please sign in to comment.