From df36d02311c05938a3ea57a31dc0a0790c63f564 Mon Sep 17 00:00:00 2001 From: Chris R Date: Mon, 22 May 2017 14:06:13 -0700 Subject: [PATCH] Retarget to netstandard2.0 --- build/common.props | 4 +- build/dependencies.props | 4 +- samples/HotAddSample/HotAddSample.csproj | 5 ++- samples/SelfHostServer/SelfHostServer.csproj | 5 ++- ...Microsoft.AspNetCore.Server.HttpSys.csproj | 2 +- .../AuthenticationTests.cs | 21 ++++++---- .../Listener/AuthenticationTests.cs | 9 +++-- .../Listener/ResponseBodyTests.cs | 38 +++++++++++++++++-- .../Listener/ResponseHeaderTests.cs | 14 ++++++- .../Listener/ResponseSendFileTests.cs | 28 +++++++++++++- .../Listener/ServerTests.cs | 9 ++++- ...Core.Server.HttpSys.FunctionalTests.csproj | 3 +- .../ResponseHeaderTests.cs | 12 ++++++ ...oft.AspNetCore.Server.HttpSys.Tests.csproj | 3 +- 14 files changed, 130 insertions(+), 27 deletions(-) diff --git a/build/common.props b/build/common.props index ba53fc2f1f..f336a03553 100644 --- a/build/common.props +++ b/build/common.props @@ -16,8 +16,8 @@ - - + + diff --git a/build/dependencies.props b/build/dependencies.props index ed2c89867f..75ab009a69 100644 --- a/build/dependencies.props +++ b/build/dependencies.props @@ -1,9 +1,9 @@ 2.0.0-* - 4.3.0 + 4.4.0-* 2.1.0-* - $(BundledNETStandardPackageVersion) + 2.0.0-* 15.3.0-* 2.3.0-beta2-* diff --git a/samples/HotAddSample/HotAddSample.csproj b/samples/HotAddSample/HotAddSample.csproj index 4a41f19c4c..a02b6162da 100644 --- a/samples/HotAddSample/HotAddSample.csproj +++ b/samples/HotAddSample/HotAddSample.csproj @@ -3,7 +3,7 @@ - netcoreapp2.0 + netcoreapp2.0;net461 Exe true @@ -13,4 +13,7 @@ + + + diff --git a/samples/SelfHostServer/SelfHostServer.csproj b/samples/SelfHostServer/SelfHostServer.csproj index 4a41f19c4c..a02b6162da 100644 --- a/samples/SelfHostServer/SelfHostServer.csproj +++ b/samples/SelfHostServer/SelfHostServer.csproj @@ -3,7 +3,7 @@ - netcoreapp2.0 + netcoreapp2.0;net461 Exe true @@ -13,4 +13,7 @@ + + + diff --git a/src/Microsoft.AspNetCore.Server.HttpSys/Microsoft.AspNetCore.Server.HttpSys.csproj b/src/Microsoft.AspNetCore.Server.HttpSys/Microsoft.AspNetCore.Server.HttpSys.csproj index d43ccbe0ca..4bbc01835d 100644 --- a/src/Microsoft.AspNetCore.Server.HttpSys/Microsoft.AspNetCore.Server.HttpSys.csproj +++ b/src/Microsoft.AspNetCore.Server.HttpSys/Microsoft.AspNetCore.Server.HttpSys.csproj @@ -4,7 +4,7 @@ ASP.NET Core HTTP server that uses the Windows HTTP Server API. - netcoreapp2.0 + netstandard2.0 $(NoWarn);CS1591 true true diff --git a/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/AuthenticationTests.cs b/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/AuthenticationTests.cs index 6c7618b5d3..59d5f49438 100644 --- a/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/AuthenticationTests.cs +++ b/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/AuthenticationTests.cs @@ -40,7 +40,8 @@ namespace Microsoft.AspNetCore.Server.HttpSys } } - [ConditionalTheory(Skip = "HttpClientHandler issue (https://github.com/aspnet/ServerTests/issues/82).")] + [ConditionalTheory] + [FrameworkSkipCondition(RuntimeFrameworks.CoreCLR, SkipReason = "HttpClientHandler issue (https://github.com/aspnet/ServerTests/issues/82).")] [InlineData(AuthenticationSchemes.Negotiate)] [InlineData(AuthenticationSchemes.NTLM)] // [InlineData(AuthenticationSchemes.Digest)] // TODO: Not implemented @@ -58,7 +59,8 @@ namespace Microsoft.AspNetCore.Server.HttpSys } } - [ConditionalTheory(Skip = "HttpClientHandler issue (https://github.com/aspnet/ServerTests/issues/82).")] + [ConditionalTheory] + [FrameworkSkipCondition(RuntimeFrameworks.CoreCLR, SkipReason = "HttpClientHandler issue (https://github.com/aspnet/ServerTests/issues/82).")] [InlineData(AuthenticationSchemes.Negotiate)] [InlineData(AuthenticationSchemes.NTLM)] // [InlineData(AuthenticationSchemes.Digest)] // TODO: Not implemented @@ -80,7 +82,8 @@ namespace Microsoft.AspNetCore.Server.HttpSys } } - [Fact(Skip = "HttpClientHandler issue (https://github.com/aspnet/ServerTests/issues/82).")] + [ConditionalFact] + [FrameworkSkipCondition(RuntimeFrameworks.CoreCLR, SkipReason = "HttpClientHandler issue (https://github.com/aspnet/ServerTests/issues/82).")] public async Task MultipleAuthTypes_AllowAnonymousButSpecify401_ChallengesAdded() { string address; @@ -209,7 +212,8 @@ namespace Microsoft.AspNetCore.Server.HttpSys } } - [ConditionalTheory(Skip = "HttpClientHandler issue (https://github.com/aspnet/ServerTests/issues/82).")] + [ConditionalTheory] + [FrameworkSkipCondition(RuntimeFrameworks.CoreCLR, SkipReason = "HttpClientHandler issue (https://github.com/aspnet/ServerTests/issues/82).")] [InlineData(AuthenticationSchemes.Negotiate)] [InlineData(AuthenticationSchemes.NTLM)] // [InlineData(AuthenticationSchemes.Digest)] @@ -232,7 +236,8 @@ namespace Microsoft.AspNetCore.Server.HttpSys } } - [ConditionalTheory(Skip = "HttpClientHandler issue (https://github.com/aspnet/ServerTests/issues/82).")] + [ConditionalTheory] + [FrameworkSkipCondition(RuntimeFrameworks.CoreCLR, SkipReason = "HttpClientHandler issue (https://github.com/aspnet/ServerTests/issues/82).")] [InlineData(AuthenticationSchemes.Negotiate)] [InlineData(AuthenticationSchemes.NTLM)] // [InlineData(AuthenticationSchemes.Digest)] @@ -255,7 +260,8 @@ namespace Microsoft.AspNetCore.Server.HttpSys } } - [Fact(Skip = "HttpClientHandler issue (https://github.com/aspnet/ServerTests/issues/82).")] + [ConditionalFact] + [FrameworkSkipCondition(RuntimeFrameworks.CoreCLR, SkipReason = "HttpClientHandler issue (https://github.com/aspnet/ServerTests/issues/82).")] public async Task AuthTypes_OneChallengeSent() { var authTypes = AuthenticationSchemes.Negotiate | AuthenticationSchemes.NTLM | /*AuthenticationSchemes.Digest |*/ AuthenticationSchemes.Basic; @@ -273,7 +279,8 @@ namespace Microsoft.AspNetCore.Server.HttpSys } } - [ConditionalTheory(Skip = "HttpClientHandler issue (https://github.com/aspnet/ServerTests/issues/82).")] + [ConditionalTheory] + [FrameworkSkipCondition(RuntimeFrameworks.CoreCLR, SkipReason = "HttpClientHandler issue (https://github.com/aspnet/ServerTests/issues/82).")] [InlineData(AuthenticationSchemes.Negotiate)] [InlineData(AuthenticationSchemes.NTLM)] // [InlineData(AuthenticationSchemes.Digest)] diff --git a/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/Listener/AuthenticationTests.cs b/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/Listener/AuthenticationTests.cs index c189a04a32..13c75bbfd2 100644 --- a/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/Listener/AuthenticationTests.cs +++ b/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/Listener/AuthenticationTests.cs @@ -41,7 +41,8 @@ namespace Microsoft.AspNetCore.Server.HttpSys.Listener } } - [ConditionalTheory(Skip = "HttpClientHandler issue (https://github.com/aspnet/ServerTests/issues/82).")] + [ConditionalTheory] + [FrameworkSkipCondition(RuntimeFrameworks.CoreCLR, SkipReason = "HttpClientHandler issue (https://github.com/aspnet/ServerTests/issues/82).")] [InlineData(AuthenticationSchemes.Negotiate)] [InlineData(AuthenticationSchemes.NTLM)] // [InlineData(AuthenticationType.Digest)] // TODO: Not implemented @@ -60,7 +61,8 @@ namespace Microsoft.AspNetCore.Server.HttpSys.Listener } } - [ConditionalTheory(Skip = "HttpClientHandler issue (https://github.com/aspnet/ServerTests/issues/82).")] + [ConditionalTheory] + [FrameworkSkipCondition(RuntimeFrameworks.CoreCLR, SkipReason = "HttpClientHandler issue (https://github.com/aspnet/ServerTests/issues/82).")] [InlineData(AuthenticationSchemes.Negotiate)] [InlineData(AuthenticationSchemes.NTLM)] // [InlineData(AuthenticationSchemes.Digest)] // TODO: Not implemented @@ -85,7 +87,8 @@ namespace Microsoft.AspNetCore.Server.HttpSys.Listener } } - [ConditionalFact(Skip = "HttpClientHandler issue (https://github.com/aspnet/ServerTests/issues/82).")] + [ConditionalFact] + [FrameworkSkipCondition(RuntimeFrameworks.CoreCLR, SkipReason = "HttpClientHandler issue (https://github.com/aspnet/ServerTests/issues/82).")] public async Task MultipleAuthTypes_AllowAnonymousButSpecify401_ChallengesAdded() { string address; diff --git a/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/Listener/ResponseBodyTests.cs b/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/Listener/ResponseBodyTests.cs index 9fe7cea307..c3e681b848 100644 --- a/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/Listener/ResponseBodyTests.cs +++ b/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/Listener/ResponseBodyTests.cs @@ -125,7 +125,15 @@ namespace Microsoft.AspNetCore.Server.HttpSys.Listener var context = await server.AcceptAsync(Utilities.DefaultTimeout); context.Response.Headers["Content-lenGth"] = " 20 "; context.Dispose(); - +#if NET461 + // HttpClient retries the request because it didn't get a response. + context = await server.AcceptAsync(Utilities.DefaultTimeout); + context.Response.Headers["Content-lenGth"] = " 20 "; + context.Dispose(); +#elif NETCOREAPP2_0 +#else +#error Target framework needs to be updated +#endif await Assert.ThrowsAsync(() => responseTask); } } @@ -273,7 +281,19 @@ namespace Microsoft.AspNetCore.Server.HttpSys.Listener var writeTask = context.Response.Body.WriteAsync(new byte[10], 0, 10, cts.Token); Assert.True(writeTask.IsCanceled); context.Dispose(); - +#if NET461 + // HttpClient retries the request because it didn't get a response. + context = await server.AcceptAsync(Utilities.DefaultTimeout); + cts = new CancellationTokenSource(); + cts.Cancel(); + // First write sends headers + writeTask = context.Response.Body.WriteAsync(new byte[10], 0, 10, cts.Token); + Assert.True(writeTask.IsCanceled); + context.Dispose(); +#elif NETCOREAPP2_0 +#else +#error Target framework needs to be updated +#endif await Assert.ThrowsAsync(() => responseTask); } } @@ -293,7 +313,19 @@ namespace Microsoft.AspNetCore.Server.HttpSys.Listener var writeTask = context.Response.Body.WriteAsync(new byte[10], 0, 10, cts.Token); Assert.True(writeTask.IsCanceled); context.Dispose(); - +#if NET461 + // HttpClient retries the request because it didn't get a response. + context = await server.AcceptAsync(Utilities.DefaultTimeout); + cts = new CancellationTokenSource(); + cts.Cancel(); + // First write sends headers + writeTask = context.Response.Body.WriteAsync(new byte[10], 0, 10, cts.Token); + Assert.True(writeTask.IsCanceled); + context.Dispose(); +#elif NETCOREAPP2_0 +#else +#error Target framework needs to be updated +#endif await Assert.ThrowsAsync(() => responseTask); } } diff --git a/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/Listener/ResponseHeaderTests.cs b/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/Listener/ResponseHeaderTests.cs index f7aaa4c9cb..3ba6cba3b2 100644 --- a/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/Listener/ResponseHeaderTests.cs +++ b/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/Listener/ResponseHeaderTests.cs @@ -221,8 +221,13 @@ namespace Microsoft.AspNetCore.Server.HttpSys.Listener Assert.Equal(0, response.ContentLength); Assert.NotNull(response.Headers["Date"]); Assert.Equal("Microsoft-HTTPAPI/2.0", response.Headers["Server"]); - // WebHeaderCollection.GetValues() not available in CoreCLR. +#if NETCOREAPP2_0 // WebHeaderCollection.GetValues() not available in CoreCLR. Assert.Equal("custom1, and custom2, custom3", response.Headers["WWW-Authenticate"]); +#elif NET461 + Assert.Equal(new string[] { "custom1, and custom2", "custom3" }, response.Headers.GetValues("WWW-Authenticate")); +#else +#error Target framework needs to be updated +#endif } } @@ -247,8 +252,13 @@ namespace Microsoft.AspNetCore.Server.HttpSys.Listener Assert.Equal(0, response.ContentLength); Assert.NotNull(response.Headers["Date"]); Assert.Equal("Microsoft-HTTPAPI/2.0", response.Headers["Server"]); - // WebHeaderCollection.GetValues() not available in CoreCLR. +#if NETCOREAPP2_0 // WebHeaderCollection.GetValues() not available in CoreCLR. Assert.Equal("custom1, and custom2, custom3", response.Headers["Custom-Header1"]); +#elif NET461 + Assert.Equal(new string[] { "custom1, and custom2", "custom3" }, response.Headers.GetValues("Custom-Header1")); +#else +#error Target framework needs to be updated +#endif } } diff --git a/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/Listener/ResponseSendFileTests.cs b/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/Listener/ResponseSendFileTests.cs index e13c700717..f8d94e1087 100644 --- a/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/Listener/ResponseSendFileTests.cs +++ b/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/Listener/ResponseSendFileTests.cs @@ -362,7 +362,19 @@ namespace Microsoft.AspNetCore.Server.HttpSys.Listener var writeTask = context.Response.SendFileAsync(AbsoluteFilePath, 0, null, cts.Token); Assert.True(writeTask.IsCanceled); context.Dispose(); - +#if NET461 + // .NET HttpClient automatically retries a request if it does not get a response. + context = await server.AcceptAsync(Utilities.DefaultTimeout); + cts = new CancellationTokenSource(); + cts.Cancel(); + // First write sends headers + writeTask = context.Response.SendFileAsync(AbsoluteFilePath, 0, null, cts.Token); + Assert.True(writeTask.IsCanceled); + context.Dispose(); +#elif NETCOREAPP2_0 +#else +#error Target framework needs to be updated +#endif await Assert.ThrowsAsync(() => responseTask); } } @@ -382,7 +394,19 @@ namespace Microsoft.AspNetCore.Server.HttpSys.Listener var writeTask = context.Response.SendFileAsync(AbsoluteFilePath, 0, null, cts.Token); Assert.True(writeTask.IsCanceled); context.Dispose(); - +#if NET461 + // .NET HttpClient automatically retries a request if it does not get a response. + context = await server.AcceptAsync(Utilities.DefaultTimeout); + cts = new CancellationTokenSource(); + cts.Cancel(); + // First write sends headers + writeTask = context.Response.SendFileAsync(AbsoluteFilePath, 0, null, cts.Token); + Assert.True(writeTask.IsCanceled); + context.Dispose(); +#elif NETCOREAPP2_0 +#else +#error Target framework needs to be updated +#endif await Assert.ThrowsAsync(() => responseTask); } } diff --git a/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/Listener/ServerTests.cs b/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/Listener/ServerTests.cs index 5675d76a21..cbd7000614 100644 --- a/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/Listener/ServerTests.cs +++ b/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/Listener/ServerTests.cs @@ -186,7 +186,14 @@ namespace Microsoft.AspNetCore.Server.HttpSys.Listener context.Abort(); Assert.True(canceled.WaitOne(interval), "Aborted"); Assert.True(ct.IsCancellationRequested, "IsCancellationRequested"); - +#if NET461 + // HttpClient re-tries the request because it doesn't know if the request was received. + context = await server.AcceptAsync(Utilities.DefaultTimeout); + context.Abort(); +#elif NETCOREAPP2_0 +#else +#error Target framework needs to be updated +#endif await Assert.ThrowsAsync(() => responseTask); } } diff --git a/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests.csproj b/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests.csproj index 47ebda88eb..8db416c863 100644 --- a/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests.csproj +++ b/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests.csproj @@ -3,7 +3,8 @@ - netcoreapp2.0 + netcoreapp2.0;net461 + netcoreapp2.0 diff --git a/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/ResponseHeaderTests.cs b/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/ResponseHeaderTests.cs index 2153dde2ce..96b112ae59 100644 --- a/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/ResponseHeaderTests.cs +++ b/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/ResponseHeaderTests.cs @@ -81,7 +81,13 @@ namespace Microsoft.AspNetCore.Server.HttpSys Assert.Equal(0, response.ContentLength); Assert.NotNull(response.Headers["Date"]); Assert.Equal("Microsoft-HTTPAPI/2.0", response.Headers["Server"]); +#if NETCOREAPP2_0 // WebHeaderCollection.GetValues() not available in CoreCLR. Assert.Equal("custom1, and custom2, custom3", response.Headers["WWW-Authenticate"]); +#elif NET461 + Assert.Equal(new string[] { "custom1, and custom2", "custom3" }, response.Headers.GetValues("WWW-Authenticate")); +#else +#error Target framework needs to be updated +#endif } } @@ -105,7 +111,13 @@ namespace Microsoft.AspNetCore.Server.HttpSys Assert.Equal(0, response.ContentLength); Assert.NotNull(response.Headers["Date"]); Assert.Equal("Microsoft-HTTPAPI/2.0", response.Headers["Server"]); +#if NETCOREAPP2_0 // WebHeaderCollection.GetValues() not available in CoreCLR. Assert.Equal("custom1, and custom2, custom3", response.Headers["Custom-Header1"]); +#elif NET461 + Assert.Equal(new string[] { "custom1, and custom2", "custom3" }, response.Headers.GetValues("Custom-Header1")); +#else +#error Target framework needs to be updated +#endif } } diff --git a/test/Microsoft.AspNetCore.Server.HttpSys.Tests/Microsoft.AspNetCore.Server.HttpSys.Tests.csproj b/test/Microsoft.AspNetCore.Server.HttpSys.Tests/Microsoft.AspNetCore.Server.HttpSys.Tests.csproj index 36763d0a06..f8e1c7ff0f 100644 --- a/test/Microsoft.AspNetCore.Server.HttpSys.Tests/Microsoft.AspNetCore.Server.HttpSys.Tests.csproj +++ b/test/Microsoft.AspNetCore.Server.HttpSys.Tests/Microsoft.AspNetCore.Server.HttpSys.Tests.csproj @@ -3,7 +3,8 @@ - netcoreapp2.0 + netcoreapp2.0;net461 + netcoreapp2.0