Update basic middleware projects to netcoreapp3.0

This commit is contained in:
Nate McMaster 2018-12-05 10:06:29 -08:00
parent 4c6bbe5a01
commit e0bbda07fc
No known key found for this signature in database
GPG Key ID: A778D9601BD78810
17 changed files with 17 additions and 95 deletions

View File

@ -30,7 +30,6 @@
<ProjectReferenceProvider Include="Microsoft.AspNetCore.Html.Abstractions" ProjectPath="$(RepositoryRoot)src\Html\Abstractions\src\Microsoft.AspNetCore.Html.Abstractions.csproj" /> <ProjectReferenceProvider Include="Microsoft.AspNetCore.Html.Abstractions" ProjectPath="$(RepositoryRoot)src\Html\Abstractions\src\Microsoft.AspNetCore.Html.Abstractions.csproj" />
<ProjectReferenceProvider Include="Microsoft.AspNetCore.Connections.Abstractions" ProjectPath="$(RepositoryRoot)src\Servers\Connections.Abstractions\src\Microsoft.AspNetCore.Connections.Abstractions.csproj" /> <ProjectReferenceProvider Include="Microsoft.AspNetCore.Connections.Abstractions" ProjectPath="$(RepositoryRoot)src\Servers\Connections.Abstractions\src\Microsoft.AspNetCore.Connections.Abstractions.csproj" />
<ProjectReferenceProvider Include="Microsoft.AspNetCore.Server.Kestrel.Core" ProjectPath="$(RepositoryRoot)src\Servers\Kestrel\Core\src\Microsoft.AspNetCore.Server.Kestrel.Core.csproj" /> <ProjectReferenceProvider Include="Microsoft.AspNetCore.Server.Kestrel.Core" ProjectPath="$(RepositoryRoot)src\Servers\Kestrel\Core\src\Microsoft.AspNetCore.Server.Kestrel.Core.csproj" />
<ProjectReferenceProvider Include="Microsoft.AspNetCore.Server.Kestrel.Https" ProjectPath="$(RepositoryRoot)src\Servers\Kestrel\Https\src\Microsoft.AspNetCore.Server.Kestrel.Https.csproj" />
<ProjectReferenceProvider Include="Microsoft.AspNetCore.Server.Kestrel" ProjectPath="$(RepositoryRoot)src\Servers\Kestrel\Kestrel\src\Microsoft.AspNetCore.Server.Kestrel.csproj" /> <ProjectReferenceProvider Include="Microsoft.AspNetCore.Server.Kestrel" ProjectPath="$(RepositoryRoot)src\Servers\Kestrel\Kestrel\src\Microsoft.AspNetCore.Server.Kestrel.csproj" />
<ProjectReferenceProvider Include="PlatformBenchmarks" ProjectPath="$(RepositoryRoot)src\Servers\Kestrel\perf\PlatformBenchmarks\PlatformBenchmarks.csproj" /> <ProjectReferenceProvider Include="PlatformBenchmarks" ProjectPath="$(RepositoryRoot)src\Servers\Kestrel\perf\PlatformBenchmarks\PlatformBenchmarks.csproj" />
<ProjectReferenceProvider Include="CodeGenerator" ProjectPath="$(RepositoryRoot)src\Servers\Kestrel\tools\CodeGenerator\CodeGenerator.csproj" /> <ProjectReferenceProvider Include="CodeGenerator" ProjectPath="$(RepositoryRoot)src\Servers\Kestrel\tools\CodeGenerator\CodeGenerator.csproj" />

View File

