Skip to content

Commit e1d41f5

Browse files
Add support for .NET Core 3.1 to 6.0. Fixes #815
1 parent 8f732ee commit e1d41f5

File tree

59 files changed

+457
-29
lines changed

Some content is hidden

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

59 files changed

+457
-29
lines changed

build/test.props

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,6 @@
2020
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3" />
2121
</ItemGroup>
2222

23-
<ItemGroup Condition=" '$(IsAspNetCore)' == 'true' ">
24-
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="6.0.2-*" />
25-
</ItemGroup>
26-
2723
<ItemGroup>
2824
<Using Include="Moq" />
2925
<Using Include="Xunit" />

build/test.targets

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,20 @@
22
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33

44
<PropertyGroup>
5-
<FluentAssertionsVersion>6.5.1</FluentAssertionsVersion>
6-
<FluentAssertionsVersion Condition=" '$(TargetFramework)' != 'net6.0' ">5.10.3</FluentAssertionsVersion>
5+
<FluentAssertionsVersion>6.6.0</FluentAssertionsVersion>
6+
<FluentAssertionsVersion Condition=" '$(TargetFramework)' == 'net452' ">5.10.3</FluentAssertionsVersion>
7+
<TestHostVersion>6.0.4-*</TestHostVersion>
8+
<TestHostVersion Condition=" '$(TargetFramework)' == 'netcoreapp3.1' ">3.1.24</TestHostVersion>
79
</PropertyGroup>
810

911
<ItemGroup Condition=" '$(IsSharedProject)' == 'false' ">
1012
<PackageReference Include="FluentAssertions" Version="$(FluentAssertionsVersion)" />
1113
</ItemGroup>
1214

15+
<ItemGroup Condition=" '$(IsAspNetCore)' == 'true' ">
16+
<PackageReference Include="Microsoft.AspNetCore.TestHost" Version="$(TestHostVersion)" />
17+
</ItemGroup>
18+
1319
<ItemGroup>
1420
<Using Include="FluentAssertions" />
1521
</ItemGroup>

src/Abstractions/src/Asp.Versioning.Abstractions/ISunsetPolicyManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ bool TryGetPolicy(
2222
string? name,
2323
ApiVersion? apiVersion,
2424
#if !NETSTANDARD
25-
[MaybeNullWhen(false)]
25+
[MaybeNullWhen( false )]
2626
#endif
2727
out SunsetPolicy sunsetPolicy );
2828
}

src/AspNetCore/Acceptance/Asp.Versioning.Mvc.Acceptance.Tests/Asp.Versioning.Mvc.Acceptance.Tests.csproj

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,27 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>net6.0</TargetFramework>
4+
<TargetFrameworks>net6.0;netcoreapp3.1</TargetFrameworks>
55
<RootNamespace>Asp.Versioning</RootNamespace>
66
</PropertyGroup>
77

8+
<PropertyGroup>
9+
<RuntimeCompilationVersion>6.0.4-*</RuntimeCompilationVersion>
10+
<RuntimeCompilationVersion Condition=" '$(TargetFramework)' == 'netcoreapp3.1' ">3.1.24</RuntimeCompilationVersion>
11+
</PropertyGroup>
12+
813
<ItemGroup>
914
<PackageReference Include="Microsoft.AspNet.WebApi.Client" Version="5.2.7" />
10-
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="6.0.2" />
15+
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="$(RuntimeCompilationVersion)" />
16+
</ItemGroup>
17+
18+
<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp3.1' ">
19+
<PackageReference Include="System.Net.Http.Json" Version="3.2.1" />
20+
</ItemGroup>
21+
22+
<ItemGroup Condition=" '$(TargetFramework)' == 'netcoreapp3.1' ">
23+
<Compile Remove="Http\**\*.cs" />
24+
<None Include="Http\**\*.cs" />
1125
</ItemGroup>
1226

1327
<ItemGroup>

src/AspNetCore/Acceptance/Asp.Versioning.Mvc.Acceptance.Tests/HttpServerFixture.cs

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ namespace Asp.Versioning;
1313
using Microsoft.Extensions.DependencyInjection;
1414
using System.IO;
1515
using System.Reflection;
16+
using System.Text;
1617
using static Microsoft.Extensions.DependencyInjection.ServiceDescriptor;
1718

1819
public abstract partial class HttpServerFixture
@@ -35,14 +36,34 @@ protected virtual void OnAddApiVersioning( IApiVersioningBuilder builder ) { }
3536

3637
private static string GenerateEndpointDirectedGraph( IServiceProvider services )
3738
{
39+
const int MaxUriLength = 65519;
3840
var dfa = services.GetRequiredService<DfaGraphWriter>();
3941
var dataSource = services.GetRequiredService<EndpointDataSource>();
40-
using var writer = new StringWriter();
42+
string graph;
4143

42-
dfa.Write( dataSource, writer );
43-
writer.Flush();
44+
using ( var writer = new StringWriter() )
45+
{
46+
dfa.Write( dataSource, writer );
47+
writer.Flush();
48+
graph = writer.ToString();
49+
}
50+
51+
var count = graph.Length / MaxUriLength;
52+
var fragment = new StringBuilder();
53+
54+
for ( var i = 0; i <= count; i++ )
55+
{
56+
if ( i < count )
57+
{
58+
fragment.Append( Uri.EscapeDataString( graph.Substring( MaxUriLength * i, MaxUriLength ) ) );
59+
}
60+
else
61+
{
62+
fragment.Append( Uri.EscapeDataString( graph[( MaxUriLength * i )..] ) );
63+
}
64+
}
4465

45-
return "https://edotor.net/?engine=dot#" + Uri.EscapeDataString( writer.ToString() );
66+
return "https://edotor.net/?engine=dot#" + fragment.ToString();
4667
}
4768

4869
private TestServer CreateServer()

src/AspNetCore/Acceptance/Asp.Versioning.Mvc.Acceptance.Tests/OData/Basic/Controllers/WeatherForecastsController.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// Copyright (c) .NET Foundation and contributors. All rights reserved.
22

3+
#pragma warning disable IDE0060 // Remove unused parameter
34
#pragma warning disable CA1822 // Mark members as static
45

56
namespace Asp.Versioning.OData.Basic.Controllers;

src/AspNetCore/Acceptance/Asp.Versioning.Mvc.Acceptance.Tests/OData/Basic/given a versioned ODataController/when using a query string and split into two types.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,15 @@ public async Task then_get_should_return_400_for_an_unspecified_version()
107107
var problem = await response.Content.ReadAsProblemDetailsAsync();
108108

109109
// assert
110+
111+
// change from 3.1 to 6.0; DELETE is version-neutral
112+
// and the only candidate, so GET returns 405
113+
#if NETCOREAPP3_1
114+
response.StatusCode.Should().Be( MethodNotAllowed );
115+
#else
110116
response.StatusCode.Should().Be( BadRequest );
111117
problem.Type.Should().Be( ProblemDetailsDefaults.Unspecified.Type );
118+
#endif
112119
}
113120

114121
public when_using_a_query_string_and_split_into_two_types( BasicFixture fixture, ITestOutputHelper console )

src/AspNetCore/Acceptance/Asp.Versioning.Mvc.Acceptance.Tests/OData/Basic/given a versioned ODataController/when using a query string.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,15 @@ public async Task then_get_should_return_400_for_an_unspecified_version()
4747
var problem = await response.Content.ReadAsProblemDetailsAsync();
4848

4949
// assert
50+
51+
// change from 3.1 to 6.0; DELETE is version-neutral
52+
// and the only candidate, so GET returns 405
53+
#if NETCOREAPP3_1
54+
response.StatusCode.Should().Be( MethodNotAllowed );
55+
#else
5056
response.StatusCode.Should().Be( BadRequest );
5157
problem.Type.Should().Be( ProblemDetailsDefaults.Unspecified.Type );
58+
#endif
5259
}
5360

5461
public when_using_a_query_string( BasicFixture fixture, ITestOutputHelper console )

src/AspNetCore/Acceptance/Asp.Versioning.Mvc.Acceptance.Tests/OData/UsingConventions/given a versioned ODataController using conventions/when using a query string and split into two types.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,20 @@ public async Task then_get_should_return_400_for_an_unspecified_version()
8888
{
8989
// arrange
9090

91-
9291
// act
9392
var response = await GetAsync( "api/people" );
9493
var problem = await response.Content.ReadAsProblemDetailsAsync();
9594

9695
// assert
96+
97+
// change from 3.1 to 6.0; DELETE is version-neutral
98+
// and the only candidate, so GET returns 405
99+
#if NETCOREAPP3_1
100+
response.StatusCode.Should().Be( MethodNotAllowed );
101+
#else
97102
response.StatusCode.Should().Be( BadRequest );
98103
problem.Type.Should().Be( ProblemDetailsDefaults.Unspecified.Type );
104+
#endif
99105
}
100106

101107
public when_using_a_query_string_and_split_into_two_types( ConventionsFixture fixture ) : base( fixture ) { }

src/AspNetCore/Acceptance/Asp.Versioning.Mvc.Acceptance.Tests/OData/UsingConventions/given a versioned ODataController using conventions/when using a query string.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public async Task then_get_should_return_200( string requestUrl )
1717

1818

1919
// act
20-
var response = (await GetAsync( requestUrl )).EnsureSuccessStatusCode();
20+
var response = ( await GetAsync( requestUrl ) ).EnsureSuccessStatusCode();
2121

2222
// assert
2323
response.Headers.GetValues( "api-supported-versions" ).Single().Should().Be( "1.0" );
@@ -47,8 +47,15 @@ public async Task then_get_should_return_400_for_an_unspecified_version()
4747
var problem = await response.Content.ReadAsProblemDetailsAsync();
4848

4949
// assert
50+
51+
// change from 3.1 to 6.0; DELETE is version-neutral
52+
// and the only candidate, so GET returns 405
53+
#if NETCOREAPP3_1
54+
response.StatusCode.Should().Be( MethodNotAllowed );
55+
#else
5056
response.StatusCode.Should().Be( BadRequest );
5157
problem.Type.Should().Be( ProblemDetailsDefaults.Unspecified.Type );
58+
#endif
5259
}
5360

5461
public when_using_a_query_string( ConventionsFixture fixture ) : base( fixture ) { }

0 commit comments

Comments
 (0)