Merge remote-tracking branch 'origin/release/2.2' into feature/master-routing-api-review-p1
This commit is contained in:
commit
2f7ec2ada2
|
|
@ -29,11 +29,11 @@ namespace Benchmarks
|
||||||
.UseKestrel();
|
.UseKestrel();
|
||||||
|
|
||||||
var scenario = config["scenarios"]?.ToLower();
|
var scenario = config["scenarios"]?.ToLower();
|
||||||
if (scenario == "plaintextdispatcher" || scenario == "plaintextglobalrouting")
|
if (scenario == "plaintextdispatcher" || scenario == "plaintextendpointrouting")
|
||||||
{
|
{
|
||||||
webHostBuilder.UseStartup<StartupUsingGlobalRouting>();
|
webHostBuilder.UseStartup<StartupUsingEndpointRouting>();
|
||||||
// for testing
|
// for testing
|
||||||
webHostBuilder.UseSetting("Startup", nameof(StartupUsingGlobalRouting));
|
webHostBuilder.UseSetting("Startup", nameof(StartupUsingEndpointRouting));
|
||||||
}
|
}
|
||||||
else if (scenario == "plaintextrouting" || scenario == "plaintextrouter")
|
else if (scenario == "plaintextrouting" || scenario == "plaintextrouter")
|
||||||
{
|
{
|
||||||
|
|
@ -44,7 +44,7 @@ namespace Benchmarks
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new InvalidOperationException(
|
throw new InvalidOperationException(
|
||||||
$"Invalid scenario '{scenario}'. Allowed scenarios are PlaintextGlobalRouting and PlaintextRouter");
|
$"Invalid scenario '{scenario}'. Allowed scenarios are PlaintextEndpointRouting and PlaintextRouter");
|
||||||
}
|
}
|
||||||
|
|
||||||
return webHostBuilder;
|
return webHostBuilder;
|
||||||
|
|
|
||||||
|
|
@ -2,15 +2,15 @@
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using Microsoft.AspNetCore.Builder;
|
using Microsoft.AspNetCore.Internal;
|
||||||
using Microsoft.AspNetCore.Routing;
|
using Microsoft.AspNetCore.Routing;
|
||||||
using Microsoft.AspNetCore.Routing.Matchers;
|
using Microsoft.AspNetCore.Routing.Matching;
|
||||||
using Microsoft.AspNetCore.Routing.Patterns;
|
using Microsoft.AspNetCore.Routing.Patterns;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
|
||||||
namespace Benchmarks
|
namespace Benchmarks
|
||||||
{
|
{
|
||||||
public class StartupUsingGlobalRouting
|
public class StartupUsingEndpointRouting
|
||||||
{
|
{
|
||||||
private static readonly byte[] _helloWorldPayload = Encoding.UTF8.GetBytes("Hello, World!");
|
private static readonly byte[] _helloWorldPayload = Encoding.UTF8.GetBytes("Hello, World!");
|
||||||
|
|
||||||
|
|
@ -41,9 +41,9 @@ namespace Benchmarks
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Configure(IApplicationBuilder app)
|
public void Configure(Microsoft.AspNetCore.Builder.IApplicationBuilder app)
|
||||||
{
|
{
|
||||||
app.UseGlobalRouting();
|
app.UseEndpointRouting();
|
||||||
|
|
||||||
app.UseEndpoint();
|
app.UseEndpoint();
|
||||||
}
|
}
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Routing.Matchers
|
namespace Microsoft.AspNetCore.Routing.Matching
|
||||||
{
|
{
|
||||||
// An optimized jump table that trades a small amount of additional memory for
|
// An optimized jump table that trades a small amount of additional memory for
|
||||||
// hash-table like performance.
|
// hash-table like performance.
|
||||||
|
|
@ -6,7 +6,7 @@ using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Routing.Matchers
|
namespace Microsoft.AspNetCore.Routing.Matching
|
||||||
{
|
{
|
||||||
internal class CustomHashTableJumpTable : JumpTable
|
internal class CustomHashTableJumpTable : JumpTable
|
||||||
{
|
{
|
||||||
|
|
@ -5,7 +5,7 @@ using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Routing.Matchers
|
namespace Microsoft.AspNetCore.Routing.Matching
|
||||||
{
|
{
|
||||||
internal class DictionaryLookupJumpTable : JumpTable
|
internal class DictionaryLookupJumpTable : JumpTable
|
||||||
{
|
{
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Routing.Matchers
|
namespace Microsoft.AspNetCore.Routing.Matching
|
||||||
{
|
{
|
||||||
public abstract class FastPathTokenizerBenchmarkBase
|
public abstract class FastPathTokenizerBenchmarkBase
|
||||||
{
|
{
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
using System;
|
using System;
|
||||||
using BenchmarkDotNet.Attributes;
|
using BenchmarkDotNet.Attributes;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Routing.Matchers
|
namespace Microsoft.AspNetCore.Routing.Matching
|
||||||
{
|
{
|
||||||
public class FastPathTokenizerEmptyBenchmark : FastPathTokenizerBenchmarkBase
|
public class FastPathTokenizerEmptyBenchmark : FastPathTokenizerBenchmarkBase
|
||||||
{
|
{
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
using System;
|
using System;
|
||||||
using BenchmarkDotNet.Attributes;
|
using BenchmarkDotNet.Attributes;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Routing.Matchers
|
namespace Microsoft.AspNetCore.Routing.Matching
|
||||||
{
|
{
|
||||||
public class FastPathTokenizerLargeBenchmark : FastPathTokenizerBenchmarkBase
|
public class FastPathTokenizerLargeBenchmark : FastPathTokenizerBenchmarkBase
|
||||||
{
|
{
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
using System;
|
using System;
|
||||||
using BenchmarkDotNet.Attributes;
|
using BenchmarkDotNet.Attributes;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Routing.Matchers
|
namespace Microsoft.AspNetCore.Routing.Matching
|
||||||
{
|
{
|
||||||
public class FastPathTokenizerPlaintextBenchmark : FastPathTokenizerBenchmarkBase
|
public class FastPathTokenizerPlaintextBenchmark : FastPathTokenizerBenchmarkBase
|
||||||
{
|
{
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
using System;
|
using System;
|
||||||
using BenchmarkDotNet.Attributes;
|
using BenchmarkDotNet.Attributes;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Routing.Matchers
|
namespace Microsoft.AspNetCore.Routing.Matching
|
||||||
{
|
{
|
||||||
public class FastPathTokenizerSmallBenchmark : FastPathTokenizerBenchmarkBase
|
public class FastPathTokenizerSmallBenchmark : FastPathTokenizerBenchmarkBase
|
||||||
{
|
{
|
||||||
|
|
@ -6,7 +6,7 @@ using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using BenchmarkDotNet.Attributes;
|
using BenchmarkDotNet.Attributes;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Routing.Matchers
|
namespace Microsoft.AspNetCore.Routing.Matching
|
||||||
{
|
{
|
||||||
public class JumpTableMultipleEntryBenchmark
|
public class JumpTableMultipleEntryBenchmark
|
||||||
{
|
{
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
using System;
|
using System;
|
||||||
using BenchmarkDotNet.Attributes;
|
using BenchmarkDotNet.Attributes;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Routing.Matchers
|
namespace Microsoft.AspNetCore.Routing.Matching
|
||||||
{
|
{
|
||||||
public class JumpTableSingleEntryBenchmark
|
public class JumpTableSingleEntryBenchmark
|
||||||
{
|
{
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
using BenchmarkDotNet.Attributes;
|
using BenchmarkDotNet.Attributes;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Routing.Matchers
|
namespace Microsoft.AspNetCore.Routing.Matching
|
||||||
{
|
{
|
||||||
public class JumpTableZeroEntryBenchmark
|
public class JumpTableZeroEntryBenchmark
|
||||||
{
|
{
|
||||||
|
|
@ -5,7 +5,7 @@ using System;
|
||||||
using BenchmarkDotNet.Attributes;
|
using BenchmarkDotNet.Attributes;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Routing.Matchers
|
namespace Microsoft.AspNetCore.Routing.Matching
|
||||||
{
|
{
|
||||||
public class MatcheFindCandidateSetSingleEntryBenchmark : MatcherBenchmarkBase
|
public class MatcheFindCandidateSetSingleEntryBenchmark : MatcherBenchmarkBase
|
||||||
{
|
{
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using BenchmarkDotNet.Attributes;
|
using BenchmarkDotNet.Attributes;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Routing.Matchers
|
namespace Microsoft.AspNetCore.Routing.Matching
|
||||||
{
|
{
|
||||||
// Generated from https://github.com/Azure/azure-rest-api-specs
|
// Generated from https://github.com/Azure/azure-rest-api-specs
|
||||||
public partial class MatcherAzureBenchmark : MatcherBenchmarkBase
|
public partial class MatcherAzureBenchmark : MatcherBenchmarkBase
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Routing.Matchers
|
namespace Microsoft.AspNetCore.Routing.Matching
|
||||||
{
|
{
|
||||||
// This code was generated by the Swaggatherer
|
// This code was generated by the Swaggatherer
|
||||||
public partial class MatcherAzureBenchmark : MatcherBenchmarkBase
|
public partial class MatcherAzureBenchmark : MatcherBenchmarkBase
|
||||||
|
|
@ -11,7 +11,7 @@ using Microsoft.AspNetCore.Routing.Metadata;
|
||||||
using Microsoft.AspNetCore.Routing.Patterns;
|
using Microsoft.AspNetCore.Routing.Patterns;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Routing.Matchers
|
namespace Microsoft.AspNetCore.Routing.Matching
|
||||||
{
|
{
|
||||||
public abstract class MatcherBenchmarkBase
|
public abstract class MatcherBenchmarkBase
|
||||||
{
|
{
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
using System;
|
using System;
|
||||||
using BenchmarkDotNet.Attributes;
|
using BenchmarkDotNet.Attributes;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Routing.Matchers
|
namespace Microsoft.AspNetCore.Routing.Matching
|
||||||
{
|
{
|
||||||
// Generated from https://github.com/Azure/azure-rest-api-specs
|
// Generated from https://github.com/Azure/azure-rest-api-specs
|
||||||
public partial class MatcherFindCandidateSetAzureBenchmark : MatcherBenchmarkBase
|
public partial class MatcherFindCandidateSetAzureBenchmark : MatcherBenchmarkBase
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Routing.Matchers
|
namespace Microsoft.AspNetCore.Routing.Matching
|
||||||
{
|
{
|
||||||
// This code was generated by the Swaggatherer
|
// This code was generated by the Swaggatherer
|
||||||
public partial class MatcherFindCandidateSetAzureBenchmark : MatcherBenchmarkBase
|
public partial class MatcherFindCandidateSetAzureBenchmark : MatcherBenchmarkBase
|
||||||
|
|
@ -5,7 +5,7 @@ using System;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using BenchmarkDotNet.Attributes;
|
using BenchmarkDotNet.Attributes;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Routing.Matchers
|
namespace Microsoft.AspNetCore.Routing.Matching
|
||||||
{
|
{
|
||||||
// Generated from https://github.com/APIs-guru/openapi-directory
|
// Generated from https://github.com/APIs-guru/openapi-directory
|
||||||
// Use https://editor2.swagger.io/ to convert from yaml to json-
|
// Use https://editor2.swagger.io/ to convert from yaml to json-
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Routing.Matchers
|
namespace Microsoft.AspNetCore.Routing.Matching
|
||||||
{
|
{
|
||||||
// This code was generated by the Swaggatherer
|
// This code was generated by the Swaggatherer
|
||||||
public partial class MatcherFindCandidateSetGithubBenchmark : MatcherBenchmarkBase
|
public partial class MatcherFindCandidateSetGithubBenchmark : MatcherBenchmarkBase
|
||||||
|
|
@ -5,7 +5,7 @@ using System;
|
||||||
using BenchmarkDotNet.Attributes;
|
using BenchmarkDotNet.Attributes;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Routing.Matchers
|
namespace Microsoft.AspNetCore.Routing.Matching
|
||||||
{
|
{
|
||||||
public class MatcherFindCandidateSetSmallEntryCountBenchmark : MatcherBenchmarkBase
|
public class MatcherFindCandidateSetSmallEntryCountBenchmark : MatcherBenchmarkBase
|
||||||
{
|
{
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using BenchmarkDotNet.Attributes;
|
using BenchmarkDotNet.Attributes;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Routing.Matchers
|
namespace Microsoft.AspNetCore.Routing.Matching
|
||||||
{
|
{
|
||||||
// Generated from https://github.com/APIs-guru/openapi-directory
|
// Generated from https://github.com/APIs-guru/openapi-directory
|
||||||
// Use https://editor2.swagger.io/ to convert from yaml to json-
|
// Use https://editor2.swagger.io/ to convert from yaml to json-
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Routing.Matchers
|
namespace Microsoft.AspNetCore.Routing.Matching
|
||||||
{
|
{
|
||||||
// This code was generated by the Swaggatherer
|
// This code was generated by the Swaggatherer
|
||||||
public partial class MatcherGithubBenchmark : MatcherBenchmarkBase
|
public partial class MatcherGithubBenchmark : MatcherBenchmarkBase
|
||||||
|
|
@ -5,7 +5,7 @@ using System.Threading.Tasks;
|
||||||
using BenchmarkDotNet.Attributes;
|
using BenchmarkDotNet.Attributes;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Routing.Matchers
|
namespace Microsoft.AspNetCore.Routing.Matching
|
||||||
{
|
{
|
||||||
// Just like TechEmpower Plaintext
|
// Just like TechEmpower Plaintext
|
||||||
public partial class MatcherSingleEntryBenchmark : MatcherBenchmarkBase
|
public partial class MatcherSingleEntryBenchmark : MatcherBenchmarkBase
|
||||||
|
|
@ -5,7 +5,7 @@ using System;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Routing.Matchers
|
namespace Microsoft.AspNetCore.Routing.Matching
|
||||||
{
|
{
|
||||||
// A test-only matcher implementation - used as a baseline for simpler
|
// A test-only matcher implementation - used as a baseline for simpler
|
||||||
// perf tests. The idea with this matcher is that we can cheat on the requirements
|
// perf tests. The idea with this matcher is that we can cheat on the requirements
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Routing.Matchers
|
namespace Microsoft.AspNetCore.Routing.Matching
|
||||||
{
|
{
|
||||||
internal class TrivialMatcherBuilder : MatcherBuilder
|
internal class TrivialMatcherBuilder : MatcherBuilder
|
||||||
{
|
{
|
||||||
|
|
@ -18,23 +18,23 @@
|
||||||
for perf comparisons.
|
for perf comparisons.
|
||||||
-->
|
-->
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="..\..\test\Microsoft.AspNetCore.Routing.Tests\Matchers\BarebonesMatcher.cs">
|
<Compile Include="..\..\test\Microsoft.AspNetCore.Routing.Tests\Matching\BarebonesMatcher.cs">
|
||||||
<Link>Matchers\BarebonesMatcher.cs</Link>
|
<Link>Matching\BarebonesMatcher.cs</Link>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="..\..\test\Microsoft.AspNetCore.Routing.Tests\Matchers\BarebonesMatcherBuilder.cs">
|
<Compile Include="..\..\test\Microsoft.AspNetCore.Routing.Tests\Matching\BarebonesMatcherBuilder.cs">
|
||||||
<Link>Matchers\BarebonesMatcherBuilder.cs</Link>
|
<Link>Matching\BarebonesMatcherBuilder.cs</Link>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="..\..\test\Microsoft.AspNetCore.Routing.Tests\Matchers\RouteMatcher.cs">
|
<Compile Include="..\..\test\Microsoft.AspNetCore.Routing.Tests\Matching\RouteMatcher.cs">
|
||||||
<Link>Matchers\RouteMatcher.cs</Link>
|
<Link>Matching\RouteMatcher.cs</Link>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="..\..\test\Microsoft.AspNetCore.Routing.Tests\Matchers\RouteMatcherBuilder.cs">
|
<Compile Include="..\..\test\Microsoft.AspNetCore.Routing.Tests\Matching\RouteMatcherBuilder.cs">
|
||||||
<Link>Matchers\RouteMatcherBuilder.cs</Link>
|
<Link>Matching\RouteMatcherBuilder.cs</Link>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="..\..\test\Microsoft.AspNetCore.Routing.Tests\Matchers\TreeRouterMatcher.cs">
|
<Compile Include="..\..\test\Microsoft.AspNetCore.Routing.Tests\Matching\TreeRouterMatcher.cs">
|
||||||
<Link>Matchers\TreeRouterMatcher.cs</Link>
|
<Link>Matching\TreeRouterMatcher.cs</Link>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="..\..\test\Microsoft.AspNetCore.Routing.Tests\Matchers\TreeRouterMatcherBuilder.cs">
|
<Compile Include="..\..\test\Microsoft.AspNetCore.Routing.Tests\Matching\TreeRouterMatcherBuilder.cs">
|
||||||
<Link>Matchers\TreeRouterMatcherBuilder.cs</Link>
|
<Link>Matching\TreeRouterMatcherBuilder.cs</Link>
|
||||||
</Compile>
|
</Compile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ namespace Swaggatherer
|
||||||
|
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Routing.Matchers
|
namespace Microsoft.AspNetCore.Routing.Matching
|
||||||
{{
|
{{
|
||||||
// This code was generated by the Swaggatherer
|
// This code was generated by the Swaggatherer
|
||||||
public partial class GeneratedBenchmark : MatcherBenchmarkBase
|
public partial class GeneratedBenchmark : MatcherBenchmarkBase
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using Microsoft.AspNetCore.Routing.Matchers;
|
using Microsoft.AspNetCore.Routing.Matching;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
namespace RoutingSample.Web
|
namespace RoutingSample.Web
|
||||||
|
|
|
||||||
|
|
@ -9,8 +9,8 @@ namespace RoutingSample.Web
|
||||||
{
|
{
|
||||||
public class Program
|
public class Program
|
||||||
{
|
{
|
||||||
public static readonly string GlobalRoutingScenario = "globalrouting";
|
public const string EndpointRoutingScenario = "endpointrouting";
|
||||||
public static readonly string RouterScenario = "router";
|
public const string RouterScenario = "router";
|
||||||
|
|
||||||
public static void Main(string[] args)
|
public static void Main(string[] args)
|
||||||
{
|
{
|
||||||
|
|
@ -25,7 +25,7 @@ namespace RoutingSample.Web
|
||||||
if (args.Length == 0)
|
if (args.Length == 0)
|
||||||
{
|
{
|
||||||
Console.WriteLine("Choose a sample to run:");
|
Console.WriteLine("Choose a sample to run:");
|
||||||
Console.WriteLine($"1. {GlobalRoutingScenario}");
|
Console.WriteLine($"1. {EndpointRoutingScenario}");
|
||||||
Console.WriteLine($"2. {RouterScenario}");
|
Console.WriteLine($"2. {RouterScenario}");
|
||||||
Console.WriteLine();
|
Console.WriteLine();
|
||||||
|
|
||||||
|
|
@ -40,18 +40,18 @@ namespace RoutingSample.Web
|
||||||
switch (scenario)
|
switch (scenario)
|
||||||
{
|
{
|
||||||
case "1":
|
case "1":
|
||||||
case "globalrouting":
|
case EndpointRoutingScenario:
|
||||||
startupType = typeof(UseGlobalRoutingStartup);
|
startupType = typeof(UseEndpointRoutingStartup);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "2":
|
case "2":
|
||||||
case "router":
|
case RouterScenario:
|
||||||
startupType = typeof(UseRouterStartup);
|
startupType = typeof(UseRouterStartup);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
Console.WriteLine($"unknown scenario {scenario}");
|
Console.WriteLine($"unknown scenario {scenario}");
|
||||||
Console.WriteLine($"usage: dotnet run -- ({GlobalRoutingScenario}|{RouterScenario})");
|
Console.WriteLine($"usage: dotnet run -- ({EndpointRoutingScenario}|{RouterScenario})");
|
||||||
throw new InvalidOperationException();
|
throw new InvalidOperationException();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,18 +3,18 @@
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using Microsoft.AspNetCore.Builder;
|
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.AspNetCore.Internal;
|
||||||
using Microsoft.AspNetCore.Routing;
|
using Microsoft.AspNetCore.Routing;
|
||||||
using Microsoft.AspNetCore.Routing.Matchers;
|
using Microsoft.AspNetCore.Routing.Matching;
|
||||||
using Microsoft.AspNetCore.Routing.Patterns;
|
using Microsoft.AspNetCore.Routing.Patterns;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
|
||||||
namespace RoutingSample.Web
|
namespace RoutingSample.Web
|
||||||
{
|
{
|
||||||
public class UseGlobalRoutingStartup
|
public class UseEndpointRoutingStartup
|
||||||
{
|
{
|
||||||
private static readonly byte[] _homePayload = Encoding.UTF8.GetBytes("Global Routing sample endpoints:" + Environment.NewLine + "/plaintext");
|
private static readonly byte[] _homePayload = Encoding.UTF8.GetBytes("Endpoint Routing sample endpoints:" + Environment.NewLine + "/plaintext");
|
||||||
private static readonly byte[] _helloWorldPayload = Encoding.UTF8.GetBytes("Hello, World!");
|
private static readonly byte[] _helloWorldPayload = Encoding.UTF8.GetBytes("Hello, World!");
|
||||||
|
|
||||||
public void ConfigureServices(IServiceCollection services)
|
public void ConfigureServices(IServiceCollection services)
|
||||||
|
|
@ -86,9 +86,9 @@ namespace RoutingSample.Web
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Configure(IApplicationBuilder app)
|
public void Configure(Microsoft.AspNetCore.Builder.IApplicationBuilder app)
|
||||||
{
|
{
|
||||||
app.UseGlobalRouting();
|
app.UseEndpointRouting();
|
||||||
|
|
||||||
// Imagine some more stuff here...
|
// Imagine some more stuff here...
|
||||||
|
|
||||||
|
|
@ -8,7 +8,7 @@ using System.Linq;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Routing
|
namespace Microsoft.AspNetCore.Routing
|
||||||
{
|
{
|
||||||
public class EndpointMetadataCollection : IReadOnlyList<object>
|
public sealed class EndpointMetadataCollection : IReadOnlyList<object>
|
||||||
{
|
{
|
||||||
public static readonly EndpointMetadataCollection Empty = new EndpointMetadataCollection(Array.Empty<object>());
|
public static readonly EndpointMetadataCollection Empty = new EndpointMetadataCollection(Array.Empty<object>());
|
||||||
|
|
||||||
|
|
@ -24,6 +24,11 @@ namespace Microsoft.AspNetCore.Routing
|
||||||
_items = items.ToArray();
|
_items = items.ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public EndpointMetadataCollection(params object[] items)
|
||||||
|
: this((IEnumerable<object>)items)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
public object this[int index] => _items[index];
|
public object this[int index] => _items[index];
|
||||||
|
|
||||||
public int Count => _items.Length;
|
public int Count => _items.Length;
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
|
namespace Microsoft.AspNetCore.Builder
|
||||||
|
{
|
||||||
|
// TODO: Remove once MVC is updated
|
||||||
|
public static class EndpointRoutingApplicationBuilderExtensions
|
||||||
|
{
|
||||||
|
public static IApplicationBuilder UseGlobalRouting(this IApplicationBuilder builder)
|
||||||
|
{
|
||||||
|
return Internal.EndpointRoutingApplicationBuilderExtensions.UseEndpointRouting(builder);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IApplicationBuilder UseEndpoint(this IApplicationBuilder builder)
|
||||||
|
{
|
||||||
|
return Internal.EndpointRoutingApplicationBuilderExtensions.UseEndpoint(builder);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -7,14 +7,14 @@ using System.Diagnostics;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using Microsoft.AspNetCore.Routing.Matchers;
|
using Microsoft.AspNetCore.Routing.Matching;
|
||||||
using Microsoft.AspNetCore.Routing.Metadata;
|
using Microsoft.AspNetCore.Routing.Metadata;
|
||||||
using Microsoft.Extensions.Primitives;
|
using Microsoft.Extensions.Primitives;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Routing
|
namespace Microsoft.AspNetCore.Routing
|
||||||
{
|
{
|
||||||
[DebuggerDisplay("{DebuggerDisplayString,nq}")]
|
[DebuggerDisplay("{DebuggerDisplayString,nq}")]
|
||||||
public class CompositeEndpointDataSource : EndpointDataSource
|
public sealed class CompositeEndpointDataSource : EndpointDataSource
|
||||||
{
|
{
|
||||||
private readonly EndpointDataSource[] _dataSources;
|
private readonly EndpointDataSource[] _dataSources;
|
||||||
private readonly object _lock;
|
private readonly object _lock;
|
||||||
|
|
|
||||||
|
|
@ -8,9 +8,14 @@ using Microsoft.Extensions.Primitives;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Routing
|
namespace Microsoft.AspNetCore.Routing
|
||||||
{
|
{
|
||||||
public class DefaultEndpointDataSource : EndpointDataSource
|
public sealed class DefaultEndpointDataSource : EndpointDataSource
|
||||||
{
|
{
|
||||||
private readonly List<Endpoint> _endpoints;
|
private readonly List<Endpoint> _endpoints;
|
||||||
|
|
||||||
|
public DefaultEndpointDataSource(params Endpoint[] endpoints)
|
||||||
|
: this((IEnumerable<Endpoint>) endpoints)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
public DefaultEndpointDataSource(IEnumerable<Endpoint> endpoints)
|
public DefaultEndpointDataSource(IEnumerable<Endpoint> endpoints)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ using System.Linq;
|
||||||
using System.Text.Encodings.Web;
|
using System.Text.Encodings.Web;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Routing.Internal;
|
using Microsoft.AspNetCore.Routing.Internal;
|
||||||
using Microsoft.AspNetCore.Routing.Matchers;
|
using Microsoft.AspNetCore.Routing.Matching;
|
||||||
using Microsoft.AspNetCore.Routing.Template;
|
using Microsoft.AspNetCore.Routing.Template;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Microsoft.Extensions.ObjectPool;
|
using Microsoft.Extensions.ObjectPool;
|
||||||
|
|
|
||||||
|
|
@ -3,10 +3,8 @@
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using Microsoft.AspNetCore.Routing;
|
using Microsoft.AspNetCore.Routing;
|
||||||
using Microsoft.AspNetCore.Routing.Constraints;
|
|
||||||
using Microsoft.AspNetCore.Routing.EndpointFinders;
|
|
||||||
using Microsoft.AspNetCore.Routing.Internal;
|
using Microsoft.AspNetCore.Routing.Internal;
|
||||||
using Microsoft.AspNetCore.Routing.Matchers;
|
using Microsoft.AspNetCore.Routing.Matching;
|
||||||
using Microsoft.AspNetCore.Routing.Tree;
|
using Microsoft.AspNetCore.Routing.Tree;
|
||||||
using Microsoft.Extensions.DependencyInjection.Extensions;
|
using Microsoft.Extensions.DependencyInjection.Extensions;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
@ -70,7 +68,7 @@ namespace Microsoft.Extensions.DependencyInjection
|
||||||
|
|
||||||
// Link generation related services
|
// Link generation related services
|
||||||
services.TryAddSingleton<IEndpointFinder<string>, NameBasedEndpointFinder>();
|
services.TryAddSingleton<IEndpointFinder<string>, NameBasedEndpointFinder>();
|
||||||
services.TryAddSingleton<IEndpointFinder<RouteValuesBasedEndpointFinderContext>, RouteValuesBasedEndpointFinder>();
|
services.TryAddSingleton<IEndpointFinder<RouteValuesAddress>, RouteValuesBasedEndpointFinder>();
|
||||||
services.TryAddSingleton<LinkGenerator, DefaultLinkGenerator>();
|
services.TryAddSingleton<LinkGenerator, DefaultLinkGenerator>();
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
|
||||||
|
|
@ -34,8 +34,8 @@ namespace Microsoft.AspNetCore.Routing
|
||||||
var feature = httpContext.Features.Get<IEndpointFeature>();
|
var feature = httpContext.Features.Get<IEndpointFeature>();
|
||||||
if (feature == null)
|
if (feature == null)
|
||||||
{
|
{
|
||||||
var message = $"Unable to execute an endpoint because the {nameof(GlobalRoutingMiddleware)} was not run for this request. " +
|
var message = $"Unable to execute an endpoint because the {nameof(EndpointRoutingMiddleware)} was not run for this request. " +
|
||||||
$"Ensure {nameof(GlobalRoutingMiddleware)} is added to the request execution pipeline before {nameof(EndpointMiddleware)} in application startup code.";
|
$"Ensure {nameof(EndpointRoutingMiddleware)} is added to the request execution pipeline before {nameof(EndpointMiddleware)} in application startup code.";
|
||||||
|
|
||||||
throw new InvalidOperationException(message);
|
throw new InvalidOperationException(message);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,13 +5,13 @@ using System;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Routing.Matchers;
|
using Microsoft.AspNetCore.Routing.Matching;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using Microsoft.Extensions.Options;
|
using Microsoft.Extensions.Options;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Routing
|
namespace Microsoft.AspNetCore.Routing
|
||||||
{
|
{
|
||||||
internal sealed class GlobalRoutingMiddleware
|
internal sealed class EndpointRoutingMiddleware
|
||||||
{
|
{
|
||||||
private readonly MatcherFactory _matcherFactory;
|
private readonly MatcherFactory _matcherFactory;
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
|
|
@ -20,10 +20,10 @@ namespace Microsoft.AspNetCore.Routing
|
||||||
|
|
||||||
private Task<Matcher> _initializationTask;
|
private Task<Matcher> _initializationTask;
|
||||||
|
|
||||||
public GlobalRoutingMiddleware(
|
public EndpointRoutingMiddleware(
|
||||||
MatcherFactory matcherFactory,
|
MatcherFactory matcherFactory,
|
||||||
CompositeEndpointDataSource endpointDataSource,
|
CompositeEndpointDataSource endpointDataSource,
|
||||||
ILogger<GlobalRoutingMiddleware> logger,
|
ILogger<EndpointRoutingMiddleware> logger,
|
||||||
RequestDelegate next)
|
RequestDelegate next)
|
||||||
{
|
{
|
||||||
if (matcherFactory == null)
|
if (matcherFactory == null)
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Routing
|
namespace Microsoft.AspNetCore.Routing
|
||||||
{
|
{
|
||||||
public interface INameMetadata
|
public interface INameMetadata
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Routing
|
namespace Microsoft.AspNetCore.Routing
|
||||||
{
|
{
|
||||||
public interface IRouteNameMetadata
|
public interface IRouteNameMetadata
|
||||||
|
|
@ -2,33 +2,38 @@
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using Microsoft.AspNetCore.Builder;
|
||||||
using Microsoft.AspNetCore.Routing;
|
using Microsoft.AspNetCore.Routing;
|
||||||
using Microsoft.AspNetCore.Routing.Internal;
|
using Microsoft.AspNetCore.Routing.Internal;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Builder
|
namespace Microsoft.AspNetCore.Internal
|
||||||
{
|
{
|
||||||
public static class GlobalRoutingApplicationBuilderExtensions
|
public static class EndpointRoutingApplicationBuilderExtensions
|
||||||
{
|
{
|
||||||
|
// TODO: Remove once MVC is updated
|
||||||
private const string GlobalRoutingRegisteredKey = "__GlobalRoutingMiddlewareRegistered";
|
private const string GlobalRoutingRegisteredKey = "__GlobalRoutingMiddlewareRegistered";
|
||||||
|
|
||||||
public static IApplicationBuilder UseGlobalRouting(this IApplicationBuilder builder)
|
private const string EndpointRoutingRegisteredKey = "__EndpointRoutingMiddlewareRegistered";
|
||||||
|
|
||||||
|
public static IApplicationBuilder UseEndpointRouting(this IApplicationBuilder builder)
|
||||||
{
|
{
|
||||||
VerifyRoutingIsRegistered(builder);
|
VerifyRoutingIsRegistered(builder);
|
||||||
|
|
||||||
|
builder.Properties[EndpointRoutingRegisteredKey] = true;
|
||||||
builder.Properties[GlobalRoutingRegisteredKey] = true;
|
builder.Properties[GlobalRoutingRegisteredKey] = true;
|
||||||
|
|
||||||
return builder.UseMiddleware<GlobalRoutingMiddleware>();
|
return builder.UseMiddleware<EndpointRoutingMiddleware>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IApplicationBuilder UseEndpoint(this IApplicationBuilder builder)
|
public static IApplicationBuilder UseEndpoint(this IApplicationBuilder builder)
|
||||||
{
|
{
|
||||||
VerifyRoutingIsRegistered(builder);
|
VerifyRoutingIsRegistered(builder);
|
||||||
|
|
||||||
if (!builder.Properties.TryGetValue(GlobalRoutingRegisteredKey, out _))
|
if (!builder.Properties.TryGetValue(EndpointRoutingRegisteredKey, out _))
|
||||||
{
|
{
|
||||||
var message = $"{nameof(GlobalRoutingMiddleware)} must be added to the request execution pipeline before {nameof(EndpointMiddleware)}. " +
|
var message = $"{nameof(EndpointRoutingMiddleware)} must be added to the request execution pipeline before {nameof(EndpointMiddleware)}. " +
|
||||||
$"Please add {nameof(GlobalRoutingMiddleware)} by calling '{nameof(IApplicationBuilder)}.{nameof(UseGlobalRouting)}' inside the call to 'Configure(...)' in the application startup code.";
|
$"Please add {nameof(EndpointRoutingMiddleware)} by calling '{nameof(IApplicationBuilder)}.{nameof(UseEndpointRouting)}' inside the call to 'Configure(...)' in the application startup code.";
|
||||||
|
|
||||||
throw new InvalidOperationException(message);
|
throw new InvalidOperationException(message);
|
||||||
}
|
}
|
||||||
|
|
@ -38,7 +43,7 @@ namespace Microsoft.AspNetCore.Builder
|
||||||
|
|
||||||
private static void VerifyRoutingIsRegistered(IApplicationBuilder app)
|
private static void VerifyRoutingIsRegistered(IApplicationBuilder app)
|
||||||
{
|
{
|
||||||
// Verify if AddRouting was done before calling UseGlobalRouting/UseEndpoint
|
// Verify if AddRouting was done before calling UseEndpointRouting/UseEndpoint
|
||||||
// We use the RoutingMarkerService to make sure if all the services were added.
|
// We use the RoutingMarkerService to make sure if all the services were added.
|
||||||
if (app.ApplicationServices.GetService(typeof(RoutingMarkerService)) == null)
|
if (app.ApplicationServices.GetService(typeof(RoutingMarkerService)) == null)
|
||||||
{
|
{
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Runtime.Serialization;
|
using System.Runtime.Serialization;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Routing.Matchers
|
namespace Microsoft.AspNetCore.Routing.Matching
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// An exception which indicates multiple matches in endpoint selection.
|
/// An exception which indicates multiple matches in endpoint selection.
|
||||||
|
|
@ -5,7 +5,7 @@ using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Microsoft.AspNetCore.Routing.Patterns;
|
using Microsoft.AspNetCore.Routing.Patterns;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Routing.Matchers
|
namespace Microsoft.AspNetCore.Routing.Matching
|
||||||
{
|
{
|
||||||
internal readonly struct Candidate
|
internal readonly struct Candidate
|
||||||
{
|
{
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Routing.Matchers
|
namespace Microsoft.AspNetCore.Routing.Matching
|
||||||
{
|
{
|
||||||
public sealed class CandidateSet
|
public sealed class CandidateSet
|
||||||
{
|
{
|
||||||
|
|
@ -1,17 +1,11 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Routing.Matchers
|
namespace Microsoft.AspNetCore.Routing.Matching
|
||||||
{
|
{
|
||||||
public struct CandidateState
|
public struct CandidateState
|
||||||
{
|
{
|
||||||
// Provided for testability
|
internal CandidateState(MatcherEndpoint endpoint, int score)
|
||||||
public CandidateState(MatcherEndpoint endpoint)
|
|
||||||
: this(endpoint, score: 0)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public CandidateState(MatcherEndpoint endpoint, int score)
|
|
||||||
{
|
{
|
||||||
Endpoint = endpoint;
|
Endpoint = endpoint;
|
||||||
Score = score;
|
Score = score;
|
||||||
|
|
@ -6,7 +6,7 @@ using System.Collections.Generic;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Routing.Matchers
|
namespace Microsoft.AspNetCore.Routing.Matching
|
||||||
{
|
{
|
||||||
internal class DataSourceDependentMatcher : Matcher
|
internal class DataSourceDependentMatcher : Matcher
|
||||||
{
|
{
|
||||||
|
|
@ -7,7 +7,7 @@ using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Routing.Matchers
|
namespace Microsoft.AspNetCore.Routing.Matching
|
||||||
{
|
{
|
||||||
internal class DefaultEndpointSelector : EndpointSelector
|
internal class DefaultEndpointSelector : EndpointSelector
|
||||||
{
|
{
|
||||||
|
|
@ -5,7 +5,7 @@ using System;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.Options;
|
using Microsoft.Extensions.Options;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Routing.Matchers
|
namespace Microsoft.AspNetCore.Routing.Matching
|
||||||
{
|
{
|
||||||
internal class DefaultMatchProcessorFactory : MatchProcessorFactory
|
internal class DefaultMatchProcessorFactory : MatchProcessorFactory
|
||||||
{
|
{
|
||||||
|
|
@ -7,7 +7,7 @@ using System.Threading.Tasks;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Routing.Patterns;
|
using Microsoft.AspNetCore.Routing.Patterns;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Routing.Matchers
|
namespace Microsoft.AspNetCore.Routing.Matching
|
||||||
{
|
{
|
||||||
internal sealed class DfaMatcher : Matcher
|
internal sealed class DfaMatcher : Matcher
|
||||||
{
|
{
|
||||||
|
|
@ -6,7 +6,7 @@ using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Microsoft.AspNetCore.Routing.Patterns;
|
using Microsoft.AspNetCore.Routing.Patterns;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Routing.Matchers
|
namespace Microsoft.AspNetCore.Routing.Matching
|
||||||
{
|
{
|
||||||
internal class DfaMatcherBuilder : MatcherBuilder
|
internal class DfaMatcherBuilder : MatcherBuilder
|
||||||
{
|
{
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
using System;
|
using System;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Routing.Matchers
|
namespace Microsoft.AspNetCore.Routing.Matching
|
||||||
{
|
{
|
||||||
internal class DfaMatcherFactory : MatcherFactory
|
internal class DfaMatcherFactory : MatcherFactory
|
||||||
{
|
{
|
||||||
|
|
@ -7,7 +7,7 @@ using System.Diagnostics;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Routing.Matchers
|
namespace Microsoft.AspNetCore.Routing.Matching
|
||||||
{
|
{
|
||||||
// Intermediate data structure used to build the DFA. Not used at runtime.
|
// Intermediate data structure used to build the DFA. Not used at runtime.
|
||||||
[DebuggerDisplay("{DebuggerToString(),nq}")]
|
[DebuggerDisplay("{DebuggerToString(),nq}")]
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Routing.Matchers
|
namespace Microsoft.AspNetCore.Routing.Matching
|
||||||
{
|
{
|
||||||
[DebuggerDisplay("{DebuggerToString(),nq}")]
|
[DebuggerDisplay("{DebuggerToString(),nq}")]
|
||||||
internal readonly struct DfaState
|
internal readonly struct DfaState
|
||||||
|
|
@ -6,7 +6,7 @@ using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Routing.Matchers
|
namespace Microsoft.AspNetCore.Routing.Matching
|
||||||
{
|
{
|
||||||
internal class DictionaryJumpTable : JumpTable
|
internal class DictionaryJumpTable : JumpTable
|
||||||
{
|
{
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Routing.Matchers
|
namespace Microsoft.AspNetCore.Routing.Matching
|
||||||
{
|
{
|
||||||
public abstract class EndpointMetadataComparer<TMetadata> : IComparer<Endpoint> where TMetadata : class
|
public abstract class EndpointMetadataComparer<TMetadata> : IComparer<Endpoint> where TMetadata : class
|
||||||
{
|
{
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Routing.Matchers
|
namespace Microsoft.AspNetCore.Routing.Matching
|
||||||
{
|
{
|
||||||
public abstract class EndpointSelector
|
public abstract class EndpointSelector
|
||||||
{
|
{
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Routing.Matchers
|
namespace Microsoft.AspNetCore.Routing.Matching
|
||||||
{
|
{
|
||||||
// Low level implementation of our path tokenization algorithm. Alternative
|
// Low level implementation of our path tokenization algorithm. Alternative
|
||||||
// to PathTokenizer.
|
// to PathTokenizer.
|
||||||
|
|
@ -11,7 +11,7 @@ using Microsoft.AspNetCore.Routing.Patterns;
|
||||||
using Microsoft.Extensions.Internal;
|
using Microsoft.Extensions.Internal;
|
||||||
using Microsoft.Extensions.Primitives;
|
using Microsoft.Extensions.Primitives;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Routing.Matchers
|
namespace Microsoft.AspNetCore.Routing.Matching
|
||||||
{
|
{
|
||||||
public sealed class HttpMethodMatcherPolicy : MatcherPolicy, IEndpointComparerPolicy, INodeBuilderPolicy
|
public sealed class HttpMethodMatcherPolicy : MatcherPolicy, IEndpointComparerPolicy, INodeBuilderPolicy
|
||||||
{
|
{
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Routing.Matchers
|
namespace Microsoft.AspNetCore.Routing.Matching
|
||||||
{
|
{
|
||||||
public interface IEndpointComparerPolicy
|
public interface IEndpointComparerPolicy
|
||||||
{
|
{
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Routing.Matchers
|
namespace Microsoft.AspNetCore.Routing.Matching
|
||||||
{
|
{
|
||||||
public interface IEndpointSelectorPolicy
|
public interface IEndpointSelectorPolicy
|
||||||
{
|
{
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Routing.Matchers
|
namespace Microsoft.AspNetCore.Routing.Matching
|
||||||
{
|
{
|
||||||
public interface INodeBuilderPolicy
|
public interface INodeBuilderPolicy
|
||||||
{
|
{
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Routing.Matchers
|
namespace Microsoft.AspNetCore.Routing.Matching
|
||||||
{
|
{
|
||||||
[DebuggerDisplay("{DebuggerToString(),nq}")]
|
[DebuggerDisplay("{DebuggerToString(),nq}")]
|
||||||
internal abstract class JumpTable
|
internal abstract class JumpTable
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Routing.Matchers
|
namespace Microsoft.AspNetCore.Routing.Matching
|
||||||
{
|
{
|
||||||
internal class JumpTableBuilder
|
internal class JumpTableBuilder
|
||||||
{
|
{
|
||||||
|
|
@ -5,7 +5,7 @@ using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Routing.Matchers
|
namespace Microsoft.AspNetCore.Routing.Matching
|
||||||
{
|
{
|
||||||
internal class LinearSearchJumpTable : JumpTable
|
internal class LinearSearchJumpTable : JumpTable
|
||||||
{
|
{
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Routing.Matchers
|
namespace Microsoft.AspNetCore.Routing.Matching
|
||||||
{
|
{
|
||||||
public abstract class MatchProcessor
|
public abstract class MatchProcessor
|
||||||
{
|
{
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Routing.Matchers
|
namespace Microsoft.AspNetCore.Routing.Matching
|
||||||
{
|
{
|
||||||
public abstract class MatchProcessorBase : MatchProcessor
|
public abstract class MatchProcessorBase : MatchProcessor
|
||||||
{
|
{
|
||||||
|
|
@ -5,7 +5,7 @@ using System;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using Microsoft.AspNetCore.Routing.Patterns;
|
using Microsoft.AspNetCore.Routing.Patterns;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Routing.Matchers
|
namespace Microsoft.AspNetCore.Routing.Matching
|
||||||
{
|
{
|
||||||
internal abstract class MatchProcessorFactory
|
internal abstract class MatchProcessorFactory
|
||||||
{
|
{
|
||||||
|
|
@ -4,11 +4,11 @@
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Routing.Matchers
|
namespace Microsoft.AspNetCore.Routing.Matching
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// An interface for components that can select an <see cref="Endpoint"/> given the current request, as part
|
/// An interface for components that can select an <see cref="Endpoint"/> given the current request, as part
|
||||||
/// of the execution of <see cref="GlobalRoutingMiddleware"/>.
|
/// of the execution of <see cref="EndpointRoutingMiddleware"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal abstract class Matcher
|
internal abstract class Matcher
|
||||||
{
|
{
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Routing.Matchers
|
namespace Microsoft.AspNetCore.Routing.Matching
|
||||||
{
|
{
|
||||||
internal abstract class MatcherBuilder
|
internal abstract class MatcherBuilder
|
||||||
{
|
{
|
||||||
|
|
@ -7,7 +7,7 @@ using System.Threading.Tasks;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.AspNetCore.Routing.Patterns;
|
using Microsoft.AspNetCore.Routing.Patterns;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Routing.Matchers
|
namespace Microsoft.AspNetCore.Routing.Matching
|
||||||
{
|
{
|
||||||
public sealed class MatcherEndpoint : Endpoint
|
public sealed class MatcherEndpoint : Endpoint
|
||||||
{
|
{
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Routing.Matchers
|
namespace Microsoft.AspNetCore.Routing.Matching
|
||||||
{
|
{
|
||||||
// Use to sort and group MatcherEndpoints.
|
// Use to sort and group MatcherEndpoints.
|
||||||
//
|
//
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Routing.Matchers
|
namespace Microsoft.AspNetCore.Routing.Matching
|
||||||
{
|
{
|
||||||
internal abstract class MatcherFactory
|
internal abstract class MatcherFactory
|
||||||
{
|
{
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Routing.Matchers
|
namespace Microsoft.AspNetCore.Routing.Matching
|
||||||
{
|
{
|
||||||
internal class OptionalMatchProcessor : MatchProcessor
|
internal class OptionalMatchProcessor : MatchProcessor
|
||||||
{
|
{
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Routing.Matchers
|
namespace Microsoft.AspNetCore.Routing.Matching
|
||||||
{
|
{
|
||||||
internal readonly struct PathSegment : IEquatable<PathSegment>
|
internal readonly struct PathSegment : IEquatable<PathSegment>
|
||||||
{
|
{
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Routing.Matchers
|
namespace Microsoft.AspNetCore.Routing.Matching
|
||||||
{
|
{
|
||||||
public abstract class PolicyJumpTable
|
public abstract class PolicyJumpTable
|
||||||
{
|
{
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Routing.Matchers
|
namespace Microsoft.AspNetCore.Routing.Matching
|
||||||
{
|
{
|
||||||
internal class PolicyJumpTableBuilder
|
internal class PolicyJumpTableBuilder
|
||||||
{
|
{
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Routing.Matchers
|
namespace Microsoft.AspNetCore.Routing.Matching
|
||||||
{
|
{
|
||||||
public readonly struct PolicyJumpTableEdge
|
public readonly struct PolicyJumpTableEdge
|
||||||
{
|
{
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Routing.Matchers
|
namespace Microsoft.AspNetCore.Routing.Matching
|
||||||
{
|
{
|
||||||
public readonly struct PolicyNodeEdge
|
public readonly struct PolicyNodeEdge
|
||||||
{
|
{
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
using System;
|
using System;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Routing.Matchers
|
namespace Microsoft.AspNetCore.Routing.Matching
|
||||||
{
|
{
|
||||||
internal class RouteConstraintMatchProcessor : MatchProcessor
|
internal class RouteConstraintMatchProcessor : MatchProcessor
|
||||||
{
|
{
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Routing.Matchers
|
namespace Microsoft.AspNetCore.Routing.Matching
|
||||||
{
|
{
|
||||||
internal class SingleEntryJumpTable : JumpTable
|
internal class SingleEntryJumpTable : JumpTable
|
||||||
{
|
{
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Routing.Matchers
|
namespace Microsoft.AspNetCore.Routing.Matching
|
||||||
{
|
{
|
||||||
internal class ZeroEntryJumpTable : JumpTable
|
internal class ZeroEntryJumpTable : JumpTable
|
||||||
{
|
{
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Microsoft.AspNetCore.Routing.Matchers;
|
using Microsoft.AspNetCore.Routing.Matching;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Routing
|
namespace Microsoft.AspNetCore.Routing
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using Microsoft.AspNetCore.Routing.Matchers;
|
using Microsoft.AspNetCore.Routing.Matching;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Routing.Patterns
|
namespace Microsoft.AspNetCore.Routing.Patterns
|
||||||
{
|
{
|
||||||
|
|
@ -38,7 +38,7 @@ namespace Microsoft.AspNetCore.Routing.Patterns
|
||||||
public IRouteConstraint Constraint { get; }
|
public IRouteConstraint Constraint { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a pre-existing <see cref="Matchers.MatchProcessor"/> that was used to construct this reference.
|
/// Gets a pre-existing <see cref="Matching.MatchProcessor"/> that was used to construct this reference.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public MatchProcessor MatchProcessor { get; }
|
public MatchProcessor MatchProcessor { get; }
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Microsoft.AspNetCore.Routing.Constraints;
|
using Microsoft.AspNetCore.Routing.Constraints;
|
||||||
using Microsoft.AspNetCore.Routing.Matchers;
|
using Microsoft.AspNetCore.Routing.Matching;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Routing.Patterns
|
namespace Microsoft.AspNetCore.Routing.Patterns
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ using Microsoft.Extensions.Primitives;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Routing
|
namespace Microsoft.AspNetCore.Routing
|
||||||
{
|
{
|
||||||
public class RoutePatternMatcher
|
internal class RoutePatternMatcher
|
||||||
{
|
{
|
||||||
private const string SeparatorString = "/";
|
private const string SeparatorString = "/";
|
||||||
private const char SeparatorChar = '/';
|
private const char SeparatorChar = '/';
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ using System.Text;
|
||||||
namespace Microsoft.AspNetCore.Routing.Patterns
|
namespace Microsoft.AspNetCore.Routing.Patterns
|
||||||
{
|
{
|
||||||
[DebuggerDisplay("{DebuggerToString()}")]
|
[DebuggerDisplay("{DebuggerToString()}")]
|
||||||
public class RoutePatternParameterPart : RoutePatternPart
|
public sealed class RoutePatternParameterPart : RoutePatternPart
|
||||||
{
|
{
|
||||||
internal RoutePatternParameterPart(
|
internal RoutePatternParameterPart(
|
||||||
string parameterName,
|
string parameterName,
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
// Copyright (c) .NET Foundation. All rights reserved.
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Routing.EndpointFinders
|
namespace Microsoft.AspNetCore.Routing
|
||||||
{
|
{
|
||||||
public class RouteValuesBasedEndpointFinderContext
|
public class RouteValuesAddress
|
||||||
{
|
{
|
||||||
public string RouteName { get; set; }
|
public string RouteName { get; set; }
|
||||||
|
|
||||||
|
|
@ -4,16 +4,15 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Microsoft.AspNetCore.Routing.EndpointFinders;
|
|
||||||
using Microsoft.AspNetCore.Routing.Internal;
|
using Microsoft.AspNetCore.Routing.Internal;
|
||||||
using Microsoft.AspNetCore.Routing.Matchers;
|
using Microsoft.AspNetCore.Routing.Matching;
|
||||||
using Microsoft.AspNetCore.Routing.Template;
|
using Microsoft.AspNetCore.Routing.Template;
|
||||||
using Microsoft.AspNetCore.Routing.Tree;
|
using Microsoft.AspNetCore.Routing.Tree;
|
||||||
using Microsoft.Extensions.ObjectPool;
|
using Microsoft.Extensions.ObjectPool;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Routing
|
namespace Microsoft.AspNetCore.Routing
|
||||||
{
|
{
|
||||||
internal class RouteValuesBasedEndpointFinder : IEndpointFinder<RouteValuesBasedEndpointFinderContext>
|
internal class RouteValuesBasedEndpointFinder : IEndpointFinder<RouteValuesAddress>
|
||||||
{
|
{
|
||||||
private readonly CompositeEndpointDataSource _endpointDataSource;
|
private readonly CompositeEndpointDataSource _endpointDataSource;
|
||||||
private readonly ObjectPool<UriBuildingContext> _objectPool;
|
private readonly ObjectPool<UriBuildingContext> _objectPool;
|
||||||
|
|
@ -36,16 +35,16 @@ namespace Microsoft.AspNetCore.Routing
|
||||||
HandleChange);
|
HandleChange);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<Endpoint> FindEndpoints(RouteValuesBasedEndpointFinderContext context)
|
public IEnumerable<Endpoint> FindEndpoints(RouteValuesAddress address)
|
||||||
{
|
{
|
||||||
IEnumerable<OutboundMatchResult> matchResults = null;
|
IEnumerable<OutboundMatchResult> matchResults = null;
|
||||||
if (string.IsNullOrEmpty(context.RouteName))
|
if (string.IsNullOrEmpty(address.RouteName))
|
||||||
{
|
{
|
||||||
matchResults = _allMatchesLinkGenerationTree.GetMatches(
|
matchResults = _allMatchesLinkGenerationTree.GetMatches(
|
||||||
context.ExplicitValues,
|
address.ExplicitValues,
|
||||||
context.AmbientValues);
|
address.AmbientValues);
|
||||||
}
|
}
|
||||||
else if (_namedMatchResults.TryGetValue(context.RouteName, out var namedMatchResults))
|
else if (_namedMatchResults.TryGetValue(address.RouteName, out var namedMatchResults))
|
||||||
{
|
{
|
||||||
matchResults = namedMatchResults;
|
matchResults = namedMatchResults;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -52,8 +52,5 @@ namespace Microsoft.AspNetCore.Routing.Tree
|
||||||
/// Gets or sets the <see cref="RouteTemplate"/>.
|
/// Gets or sets the <see cref="RouteTemplate"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public RouteTemplate RouteTemplate { get; set; }
|
public RouteTemplate RouteTemplate { get; set; }
|
||||||
|
|
||||||
// REVIEW: temporary change to enable reusing the tree router
|
|
||||||
public object Tag { get; set; }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,48 @@
|
||||||
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
using Xunit;
|
||||||
|
|
||||||
|
namespace Microsoft.AspNetCore.Routing
|
||||||
|
{
|
||||||
|
public class EndpointMetadataCollectionTests
|
||||||
|
{
|
||||||
|
[Fact]
|
||||||
|
public void Constructor_Enumeration_ContainsValues()
|
||||||
|
{
|
||||||
|
// Arrange & Act
|
||||||
|
var metadata = new EndpointMetadataCollection(new List<object>
|
||||||
|
{
|
||||||
|
1,
|
||||||
|
2,
|
||||||
|
3,
|
||||||
|
});
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Assert.Equal(3, metadata.Count);
|
||||||
|
|
||||||
|
Assert.Collection(metadata,
|
||||||
|
value => Assert.Equal(1, value),
|
||||||
|
value => Assert.Equal(2, value),
|
||||||
|
value => Assert.Equal(3, value));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void Constructor_ParamsArray_ContainsValues()
|
||||||
|
{
|
||||||
|
// Arrange & Act
|
||||||
|
var metadata = new EndpointMetadataCollection(1, 2, 3);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Assert.Equal(3, metadata.Count);
|
||||||
|
|
||||||
|
Assert.Collection(metadata,
|
||||||
|
value => Assert.Equal(1, value),
|
||||||
|
value => Assert.Equal(2, value),
|
||||||
|
value => Assert.Equal(3, value));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -11,20 +11,20 @@ using Xunit;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Routing.FunctionalTests
|
namespace Microsoft.AspNetCore.Routing.FunctionalTests
|
||||||
{
|
{
|
||||||
public class GlobalRoutingBenchmarkTest : IDisposable
|
public class EndpointRoutingBenchmarkTest : IDisposable
|
||||||
{
|
{
|
||||||
private readonly HttpClient _client;
|
private readonly HttpClient _client;
|
||||||
private readonly TestServer _testServer;
|
private readonly TestServer _testServer;
|
||||||
|
|
||||||
public GlobalRoutingBenchmarkTest()
|
public EndpointRoutingBenchmarkTest()
|
||||||
{
|
{
|
||||||
// This switch and value are set by benchmark server when running the app for profiling.
|
// This switch and value are set by benchmark server when running the app for profiling.
|
||||||
var args = new[] { "--scenarios", "PlaintextGlobalRouting" };
|
var args = new[] { "--scenarios", "PlaintextEndpointRouting" };
|
||||||
var webHostBuilder = Benchmarks.Program.GetWebHostBuilder(args);
|
var webHostBuilder = Benchmarks.Program.GetWebHostBuilder(args);
|
||||||
|
|
||||||
// Make sure we are using the right startup
|
// Make sure we are using the right startup
|
||||||
var startupName = webHostBuilder.GetSetting("Startup");
|
var startupName = webHostBuilder.GetSetting("Startup");
|
||||||
Assert.Equal(nameof(Benchmarks.StartupUsingGlobalRouting), startupName);
|
Assert.Equal(nameof(Benchmarks.StartupUsingEndpointRouting), startupName);
|
||||||
|
|
||||||
_testServer = new TestServer(webHostBuilder);
|
_testServer = new TestServer(webHostBuilder);
|
||||||
_client = _testServer.CreateClient();
|
_client = _testServer.CreateClient();
|
||||||
|
|
@ -11,14 +11,14 @@ using Xunit;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Routing.FunctionalTests
|
namespace Microsoft.AspNetCore.Routing.FunctionalTests
|
||||||
{
|
{
|
||||||
public class GlobalRoutingSampleTest : IDisposable
|
public class EndpointRoutingSampleTest : IDisposable
|
||||||
{
|
{
|
||||||
private readonly HttpClient _client;
|
private readonly HttpClient _client;
|
||||||
private readonly TestServer _testServer;
|
private readonly TestServer _testServer;
|
||||||
|
|
||||||
public GlobalRoutingSampleTest()
|
public EndpointRoutingSampleTest()
|
||||||
{
|
{
|
||||||
var webHostBuilder = Program.GetWebHostBuilder(new[] { Program.GlobalRoutingScenario, });
|
var webHostBuilder = Program.GetWebHostBuilder(new[] { Program.EndpointRoutingScenario, });
|
||||||
_testServer = new TestServer(webHostBuilder);
|
_testServer = new TestServer(webHostBuilder);
|
||||||
_client = _testServer.CreateClient();
|
_client = _testServer.CreateClient();
|
||||||
_client.BaseAddress = new Uri("http://localhost");
|
_client.BaseAddress = new Uri("http://localhost");
|
||||||
|
|
@ -29,7 +29,7 @@ namespace Microsoft.AspNetCore.Routing.FunctionalTests
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var expectedContentType = "text/plain";
|
var expectedContentType = "text/plain";
|
||||||
var expectedContent = "Global Routing sample endpoints:" + Environment.NewLine + "/plaintext";
|
var expectedContent = "Endpoint Routing sample endpoints:" + Environment.NewLine + "/plaintext";
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var response = await _client.GetAsync("/");
|
var response = await _client.GetAsync("/");
|
||||||
|
|
@ -5,6 +5,7 @@ using System;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNetCore.Builder.Internal;
|
using Microsoft.AspNetCore.Builder.Internal;
|
||||||
using Microsoft.AspNetCore.Http;
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.AspNetCore.Internal;
|
||||||
using Microsoft.AspNetCore.Routing;
|
using Microsoft.AspNetCore.Routing;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Moq;
|
using Moq;
|
||||||
|
|
@ -12,16 +13,16 @@ using Xunit;
|
||||||
|
|
||||||
namespace Microsoft.AspNetCore.Builder
|
namespace Microsoft.AspNetCore.Builder
|
||||||
{
|
{
|
||||||
public class GlobalRoutingBuilderExtensionsTest
|
public class EndpointRoutingBuilderExtensionsTest
|
||||||
{
|
{
|
||||||
[Fact]
|
[Fact]
|
||||||
public void UseGlobalRouting_ServicesNotRegistered_Throws()
|
public void UseEndpointRouting_ServicesNotRegistered_Throws()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var app = new ApplicationBuilder(Mock.Of<IServiceProvider>());
|
var app = new ApplicationBuilder(Mock.Of<IServiceProvider>());
|
||||||
|
|
||||||
// Act
|
// Act
|
||||||
var ex = Assert.Throws<InvalidOperationException>(() => app.UseGlobalRouting());
|
var ex = Assert.Throws<InvalidOperationException>(() => app.UseEndpointRouting());
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.Equal(
|
Assert.Equal(
|
||||||
|
|
@ -49,14 +50,14 @@ namespace Microsoft.AspNetCore.Builder
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task UseGlobalRouting_ServicesRegistered_SetsFeature()
|
public async Task UseEndpointRouting_ServicesRegistered_SetsFeature()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var services = CreateServices();
|
var services = CreateServices();
|
||||||
|
|
||||||
var app = new ApplicationBuilder(services);
|
var app = new ApplicationBuilder(services);
|
||||||
|
|
||||||
app.UseGlobalRouting();
|
app.UseEndpointRouting();
|
||||||
|
|
||||||
var appFunc = app.Build();
|
var appFunc = app.Build();
|
||||||
var httpContext = new DefaultHttpContext();
|
var httpContext = new DefaultHttpContext();
|
||||||
|
|
@ -81,21 +82,21 @@ namespace Microsoft.AspNetCore.Builder
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
Assert.Equal(
|
Assert.Equal(
|
||||||
"GlobalRoutingMiddleware must be added to the request execution pipeline before EndpointMiddleware. " +
|
"EndpointRoutingMiddleware must be added to the request execution pipeline before EndpointMiddleware. " +
|
||||||
"Please add GlobalRoutingMiddleware by calling 'IApplicationBuilder.UseGlobalRouting' " +
|
"Please add EndpointRoutingMiddleware by calling 'IApplicationBuilder.UseEndpointRouting' " +
|
||||||
"inside the call to 'Configure(...)' in the application startup code.",
|
"inside the call to 'Configure(...)' in the application startup code.",
|
||||||
ex.Message);
|
ex.Message);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task UseEndpoint_ServicesRegisteredAndGlobalRoutingRegistered_SetsFeature()
|
public async Task UseEndpoint_ServicesRegisteredAndEndpointRoutingRegistered_SetsFeature()
|
||||||
{
|
{
|
||||||
// Arrange
|
// Arrange
|
||||||
var services = CreateServices();
|
var services = CreateServices();
|
||||||
|
|
||||||
var app = new ApplicationBuilder(services);
|
var app = new ApplicationBuilder(services);
|
||||||
|
|
||||||
app.UseGlobalRouting();
|
app.UseEndpointRouting();
|
||||||
app.UseEndpoint();
|
app.UseEndpoint();
|
||||||
|
|
||||||
var appFunc = app.Build();
|
var appFunc = app.Build();
|
||||||
|
|
@ -5,7 +5,7 @@ using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.AspNetCore.Routing.Matchers;
|
using Microsoft.AspNetCore.Routing.Matching;
|
||||||
using Microsoft.AspNetCore.Routing.Patterns;
|
using Microsoft.AspNetCore.Routing.Patterns;
|
||||||
using Microsoft.AspNetCore.Routing.TestObjects;
|
using Microsoft.AspNetCore.Routing.TestObjects;
|
||||||
using Microsoft.Extensions.Primitives;
|
using Microsoft.Extensions.Primitives;
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,45 @@
|
||||||
|
// Copyright (c) .NET Foundation. All rights reserved.
|
||||||
|
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||||
|
|
||||||
|
using Microsoft.AspNetCore.Routing.TestObjects;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text;
|
||||||
|
using Xunit;
|
||||||
|
|
||||||
|
namespace Microsoft.AspNetCore.Routing
|
||||||
|
{
|
||||||
|
public class DefaultEndpointDataSourceTests
|
||||||
|
{
|
||||||
|
[Fact]
|
||||||
|
public void Constructor_Params_EndpointsInitialized()
|
||||||
|
{
|
||||||
|
// Arrange & Act
|
||||||
|
var dataSource = new DefaultEndpointDataSource(
|
||||||
|
new TestEndpoint(EndpointMetadataCollection.Empty, "1"),
|
||||||
|
new TestEndpoint(EndpointMetadataCollection.Empty, "2")
|
||||||
|
);
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Assert.Collection(dataSource.Endpoints,
|
||||||
|
endpoint => Assert.Equal("1", endpoint.DisplayName),
|
||||||
|
endpoint => Assert.Equal("2", endpoint.DisplayName));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void Constructor_Enumerable_EndpointsInitialized()
|
||||||
|
{
|
||||||
|
// Arrange & Act
|
||||||
|
var dataSource = new DefaultEndpointDataSource(new List<Endpoint>
|
||||||
|
{
|
||||||
|
new TestEndpoint(EndpointMetadataCollection.Empty, "1"),
|
||||||
|
new TestEndpoint(EndpointMetadataCollection.Empty, "2")
|
||||||
|
});
|
||||||
|
|
||||||
|
// Assert
|
||||||
|
Assert.Collection(dataSource.Endpoints,
|
||||||
|
endpoint => Assert.Equal("1", endpoint.DisplayName),
|
||||||
|
endpoint => Assert.Equal("2", endpoint.DisplayName));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue