diff --git a/src/Microsoft.Net.Http.Server/AuthenticationManager.cs b/src/Microsoft.Net.Http.Server/AuthenticationManager.cs index 4dd506ba29..26670dfa48 100644 --- a/src/Microsoft.Net.Http.Server/AuthenticationManager.cs +++ b/src/Microsoft.Net.Http.Server/AuthenticationManager.cs @@ -39,12 +39,12 @@ namespace Microsoft.Net.Http.Server /// public sealed class AuthenticationManager { -#if ASPNET50 - private static readonly int AuthInfoSize = - Marshal.SizeOf(typeof(UnsafeNclNativeMethods.HttpApi.HTTP_SERVER_AUTHENTICATION_INFO)); -#else +#if ASPNETCORE50 private static readonly int AuthInfoSize = Marshal.SizeOf(); +#else + private static readonly int AuthInfoSize = + Marshal.SizeOf(typeof(UnsafeNclNativeMethods.HttpApi.HTTP_SERVER_AUTHENTICATION_INFO)); #endif private WebListener _server; @@ -163,7 +163,7 @@ namespace Microsoft.Net.Http.Server && requestInfo->InfoType == UnsafeNclNativeMethods.HttpApi.HTTP_REQUEST_INFO_TYPE.HttpRequestInfoTypeAuth && requestInfo->pInfo->AuthStatus == UnsafeNclNativeMethods.HttpApi.HTTP_AUTH_STATUS.HttpAuthStatusSuccess) { -#if ASPNET50 +#if !ASPNETCORE50 return true; #endif } @@ -176,7 +176,7 @@ namespace Microsoft.Net.Http.Server && requestInfo->InfoType == UnsafeNclNativeMethods.HttpApi.HTTP_REQUEST_INFO_TYPE.HttpRequestInfoTypeAuth && requestInfo->pInfo->AuthStatus == UnsafeNclNativeMethods.HttpApi.HTTP_AUTH_STATUS.HttpAuthStatusSuccess) { -#if ASPNET50 +#if !ASPNETCORE50 return new WindowsPrincipal(new WindowsIdentity(requestInfo->pInfo->AccessToken, GetAuthTypeFromRequest(requestInfo->pInfo->AuthType).ToString())); #endif diff --git a/src/Microsoft.Net.Http.Server/NativeInterop/ComNetOS.cs b/src/Microsoft.Net.Http.Server/NativeInterop/ComNetOS.cs index ff8c54aa99..030b152caa 100644 --- a/src/Microsoft.Net.Http.Server/NativeInterop/ComNetOS.cs +++ b/src/Microsoft.Net.Http.Server/NativeInterop/ComNetOS.cs @@ -32,11 +32,12 @@ namespace Microsoft.Net.Http.Server static ComNetOS() { -#if ASPNET50 +#if ASPNETCORE50 + // TODO: SkipIOCPCallbackOnSuccess doesn't work on Win7. Need a way to detect Win7 vs 8+. + IsWin8orLater = false; +#else var win8Version = new Version(6, 2); IsWin8orLater = (Environment.OSVersion.Version >= win8Version); -#else - IsWin8orLater = true; #endif } } diff --git a/src/Microsoft.Net.Http.Server/NativeInterop/HttpSysSettings.cs b/src/Microsoft.Net.Http.Server/NativeInterop/HttpSysSettings.cs index f55d833576..1d6daab69d 100644 --- a/src/Microsoft.Net.Http.Server/NativeInterop/HttpSysSettings.cs +++ b/src/Microsoft.Net.Http.Server/NativeInterop/HttpSysSettings.cs @@ -26,7 +26,7 @@ using System.Diagnostics; using System.Globalization; using System.IO; using System.Security; -#if ASPNET50 +#if !ASPNETCORE50 using Microsoft.Win32; #endif @@ -34,7 +34,7 @@ namespace Microsoft.Net.Http.Server { internal static class HttpSysSettings { -#if ASPNET50 +#if !ASPNETCORE50 private const string HttpSysParametersKey = @"System\CurrentControlSet\Services\HTTP\Parameters"; #endif private const bool EnableNonUtf8Default = true; @@ -61,7 +61,7 @@ namespace Microsoft.Net.Http.Server } private static void ReadHttpSysRegistrySettings() -#if !ASPNET50 +#if ASPNETCORE50 { } #else diff --git a/src/Microsoft.Net.Http.Server/NativeInterop/NclUtilities.cs b/src/Microsoft.Net.Http.Server/NativeInterop/NclUtilities.cs index c3aaec9cb7..2e6d3c4b07 100644 --- a/src/Microsoft.Net.Http.Server/NativeInterop/NclUtilities.cs +++ b/src/Microsoft.Net.Http.Server/NativeInterop/NclUtilities.cs @@ -32,7 +32,7 @@ namespace Microsoft.Net.Http.Server get { return Environment.HasShutdownStarted -#if ASPNET50 +#if !ASPNETCORE50 || AppDomain.CurrentDomain.IsFinalizingForUnload() #endif ; diff --git a/src/Microsoft.Net.Http.Server/RequestProcessing/OpaqueStream.cs b/src/Microsoft.Net.Http.Server/RequestProcessing/OpaqueStream.cs index 54215adb62..9d6ab5bf03 100644 --- a/src/Microsoft.Net.Http.Server/RequestProcessing/OpaqueStream.cs +++ b/src/Microsoft.Net.Http.Server/RequestProcessing/OpaqueStream.cs @@ -109,7 +109,7 @@ namespace Microsoft.Net.Http.Server { return _requestStream.ReadByte(); } -#if ASPNET50 +#if !ASPNETCORE50 public override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback callback, object state) { return _requestStream.BeginRead(buffer, offset, count, callback, state); @@ -143,7 +143,7 @@ namespace Microsoft.Net.Http.Server { _responseStream.WriteByte(value); } -#if ASPNET50 +#if !ASPNETCORE50 public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, object state) { return _responseStream.BeginWrite(buffer, offset, count, callback, state); diff --git a/src/Microsoft.Net.Http.Server/RequestProcessing/Request.cs b/src/Microsoft.Net.Http.Server/RequestProcessing/Request.cs index 3d03cbc366..015cb98e47 100644 --- a/src/Microsoft.Net.Http.Server/RequestProcessing/Request.cs +++ b/src/Microsoft.Net.Http.Server/RequestProcessing/Request.cs @@ -29,7 +29,7 @@ using System.Net; using System.Runtime.InteropServices; using System.Security.Claims; using System.Security.Cryptography.X509Certificates; -#if ASPNET50 +#if !ASPNETCORE50 using System.Security.Principal; #endif using System.Threading; diff --git a/src/Microsoft.Net.Http.Server/RequestProcessing/RequestStream.cs b/src/Microsoft.Net.Http.Server/RequestProcessing/RequestStream.cs index 0beaf04cda..cbeaa2fb70 100644 --- a/src/Microsoft.Net.Http.Server/RequestProcessing/RequestStream.cs +++ b/src/Microsoft.Net.Http.Server/RequestProcessing/RequestStream.cs @@ -198,10 +198,10 @@ namespace Microsoft.Net.Http.Server } } -#if ASPNET50 - public override unsafe IAsyncResult BeginRead(byte[] buffer, int offset, int size, AsyncCallback callback, object state) -#else +#if ASPNETCORE50 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); @@ -291,10 +291,10 @@ namespace Microsoft.Net.Http.Server return asyncResult; } -#if ASPNET50 - public override int EndRead(IAsyncResult asyncResult) -#else +#if ASPNETCORE50 public int EndRead(IAsyncResult asyncResult) +#else + public override int EndRead(IAsyncResult asyncResult) #endif { if (asyncResult == null) @@ -425,20 +425,20 @@ namespace Microsoft.Net.Http.Server { throw new InvalidOperationException(Resources.Exception_ReadOnlyStream); } - -#if ASPNET50 - public override IAsyncResult BeginWrite(byte[] buffer, int offset, int size, AsyncCallback callback, object state) -#else + +#if ASPNETCORE50 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 ASPNET50 - public override void EndWrite(IAsyncResult asyncResult) -#else +#if ASPNETCORE50 public void EndWrite(IAsyncResult asyncResult) +#else + public override void EndWrite(IAsyncResult asyncResult) #endif { throw new InvalidOperationException(Resources.Exception_ReadOnlyStream); diff --git a/src/Microsoft.Net.Http.Server/RequestProcessing/RequestUriBuilder.cs b/src/Microsoft.Net.Http.Server/RequestProcessing/RequestUriBuilder.cs index 0da68b19bc..a9301ea464 100644 --- a/src/Microsoft.Net.Http.Server/RequestProcessing/RequestUriBuilder.cs +++ b/src/Microsoft.Net.Http.Server/RequestProcessing/RequestUriBuilder.cs @@ -70,10 +70,10 @@ namespace Microsoft.Net.Http.Server // TODO: False triggers more detailed/correct parsing, but it's rather slow. UseCookedRequestUrl = true; // SettingsSectionInternal.Section.HttpListenerUnescapeRequestUrl; Utf8Encoding = new UTF8Encoding(false, true); -#if ASPNET50 - AnsiEncoding = Encoding.GetEncoding(0, new EncoderExceptionFallback(), new DecoderExceptionFallback()); -#else +#if ASPNETCORE50 AnsiEncoding = Utf8Encoding; +#else + AnsiEncoding = Encoding.GetEncoding(0, new EncoderExceptionFallback(), new DecoderExceptionFallback()); #endif } diff --git a/src/Microsoft.Net.Http.Server/RequestProcessing/Response.cs b/src/Microsoft.Net.Http.Server/RequestProcessing/Response.cs index b85010f985..72aa46bd8c 100644 --- a/src/Microsoft.Net.Http.Server/RequestProcessing/Response.cs +++ b/src/Microsoft.Net.Http.Server/RequestProcessing/Response.cs @@ -702,10 +702,10 @@ namespace Microsoft.Net.Http.Server knownHeaderInfo[_nativeResponse.ResponseInfoCount].Type = UnsafeNclNativeMethods.HttpApi.HTTP_RESPONSE_INFO_TYPE.HttpResponseInfoTypeMultipleKnownHeaders; knownHeaderInfo[_nativeResponse.ResponseInfoCount].Length = -#if ASPNET50 - (uint)Marshal.SizeOf(typeof(UnsafeNclNativeMethods.HttpApi.HTTP_MULTIPLE_KNOWN_HEADERS)); -#else +#if ASPNETCORE50 (uint)Marshal.SizeOf(); +#else + (uint)Marshal.SizeOf(typeof(UnsafeNclNativeMethods.HttpApi.HTTP_MULTIPLE_KNOWN_HEADERS)); #endif UnsafeNclNativeMethods.HttpApi.HTTP_MULTIPLE_KNOWN_HEADERS header = new UnsafeNclNativeMethods.HttpApi.HTTP_MULTIPLE_KNOWN_HEADERS(); diff --git a/src/Microsoft.Net.Http.Server/RequestProcessing/ResponseStream.cs b/src/Microsoft.Net.Http.Server/RequestProcessing/ResponseStream.cs index 94c20b00d1..5572e22e5a 100644 --- a/src/Microsoft.Net.Http.Server/RequestProcessing/ResponseStream.cs +++ b/src/Microsoft.Net.Http.Server/RequestProcessing/ResponseStream.cs @@ -195,7 +195,7 @@ namespace Microsoft.Net.Http.Server throw new InvalidOperationException(Resources.Exception_WriteOnlyStream); } -#if ASPNET50 +#if !ASPNETCORE50 public override IAsyncResult BeginRead(byte[] buffer, int offset, int size, AsyncCallback callback, object state) { throw new InvalidOperationException(Resources.Exception_WriteOnlyStream); @@ -360,10 +360,10 @@ namespace Microsoft.Net.Http.Server // TODO: Verbose log data written } -#if ASPNET50 - public override unsafe IAsyncResult BeginWrite(byte[] buffer, int offset, int size, AsyncCallback callback, object state) -#else +#if ASPNETCORE50 public unsafe IAsyncResult BeginWrite(byte[] buffer, int offset, int size, AsyncCallback callback, object state) +#else + public override unsafe IAsyncResult BeginWrite(byte[] buffer, int offset, int size, AsyncCallback callback, object state) #endif { if (buffer == null) @@ -465,10 +465,10 @@ namespace Microsoft.Net.Http.Server return asyncResult; } -#if ASPNET50 - public override void EndWrite(IAsyncResult asyncResult) -#else +#if ASPNETCORE50 public void EndWrite(IAsyncResult asyncResult) +#else + public override void EndWrite(IAsyncResult asyncResult) #endif { if (asyncResult == null) diff --git a/src/Microsoft.Net.Http.Server/RequestProcessing/ResponseStreamAsyncResult.cs b/src/Microsoft.Net.Http.Server/RequestProcessing/ResponseStreamAsyncResult.cs index d1dfc1bb9e..c7b71d2aed 100644 --- a/src/Microsoft.Net.Http.Server/RequestProcessing/ResponseStreamAsyncResult.cs +++ b/src/Microsoft.Net.Http.Server/RequestProcessing/ResponseStreamAsyncResult.cs @@ -140,12 +140,12 @@ namespace Microsoft.Net.Http.Server overlapped.AsyncResult = this; int bufferSize = 1024 * 64; // TODO: Validate buffer size choice. -#if ASPNET50 +#if ASPNETCORE50 + _fileStream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite, bufferSize /*, useAsync: true*/); // Extremely expensive. +#else // It's too expensive to validate anything before opening the file. Open the file and then check the lengths. _fileStream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite, bufferSize, FileOptions.Asynchronous | FileOptions.SequentialScan); // Extremely expensive. -#else - _fileStream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite, bufferSize /*, useAsync: true*/); // Extremely expensive. #endif long length = _fileStream.Length; // Expensive if (offset < 0 || offset > length) diff --git a/src/Microsoft.Net.Http.Server/TimeoutManager.cs b/src/Microsoft.Net.Http.Server/TimeoutManager.cs index 53f819d99b..29160fe402 100644 --- a/src/Microsoft.Net.Http.Server/TimeoutManager.cs +++ b/src/Microsoft.Net.Http.Server/TimeoutManager.cs @@ -35,12 +35,12 @@ namespace Microsoft.Net.Http.Server /// public sealed class TimeoutManager { -#if ASPNET50 - private static readonly int TimeoutLimitSize = - Marshal.SizeOf(typeof(UnsafeNclNativeMethods.HttpApi.HTTP_TIMEOUT_LIMIT_INFO)); -#else +#if ASPNETCORE50 private static readonly int TimeoutLimitSize = Marshal.SizeOf(); +#else + private static readonly int TimeoutLimitSize = + Marshal.SizeOf(typeof(UnsafeNclNativeMethods.HttpApi.HTTP_TIMEOUT_LIMIT_INFO)); #endif private WebListener _server; private int[] _timeouts; diff --git a/src/Microsoft.Net.Http.Server/WebListener.cs b/src/Microsoft.Net.Http.Server/WebListener.cs index 11288670c3..70755ec5d3 100644 --- a/src/Microsoft.Net.Http.Server/WebListener.cs +++ b/src/Microsoft.Net.Http.Server/WebListener.cs @@ -44,17 +44,17 @@ namespace Microsoft.Net.Http.Server public sealed class WebListener : IDisposable { private const long DefaultRequestQueueLength = 1000; // Http.sys default. -#if ASPNET50 +#if ASPNETCORE50 + private static readonly int RequestChannelBindStatusSize = + Marshal.SizeOf(); + private static readonly int BindingInfoSize = + Marshal.SizeOf(); +#else private static readonly Type ChannelBindingStatusType = typeof(UnsafeNclNativeMethods.HttpApi.HTTP_REQUEST_CHANNEL_BIND_STATUS); private static readonly int RequestChannelBindStatusSize = Marshal.SizeOf(typeof(UnsafeNclNativeMethods.HttpApi.HTTP_REQUEST_CHANNEL_BIND_STATUS)); private static readonly int BindingInfoSize = Marshal.SizeOf(typeof(UnsafeNclNativeMethods.HttpApi.HTTP_BINDING_INFO)); -#else - private static readonly int RequestChannelBindStatusSize = - Marshal.SizeOf(); - private static readonly int BindingInfoSize = - Marshal.SizeOf(); #endif // Win8# 559317 fixed a bug in Http.sys's HttpReceiveClientCertificate method. @@ -819,10 +819,10 @@ namespace Microsoft.Net.Http.Server knownHeaderInfo[httpResponse.ResponseInfoCount].Type = UnsafeNclNativeMethods.HttpApi.HTTP_RESPONSE_INFO_TYPE.HttpResponseInfoTypeMultipleKnownHeaders; knownHeaderInfo[httpResponse.ResponseInfoCount].Length = -#if ASPNET50 - (uint)Marshal.SizeOf(typeof(UnsafeNclNativeMethods.HttpApi.HTTP_MULTIPLE_KNOWN_HEADERS)); -#else +#if ASPNETCORE50 (uint)Marshal.SizeOf(); +#else + (uint)Marshal.SizeOf(typeof(UnsafeNclNativeMethods.HttpApi.HTTP_MULTIPLE_KNOWN_HEADERS)); #endif UnsafeNclNativeMethods.HttpApi.HTTP_MULTIPLE_KNOWN_HEADERS header = new UnsafeNclNativeMethods.HttpApi.HTTP_MULTIPLE_KNOWN_HEADERS(); @@ -911,10 +911,10 @@ namespace Microsoft.Net.Http.Server private static int GetTokenOffsetFromBlob(IntPtr blob) { Debug.Assert(blob != IntPtr.Zero); -#if ASPNET50 - IntPtr tokenPointer = Marshal.ReadIntPtr(blob, (int)Marshal.OffsetOf(ChannelBindingStatusType, "ChannelToken")); -#else +#if ASPNETCORE50 IntPtr tokenPointer = Marshal.ReadIntPtr(blob, (int)Marshal.OffsetOf("ChannelToken")); +#else + IntPtr tokenPointer = Marshal.ReadIntPtr(blob, (int)Marshal.OffsetOf(ChannelBindingStatusType, "ChannelToken")); #endif Debug.Assert(tokenPointer != IntPtr.Zero); return (int)IntPtrHelper.Subtract(tokenPointer, blob); @@ -923,10 +923,10 @@ namespace Microsoft.Net.Http.Server private static int GetTokenSizeFromBlob(IntPtr blob) { Debug.Assert(blob != IntPtr.Zero); -#if ASPNET50 - return Marshal.ReadInt32(blob, (int)Marshal.OffsetOf(ChannelBindingStatusType, "ChannelTokenSize")); -#else +#if ASPNETCORE50 return Marshal.ReadInt32(blob, (int)Marshal.OffsetOf("ChannelTokenSize")); +#else + return Marshal.ReadInt32(blob, (int)Marshal.OffsetOf(ChannelBindingStatusType, "ChannelTokenSize")); #endif } diff --git a/src/Microsoft.Net.Http.Server/WebListenerException.cs b/src/Microsoft.Net.Http.Server/WebListenerException.cs index e411eccbff..0b31af9e66 100644 --- a/src/Microsoft.Net.Http.Server/WebListenerException.cs +++ b/src/Microsoft.Net.Http.Server/WebListenerException.cs @@ -45,12 +45,12 @@ namespace Microsoft.Net.Http.Server : base(errorCode, message) { } -#if ASPNET50 +#if ASPNETCORE50 + 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 -#else - public int ErrorCode #endif { get diff --git a/src/Microsoft.Net.Http.Server/fx/Microsoft/Win32/SafeHandles/CriticalHandleZeroOrMinusOneIsInvalid.cs b/src/Microsoft.Net.Http.Server/fx/Microsoft/Win32/SafeHandles/CriticalHandleZeroOrMinusOneIsInvalid.cs index c32fe193c6..cdfef44a33 100644 --- a/src/Microsoft.Net.Http.Server/fx/Microsoft/Win32/SafeHandles/CriticalHandleZeroOrMinusOneIsInvalid.cs +++ b/src/Microsoft.Net.Http.Server/fx/Microsoft/Win32/SafeHandles/CriticalHandleZeroOrMinusOneIsInvalid.cs @@ -21,7 +21,7 @@ // // ==--== -#if !ASPNET50 +#if ASPNETCORE50 namespace Microsoft.Win32.SafeHandles { diff --git a/src/Microsoft.Net.Http.Server/fx/Microsoft/Win32/SafeHandles/SafeHandleZeroOrMinusOneIsInvalid.cs b/src/Microsoft.Net.Http.Server/fx/Microsoft/Win32/SafeHandles/SafeHandleZeroOrMinusOneIsInvalid.cs index 93ae53059d..5e1b351113 100644 --- a/src/Microsoft.Net.Http.Server/fx/Microsoft/Win32/SafeHandles/SafeHandleZeroOrMinusOneIsInvalid.cs +++ b/src/Microsoft.Net.Http.Server/fx/Microsoft/Win32/SafeHandles/SafeHandleZeroOrMinusOneIsInvalid.cs @@ -21,7 +21,7 @@ // // ==--== -#if !ASPNET50 +#if ASPNETCORE50 namespace Microsoft.Win32.SafeHandles { diff --git a/src/Microsoft.Net.Http.Server/fx/System/Diagnostics/TraceEventType.cs b/src/Microsoft.Net.Http.Server/fx/System/Diagnostics/TraceEventType.cs index 27c11162bb..b58cb2b3b6 100644 --- a/src/Microsoft.Net.Http.Server/fx/System/Diagnostics/TraceEventType.cs +++ b/src/Microsoft.Net.Http.Server/fx/System/Diagnostics/TraceEventType.cs @@ -21,7 +21,7 @@ // //------------------------------------------------------------------------------ -#if !ASPNET50 +#if ASPNETCORE50 using System; using System.ComponentModel; diff --git a/src/Microsoft.Net.Http.Server/fx/System/ExternDll.cs b/src/Microsoft.Net.Http.Server/fx/System/ExternDll.cs index 50235a6447..d0c06faf22 100644 --- a/src/Microsoft.Net.Http.Server/fx/System/ExternDll.cs +++ b/src/Microsoft.Net.Http.Server/fx/System/ExternDll.cs @@ -21,17 +21,13 @@ // //------------------------------------------------------------------------------ -#if !ASPNET50 +#if ASPNETCORE50 namespace System { internal static class ExternDll { -#if ASPNETCORE50 public const string api_ms_win_core_localization_LIB = "api-ms-win-core-localization-l2-1-0.dll"; -#else - public const string Kernel32 = "kernel32.dll"; -#endif } } #endif \ No newline at end of file diff --git a/src/Microsoft.Net.Http.Server/fx/System/Runtime/InteropServices/ExternalException.cs b/src/Microsoft.Net.Http.Server/fx/System/Runtime/InteropServices/ExternalException.cs index 7ddb66a918..ff4cc36e0e 100644 --- a/src/Microsoft.Net.Http.Server/fx/System/Runtime/InteropServices/ExternalException.cs +++ b/src/Microsoft.Net.Http.Server/fx/System/Runtime/InteropServices/ExternalException.cs @@ -31,7 +31,7 @@ ** =============================================================================*/ -#if !ASPNET50 +#if ASPNETCORE50 namespace System.Runtime.InteropServices { diff --git a/src/Microsoft.Net.Http.Server/fx/System/SafeNativeMethods.cs b/src/Microsoft.Net.Http.Server/fx/System/SafeNativeMethods.cs index da9548c88b..4fdd2d425d 100644 --- a/src/Microsoft.Net.Http.Server/fx/System/SafeNativeMethods.cs +++ b/src/Microsoft.Net.Http.Server/fx/System/SafeNativeMethods.cs @@ -21,7 +21,7 @@ // //------------------------------------------------------------------------------ -#if !ASPNET50 +#if ASPNETCORE50 using System.Runtime.InteropServices; using System.Text; @@ -36,11 +36,7 @@ namespace System FORMAT_MESSAGE_FROM_SYSTEM = 0x00001000, FORMAT_MESSAGE_ARGUMENT_ARRAY = 0x00002000; -#if ASPNETCORE50 [DllImport(ExternDll.api_ms_win_core_localization_LIB, CharSet = System.Runtime.InteropServices.CharSet.Unicode, SetLastError = true, BestFitMapping = true)] -#else - [DllImport(ExternDll.Kernel32, CharSet = System.Runtime.InteropServices.CharSet.Unicode, SetLastError = true, BestFitMapping = true)] -#endif public static unsafe extern int FormatMessage(int dwFlags, IntPtr lpSource_mustBeNull, uint dwMessageId, int dwLanguageId, StringBuilder lpBuffer, int nSize, IntPtr[] arguments); } diff --git a/src/Microsoft.Net.Http.Server/project.json b/src/Microsoft.Net.Http.Server/project.json index f9abeb9eea..1cede4c5cd 100644 --- a/src/Microsoft.Net.Http.Server/project.json +++ b/src/Microsoft.Net.Http.Server/project.json @@ -8,7 +8,8 @@ "allowUnsafe": true }, "frameworks": { - "aspnet50": {}, + "net45": { }, + "aspnet50": { }, "aspnetcore50": { "dependencies": { "Microsoft.Net.WebSocketAbstractions": "1.0.0-*", diff --git a/src/Microsoft.Net.WebSockets/NativeInterop/SafeNativeOverlapped.cs b/src/Microsoft.Net.WebSockets/NativeInterop/SafeNativeOverlapped.cs index 02de75baaa..57fa75659a 100644 --- a/src/Microsoft.Net.WebSockets/NativeInterop/SafeNativeOverlapped.cs +++ b/src/Microsoft.Net.WebSockets/NativeInterop/SafeNativeOverlapped.cs @@ -87,7 +87,7 @@ namespace Microsoft.Net.WebSockets get { return Environment.HasShutdownStarted -#if ASPNET50 +#if !ASPNETCORE50 || AppDomain.CurrentDomain.IsFinalizingForUnload() #endif ; diff --git a/src/Microsoft.Net.WebSockets/NativeInterop/UnsafeNativeMethods.cs b/src/Microsoft.Net.WebSockets/NativeInterop/UnsafeNativeMethods.cs index 52de2495d6..b365a0a701 100644 --- a/src/Microsoft.Net.WebSockets/NativeInterop/UnsafeNativeMethods.cs +++ b/src/Microsoft.Net.WebSockets/NativeInterop/UnsafeNativeMethods.cs @@ -173,10 +173,10 @@ namespace Microsoft.Net.WebSockets static WebSocketProtocolComponent() { -#if ASPNET50 - DllFileName = Path.Combine(Environment.SystemDirectory, WEBSOCKET); -#else +#if ASPNETCORE50 DllFileName = Path.Combine(Environment.GetEnvironmentVariable("SYSTEMROOT"), "System32", WEBSOCKET); +#else + DllFileName = Path.Combine(Environment.SystemDirectory, WEBSOCKET); #endif WebSocketDllHandle = SafeLoadLibrary.LoadLibraryEx(DllFileName); diff --git a/src/Microsoft.Net.WebSockets/WebSocketBase.cs b/src/Microsoft.Net.WebSockets/WebSocketBase.cs index d845cc1625..4254062785 100644 --- a/src/Microsoft.Net.WebSockets/WebSocketBase.cs +++ b/src/Microsoft.Net.WebSockets/WebSocketBase.cs @@ -1103,7 +1103,7 @@ namespace Microsoft.Net.WebSockets if (thisLockTaken || sessionHandleLockTaken) { -#if ASPNET50 +#if !ASPNETCORE50 RuntimeHelpers.PrepareConstrainedRegions(); #endif try @@ -1189,7 +1189,7 @@ namespace Microsoft.Net.WebSockets Contract.Assert(lockObject != null, "'lockObject' MUST NOT be NULL."); if (lockTaken) { -#if ASPNET50 +#if !ASPNETCORE50 RuntimeHelpers.PrepareConstrainedRegions(); #endif try @@ -2253,7 +2253,9 @@ namespace Microsoft.Net.WebSockets "'webSocket.m_KeepAliveTracker' MUST NOT be NULL at this point."); int keepAliveIntervalMilliseconds = (int)_keepAliveInterval.TotalMilliseconds; Contract.Assert(keepAliveIntervalMilliseconds > 0, "'keepAliveIntervalMilliseconds' MUST be POSITIVE."); -#if ASPNET50 +#if ASPNETCORE50 + _keepAliveTimer = new Timer(_keepAliveTimerElapsedCallback, webSocket, keepAliveIntervalMilliseconds, Timeout.Infinite); +#else if (ExecutionContext.IsFlowSuppressed()) { _keepAliveTimer = new Timer(_keepAliveTimerElapsedCallback, webSocket, keepAliveIntervalMilliseconds, Timeout.Infinite); @@ -2265,8 +2267,6 @@ namespace Microsoft.Net.WebSockets _keepAliveTimer = new Timer(_keepAliveTimerElapsedCallback, webSocket, keepAliveIntervalMilliseconds, Timeout.Infinite); } } -#else - _keepAliveTimer = new Timer(_keepAliveTimerElapsedCallback, webSocket, keepAliveIntervalMilliseconds, Timeout.Infinite); #endif } diff --git a/src/Microsoft.Net.WebSockets/WebSocketBuffer.cs b/src/Microsoft.Net.WebSockets/WebSocketBuffer.cs index 7378812572..62323a106f 100644 --- a/src/Microsoft.Net.WebSockets/WebSocketBuffer.cs +++ b/src/Microsoft.Net.WebSockets/WebSocketBuffer.cs @@ -50,12 +50,12 @@ namespace Microsoft.Net.WebSockets public const int MinSendBufferSize = 16; internal const int MinReceiveBufferSize = 256; internal const int MaxBufferSize = 64 * 1024; -#if ASPNET50 - private static readonly int SizeOfUInt = Marshal.SizeOf(typeof(uint)); - private static readonly int SizeOfBool = Marshal.SizeOf(typeof(bool)); -#else +#if ASPNETCORE50 private static readonly int SizeOfUInt = Marshal.SizeOf(); private static readonly int SizeOfBool = Marshal.SizeOf(); +#else + private static readonly int SizeOfUInt = Marshal.SizeOf(typeof(uint)); + private static readonly int SizeOfBool = Marshal.SizeOf(typeof(bool)); #endif private static readonly int PropertyBufferSize = (2 * SizeOfUInt) + SizeOfBool + IntPtr.Size; diff --git a/src/Microsoft.Net.WebSockets/WebSocketException.cs b/src/Microsoft.Net.WebSockets/WebSocketException.cs index 74ee1663e8..6dd5d72c73 100644 --- a/src/Microsoft.Net.WebSockets/WebSocketException.cs +++ b/src/Microsoft.Net.WebSockets/WebSocketException.cs @@ -28,7 +28,7 @@ using System.Runtime.InteropServices; namespace Microsoft.Net.WebSockets { -#if ASPNET50 +#if !ASPNETCORE50 [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2237:MarkISerializableTypesWithSerializable")] #endif internal sealed class WebSocketException : Win32Exception diff --git a/src/Microsoft.Net.WebSockets/fx/Microsoft/Win32/SafeHandles/SafeHandleZeroOrMinusOneIsInvalid.cs b/src/Microsoft.Net.WebSockets/fx/Microsoft/Win32/SafeHandles/SafeHandleZeroOrMinusOneIsInvalid.cs index 93ae53059d..5e1b351113 100644 --- a/src/Microsoft.Net.WebSockets/fx/Microsoft/Win32/SafeHandles/SafeHandleZeroOrMinusOneIsInvalid.cs +++ b/src/Microsoft.Net.WebSockets/fx/Microsoft/Win32/SafeHandles/SafeHandleZeroOrMinusOneIsInvalid.cs @@ -21,7 +21,7 @@ // // ==--== -#if !ASPNET50 +#if ASPNETCORE50 namespace Microsoft.Win32.SafeHandles { diff --git a/src/Microsoft.Net.WebSockets/fx/System/AccessViolationException.cs b/src/Microsoft.Net.WebSockets/fx/System/AccessViolationException.cs index 7c0f5bf195..97e4ee049a 100644 --- a/src/Microsoft.Net.WebSockets/fx/System/AccessViolationException.cs +++ b/src/Microsoft.Net.WebSockets/fx/System/AccessViolationException.cs @@ -15,7 +15,7 @@ // See the Apache 2 License for the specific language governing // permissions and limitations under the License. -#if !ASPNET50 +#if ASPNETCORE50 using System; using System.Collections.Generic; diff --git a/src/Microsoft.Net.WebSockets/fx/System/ComponentModel/Win32Exception.cs b/src/Microsoft.Net.WebSockets/fx/System/ComponentModel/Win32Exception.cs index bdd0fa07bd..73f28a2b6e 100644 --- a/src/Microsoft.Net.WebSockets/fx/System/ComponentModel/Win32Exception.cs +++ b/src/Microsoft.Net.WebSockets/fx/System/ComponentModel/Win32Exception.cs @@ -21,7 +21,7 @@ // //------------------------------------------------------------------------------ -#if !ASPNET50 +#if ASPNETCORE50 using System.Runtime.InteropServices; using System.Text; diff --git a/src/Microsoft.Net.WebSockets/fx/System/ExternDll.cs b/src/Microsoft.Net.WebSockets/fx/System/ExternDll.cs index c1e1f5b20f..d0c06faf22 100644 --- a/src/Microsoft.Net.WebSockets/fx/System/ExternDll.cs +++ b/src/Microsoft.Net.WebSockets/fx/System/ExternDll.cs @@ -21,17 +21,13 @@ // //------------------------------------------------------------------------------ -#if !ASPNET50 +#if ASPNETCORE50 namespace System { internal static class ExternDll { -#if NETFX || ASPNET50 - public const string Kernel32 = "kernel32.dll"; -#else public const string api_ms_win_core_localization_LIB = "api-ms-win-core-localization-l2-1-0.dll"; -#endif } } #endif \ No newline at end of file diff --git a/src/Microsoft.Net.WebSockets/fx/System/Runtime/InteropServices/ExternalException.cs b/src/Microsoft.Net.WebSockets/fx/System/Runtime/InteropServices/ExternalException.cs index 7ddb66a918..ff4cc36e0e 100644 --- a/src/Microsoft.Net.WebSockets/fx/System/Runtime/InteropServices/ExternalException.cs +++ b/src/Microsoft.Net.WebSockets/fx/System/Runtime/InteropServices/ExternalException.cs @@ -31,7 +31,7 @@ ** =============================================================================*/ -#if !ASPNET50 +#if ASPNETCORE50 namespace System.Runtime.InteropServices { diff --git a/src/Microsoft.Net.WebSockets/fx/System/SafeNativeMethods.cs b/src/Microsoft.Net.WebSockets/fx/System/SafeNativeMethods.cs index 7ee12dbbdc..4fdd2d425d 100644 --- a/src/Microsoft.Net.WebSockets/fx/System/SafeNativeMethods.cs +++ b/src/Microsoft.Net.WebSockets/fx/System/SafeNativeMethods.cs @@ -21,7 +21,7 @@ // //------------------------------------------------------------------------------ -#if !ASPNET50 +#if ASPNETCORE50 using System.Runtime.InteropServices; using System.Text; @@ -36,11 +36,7 @@ namespace System FORMAT_MESSAGE_FROM_SYSTEM = 0x00001000, FORMAT_MESSAGE_ARGUMENT_ARRAY = 0x00002000; -#if ASPNETCORE50 [DllImport(ExternDll.api_ms_win_core_localization_LIB, CharSet = System.Runtime.InteropServices.CharSet.Unicode, SetLastError = true, BestFitMapping = true)] -#else - [DllImport(ExternDll.Kernel32, CharSet = System.Runtime.InteropServices.CharSet.Unicode, SetLastError = true, BestFitMapping = true)] -#endif public static unsafe extern int FormatMessage(int dwFlags, IntPtr lpSource_mustBeNull, uint dwMessageId, int dwLanguageId, StringBuilder lpBuffer, int nSize, IntPtr[] arguments); } diff --git a/src/Microsoft.Net.WebSockets/fx/System/SystemException.cs b/src/Microsoft.Net.WebSockets/fx/System/SystemException.cs index 3ab212bca4..5bcc7aeaa0 100644 --- a/src/Microsoft.Net.WebSockets/fx/System/SystemException.cs +++ b/src/Microsoft.Net.WebSockets/fx/System/SystemException.cs @@ -15,7 +15,7 @@ // See the Apache 2 License for the specific language governing // permissions and limitations under the License. -#if !ASPNET50 +#if ASPNETCORE50 using System; using System.Collections.Generic; diff --git a/src/Microsoft.Net.WebSockets/project.json b/src/Microsoft.Net.WebSockets/project.json index 8a03bfb293..c997ebc250 100644 --- a/src/Microsoft.Net.WebSockets/project.json +++ b/src/Microsoft.Net.WebSockets/project.json @@ -5,7 +5,7 @@ }, "compilationOptions" : { "allowUnsafe": true }, "frameworks": { - "aspnet50" : { }, + "net45" : { }, "aspnetcore50" : { "dependencies": { "Microsoft.Win32.Primitives": "4.0.0.0", diff --git a/test/Microsoft.AspNet.Server.WebListener.FunctionalTests/RequestBodyTests.cs b/test/Microsoft.AspNet.Server.WebListener.FunctionalTests/RequestBodyTests.cs index f630a6a85f..21aa1eb02f 100644 --- a/test/Microsoft.AspNet.Server.WebListener.FunctionalTests/RequestBodyTests.cs +++ b/test/Microsoft.AspNet.Server.WebListener.FunctionalTests/RequestBodyTests.cs @@ -67,7 +67,7 @@ namespace Microsoft.AspNet.Server.WebListener Assert.Equal("Hello World", response); } } -#if ASPNET50 +#if !ASPNETCORE50 [Fact] public async Task RequestBody_ReadBeginEnd_Success() { diff --git a/test/Microsoft.Net.Http.Server.FunctionalTests/project.json b/test/Microsoft.Net.Http.Server.FunctionalTests/project.json index 0c0784e8e7..37f11f8ff3 100644 --- a/test/Microsoft.Net.Http.Server.FunctionalTests/project.json +++ b/test/Microsoft.Net.Http.Server.FunctionalTests/project.json @@ -1,18 +1,18 @@ { - "commands": { - "test": "Xunit.KRunner" - }, - "dependencies": { - "Microsoft.Net.Http.Server" : "", - "Xunit.KRunner": "1.0.0-*" - }, - "frameworks": { - "aspnet50": { - "dependencies": { - "System.Net.Http": "", - "System.Net.Http.WebRequest": "", - "System.Runtime": "" + "commands": { + "test": "Xunit.KRunner" + }, + "dependencies": { + "System.Net.Http": "4.0.0.0", + "System.Runtime": "4.0.20.0", + "Microsoft.Net.Http.Server": "1.0.0-*", + "Xunit.KRunner": "1.0.0-*" + }, + "frameworks": { + "net45": { + dependencies: { + "System.Net.Http.WebRequest": "" } } - } + } }