From 31001de66a20d9e056247b558f421afedcf1d0b9 Mon Sep 17 00:00:00 2001 From: "Chris Ross (ASP.NET)" Date: Fri, 5 May 2017 12:42:01 -0700 Subject: [PATCH] Migrate to netcoreapp2.0 --- samples/HotAddSample/HotAddSample.csproj | 2 +- samples/HotAddSample/Startup.cs | 5 +-- samples/SelfHostServer/SelfHostServer.csproj | 2 +- samples/SelfHostServer/Startup.cs | 5 +-- .../HttpSysException.cs | 5 +-- ...Microsoft.AspNetCore.Server.HttpSys.csproj | 8 +--- .../NativeInterop/AddressFamily.cs | 9 ---- .../NativeInterop/ComNetOS.cs | 5 +-- .../NativeInterop/HttpSysSettings.cs | 9 ---- .../NativeInterop/NclUtilities.cs | 5 +-- .../NativeInterop/UnsafeNativeMethods.cs | 39 +--------------- .../RequestProcessing/OpaqueStream.cs | 8 ++-- .../RequestProcessing/RequestStream.cs | 16 ------- .../RequestProcessing/ResponseBody.cs | 11 +---- .../ResponseStream.cs | 12 +---- .../CriticalHandleZeroOrMinusOneIsInvalid.cs | 29 ------------ .../SafeHandleZeroOrMinusOneIsInvalid.cs | 28 ------------ .../AuthenticationTests.cs | 18 +++----- .../HttpsTests.cs | 12 ----- .../Listener/AuthenticationTests.cs | 15 +++---- .../Listener/HttpsTests.cs | 12 ----- .../Listener/RequestBodyTests.cs | 6 +-- .../Listener/ResponseBodyTests.cs | 44 ++----------------- .../Listener/ResponseHeaderTests.cs | 14 +----- .../Listener/ResponseSendFileTests.cs | 28 +----------- .../Listener/ServerTests.cs | 9 +--- .../Listener/SkipOffDomainAttribute.cs | 43 ------------------ .../Listener/Utilities.cs | 6 --- ...Core.Server.HttpSys.FunctionalTests.csproj | 3 +- .../RequestBodyTests.cs | 6 +-- .../ResponseBodyTests.cs | 13 +----- .../ResponseHeaderTests.cs | 12 ----- ...oft.AspNetCore.Server.HttpSys.Tests.csproj | 3 +- 33 files changed, 44 insertions(+), 398 deletions(-) delete mode 100644 src/Microsoft.AspNetCore.Server.HttpSys/fx/Microsoft/Win32/SafeHandles/CriticalHandleZeroOrMinusOneIsInvalid.cs delete mode 100644 src/Microsoft.AspNetCore.Server.HttpSys/fx/Microsoft/Win32/SafeHandles/SafeHandleZeroOrMinusOneIsInvalid.cs delete mode 100644 test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/Listener/SkipOffDomainAttribute.cs diff --git a/samples/HotAddSample/HotAddSample.csproj b/samples/HotAddSample/HotAddSample.csproj index e9223fff1b..4a41f19c4c 100644 --- a/samples/HotAddSample/HotAddSample.csproj +++ b/samples/HotAddSample/HotAddSample.csproj @@ -3,7 +3,7 @@ - net46;netcoreapp2.0 + netcoreapp2.0 Exe true diff --git a/samples/HotAddSample/Startup.cs b/samples/HotAddSample/Startup.cs index f0ede45da9..58975d6aa6 100644 --- a/samples/HotAddSample/Startup.cs +++ b/samples/HotAddSample/Startup.cs @@ -23,10 +23,8 @@ namespace HotAddSample public HttpSysOptions ServerOptions { get; set; } - public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) + public void Configure(IApplicationBuilder app) { - loggerfactory.AddConsole(LogLevel.Information); - var addresses = ServerOptions.UrlPrefixes; addresses.Add("http://localhost:12346/pathBase/"); @@ -101,6 +99,7 @@ namespace HotAddSample public static void Main(string[] args) { var host = new WebHostBuilder() + .ConfigureLogging(factory => factory.AddConsole()) .UseStartup() .UseHttpSys() .Build(); diff --git a/samples/SelfHostServer/SelfHostServer.csproj b/samples/SelfHostServer/SelfHostServer.csproj index e9223fff1b..4a41f19c4c 100644 --- a/samples/SelfHostServer/SelfHostServer.csproj +++ b/samples/SelfHostServer/SelfHostServer.csproj @@ -3,7 +3,7 @@ - net46;netcoreapp2.0 + netcoreapp2.0 Exe true diff --git a/samples/SelfHostServer/Startup.cs b/samples/SelfHostServer/Startup.cs index f6c0381b23..52b65bd248 100644 --- a/samples/SelfHostServer/Startup.cs +++ b/samples/SelfHostServer/Startup.cs @@ -20,10 +20,8 @@ namespace SelfHostServer }); } - public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory) + public void Configure(IApplicationBuilder app) { - loggerfactory.AddConsole(LogLevel.Debug); - app.Run(async context => { context.Response.ContentType = "text/plain"; @@ -34,6 +32,7 @@ namespace SelfHostServer public static void Main(string[] args) { var host = new WebHostBuilder() + .ConfigureLogging(factory => factory.AddConsole()) .UseStartup() .UseHttpSys(options => { diff --git a/src/Microsoft.AspNetCore.Server.HttpSys/HttpSysException.cs b/src/Microsoft.AspNetCore.Server.HttpSys/HttpSysException.cs index 7d9b6aa71e..9e65fa3916 100644 --- a/src/Microsoft.AspNetCore.Server.HttpSys/HttpSysException.cs +++ b/src/Microsoft.AspNetCore.Server.HttpSys/HttpSysException.cs @@ -25,13 +25,10 @@ namespace Microsoft.AspNetCore.Server.HttpSys : base(errorCode, message) { } -#if NETSTANDARD1_3 - public int ErrorCode -#else + // the base class returns the HResult with this property // we need the Win32 Error Code, hence the override. public override int ErrorCode -#endif { get { 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 1f01f022d7..c001a825df 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. - net46;netstandard1.3 + netcoreapp2.0 $(NoWarn);CS1591 true true @@ -13,13 +13,9 @@ - - - - - + diff --git a/src/Microsoft.AspNetCore.Server.HttpSys/NativeInterop/AddressFamily.cs b/src/Microsoft.AspNetCore.Server.HttpSys/NativeInterop/AddressFamily.cs index 239d36533e..9f4a7063be 100644 --- a/src/Microsoft.AspNetCore.Server.HttpSys/NativeInterop/AddressFamily.cs +++ b/src/Microsoft.AspNetCore.Server.HttpSys/NativeInterop/AddressFamily.cs @@ -3,20 +3,11 @@ namespace Microsoft.AspNetCore.Server.HttpSys { -#if NET46 - /// - /// - /// Specifies the address families that an instance of the - /// class can use. - /// - /// -#else /// /// /// Specifies the address families. /// /// -#endif internal enum AddressFamily { /// diff --git a/src/Microsoft.AspNetCore.Server.HttpSys/NativeInterop/ComNetOS.cs b/src/Microsoft.AspNetCore.Server.HttpSys/NativeInterop/ComNetOS.cs index 8168e2c73d..12d1381bae 100644 --- a/src/Microsoft.AspNetCore.Server.HttpSys/NativeInterop/ComNetOS.cs +++ b/src/Microsoft.AspNetCore.Server.HttpSys/NativeInterop/ComNetOS.cs @@ -8,6 +8,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys { internal static class ComNetOS { + // Windows is assumed based on HttpApi.Supported which is checked in the HttpSysListener constructor. // Minimum support for Windows 7 is assumed. internal static readonly bool IsWin8orLater; @@ -15,11 +16,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys { var win8Version = new Version(6, 2); -#if NETSTANDARD1_3 - IsWin8orLater = (new Version(RuntimeEnvironment.OperatingSystemVersion) >= win8Version); -#else IsWin8orLater = (Environment.OSVersion.Version >= win8Version); -#endif } } } diff --git a/src/Microsoft.AspNetCore.Server.HttpSys/NativeInterop/HttpSysSettings.cs b/src/Microsoft.AspNetCore.Server.HttpSys/NativeInterop/HttpSysSettings.cs index 704803bf88..d9efa35c8f 100644 --- a/src/Microsoft.AspNetCore.Server.HttpSys/NativeInterop/HttpSysSettings.cs +++ b/src/Microsoft.AspNetCore.Server.HttpSys/NativeInterop/HttpSysSettings.cs @@ -6,17 +6,13 @@ using System.Diagnostics; using System.Globalization; using System.IO; using System.Security; -#if !NETSTANDARD1_3 using Microsoft.Win32; -#endif namespace Microsoft.AspNetCore.Server.HttpSys { internal static class HttpSysSettings { -#if !NETSTANDARD1_3 private const string HttpSysParametersKey = @"System\CurrentControlSet\Services\HTTP\Parameters"; -#endif private const bool EnableNonUtf8Default = true; private const bool FavorUtf8Default = true; private const string EnableNonUtf8Name = "EnableNonUtf8"; @@ -41,10 +37,6 @@ namespace Microsoft.AspNetCore.Server.HttpSys } private static void ReadHttpSysRegistrySettings() -#if NETSTANDARD1_3 - { - } -#else { try { @@ -117,6 +109,5 @@ namespace Microsoft.AspNetCore.Server.HttpSys // TODO: log // Logging.PrintWarning(Logging.HttpListener, typeof(HttpSysSettings), methodName, SR.GetString(message, args)); } -#endif } } diff --git a/src/Microsoft.AspNetCore.Server.HttpSys/NativeInterop/NclUtilities.cs b/src/Microsoft.AspNetCore.Server.HttpSys/NativeInterop/NclUtilities.cs index 3230b11dda..abd74045e5 100644 --- a/src/Microsoft.AspNetCore.Server.HttpSys/NativeInterop/NclUtilities.cs +++ b/src/Microsoft.AspNetCore.Server.HttpSys/NativeInterop/NclUtilities.cs @@ -12,10 +12,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys get { return Environment.HasShutdownStarted -#if !NETSTANDARD1_3 - || AppDomain.CurrentDomain.IsFinalizingForUnload() -#endif - ; + || AppDomain.CurrentDomain.IsFinalizingForUnload(); } } } diff --git a/src/Microsoft.AspNetCore.Server.HttpSys/NativeInterop/UnsafeNativeMethods.cs b/src/Microsoft.AspNetCore.Server.HttpSys/NativeInterop/UnsafeNativeMethods.cs index 800bab4de2..81662ac8c1 100644 --- a/src/Microsoft.AspNetCore.Server.HttpSys/NativeInterop/UnsafeNativeMethods.cs +++ b/src/Microsoft.AspNetCore.Server.HttpSys/NativeInterop/UnsafeNativeMethods.cs @@ -9,7 +9,6 @@ namespace Microsoft.AspNetCore.Server.HttpSys { internal static unsafe class UnsafeNclNativeMethods { -#if NETSTANDARD1_3 private const string sspicli_LIB = "sspicli.dll"; private const string api_ms_win_core_processthreads_LIB = "api-ms-win-core-processthreads-l1-1-1.dll"; private const string api_ms_win_core_io_LIB = "api-ms-win-core-io-l1-1-0.dll"; @@ -18,10 +17,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys private const string api_ms_win_core_heap_LIB = "api-ms-win-core-heap-L1-2-0.dll"; private const string api_ms_win_core_heap_obsolete_LIB = "api-ms-win-core-heap-obsolete-L1-1-0.dll"; private const string api_ms_win_core_kernel32_legacy_LIB = "api-ms-win-core-kernel32-legacy-l1-1-0.dll"; -#else - private const string KERNEL32 = "kernel32.dll"; - private const string SECUR32 = "secur32.dll"; -#endif + private const string TOKENBINDING = "tokenbinding.dll"; // CONSIDER: Make this an enum, requires changing a lot of types from uint to ErrorCodes. @@ -39,18 +35,10 @@ namespace Microsoft.AspNetCore.Server.HttpSys internal const uint ERROR_CONNECTION_INVALID = 1229; } -#if NETSTANDARD1_3 [DllImport(api_ms_win_core_io_LIB, ExactSpelling = true, CallingConvention = CallingConvention.StdCall, SetLastError = true)] -#else - [DllImport(KERNEL32, ExactSpelling = true, CallingConvention = CallingConvention.StdCall, SetLastError = true)] -#endif internal static unsafe extern uint CancelIoEx(SafeHandle handle, SafeNativeOverlapped overlapped); -#if NETSTANDARD1_3 [DllImport(api_ms_win_core_kernel32_legacy_LIB, ExactSpelling = true, CallingConvention = CallingConvention.StdCall, SetLastError = true)] -#else - [DllImport(KERNEL32, ExactSpelling = true, CallingConvention = CallingConvention.StdCall, SetLastError = true)] -#endif internal static unsafe extern bool SetFileCompletionNotificationModes(SafeHandle handle, FileCompletionNotificationModes modes); [Flags] @@ -71,19 +59,11 @@ namespace Microsoft.AspNetCore.Server.HttpSys [Out] out HeapAllocHandle resultList); // http://msdn.microsoft.com/en-us/library/windows/desktop/aa366569(v=vs.85).aspx -#if NETSTANDARD1_3 [DllImport(api_ms_win_core_heap_LIB, CallingConvention = CallingConvention.Winapi, SetLastError = true)] -#else - [DllImport(KERNEL32, CallingConvention = CallingConvention.Winapi, SetLastError = true)] -#endif internal static extern IntPtr GetProcessHeap(); // http://msdn.microsoft.com/en-us/library/windows/desktop/aa366701(v=vs.85).aspx -#if NETSTANDARD1_3 [DllImport(api_ms_win_core_heap_LIB, CallingConvention = CallingConvention.Winapi, SetLastError = true)] -#else - [DllImport(KERNEL32, CallingConvention = CallingConvention.Winapi, SetLastError = true)] -#endif internal static extern bool HeapFree( [In] IntPtr hHeap, [In] uint dwFlags, @@ -91,34 +71,17 @@ namespace Microsoft.AspNetCore.Server.HttpSys internal static class SafeNetHandles { -#if NETSTANDARD1_3 [DllImport(sspicli_LIB, ExactSpelling = true, SetLastError = true)] -#else - [DllImport(SECUR32, ExactSpelling = true, SetLastError = true)] -#endif internal static extern int FreeContextBuffer( [In] IntPtr contextBuffer); -#if NETSTANDARD1_3 [DllImport(api_ms_win_core_handle_LIB, ExactSpelling = true, SetLastError = true)] -#else - [DllImport(KERNEL32, ExactSpelling = true, SetLastError = true)] -#endif internal static extern bool CloseHandle(IntPtr handle); -#if NETSTANDARD1_3 [DllImport(api_ms_win_core_heap_obsolete_LIB, EntryPoint = "LocalAlloc", SetLastError = true)] -#else - [DllImport(KERNEL32, EntryPoint = "LocalAlloc", SetLastError = true)] -#endif - internal static extern SafeLocalFreeChannelBinding LocalAllocChannelBinding(int uFlags, UIntPtr sizetdwBytes); -#if NETSTANDARD1_3 [DllImport(api_ms_win_core_heap_obsolete_LIB, ExactSpelling = true, SetLastError = true)] -#else - [DllImport(KERNEL32, ExactSpelling = true, SetLastError = true)] -#endif internal static extern IntPtr LocalFree(IntPtr handle); } diff --git a/src/Microsoft.AspNetCore.Server.HttpSys/RequestProcessing/OpaqueStream.cs b/src/Microsoft.AspNetCore.Server.HttpSys/RequestProcessing/OpaqueStream.cs index 40967efa7c..0bd9bba848 100644 --- a/src/Microsoft.AspNetCore.Server.HttpSys/RequestProcessing/OpaqueStream.cs +++ b/src/Microsoft.AspNetCore.Server.HttpSys/RequestProcessing/OpaqueStream.cs @@ -89,7 +89,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys { return _requestStream.ReadByte(); } -#if !NETSTANDARD1_3 + public override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback callback, object state) { return _requestStream.BeginRead(buffer, offset, count, callback, state); @@ -99,7 +99,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys { return _requestStream.EndRead(asyncResult); } -#endif + public override Task ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken) { return _requestStream.ReadAsync(buffer, offset, count, cancellationToken); @@ -123,7 +123,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys { _responseStream.WriteByte(value); } -#if !NETSTANDARD1_3 + public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, object state) { return _responseStream.BeginWrite(buffer, offset, count, callback, state); @@ -133,7 +133,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys { _responseStream.EndWrite(asyncResult); } -#endif + public override Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken) { return _responseStream.WriteAsync(buffer, offset, count, cancellationToken); diff --git a/src/Microsoft.AspNetCore.Server.HttpSys/RequestProcessing/RequestStream.cs b/src/Microsoft.AspNetCore.Server.HttpSys/RequestProcessing/RequestStream.cs index 94e7fa7553..0129c290e8 100644 --- a/src/Microsoft.AspNetCore.Server.HttpSys/RequestProcessing/RequestStream.cs +++ b/src/Microsoft.AspNetCore.Server.HttpSys/RequestProcessing/RequestStream.cs @@ -190,11 +190,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys } } -#if NETSTANDARD1_3 - public unsafe IAsyncResult BeginRead(byte[] buffer, int offset, int size, AsyncCallback callback, object state) -#else public override unsafe IAsyncResult BeginRead(byte[] buffer, int offset, int size, AsyncCallback callback, object state) -#endif { ValidateReadBuffer(buffer, offset, size); if (_closed) @@ -281,11 +277,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys return asyncResult; } -#if NETSTANDARD1_3 - public int EndRead(IAsyncResult asyncResult) -#else public override int EndRead(IAsyncResult asyncResult) -#endif { if (asyncResult == null) { @@ -416,20 +408,12 @@ namespace Microsoft.AspNetCore.Server.HttpSys throw new InvalidOperationException(Resources.Exception_ReadOnlyStream); } -#if NETSTANDARD1_3 - public IAsyncResult BeginWrite(byte[] buffer, int offset, int size, AsyncCallback callback, object state) -#else public override IAsyncResult BeginWrite(byte[] buffer, int offset, int size, AsyncCallback callback, object state) -#endif { throw new InvalidOperationException(Resources.Exception_ReadOnlyStream); } -#if NETSTANDARD1_3 - public void EndWrite(IAsyncResult asyncResult) -#else public override void EndWrite(IAsyncResult asyncResult) -#endif { throw new InvalidOperationException(Resources.Exception_ReadOnlyStream); } diff --git a/src/Microsoft.AspNetCore.Server.HttpSys/RequestProcessing/ResponseBody.cs b/src/Microsoft.AspNetCore.Server.HttpSys/RequestProcessing/ResponseBody.cs index e34f3184e5..506bba99a7 100644 --- a/src/Microsoft.AspNetCore.Server.HttpSys/RequestProcessing/ResponseBody.cs +++ b/src/Microsoft.AspNetCore.Server.HttpSys/RequestProcessing/ResponseBody.cs @@ -374,7 +374,6 @@ namespace Microsoft.AspNetCore.Server.HttpSys throw new InvalidOperationException(Resources.Exception_WriteOnlyStream); } -#if !NETSTANDARD1_3 public override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback callback, object state) { throw new InvalidOperationException(Resources.Exception_WriteOnlyStream); @@ -384,7 +383,6 @@ namespace Microsoft.AspNetCore.Server.HttpSys { throw new InvalidOperationException(Resources.Exception_WriteOnlyStream); } -#endif #endregion @@ -477,19 +475,12 @@ namespace Microsoft.AspNetCore.Server.HttpSys } } -#if NETSTANDARD1_3 - public IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, object state) -#else public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, object state) -#endif { return WriteAsync(buffer, offset, count).ToIAsyncResult(callback, state); } -#if NETSTANDARD1_3 - public void EndWrite(IAsyncResult asyncResult) -#else + public override void EndWrite(IAsyncResult asyncResult) -#endif { if (asyncResult == null) { diff --git a/src/Microsoft.AspNetCore.Server.HttpSys/ResponseStream.cs b/src/Microsoft.AspNetCore.Server.HttpSys/ResponseStream.cs index f326853545..130303482d 100644 --- a/src/Microsoft.AspNetCore.Server.HttpSys/ResponseStream.cs +++ b/src/Microsoft.AspNetCore.Server.HttpSys/ResponseStream.cs @@ -39,7 +39,6 @@ namespace Microsoft.AspNetCore.Server.HttpSys public override int Read(byte[] buffer, int offset, int count) => _innerStream.Read(buffer, offset, count); -#if !NETSTANDARD1_3 public override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback callback, object state) { return _innerStream.BeginRead(buffer, offset, count, callback, state); @@ -49,7 +48,6 @@ namespace Microsoft.AspNetCore.Server.HttpSys { return _innerStream.EndRead(asyncResult); } -#endif public override void Flush() { _onStart().GetAwaiter().GetResult(); @@ -73,19 +71,13 @@ namespace Microsoft.AspNetCore.Server.HttpSys await _onStart(); await _innerStream.WriteAsync(buffer, offset, count, cancellationToken); } -#if NETSTANDARD1_3 - public IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, object state) -#else + public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, object state) -#endif { return ToIAsyncResult(WriteAsync(buffer, offset, count), callback, state); } -#if NETSTANDARD1_3 - public void EndWrite(IAsyncResult asyncResult) -#else + public override void EndWrite(IAsyncResult asyncResult) -#endif { if (asyncResult == null) { diff --git a/src/Microsoft.AspNetCore.Server.HttpSys/fx/Microsoft/Win32/SafeHandles/CriticalHandleZeroOrMinusOneIsInvalid.cs b/src/Microsoft.AspNetCore.Server.HttpSys/fx/Microsoft/Win32/SafeHandles/CriticalHandleZeroOrMinusOneIsInvalid.cs deleted file mode 100644 index a7af472718..0000000000 --- a/src/Microsoft.AspNetCore.Server.HttpSys/fx/Microsoft/Win32/SafeHandles/CriticalHandleZeroOrMinusOneIsInvalid.cs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -#if NETSTANDARD1_3 - -namespace Microsoft.Win32.SafeHandles -{ - using System; - using System.Runtime.InteropServices; - using System.Runtime.CompilerServices; - - // Class of critical handle which uses 0 or -1 as an invalid handle. - [System.Security.SecurityCritical] // auto-generated_required - internal abstract class CriticalHandleZeroOrMinusOneIsInvalid : CriticalHandle - { - protected CriticalHandleZeroOrMinusOneIsInvalid() - : base(IntPtr.Zero) - { - } - - public override bool IsInvalid - { - [System.Security.SecurityCritical] - get { return handle == new IntPtr(0) || handle == new IntPtr(-1); } - } - } -} - -#endif diff --git a/src/Microsoft.AspNetCore.Server.HttpSys/fx/Microsoft/Win32/SafeHandles/SafeHandleZeroOrMinusOneIsInvalid.cs b/src/Microsoft.AspNetCore.Server.HttpSys/fx/Microsoft/Win32/SafeHandles/SafeHandleZeroOrMinusOneIsInvalid.cs deleted file mode 100644 index 3bf6498c75..0000000000 --- a/src/Microsoft.AspNetCore.Server.HttpSys/fx/Microsoft/Win32/SafeHandles/SafeHandleZeroOrMinusOneIsInvalid.cs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -#if NETSTANDARD1_3 - -namespace Microsoft.Win32.SafeHandles -{ - using System; - using System.Runtime.InteropServices; - using System.Runtime.CompilerServices; - - // Class of safe handle which uses 0 or -1 as an invalid handle. - [System.Security.SecurityCritical] // auto-generated_required - internal abstract class SafeHandleZeroOrMinusOneIsInvalid : SafeHandle - { - protected SafeHandleZeroOrMinusOneIsInvalid(bool ownsHandle) - : base(IntPtr.Zero, ownsHandle) - { - } - - public override bool IsInvalid - { - [System.Security.SecurityCritical] - get { return handle == new IntPtr(0) || handle == new IntPtr(-1); } - } - } -} -#endif diff --git a/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/AuthenticationTests.cs b/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/AuthenticationTests.cs index c5cddc6e6d..6c543f41e5 100644 --- a/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/AuthenticationTests.cs +++ b/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/AuthenticationTests.cs @@ -41,12 +41,11 @@ namespace Microsoft.AspNetCore.Server.HttpSys } } - [ConditionalTheory] + [ConditionalTheory(Skip = "HttpClientHandler issue (https://github.com/aspnet/ServerTests/issues/82).")] [InlineData(AuthenticationSchemes.Negotiate)] [InlineData(AuthenticationSchemes.NTLM)] // [InlineData(AuthenticationSchemes.Digest)] // TODO: Not implemented [InlineData(AuthenticationSchemes.Basic)] - [FrameworkSkipCondition(RuntimeFrameworks.CoreCLR, SkipReason = "HttpClientHandler issue (https://github.com/dotnet/corefx/issues/5045).")] public async Task AuthType_RequireAuth_ChallengesAdded(AuthenticationSchemes authType) { string address; @@ -61,12 +60,11 @@ namespace Microsoft.AspNetCore.Server.HttpSys } } - [ConditionalTheory] + [ConditionalTheory(Skip = "HttpClientHandler issue (https://github.com/aspnet/ServerTests/issues/82).")] [InlineData(AuthenticationSchemes.Negotiate)] [InlineData(AuthenticationSchemes.NTLM)] // [InlineData(AuthenticationSchemes.Digest)] // TODO: Not implemented [InlineData(AuthenticationSchemes.Basic)] - [FrameworkSkipCondition(RuntimeFrameworks.CoreCLR, SkipReason = "HttpClientHandler issue (https://github.com/dotnet/corefx/issues/5045).")] public async Task AuthType_AllowAnonymousButSpecify401_ChallengesAdded(AuthenticationSchemes authType) { string address; @@ -85,8 +83,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys } } - [ConditionalFact] - [FrameworkSkipCondition(RuntimeFrameworks.CoreCLR, SkipReason = "HttpClientHandler issue (https://github.com/dotnet/corefx/issues/5045).")] + [ConditionalTheory(Skip = "HttpClientHandler issue (https://github.com/aspnet/ServerTests/issues/82).")] public async Task MultipleAuthTypes_AllowAnonymousButSpecify401_ChallengesAdded() { string address; @@ -285,13 +282,12 @@ namespace Microsoft.AspNetCore.Server.HttpSys } } - [ConditionalTheory] + [ConditionalTheory(Skip = "HttpClientHandler issue (https://github.com/aspnet/ServerTests/issues/82).")] [InlineData(AuthenticationSchemes.Negotiate)] [InlineData(AuthenticationSchemes.NTLM)] // [InlineData(AuthenticationSchemes.Digest)] [InlineData(AuthenticationSchemes.Basic)] [InlineData(AuthenticationSchemes.Negotiate | AuthenticationSchemes.NTLM | /*AuthenticationSchemes.Digest |*/ AuthenticationSchemes.Basic)] - [FrameworkSkipCondition(RuntimeFrameworks.CoreCLR, SkipReason = "HttpClientHandler issue (https://github.com/dotnet/corefx/issues/5045).")] public async Task AuthTypes_ChallengeWithoutAuthTypes_AllChallengesSent(AuthenticationSchemes authType) { string address; @@ -310,13 +306,12 @@ namespace Microsoft.AspNetCore.Server.HttpSys } } - [ConditionalTheory] + [ConditionalTheory(Skip = "HttpClientHandler issue (https://github.com/aspnet/ServerTests/issues/82).")] [InlineData(AuthenticationSchemes.Negotiate)] [InlineData(AuthenticationSchemes.NTLM)] // [InlineData(AuthenticationSchemes.Digest)] [InlineData(AuthenticationSchemes.Basic)] [InlineData(AuthenticationSchemes.Negotiate | AuthenticationSchemes.NTLM | /*AuthenticationSchemes.Digest |*/ AuthenticationSchemes.Basic)] - [FrameworkSkipCondition(RuntimeFrameworks.CoreCLR, SkipReason = "HttpClientHandler issue (https://github.com/dotnet/corefx/issues/5045).")] public async Task AuthTypes_ChallengeWithAllAuthTypes_AllChallengesSent(AuthenticationSchemes authType) { string address; @@ -338,12 +333,11 @@ namespace Microsoft.AspNetCore.Server.HttpSys } } - [ConditionalTheory] + [ConditionalTheory(Skip = "HttpClientHandler issue (https://github.com/aspnet/ServerTests/issues/82).")] [InlineData(AuthenticationSchemes.Negotiate)] [InlineData(AuthenticationSchemes.NTLM)] // [InlineData(AuthenticationSchemes.Digest)] [InlineData(AuthenticationSchemes.Basic)] - [FrameworkSkipCondition(RuntimeFrameworks.CoreCLR, SkipReason = "HttpClientHandler issue (https://github.com/dotnet/corefx/issues/5045).")] public async Task AuthTypes_ChallengeOneAuthType_OneChallengeSent(AuthenticationSchemes authType) { string address; diff --git a/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/HttpsTests.cs b/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/HttpsTests.cs index d42936325d..b3ae85687a 100644 --- a/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/HttpsTests.cs +++ b/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/HttpsTests.cs @@ -102,13 +102,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys private async Task SendRequestAsync(string uri, X509Certificate cert = null) { -#if NET46 - var handler = new WebRequestHandler(); -#elif NETCOREAPP2_0 var handler = new WinHttpHandler(); -#else -#error Target framework needs to be updated -#endif handler.ServerCertificateValidationCallback = (a, b, c, d) => true; if (cert != null) { @@ -122,13 +116,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys private async Task SendRequestAsync(string uri, string upload) { -#if NET46 - var handler = new WebRequestHandler(); -#elif NETCOREAPP2_0 var handler = new WinHttpHandler(); -#else -#error Target framework needs to be updated -#endif handler.ServerCertificateValidationCallback = (a, b, c, d) => true; using (HttpClient client = new HttpClient(handler)) { diff --git a/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/Listener/AuthenticationTests.cs b/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/Listener/AuthenticationTests.cs index 9281b71817..0ccc678909 100644 --- a/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/Listener/AuthenticationTests.cs +++ b/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/Listener/AuthenticationTests.cs @@ -41,12 +41,11 @@ namespace Microsoft.AspNetCore.Server.HttpSys.Listener } } - [ConditionalTheory] + [ConditionalTheory(Skip = "HttpClientHandler issue (https://github.com/aspnet/ServerTests/issues/82).")] [InlineData(AuthenticationSchemes.Negotiate)] [InlineData(AuthenticationSchemes.NTLM)] // [InlineData(AuthenticationType.Digest)] // TODO: Not implemented [InlineData(AuthenticationSchemes.Basic)] - [FrameworkSkipCondition(RuntimeFrameworks.CoreCLR, SkipReason = "HttpClientHandler issue (https://github.com/dotnet/corefx/issues/5045).")] public async Task AuthType_RequireAuth_ChallengesAdded(AuthenticationSchemes authType) { string address; @@ -61,12 +60,11 @@ namespace Microsoft.AspNetCore.Server.HttpSys.Listener } } - [ConditionalTheory] + [ConditionalTheory(Skip = "HttpClientHandler issue (https://github.com/aspnet/ServerTests/issues/82).")] [InlineData(AuthenticationSchemes.Negotiate)] [InlineData(AuthenticationSchemes.NTLM)] // [InlineData(AuthenticationSchemes.Digest)] // TODO: Not implemented [InlineData(AuthenticationSchemes.Basic)] - [FrameworkSkipCondition(RuntimeFrameworks.CoreCLR, SkipReason = "HttpClientHandler issue (https://github.com/dotnet/corefx/issues/5045).")] public async Task AuthType_AllowAnonymousButSpecify401_ChallengesAdded(AuthenticationSchemes authType) { string address; @@ -87,8 +85,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys.Listener } } - [ConditionalFact] - [FrameworkSkipCondition(RuntimeFrameworks.CoreCLR, SkipReason = "HttpClientHandler issue (https://github.com/dotnet/corefx/issues/5045).")] + [ConditionalTheory(Skip = "HttpClientHandler issue (https://github.com/aspnet/ServerTests/issues/82).")] public async Task MultipleAuthTypes_AllowAnonymousButSpecify401_ChallengesAdded() { string address; @@ -169,8 +166,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys.Listener } } - [ConditionalFact] - [SkipOffDomain] + [ConditionalFact(Skip = "Requires a domain joined machine - https://github.com/aspnet/HttpSysServer/issues/357")] public async Task AuthTypes_RequireKerberosAuth_Success() { string address; @@ -189,8 +185,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys.Listener } } - [ConditionalFact] - [SkipOffDomain] + [ConditionalFact(Skip = "Requires a domain joined machine - https://github.com/aspnet/HttpSysServer/issues/357")] public async Task MultipleAuthTypes_KerberosAllowAnonymousButSpecify401_ChallengesAdded() { string address; diff --git a/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/Listener/HttpsTests.cs b/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/Listener/HttpsTests.cs index 9075e8e831..4291f00e6e 100644 --- a/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/Listener/HttpsTests.cs +++ b/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/Listener/HttpsTests.cs @@ -109,13 +109,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys.Listener private async Task SendRequestAsync(string uri, X509Certificate cert = null) { -#if NET46 - WebRequestHandler handler = new WebRequestHandler(); -#elif NETCOREAPP2_0 WinHttpHandler handler = new WinHttpHandler(); -#else -#error Target framework needs to be updated -#endif handler.ServerCertificateValidationCallback = (a, b, c, d) => true; if (cert != null) { @@ -129,13 +123,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys.Listener private async Task SendRequestAsync(string uri, string upload) { -#if NET46 - WebRequestHandler handler = new WebRequestHandler(); -#elif NETCOREAPP2_0 WinHttpHandler handler = new WinHttpHandler(); -#else -#error Target framework needs to be updated -#endif handler.ServerCertificateValidationCallback = (a, b, c, d) => true; using (HttpClient client = new HttpClient(handler)) { diff --git a/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/Listener/RequestBodyTests.cs b/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/Listener/RequestBodyTests.cs index 78a37d1af7..d716e2a407 100644 --- a/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/Listener/RequestBodyTests.cs +++ b/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/Listener/RequestBodyTests.cs @@ -53,7 +53,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys.Listener Assert.Equal("Hello World", response); } } -#if NET46 + [ConditionalFact] public async Task RequestBody_ReadBeginEnd_Success() { @@ -72,10 +72,6 @@ namespace Microsoft.AspNetCore.Server.HttpSys.Listener Assert.Equal("Hello World", response); } } -#elif NETCOREAPP2_0 -#else -#error Target framework needs to be updated -#endif [ConditionalFact] public async Task RequestBody_InvalidBuffer_ArgumentException() diff --git a/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/Listener/ResponseBodyTests.cs b/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/Listener/ResponseBodyTests.cs index 46fcdda5e4..9fe7cea307 100644 --- a/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/Listener/ResponseBodyTests.cs +++ b/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/Listener/ResponseBodyTests.cs @@ -98,13 +98,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys.Listener var context = await server.AcceptAsync(Utilities.DefaultTimeout); context.Response.Headers["Content-lenGth"] = " 30 "; var stream = context.Response.Body; -#if NET46 stream.EndWrite(stream.BeginWrite(new byte[10], 0, 10, null, null)); -#elif NETCOREAPP2_0 - await stream.WriteAsync(new byte[10], 0, 10); -#else -#error Target framework needs to be updated -#endif stream.Write(new byte[10], 0, 10); await stream.WriteAsync(new byte[10], 0, 10); context.Dispose(); @@ -131,15 +125,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys.Listener var context = await server.AcceptAsync(Utilities.DefaultTimeout); context.Response.Headers["Content-lenGth"] = " 20 "; context.Dispose(); -#if NET46 - // 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); } } @@ -287,19 +273,7 @@ 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 NET46 - // .NET 4.5 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.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); } } @@ -319,19 +293,7 @@ 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 NET46 - // .NET 4.5 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.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 1da87eab2c..f7aaa4c9cb 100644 --- a/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/Listener/ResponseHeaderTests.cs +++ b/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/Listener/ResponseHeaderTests.cs @@ -221,13 +221,8 @@ 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"]); -#if NETCOREAPP2_0 // WebHeaderCollection.GetValues() not available in CoreCLR. + // WebHeaderCollection.GetValues() not available in CoreCLR. Assert.Equal("custom1, and custom2, custom3", response.Headers["WWW-Authenticate"]); -#elif NET46 - Assert.Equal(new string[] { "custom1, and custom2", "custom3" }, response.Headers.GetValues("WWW-Authenticate")); -#else -#error Target framework needs to be updated -#endif } } @@ -252,13 +247,8 @@ 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"]); -#if NETCOREAPP2_0 // WebHeaderCollection.GetValues() not available in CoreCLR. + // WebHeaderCollection.GetValues() not available in CoreCLR. Assert.Equal("custom1, and custom2, custom3", response.Headers["Custom-Header1"]); -#elif NET46 - 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 b025dff302..e13c700717 100644 --- a/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/Listener/ResponseSendFileTests.cs +++ b/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/Listener/ResponseSendFileTests.cs @@ -362,19 +362,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys.Listener var writeTask = context.Response.SendFileAsync(AbsoluteFilePath, 0, null, cts.Token); Assert.True(writeTask.IsCanceled); context.Dispose(); -#if NET46 - // .NET 4.5 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); } } @@ -394,19 +382,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys.Listener var writeTask = context.Response.SendFileAsync(AbsoluteFilePath, 0, null, cts.Token); Assert.True(writeTask.IsCanceled); context.Dispose(); -#if NET46 - // .NET 4.5 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 6633fbbaca..5675d76a21 100644 --- a/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/Listener/ServerTests.cs +++ b/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/Listener/ServerTests.cs @@ -186,14 +186,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys.Listener context.Abort(); Assert.True(canceled.WaitOne(interval), "Aborted"); Assert.True(ct.IsCancellationRequested, "IsCancellationRequested"); -#if NET46 - // 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/Listener/SkipOffDomainAttribute.cs b/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/Listener/SkipOffDomainAttribute.cs deleted file mode 100644 index f74046ec1d..0000000000 --- a/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/Listener/SkipOffDomainAttribute.cs +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (c) .NET Foundation. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using Microsoft.AspNetCore.Testing.xunit; - -namespace Microsoft.AspNetCore.Server.HttpSys.Listener -{ - /// - /// Skips an auth test if the machine is not joined to a Windows domain. - /// - [AttributeUsage(AttributeTargets.Method, AllowMultiple = false)] - public class SkipOffDomainAttribute : Attribute, ITestCondition - { - public bool IsMet - { - get - { - try - { -#if NET46 - return !string.IsNullOrEmpty(System.DirectoryServices.ActiveDirectory.Domain.GetComputerDomain().Name); -#elif NETCOREAPP2_0 -#else -#error Target framework needs to be updated -#endif - } - catch - { - } - return false; - } - } - - public string SkipReason - { - get - { - return "Machine is not joined to a domain."; - } - } - } -} \ No newline at end of file diff --git a/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/Listener/Utilities.cs b/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/Listener/Utilities.cs index 8a5d5d9a55..db41469119 100644 --- a/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/Listener/Utilities.cs +++ b/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/Listener/Utilities.cs @@ -24,13 +24,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys.Listener static Utilities() { var win8Version = new Version(6, 2); -#if NET46 IsWin8orLater = (Environment.OSVersion.Version >= win8Version); -#elif NETCOREAPP2_0 - IsWin8orLater = (new Version(RuntimeEnvironment.OperatingSystemVersion) >= win8Version); -#else -#error Target framework needs to be updated -#endif } internal static HttpSysListener CreateHttpAuthServer(AuthenticationSchemes authScheme, bool allowAnonymos, out string baseAddress) 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 809f73775c..1c0f20cb27 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,8 +3,7 @@ - netcoreapp2.0;net46 - netcoreapp2.0 + netcoreapp2.0 diff --git a/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/RequestBodyTests.cs b/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/RequestBodyTests.cs index b55b3f9d50..820c999da4 100644 --- a/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/RequestBodyTests.cs +++ b/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/RequestBodyTests.cs @@ -50,7 +50,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys Assert.Equal("Hello World", response); } } -#if NET46 + [ConditionalFact] public async Task RequestBody_ReadBeginEnd_Success() { @@ -68,10 +68,6 @@ namespace Microsoft.AspNetCore.Server.HttpSys Assert.Equal("Hello World", response); } } -#elif NETCOREAPP2_0 -#else -#error Target framework needs to be updated -#endif [ConditionalFact] public async Task RequestBody_InvalidBuffer_ArgumentException() diff --git a/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/ResponseBodyTests.cs b/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/ResponseBodyTests.cs index f35d322add..18dee99410 100644 --- a/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/ResponseBodyTests.cs +++ b/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/ResponseBodyTests.cs @@ -87,13 +87,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys { httpContext.Response.Headers["Content-lenGth"] = " 30 "; Stream stream = httpContext.Response.Body; -#if NET46 stream.EndWrite(stream.BeginWrite(new byte[10], 0, 10, null, null)); -#elif NETCOREAPP2_0 - await stream.WriteAsync(new byte[10], 0, 10); -#else -#error Target framework needs to be updated -#endif stream.Write(new byte[10], 0, 10); await stream.WriteAsync(new byte[10], 0, 10); })) @@ -223,7 +217,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys Assert.Equal(new byte[10], await response.Content.ReadAsByteArrayAsync()); } } -#if NET46 + [ConditionalFact] public async Task ResponseBody_BeginWrite_TriggersOnStarting() { @@ -251,10 +245,7 @@ namespace Microsoft.AspNetCore.Server.HttpSys Assert.Equal(new byte[10], await response.Content.ReadAsByteArrayAsync()); } } -#elif NETCOREAPP2_0 -#else -#error Target framework needs to be updated -#endif + [ConditionalFact] public async Task ResponseBody_WriteAsync_TriggersOnStarting() { diff --git a/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/ResponseHeaderTests.cs b/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/ResponseHeaderTests.cs index cc9f5ad87c..2153dde2ce 100644 --- a/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/ResponseHeaderTests.cs +++ b/test/Microsoft.AspNetCore.Server.HttpSys.FunctionalTests/ResponseHeaderTests.cs @@ -81,13 +81,7 @@ 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 NET46 - Assert.Equal(new string[] { "custom1, and custom2", "custom3" }, response.Headers.GetValues("WWW-Authenticate")); -#else -#error Target framework needs to be updated -#endif } } @@ -111,13 +105,7 @@ 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 NET46 - 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 cef136bb6b..dbf7edb1a7 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,8 +3,7 @@ - netcoreapp2.0;net46 - netcoreapp2.0 + netcoreapp2.0