@ -6,6 +6,7 @@ This is required to provide dependencies for samples and tests.
<ItemGroup> <ItemGroup>
<LatestPackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="3.0.0-preview-18571-0010" /> <LatestPackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="3.0.0-preview-18571-0010" />
<LatestPackageReference Include="Microsoft.AspNetCore.Server.IISIntegration" Version="3.0.0-preview-18571-0010" /> <LatestPackageReference Include="Microsoft.AspNetCore.Server.IISIntegration" Version="3.0.0-preview-18571-0010" />
<LatestPackageReference Include="Microsoft.AspNetCore.Routing.Abstractions" Version="3.0.0-preview-18571-0010" />
<LatestPackageReference Include="Microsoft.AspNetCore.Routing" Version="3.0.0-preview-18571-0010" /> <LatestPackageReference Include="Microsoft.AspNetCore.Routing" Version="3.0.0-preview-18571-0010" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -4,7 +4,7 @@
<Description> <Description>
ASP.NET Core middleware for filtering out requests with unknown HTTP host headers. ASP.NET Core middleware for filtering out requests with unknown HTTP host headers.
</Description> </Description>
<TargetFramework>netstandard2.0</TargetFramework> <TargetFramework>netcoreapp3.0</TargetFramework>
<GenerateDocumentationFile>true</GenerateDocumentationFile> <GenerateDocumentationFile>true</GenerateDocumentationFile>
<PackageTags>aspnetcore</PackageTags> <PackageTags>aspnetcore</PackageTags>
</PropertyGroup> </PropertyGroup>

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFrameworks>$(StandardTestTfms)</TargetFrameworks> <TargetFramework>netcoreapp3.0</TargetFramework>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

View File

@ -4,7 +4,7 @@
<Description>ASP.NET Core basic middleware for supporting HTTP method overrides. Includes: <Description>ASP.NET Core basic middleware for supporting HTTP method overrides. Includes:
* X-Forwarded-* headers to forward headers from a proxy. * X-Forwarded-* headers to forward headers from a proxy.
* HTTP method override header.</Description> * HTTP method override header.</Description>
<TargetFramework>netstandard2.0</TargetFramework> <TargetFramework>netcoreapp3.0</TargetFramework>
<NoWarn>$(NoWarn);CS1591</NoWarn> <NoWarn>$(NoWarn);CS1591</NoWarn>
<GenerateDocumentationFile>true</GenerateDocumentationFile> <GenerateDocumentationFile>true</GenerateDocumentationFile>
<PackageTags>aspnetcore;proxy;headers;xforwarded</PackageTags> <PackageTags>aspnetcore;proxy;headers;xforwarded</PackageTags>

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFrameworks>$(StandardTestTfms)</TargetFrameworks> <TargetFramework>netcoreapp3.0</TargetFramework>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

View File

@ -6,7 +6,6 @@
<ItemGroup> <ItemGroup>
<Reference Include="Microsoft.AspNetCore.Server.Kestrel" /> <Reference Include="Microsoft.AspNetCore.Server.Kestrel" />
<Reference Include="Microsoft.AspNetCore.Server.Kestrel.Https" />
<Reference Include="Microsoft.Extensions.Logging.Console" /> <Reference Include="Microsoft.Extensions.Logging.Console" />
<Reference Include="Microsoft.AspNetCore.HttpsPolicy" /> <Reference Include="Microsoft.AspNetCore.HttpsPolicy" />
</ItemGroup> </ItemGroup>

View File

@ -4,7 +4,7 @@
<Description> <Description>
ASP.NET Core basic middleware for supporting HTTPS Redirection and HTTP Strict-Transport-Security. ASP.NET Core basic middleware for supporting HTTPS Redirection and HTTP Strict-Transport-Security.
</Description> </Description>
<TargetFramework>netstandard2.0</TargetFramework> <TargetFramework>netcoreapp3.0</TargetFramework>
<NoWarn>$(NoWarn);CS1591</NoWarn> <NoWarn>$(NoWarn);CS1591</NoWarn>
<GenerateDocumentationFile>true</GenerateDocumentationFile> <GenerateDocumentationFile>true</GenerateDocumentationFile>
<PackageTags>aspnetcore;https;hsts</PackageTags> <PackageTags>aspnetcore;https;hsts</PackageTags>

View File

@ -30,22 +30,13 @@ namespace Microsoft.AspNetCore.ResponseCompression
private BrotliCompressionProviderOptions Options { get; } private BrotliCompressionProviderOptions Options { get; }
/// <inheritdoc /> /// <inheritdoc />
public string EncodingName => "br"; public string EncodingName { get; } = "br";
/// <inheritdoc /> /// <inheritdoc />
public bool SupportsFlush => true; public bool SupportsFlush { get; } = true;
/// <inheritdoc /> /// <inheritdoc />
public Stream CreateStream(Stream outputStream) public Stream CreateStream(Stream outputStream)
{ => new BrotliStream(outputStream, Options.Level, leaveOpen: true);
#if NETCOREAPP2_1
return new BrotliStream(outputStream, Options.Level, leaveOpen: true);
#elif NET461 || NETSTANDARD2_0
// Brotli is only supported in .NET Core 2.1+
throw new PlatformNotSupportedException();
#else
#error Target frameworks need to be updated.
#endif
}
} }
} }

View File

@ -30,27 +30,13 @@ namespace Microsoft.AspNetCore.ResponseCompression
private GzipCompressionProviderOptions Options { get; } private GzipCompressionProviderOptions Options { get; }
/// <inheritdoc /> /// <inheritdoc />
public string EncodingName => "gzip"; public string EncodingName { get; } = "gzip";
/// <inheritdoc /> /// <inheritdoc />
public bool SupportsFlush public bool SupportsFlush { get; } = true;
{
get
{
#if NET461
return false;
#elif NETSTANDARD2_0 || NETCOREAPP2_1
return true;
#else
#error target frameworks need to be updated
#endif
}
}
/// <inheritdoc /> /// <inheritdoc />
public Stream CreateStream(Stream outputStream) public Stream CreateStream(Stream outputStream)
{ => new GZipStream(outputStream, Options.Level, leaveOpen: true);
return new GZipStream(outputStream, Options.Level, leaveOpen: true);
}
} }
} }

View File

@ -8,7 +8,6 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="Microsoft.Extensions.Logging.Abstractions" />
<Reference Include="Microsoft.AspNetCore.Http.Extensions" /> <Reference Include="Microsoft.AspNetCore.Http.Extensions" />
<Reference Include="Microsoft.Extensions.Logging.Abstractions" /> <Reference Include="Microsoft.Extensions.Logging.Abstractions" />
<Reference Include="Microsoft.Extensions.Options" /> <Reference Include="Microsoft.Extensions.Options" />

View File

@ -48,13 +48,7 @@ namespace Microsoft.AspNetCore.ResponseCompression
// Use the factory so it can resolve IOptions<GzipCompressionProviderOptions> from DI. // Use the factory so it can resolve IOptions<GzipCompressionProviderOptions> from DI.
_providers = new ICompressionProvider[] _providers = new ICompressionProvider[]
{ {
#if NETCOREAPP2_1
new CompressionProviderFactory(typeof(BrotliCompressionProvider)), new CompressionProviderFactory(typeof(BrotliCompressionProvider)),
#elif NET461 || NETSTANDARD2_0
// Brotli is only supported in .NET Core 2.1+
#else
#error Target frameworks need to be updated.
#endif
new CompressionProviderFactory(typeof(GzipCompressionProvider)), new CompressionProviderFactory(typeof(GzipCompressionProvider)),
}; };
} }

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFrameworks>$(StandardTestTfms)</TargetFrameworks> <TargetFramework>netcoreapp3.0</TargetFramework>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

View File

