Skip to content

Commit be900ca

Browse files
author
Chris Martinez
committed
Add support for ASP.NET Core 3.0
1 parent 7f965a7 commit be900ca

File tree

57 files changed

+1469
-613
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+1469
-613
lines changed

ApiVersioning.sln

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

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio 15
4-
VisualStudioVersion = 15.0.27130.2024
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.29102.190
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{4D5F5F21-0CB7-4B4E-A42F-732BD4AFD0FF}"
77
ProjectSection(SolutionItems) = preProject

nuget.config

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<configuration>
3-
<packageSources>
4-
<clear />
5-
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
6-
</packageSources>
3+
<packageSources>
4+
<clear />
5+
<add key="dotnet-core" value="https://dotnetfeed.blob.core.windows.net/dotnet-core/index.json" />
6+
<add key="extensions" value="https://dotnetfeed.blob.core.windows.net/aspnet-extensions/index.json" />
7+
<add key="entityframeworkcore" value="https://dotnetfeed.blob.core.windows.net/aspnet-entityframeworkcore/index.json" />
8+
<add key="aspnetcore-tooling" value="https://dotnetfeed.blob.core.windows.net/aspnet-aspnetcore-tooling/index.json" />
9+
<add key="aspnetcore" value="https://dotnetfeed.blob.core.windows.net/aspnet-aspnetcore/index.json" />
10+
<add key="aspnet-blazor" value="https://dotnetfeed.blob.core.windows.net/aspnet-blazor/index.json" />
11+
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
12+
</packageSources>
713
</configuration>

samples/aspnetcore/BasicSample/BasicSample.csproj

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
11
<Project Sdk="Microsoft.NET.Sdk.Web">
22

33
<PropertyGroup>
4-
<TargetFramework>netcoreapp2.2</TargetFramework>
5-
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
4+
<TargetFramework>netcoreapp3.0</TargetFramework>
65
<RootNamespace>Microsoft.Examples</RootNamespace>
76
</PropertyGroup>
87

9-
<ItemGroup>
10-
<PackageReference Include="Microsoft.AspNetCore.App" />
11-
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0" PrivateAssets="All" />
12-
</ItemGroup>
13-
148
<ItemGroup>
159
<ProjectReference Include="..\..\..\src\Microsoft.AspNetCore.Mvc.Versioning\Microsoft.AspNetCore.Mvc.Versioning.csproj" />
1610
</ItemGroup>
Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
namespace Microsoft.Examples
22
{
33
using Microsoft.AspNetCore.Builder;
4-
using Microsoft.AspNetCore.Hosting;
54
using Microsoft.Extensions.Configuration;
65
using Microsoft.Extensions.DependencyInjection;
7-
using static Microsoft.AspNetCore.Mvc.CompatibilityVersion;
86

97
public class Startup
108
{
@@ -15,12 +13,9 @@ public Startup( IConfiguration configuration )
1513

1614
public IConfiguration Configuration { get; }
1715

18-
// This method gets called by the runtime. Use this method to add services to the container.
1916
public void ConfigureServices( IServiceCollection services )
2017
{
21-
// the sample application always uses the latest version, but you may want an explicit version such as Version_2_2
22-
// note: Endpoint Routing is enabled by default; however, if you need legacy style routing via IRouter, change it to false
23-
services.AddMvc( options => options.EnableEndpointRouting = true ).SetCompatibilityVersion( Latest );
18+
services.AddControllers();
2419
services.AddApiVersioning(
2520
options =>
2621
{
@@ -29,9 +24,10 @@ public void ConfigureServices( IServiceCollection services )
2924
} );
3025
}
3126

32-
public void Configure( IApplicationBuilder app, IHostingEnvironment env )
27+
public void Configure( IApplicationBuilder app )
3328
{
34-
app.UseMvc();
29+
app.UseRouting();
30+
app.UseEndpoints( builder => builder.MapControllers() );
3531
}
3632
}
3733
}

samples/aspnetcore/ByNamespaceSample/ByNamespaceSample.csproj

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
11
<Project Sdk="Microsoft.NET.Sdk.Web">
22

33
<PropertyGroup>
4-
<TargetFramework>netcoreapp2.2</TargetFramework>
5-
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
4+
<TargetFramework>netcoreapp3.0</TargetFramework>
65
<RootNamespace>Microsoft.Examples</RootNamespace>
76
</PropertyGroup>
87

