Skip to content

Commit 9be8075

Browse files
authored
Merge pull request #891 from dotnet-maestro-bot/merge/release/2.2-to-master
[automated] Merge branch 'release/2.2' => 'master'
2 parents 0ef4b41 + 06ce57d commit 9be8075

23 files changed

+422
-168
lines changed

Routing.sln

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Routin
1919
EndProject
2020
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.AspNetCore.Routing.Tests", "test\Microsoft.AspNetCore.Routing.Tests\Microsoft.AspNetCore.Routing.Tests.csproj", "{636D79ED-7B32-487C-BDA5-D2A1AAA97371}"
2121
EndProject
22-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RoutingSample.Web", "samples\RoutingSample.Web\RoutingSample.Web.csproj", "{DB94E647-C73A-4F52-A126-AA7544CCF33B}"
22+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RoutingSandbox", "samples\RoutingSample.Web\RoutingSandbox.csproj", "{DB94E647-C73A-4F52-A126-AA7544CCF33B}"
2323
EndProject
2424
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{C430C499-382D-47BD-B351-CF8F89C08CD2}"
2525
ProjectSection(SolutionItems) = preProject
@@ -55,6 +55,13 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tools", "tools", "{6824486A
5555
EndProject
5656
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Swaggatherer", "tools\Swaggatherer\Swaggatherer.csproj", "{B8516771-E850-4724-BEC3-63FC00C2AE57}"
5757
EndProject
58+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "WebSites", "WebSites", "{8E5E51D4-6B03-4FC6-9F34-6E9FA24702BD}"
59+
ProjectSection(SolutionItems) = preProject
60+
test\WebSites\Directory.Build.props = test\WebSites\Directory.Build.props
61+
EndProjectSection
62+
EndProject
63+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "RoutingWebSite", "test\WebSites\RoutingWebSite\RoutingWebSite.csproj", "{E91EC5EC-30A8-45EC-9B2F-67E2D6C39D74}"
64+
EndProject
5865
Global
5966
GlobalSection(SolutionConfigurationPlatforms) = preSolution
6067
Debug|Any CPU = Debug|Any CPU
@@ -179,6 +186,18 @@ Global
179186
{B8516771-E850-4724-BEC3-63FC00C2AE57}.Release|Mixed Platforms.Build.0 = Release|Any CPU
180187
{B8516771-E850-4724-BEC3-63FC00C2AE57}.Release|x86.ActiveCfg = Release|Any CPU
181188
{B8516771-E850-4724-BEC3-63FC00C2AE57}.Release|x86.Build.0 = Release|Any CPU
189+
{E91EC5EC-30A8-45EC-9B2F-67E2D6C39D74}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
190+
{E91EC5EC-30A8-45EC-9B2F-67E2D6C39D74}.Debug|Any CPU.Build.0 = Debug|Any CPU
191+
{E91EC5EC-30A8-45EC-9B2F-67E2D6C39D74}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
192+
{E91EC5EC-30A8-45EC-9B2F-67E2D6C39D74}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
193+
{E91EC5EC-30A8-45EC-9B2F-67E2D6C39D74}.Debug|x86.ActiveCfg = Debug|Any CPU
194+
{E91EC5EC-30A8-45EC-9B2F-67E2D6C39D74}.Debug|x86.Build.0 = Debug|Any CPU
195+
{E91EC5EC-30A8-45EC-9B2F-67E2D6C39D74}.Release|Any CPU.ActiveCfg = Release|Any CPU
196+
{E91EC5EC-30A8-45EC-9B2F-67E2D6C39D74}.Release|Any CPU.Build.0 = Release|Any CPU
197+
{E91EC5EC-30A8-45EC-9B2F-67E2D6C39D74}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
198+
{E91EC5EC-30A8-45EC-9B2F-67E2D6C39D74}.Release|Mixed Platforms.Build.0 = Release|Any CPU
199+
{E91EC5EC-30A8-45EC-9B2F-67E2D6C39D74}.Release|x86.ActiveCfg = Release|Any CPU
200+
{E91EC5EC-30A8-45EC-9B2F-67E2D6C39D74}.Release|x86.Build.0 = Release|Any CPU
182201
EndGlobalSection
183202
GlobalSection(SolutionProperties) = preSolution
184203
HideSolutionNode = FALSE
@@ -194,6 +213,8 @@ Global
194213
{F3D86714-4E64-41A6-9B36-A47B3683CF5D} = {D5F39F59-5725-4127-82E7-67028D006185}
195214
{91F47A60-9A78-4968-B10D-157D9BFAC37F} = {7F5914E2-C63F-4759-898E-462804357C90}
196215
{B8516771-E850-4724-BEC3-63FC00C2AE57} = {6824486A-3EFF-45D1-BEE8-8B137639C890}
216+
{8E5E51D4-6B03-4FC6-9F34-6E9FA24702BD} = {95359B4B-4C85-4B44-A75B-0621905C4CF6}
217+
{E91EC5EC-30A8-45EC-9B2F-67E2D6C39D74} = {8E5E51D4-6B03-4FC6-9F34-6E9FA24702BD}
197218
EndGlobalSection
198219
GlobalSection(ExtensibilityGlobals) = postSolution
199220
SolutionGuid = {36C8D815-B7F1-479D-894B-E606FB8DECDA}

samples/RoutingSample.Web/PrefixRoute.cs

Lines changed: 0 additions & 62 deletions
This file was deleted.

samples/RoutingSample.Web/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
using Microsoft.AspNetCore.Hosting;
77
using Microsoft.Extensions.Logging;
88

9-
namespace RoutingSample.Web
9+
namespace RoutingSandbox
1010
{
1111
public class Program
1212
{

samples/RoutingSample.Web/RouteBuilderExtensions.cs

Lines changed: 0 additions & 43 deletions
This file was deleted.

samples/RoutingSample.Web/UseEndpointRoutingStartup.cs

Lines changed: 2 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
using Microsoft.Extensions.DependencyInjection;
1515
using Microsoft.Extensions.DependencyInjection.Extensions;
1616

17-
namespace RoutingSample.Web
17+
namespace RoutingSandbox
1818
{
1919
public class UseEndpointRoutingStartup
2020
{
@@ -23,12 +23,7 @@ public class UseEndpointRoutingStartup
2323

2424
public void ConfigureServices(IServiceCollection services)
2525
{
26-
services.AddTransient<EndsWithStringRouteConstraint>();
27-
28-
services.AddRouting(options =>
29-
{
30-
options.ConstraintMap.Add("endsWith", typeof(EndsWithStringRouteConstraint));
31-
});
26+
services.AddRouting();
3227
}
3328

3429
public void Configure(IApplicationBuilder app)
@@ -69,24 +64,6 @@ public void Configure(IApplicationBuilder app)
6964
response.ContentLength = payloadLength;
7065
return response.Body.WriteAsync(_plainTextPayload, 0, payloadLength);
7166
});
72-
builder.MapGet(
73-
"/withconstraints/{id:endsWith(_001)}",
74-
(httpContext) =>
75-
{
76-
var response = httpContext.Response;
77-
response.StatusCode = 200;
78-
response.ContentType = "text/plain";
79-
return response.WriteAsync("WithConstraints");
80-
});
81-
builder.MapGet(
82-
"/withoptionalconstraints/{id:endsWith(_001)?}",
83-
(httpContext) =>
84-
{
85-
var response = httpContext.Response;
86-
response.StatusCode = 200;
87-
response.ContentType = "text/plain";
88-
return response.WriteAsync("withoptionalconstraints");
89-
});
9067
builder.MapGet(
9168
"/graph",
9269
"DFA Graph",
@@ -101,32 +78,6 @@ public void Configure(IApplicationBuilder app)
10178

10279
return Task.CompletedTask;
10380
});
104-
builder.MapGet(
105-
"/WithSingleAsteriskCatchAll/{*path}",
106-
(httpContext) =>
107-
{
108-
var linkGenerator = httpContext.RequestServices.GetRequiredService<LinkGenerator>();
109-
110-
var response = httpContext.Response;
111-
response.StatusCode = 200;
112-
response.ContentType = "text/plain";
113-
return response.WriteAsync(
114-
"Link: " + linkGenerator.GetPathByRouteValues(httpContext, "WithSingleAsteriskCatchAll", new { }));
115-
},
116-
new RouteValuesAddressMetadata(routeName: "WithSingleAsteriskCatchAll", requiredValues: new RouteValueDictionary()));
117-
builder.MapGet(
118-
"/WithDoubleAsteriskCatchAll/{**path}",
119-
(httpContext) =>
120-
{
121-
var linkGenerator = httpContext.RequestServices.GetRequiredService<LinkGenerator>();
122-
123-
var response = httpContext.Response;
124-
response.StatusCode = 200;
125-
response.ContentType = "text/plain";
126-
return response.WriteAsync(
127-
"Link: " + linkGenerator.GetPathByRouteValues(httpContext, "WithDoubleAsteriskCatchAll", new { }));
128-
},
129-
new RouteValuesAddressMetadata(routeName: "WithDoubleAsteriskCatchAll", requiredValues: new RouteValueDictionary()));
13081
});
13182