@ -37,12 +37,7 @@ namespace Microsoft.AspNetCore.ResponseCompression.Tests
get get
{ {
yield return new EncodingTestData("gzip", expectedBodyLength: 24); yield return new EncodingTestData("gzip", expectedBodyLength: 24);
#if NETCOREAPP2_2
yield return new EncodingTestData("br", expectedBodyLength: 20); yield return new EncodingTestData("br", expectedBodyLength: 20);
#elif NET461
#else
#error Target frameworks need to be updated.
#endif
} }
} }
@ -77,14 +72,8 @@ namespace Microsoft.AspNetCore.ResponseCompression.Tests
{ {
var (response, logMessages) = await InvokeMiddleware(100, requestAcceptEncodings: new[] { "br" }, responseType: TextPlain); var (response, logMessages) = await InvokeMiddleware(100, requestAcceptEncodings: new[] { "br" }, responseType: TextPlain);
#if NET461
CheckResponseNotCompressed(response, expectedBodyLength: 100, sendVaryHeader: true);
#elif NETCOREAPP2_2
CheckResponseCompressed(response, expectedBodyLength: 20, expectedEncoding: "br"); CheckResponseCompressed(response, expectedBodyLength: 20, expectedEncoding: "br");
AssertCompressedWithLog(logMessages, "br"); AssertCompressedWithLog(logMessages, "br");
#else
#error Target frameworks need to be updated.
#endif
} }
[Theory] [Theory]
@ -94,18 +83,10 @@ namespace Microsoft.AspNetCore.ResponseCompression.Tests
{ {
var (response, logMessages) = await InvokeMiddleware(100, new[] { encoding1, encoding2 }, responseType: TextPlain); var (response, logMessages) = await InvokeMiddleware(100, new[] { encoding1, encoding2 }, responseType: TextPlain);
#if NET461
CheckResponseCompressed(response, expectedBodyLength: 24, expectedEncoding: "gzip");
AssertCompressedWithLog(logMessages, "gzip");
#elif NETCOREAPP2_2
CheckResponseCompressed(response, expectedBodyLength: 20, expectedEncoding: "br"); CheckResponseCompressed(response, expectedBodyLength: 20, expectedEncoding: "br");
AssertCompressedWithLog(logMessages, "br"); AssertCompressedWithLog(logMessages, "br");
#else
#error Target frameworks need to be updated.
#endif
} }
#if NETCOREAPP2_2
[Theory] [Theory]
[InlineData("gzip", "br")] [InlineData("gzip", "br")]
[InlineData("br", "gzip")] [InlineData("br", "gzip")]
@ -122,10 +103,6 @@ namespace Microsoft.AspNetCore.ResponseCompression.Tests
CheckResponseCompressed(response, expectedBodyLength: 24, expectedEncoding: "gzip"); CheckResponseCompressed(response, expectedBodyLength: 24, expectedEncoding: "gzip");
AssertCompressedWithLog(logMessages, "gzip"); AssertCompressedWithLog(logMessages, "gzip");
} }
#elif NET461
#else
#error Target frameworks need to be updated.
#endif
[Fact] [Fact]
public async Task Request_AcceptUnknown_NotCompressed() public async Task Request_AcceptUnknown_NotCompressed()
@ -339,15 +316,8 @@ namespace Microsoft.AspNetCore.ResponseCompression.Tests
{ {
var (response, logMessages) = await InvokeMiddleware(100, requestAcceptEncodings: new[] { "*" }, responseType: TextPlain); var (response, logMessages) = await InvokeMiddleware(100, requestAcceptEncodings: new[] { "*" }, responseType: TextPlain);
#if NET461
CheckResponseCompressed(response, expectedBodyLength: 24, expectedEncoding: "gzip");
AssertCompressedWithLog(logMessages, "gzip");
#elif NETCOREAPP2_2
CheckResponseCompressed(response, expectedBodyLength: 20, expectedEncoding: "br"); CheckResponseCompressed(response, expectedBodyLength: 20, expectedEncoding: "br");
AssertCompressedWithLog(logMessages, "br"); AssertCompressedWithLog(logMessages, "br");
#else
#error Target frameworks need to be updated.
#endif
} }
[Fact] [Fact]
@ -699,16 +669,8 @@ namespace Microsoft.AspNetCore.ResponseCompression.Tests
request.Headers.AcceptEncoding.ParseAdd(encoding); request.Headers.AcceptEncoding.ParseAdd(encoding);
var response = await client.SendAsync(request, HttpCompletionOption.ResponseHeadersRead); var response = await client.SendAsync(request, HttpCompletionOption.ResponseHeadersRead);
#if NET461 // Flush not supported, compression disabled
Assert.NotNull(response.Content.Headers.GetValues(HeaderNames.ContentMD5));
Assert.Empty(response.Content.Headers.ContentEncoding);
#elif NETCOREAPP2_2 // Flush supported, compression enabled
Assert.False(response.Content.Headers.TryGetValues(HeaderNames.ContentMD5, out _)); Assert.False(response.Content.Headers.TryGetValues(HeaderNames.ContentMD5, out _));
Assert.Single(response.Content.Headers.ContentEncoding, encoding); Assert.Single(response.Content.Headers.ContentEncoding, encoding);
#else
#error Target frameworks need to be updated.
#endif
var body = await response.Content.ReadAsStreamAsync(); var body = await response.Content.ReadAsStreamAsync();
@ -764,16 +726,8 @@ namespace Microsoft.AspNetCore.ResponseCompression.Tests
request.Headers.AcceptEncoding.ParseAdd(encoding); request.Headers.AcceptEncoding.ParseAdd(encoding);
var response = await client.SendAsync(request, HttpCompletionOption.ResponseHeadersRead); var response = await client.SendAsync(request, HttpCompletionOption.ResponseHeadersRead);
#if NET461 // Flush not supported, compression disabled
Assert.NotNull(response.Content.Headers.GetValues(HeaderNames.ContentMD5));
Assert.Empty(response.Content.Headers.ContentEncoding);
#elif NETCOREAPP2_2 // Flush supported, compression enabled
Assert.False(response.Content.Headers.TryGetValues(HeaderNames.ContentMD5, out _)); Assert.False(response.Content.Headers.TryGetValues(HeaderNames.ContentMD5, out _));
Assert.Single(response.Content.Headers.ContentEncoding, encoding); Assert.Single(response.Content.Headers.ContentEncoding, encoding);
#else
#error Target framework needs to be updated
#endif
var body = await response.Content.ReadAsStreamAsync(); var body = await response.Content.ReadAsStreamAsync();