9-
<ItemGroup>
10-
<PackageReference Include="Microsoft.AspNetCore.App" />
11-
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0" PrivateAssets="All" />
12-
</ItemGroup>
13-
148
<ItemGroup>
159
<ProjectReference Include="..\..\..\src\Microsoft.AspNetCore.Mvc.Versioning\Microsoft.AspNetCore.Mvc.Versioning.csproj" />
1610
</ItemGroup>
Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
namespace Microsoft.Examples
22
{
33
using Microsoft.AspNetCore.Builder;
4-
using Microsoft.AspNetCore.Hosting;
54
using Microsoft.AspNetCore.Mvc.Versioning.Conventions;
65
using Microsoft.Extensions.Configuration;
76
using Microsoft.Extensions.DependencyInjection;
8-
using static Microsoft.AspNetCore.Mvc.CompatibilityVersion;
97

108
public class Startup
119
{
@@ -16,12 +14,9 @@ public Startup( IConfiguration configuration )
1614

1715
public IConfiguration Configuration { get; }
1816

19-
// This method gets called by the runtime. Use this method to add services to the container.
2017
public void ConfigureServices( IServiceCollection services )
2118
{
22-
// the sample application always uses the latest version, but you may want an explicit version such as Version_2_2
23-
// note: Endpoint Routing is enabled by default; however, if you need legacy style routing via IRouter, change it to false
24-
services.AddMvc( options => options.EnableEndpointRouting = true ).SetCompatibilityVersion( Latest );
19+
services.AddControllers();
2520
services.AddApiVersioning(
2621
options =>
2722
{
@@ -33,10 +28,10 @@ public void ConfigureServices( IServiceCollection services )
3328
} );
3429
}
3530

36-
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
37-
public void Configure( IApplicationBuilder app, IHostingEnvironment env )
31+
public void Configure( IApplicationBuilder app )
3832
{
39-
app.UseMvc();
33+
app.UseRouting();
34+
app.UseEndpoints( builder => builder.MapControllers() );
4035
}
4136
}
4237
}

samples/aspnetcore/ConventionsSample/ConventionsSample.csproj

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
11
<Project Sdk="Microsoft.NET.Sdk.Web">
22

33
<PropertyGroup>
4-
<TargetFramework>netcoreapp2.2</TargetFramework>
5-
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
4+
<TargetFramework>netcoreapp3.0</TargetFramework>
65
<RootNamespace>Microsoft.Examples</RootNamespace>
76
</PropertyGroup>
8-
9-
<ItemGroup>
10-
<PackageReference Include="Microsoft.AspNetCore.App" />
11-
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0" PrivateAssets="All" />
12-
</ItemGroup>
137

148
<ItemGroup>
159
<ProjectReference Include="..\..\..\src\Microsoft.AspNetCore.Mvc.Versioning\Microsoft.AspNetCore.Mvc.Versioning.csproj" />

samples/aspnetcore/ConventionsSample/Startup.cs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,10 @@
22
{
33
using Controllers;
44
using Microsoft.AspNetCore.Builder;
5-
using Microsoft.AspNetCore.Hosting;
65
using Microsoft.AspNetCore.Mvc;
76
using Microsoft.AspNetCore.Mvc.Versioning.Conventions;
87
using Microsoft.Extensions.Configuration;
98
using Microsoft.Extensions.DependencyInjection;
10-
using static Microsoft.AspNetCore.Mvc.CompatibilityVersion;
119

1210
public class Startup
1311
{
@@ -18,12 +16,9 @@ public Startup( IConfiguration configuration )
1816

1917
public IConfiguration Configuration { get; }
2018

21-
// This method gets called by the runtime. Use this method to add services to the container.
2219
public void ConfigureServices( IServiceCollection services )
2320
{
24-
// the sample application always uses the latest version, but you may want an explicit version such as Version_2_2
25-
// note: Endpoint Routing is enabled by default; however, if you need legacy style routing via IRouter, change it to false
26-
services.AddMvc( options => options.EnableEndpointRouting = true ).SetCompatibilityVersion( Latest );
21+
services.AddControllers();
2722
services.AddApiVersioning(
2823
options =>
2924
{
@@ -45,10 +40,10 @@ public void ConfigureServices( IServiceCollection services )
4540
} );
4641
}
4742

48-
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
49-
public void Configure( IApplicationBuilder app, IHostingEnvironment env )
43+
public void Configure( IApplicationBuilder app )
5044
{
51-
app.UseMvc();
45+
app.UseRouting();
46+
app.UseEndpoints( builder => builder.MapControllers() );
5247
}
5348
}
5449
}

