Retarget to netstandard2.0

This commit is contained in:
Chris R 2017-05-22 14:06:13 -07:00
parent bff13c7f43
commit df36d02311
14 changed files with 130 additions and 27 deletions

View File

@ -16,8 +16,8 @@
<PackageReference Include="Internal.AspNetCore.Sdk" Version="$(InternalAspNetCoreSdkVersion)" PrivateAssets="All" /> <PackageReference Include="Internal.AspNetCore.Sdk" Version="$(InternalAspNetCoreSdkVersion)" PrivateAssets="All" />
</ItemGroup> </ItemGroup>
<ItemGroup Condition="'$(TargetFrameworkIdentifier)'=='.NETFramework' AND '$(OutputType)'=='library'"> <ItemGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework'">
<PackageReference Include="NETStandard.Library" Version="$(BundledNETStandardPackageVersion)" /> <PackageReference Include="NETStandard.Library.NETFramework" Version="$(NETStandardLibraryNETFrameworkVersion)" PrivateAssets="All" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -1,9 +1,9 @@
<Project> <Project>
<PropertyGroup> <PropertyGroup>
<AspNetCoreVersion>2.0.0-*</AspNetCoreVersion> <AspNetCoreVersion>2.0.0-*</AspNetCoreVersion>
<CoreFxVersion>4.3.0</CoreFxVersion> <CoreFxVersion>4.4.0-*</CoreFxVersion>
<InternalAspNetCoreSdkVersion>2.1.0-*</InternalAspNetCoreSdkVersion> <InternalAspNetCoreSdkVersion>2.1.0-*</InternalAspNetCoreSdkVersion>
<NETStandardImplicitPackageVersion>$(BundledNETStandardPackageVersion)</NETStandardImplicitPackageVersion> <NETStandardLibraryNETFrameworkVersion>2.0.0-*</NETStandardLibraryNETFrameworkVersion>
<TestSdkVersion>15.3.0-*</TestSdkVersion> <TestSdkVersion>15.3.0-*</TestSdkVersion>
<XunitVersion>2.3.0-beta2-*</XunitVersion> <XunitVersion>2.3.0-beta2-*</XunitVersion>
</PropertyGroup> </PropertyGroup>

View File

@ -3,7 +3,7 @@
<Import Project="..\..\build\dependencies.props" /> <Import Project="..\..\build\dependencies.props" />
<PropertyGroup> <PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework> <TargetFrameworks>netcoreapp2.0;net461</TargetFrameworks>
<OutputType>Exe</OutputType> <OutputType>Exe</OutputType>
<ServerGarbageCollection>true</ServerGarbageCollection> <ServerGarbageCollection>true</ServerGarbageCollection>
</PropertyGroup> </PropertyGroup>
@ -13,4 +13,7 @@
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="$(AspNetCoreVersion)" /> <PackageReference Include="Microsoft.Extensions.Logging.Console" Version="$(AspNetCoreVersion)" />
</ItemGroup> </ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net461' ">
<PackageReference Include="NETStandard.Library.NETFramework" Version="$(NETStandardLibraryNETFrameworkVersion)" />
</ItemGroup>
</Project> </Project>

View File

@ -3,7 +3,7 @@
<Import Project="..\..\build\dependencies.props" /> <Import Project="..\..\build\dependencies.props" />
<PropertyGroup> <PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework> <TargetFrameworks>netcoreapp2.0;net461</TargetFrameworks>
<OutputType>Exe</OutputType> <OutputType>Exe</OutputType>
<ServerGarbageCollection>true</ServerGarbageCollection> <ServerGarbageCollection>true</ServerGarbageCollection>
</PropertyGroup> </PropertyGroup>
@ -13,4 +13,7 @@
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="$(AspNetCoreVersion)" /> <PackageReference Include="Microsoft.Extensions.Logging.Console" Version="$(AspNetCoreVersion)" />
</ItemGroup> </ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net461' ">
<PackageReference Include="NETStandard.Library.NETFramework" Version="$(NETStandardLibraryNETFrameworkVersion)" />
</ItemGroup>
</Project> </Project>

View File

@ -4,7 +4,7 @@
<PropertyGroup> <PropertyGroup>
<Description>ASP.NET Core HTTP server that uses the Windows HTTP Server API.</Description> <Description>ASP.NET Core HTTP server that uses the Windows HTTP Server API.</Description>
<TargetFramework>netcoreapp2.0</TargetFramework> <TargetFramework>netstandard2.0</TargetFramework>
<NoWarn>$(NoWarn);CS1591</NoWarn> <NoWarn>$(NoWarn);CS1591</NoWarn>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<GenerateDocumentationFile>true</GenerateDocumentationFile> <GenerateDocumentationFile>true</GenerateDocumentationFile>

View File

@ -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.Negotiate)]
[InlineData(AuthenticationSchemes.NTLM)] [InlineData(AuthenticationSchemes.NTLM)]
// [InlineData(AuthenticationSchemes.Digest)] // TODO: Not implemented // [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.Negotiate)]
[InlineData(AuthenticationSchemes.NTLM)] [InlineData(AuthenticationSchemes.NTLM)]
// [InlineData(AuthenticationSchemes.Digest)] // TODO: Not implemented // [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() public async Task MultipleAuthTypes_AllowAnonymousButSpecify401_ChallengesAdded()
{ {
string address; 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.Negotiate)]
[InlineData(AuthenticationSchemes.NTLM)] [InlineData(AuthenticationSchemes.NTLM)]
// [InlineData(AuthenticationSchemes.Digest)] // [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.Negotiate)]
[InlineData(AuthenticationSchemes.NTLM)] [InlineData(AuthenticationSchemes.NTLM)]
// [InlineData(AuthenticationSchemes.Digest)] // [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() public async Task AuthTypes_OneChallengeSent()
{ {
var authTypes = AuthenticationSchemes.Negotiate | AuthenticationSchemes.NTLM | /*AuthenticationSchemes.Digest |*/ AuthenticationSchemes.Basic; 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.Negotiate)]
[InlineData(AuthenticationSchemes.NTLM)] [InlineData(AuthenticationSchemes.NTLM)]
// [InlineData(AuthenticationSchemes.Digest)] // [InlineData(AuthenticationSchemes.Digest)]

View File

@ -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.Negotiate)]
[InlineData(AuthenticationSchemes.NTLM)] [InlineData(AuthenticationSchemes.NTLM)]
// [InlineData(AuthenticationType.Digest)] // TODO: Not implemented // [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.Negotiate)]
[InlineData(AuthenticationSchemes.NTLM)] [InlineData(AuthenticationSchemes.NTLM)]
// [InlineData(AuthenticationSchemes.Digest)] // TODO: Not implemented // [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() public async Task MultipleAuthTypes_AllowAnonymousButSpecify401_ChallengesAdded()
{ {
string address; string address;

View File

@ -125,7 +125,15 @@ namespace Microsoft.AspNetCore.Server.HttpSys.Listener
var context = await server.AcceptAsync(Utilities.DefaultTimeout); var context = await server.AcceptAsync(Utilities.DefaultTimeout);
context.Response.Headers["Content-lenGth"] = " 20 "; context.Response.Headers["Content-lenGth"] = " 20 ";
context.Dispose(); 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<HttpRequestException>(() => responseTask); await Assert.ThrowsAsync<HttpRequestException>(() => responseTask);
} }
} }
@ -273,7 +281,19 @@ namespace Microsoft.AspNetCore.Server.HttpSys.Listener
var writeTask = context.Response.Body.WriteAsync(new byte[10], 0, 10, cts.Token); var writeTask = context.Response.Body.WriteAsync(new byte[10], 0, 10, cts.Token);
Assert.True(writeTask.IsCanceled); Assert.True(writeTask.IsCanceled);
context.Dispose(); 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<HttpRequestException>(() => responseTask); await Assert.ThrowsAsync<HttpRequestException>(() => responseTask);
} }
} }
@ -293,7 +313,19 @@ namespace Microsoft.AspNetCore.Server.HttpSys.Listener
var writeTask = context.Response.Body.WriteAsync(new byte[10], 0, 10, cts.Token); var writeTask = context.Response.Body.WriteAsync(new byte[10], 0, 10, cts.Token);
Assert.True(writeTask.IsCanceled); Assert.True(writeTask.IsCanceled);
context.Dispose(); 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<HttpRequestException>(() => responseTask); await Assert.ThrowsAsync<HttpRequestException>(() => responseTask);
} }
} }