View File

@ -7,7 +7,6 @@
<ItemGroup> <ItemGroup>
<Reference Include="Microsoft.AspNetCore.Rewrite" /> <Reference Include="Microsoft.AspNetCore.Rewrite" />
<Reference Include="Microsoft.AspNetCore.Server.Kestrel" /> <Reference Include="Microsoft.AspNetCore.Server.Kestrel" />
<Reference Include="Microsoft.AspNetCore.Server.Kestrel.Https" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -5,7 +5,7 @@
* Support for custom URL rewrite rules * Support for custom URL rewrite rules
* Support for running IIS URL Rewrite module rules * Support for running IIS URL Rewrite module rules
* Support for running Apache mod_rewrite rules.</Description> * Support for running Apache mod_rewrite rules.</Description>
<TargetFramework>netstandard2.0</TargetFramework> <TargetFramework>netcoreapp3.0</TargetFramework>
<NoWarn>$(NoWarn);CS1591</NoWarn> <NoWarn>$(NoWarn);CS1591</NoWarn>
<GenerateDocumentationFile>true</GenerateDocumentationFile> <GenerateDocumentationFile>true</GenerateDocumentationFile>
<PackageTags>aspnetcore;urlrewrite;mod_rewrite</PackageTags> <PackageTags>aspnetcore;urlrewrite;mod_rewrite</PackageTags>

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFrameworks>$(StandardTestTfms)</TargetFrameworks> <TargetFramework>netcoreapp3.0</TargetFramework>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>