13283
app.UseStaticFiles();

samples/RoutingSample.Web/UseRouterStartup.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
using Microsoft.AspNetCore.Routing.Constraints;
1010
using Microsoft.Extensions.DependencyInjection;
1111

12-
namespace RoutingSample.Web
12+
namespace RoutingSandbox
1313
{
1414
public class UseRouterStartup
1515
{

test/Directory.Build.props

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@
88
<StandardTestTfms Condition=" '$(DeveloperBuild)' != 'true' AND '$(OS)' == 'Windows_NT' ">$(StandardTestTfms);net461</StandardTestTfms>
99
</PropertyGroup>
1010

11+
<PropertyGroup>
12+
<IsPackable>false</IsPackable>
13+
</PropertyGroup>
14+
1115
<ItemGroup>
12-
<PackageReference Include="Internal.AspNetCore.Sdk" PrivateAssets="All" Version="$(InternalAspNetCoreSdkPackageVersion)" />
13-
<PackageReference Include="Microsoft.AspNetCore.Testing" Version="$(MicrosoftAspNetCoreTestingPackageVersion)" />
1416
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(MicrosoftNETTestSdkPackageVersion)" />
1517
<PackageReference Include="Moq" Version="$(MoqPackageVersion)" />
1618
<PackageReference Include="xunit" Version="$(XunitPackageVersion)" />

test/Microsoft.AspNetCore.Mvc.Routing.Abstractions.Tests/Microsoft.AspNetCore.Mvc.Routing.Abstractions.Tests.csproj

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
44
<TargetFrameworks>$(StandardTestTfms)</TargetFrameworks>
@@ -8,4 +8,8 @@
88
<ProjectReference Include="..\..\src\Microsoft.AspNetCore.Routing.Abstractions\Microsoft.AspNetCore.Routing.Abstractions.csproj" />
99
</ItemGroup>
1010

11+
<ItemGroup>
12+
<PackageReference Include="Microsoft.AspNetCore.Testing" Version="$(MicrosoftAspNetCoreTestingPackageVersion)" />
13+
</ItemGroup>
14+
1115
</Project>

test/Microsoft.AspNetCore.Routing.DecisionTree.Sources.Tests/Microsoft.AspNetCore.Routing.DecisionTree.Sources.Tests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
44
<TargetFrameworks>$(StandardTestTfms)</TargetFrameworks>

test/Microsoft.AspNetCore.Routing.FunctionalTests/EndpointRoutingSampleTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
using System.Net.Http;
77
using System.Threading.Tasks;
88
using Microsoft.AspNetCore.TestHost;
9-
using RoutingSample.Web;
9+
using RoutingWebSite;
1010
using Xunit;
1111

1212
namespace Microsoft.AspNetCore.Routing.FunctionalTests

test/Microsoft.AspNetCore.Routing.FunctionalTests/Microsoft.AspNetCore.Routing.FunctionalTests.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<ItemGroup>
88
<ProjectReference Include="..\..\src\Microsoft.AspNetCore.Routing\Microsoft.AspNetCore.Routing.csproj" />
9-
<ProjectReference Include="..\..\samples\RoutingSample.Web\RoutingSample.Web.csproj" />
9+
<ProjectReference Include="..\WebSites\RoutingWebSite\RoutingWebSite.csproj" />
1010
</ItemGroup>
1111

1212
<ItemGroup>
@@ -17,4 +17,4 @@
1717
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="$(MicrosoftAspNetCoreTestHostPackageVersion)" />
1818
</ItemGroup>
1919

20-
</Project>
20+
</Project>

test/Microsoft.AspNetCore.Routing.FunctionalTests/RouterSampleTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
using System.Net.Http;
77
using System.Threading.Tasks;
88
using Microsoft.AspNetCore.TestHost;
9-
using RoutingSample.Web;
9+
using RoutingWebSite;
1010
using Xunit;
1111

1212
namespace Microsoft.AspNetCore.Routing.FunctionalTests

test/WebSites/Directory.Build.props

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<Project>
2+
<!-- Skip the parent folder to prevent getting test package references. -->
3+
<Import Project="..\..\Directory.Build.props" />
4+
5+
<PropertyGroup>
6+
<DeveloperBuildTestWebsiteTfms>netcoreapp2.2</DeveloperBuildTestWebsiteTfms>
7+
<StandardTestWebsiteTfms>$(DeveloperBuildTestWebsiteTfms)</StandardTestWebsiteTfms>
8+
<StandardTestWebsiteTfms Condition=" '$(DeveloperBuild)' != 'true' ">netcoreapp2.2</StandardTestWebsiteTfms>
9+
<StandardTestWebsiteTfms Condition=" '$(DeveloperBuild)' != 'true' AND '$(OS)' == 'Windows_NT' ">$(StandardTestWebsiteTfms);net461</StandardTestWebsiteTfms>
10+
</PropertyGroup>
11+
</Project>

samples/RoutingSample.Web/EndsWithStringRouteConstraint.cs renamed to test/WebSites/RoutingWebSite/EndsWithStringRouteConstraint.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
using Microsoft.AspNetCore.Http;
77
using Microsoft.AspNetCore.Routing;
88

9-
namespace RoutingSample.Web
9+
namespace RoutingWebSite
1010
{
1111
internal class EndsWithStringRouteConstraint : IRouteConstraint
1212
{
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
// Copyright (c) .NET Foundation. All rights reserved.
2+
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3+
4+
using System;
5+
using System.Collections.Generic;
6+
using System.Linq;
7+
using System.Threading.Tasks;
8+
using Microsoft.AspNetCore.Routing;
9+
using Microsoft.AspNetCore.Routing.Matching;
10+
using Microsoft.AspNetCore.Routing.Patterns;
11+
12+
namespace Microsoft.AspNetCore.Builder
13+
{
14+
public static class EndpointRouteBuilderExtensions
15+
{
16+
public static IEndpointConventionBuilder MapHello(this IEndpointRouteBuilder builder, string template, string greeter)
17+
{
18+
if (builder == null)
19+
{
20+
throw new ArgumentNullException(nameof(builder));
21+
}
22+
23+
var pipeline = builder.CreateApplicationBuilder()
24+
.UseHello(greeter)
25+
.Build();
26+
27+
return builder.Map(
28+
template,
29+
"Hello " + greeter,
30+
pipeline);
31+
}
32+
}
33+
}

0 commit comments

Comments
 (0)