View File

@ -221,8 +221,13 @@ namespace Microsoft.AspNetCore.Server.HttpSys.Listener
Assert.Equal(0, response.ContentLength); Assert.Equal(0, response.ContentLength);
Assert.NotNull(response.Headers["Date"]); Assert.NotNull(response.Headers["Date"]);
Assert.Equal("Microsoft-HTTPAPI/2.0", response.Headers["Server"]); 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"]); 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.Equal(0, response.ContentLength);
Assert.NotNull(response.Headers["Date"]); Assert.NotNull(response.Headers["Date"]);
Assert.Equal("Microsoft-HTTPAPI/2.0", response.Headers["Server"]); 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"]); 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
} }
} }

View File

@ -362,7 +362,19 @@ namespace Microsoft.AspNetCore.Server.HttpSys.Listener
var writeTask = context.Response.SendFileAsync(AbsoluteFilePath, 0, null, cts.Token); var writeTask = context.Response.SendFileAsync(AbsoluteFilePath, 0, null, cts.Token);
Assert.True(writeTask.IsCanceled); Assert.True(writeTask.IsCanceled);
context.Dispose(); 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<HttpRequestException>(() => responseTask); await Assert.ThrowsAsync<HttpRequestException>(() => responseTask);
} }
} }
@ -382,7 +394,19 @@ namespace Microsoft.AspNetCore.Server.HttpSys.Listener
var writeTask = context.Response.SendFileAsync(AbsoluteFilePath, 0, null, cts.Token); var writeTask = context.Response.SendFileAsync(AbsoluteFilePath, 0, null, cts.Token);
Assert.True(writeTask.IsCanceled); Assert.True(writeTask.IsCanceled);
context.Dispose(); 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<HttpRequestException>(() => responseTask); await Assert.ThrowsAsync<HttpRequestException>(() => responseTask);
} }
} }

View File

@ -186,7 +186,14 @@ namespace Microsoft.AspNetCore.Server.HttpSys.Listener
context.Abort(); context.Abort();
Assert.True(canceled.WaitOne(interval), "Aborted"); Assert.True(canceled.WaitOne(interval), "Aborted");
Assert.True(ct.IsCancellationRequested, "IsCancellationRequested"); 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<HttpRequestException>(() => responseTask); await Assert.ThrowsAsync<HttpRequestException>(() => responseTask);
} }
} }

View File

@ -3,7 +3,8 @@
<Import Project="..\..\build\common.props" /> <Import Project="..\..\build\common.props" />
<PropertyGroup> <PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework> <TargetFrameworks>netcoreapp2.0;net461</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' != 'Windows_NT' ">netcoreapp2.0</TargetFrameworks>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

View File

@ -81,7 +81,13 @@ namespace Microsoft.AspNetCore.Server.HttpSys
Assert.Equal(0, response.ContentLength); Assert.Equal(0, response.ContentLength);
Assert.NotNull(response.Headers["Date"]); Assert.NotNull(response.Headers["Date"]);
Assert.Equal("Microsoft-HTTPAPI/2.0", response.Headers["Server"]); 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"]); 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.Equal(0, response.ContentLength);
Assert.NotNull(response.Headers["Date"]); Assert.NotNull(response.Headers["Date"]);
Assert.Equal("Microsoft-HTTPAPI/2.0", response.Headers["Server"]); 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"]); 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
} }
} }

View File

@ -3,7 +3,8 @@
<Import Project="..\..\build\common.props" /> <Import Project="..\..\build\common.props" />
<PropertyGroup> <PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework> <TargetFrameworks>netcoreapp2.0;net461</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' != 'Windows_NT' ">netcoreapp2.0</TargetFrameworks>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>