samples/aspnetcore/SwaggerSample/ConfigureSwaggerOptions.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
using Microsoft.AspNetCore.Mvc.ApiExplorer;
44
using Microsoft.Extensions.DependencyInjection;
55
using Microsoft.Extensions.Options;
6-
using Swashbuckle.AspNetCore.Swagger;
6+
using Microsoft.OpenApi.Models;
77
using Swashbuckle.AspNetCore.SwaggerGen;
8+
using System;
89

910
/// <summary>
1011
/// Configures the Swagger generation options.
@@ -32,16 +33,15 @@ public void Configure( SwaggerGenOptions options )
3233
}
3334
}
3435

35-
static Info CreateInfoForApiVersion( ApiVersionDescription description )
36+
static OpenApiInfo CreateInfoForApiVersion( ApiVersionDescription description )
3637
{
37-
var info = new Info()
38+
var info = new OpenApiInfo()
3839
{
3940
Title = "Sample API",
4041
Version = description.ApiVersion.ToString(),
4142
Description = "A sample application with Swagger, Swashbuckle, and API versioning.",
42-
Contact = new Contact() { Name = "Bill Mei", Email = "bill.mei@somewhere.com" },
43-
TermsOfService = "Shareware",
44-
License = new License() { Name = "MIT", Url = "https://opensource.org/licenses/MIT" }
43+
Contact = new OpenApiContact() { Name = "Bill Mei", Email = "bill.mei@somewhere.com" },
44+
License = new OpenApiLicense() { Name = "MIT", Url = new Uri( "https://opensource.org/licenses/MIT" ) }
4545
};
4646

4747
if ( description.IsDeprecated )

samples/aspnetcore/SwaggerSample/Startup.cs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
namespace Microsoft.Examples
22
{
33
using Microsoft.AspNetCore.Builder;
4-
using Microsoft.AspNetCore.Hosting;
54
using Microsoft.AspNetCore.Mvc.ApiExplorer;
65
using Microsoft.Extensions.Configuration;
76
using Microsoft.Extensions.DependencyInjection;
@@ -10,7 +9,6 @@
109
using Swashbuckle.AspNetCore.SwaggerGen;
1110
using System.IO;
1211
using System.Reflection;
13-
using static Microsoft.AspNetCore.Mvc.CompatibilityVersion;
1412

1513
/// <summary>
1614
/// Represents the startup process for the application.
@@ -38,9 +36,7 @@ public Startup( IConfiguration configuration )
3836
/// <param name="services">The collection of services to configure the application with.</param>
3937
public void ConfigureServices( IServiceCollection services )
4038
{
41-
// the sample application always uses the latest version, but you may want an explicit version such as Version_2_2
42-
// note: Endpoint Routing is enabled by default; however, if you need legacy style routing via IRouter, change it to false
43-
services.AddMvc( options => options.EnableEndpointRouting = true ).SetCompatibilityVersion( Latest );
39+
services.AddControllers();
4440
services.AddApiVersioning(
4541
options =>
4642
{
@@ -74,11 +70,11 @@ public void ConfigureServices( IServiceCollection services )
7470
/// Configures the application using the provided builder, hosting environment, and API version description provider.
7571
/// </summary>
7672
/// <param name="app">The current application builder.</param>
77-
/// <param name="env">The current hosting environment.</param>
7873
/// <param name="provider">The API version descriptor provider used to enumerate defined API versions.</param>
79-
public void Configure( IApplicationBuilder app, IHostingEnvironment env, IApiVersionDescriptionProvider provider )
74+
public void Configure( IApplicationBuilder app, IApiVersionDescriptionProvider provider )
8075
{
81-
app.UseMvc();
76+
app.UseRouting();
77+
app.UseEndpoints( builder => builder.MapControllers() );
8278
app.UseSwagger();
8379
app.UseSwaggerUI(
8480
options =>

0 commit comments

Comments
 (0)