Skip to content
This repository was archived by the owner on Mar 19, 2019. It is now read-only.

Commit 31001de

Browse files
committed
Migrate to netcoreapp2.0
1 parent fdfc8c0 commit 31001de

33 files changed

+44
-398
lines changed

samples/HotAddSample/HotAddSample.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<Import Project="..\..\build\dependencies.props" />
44

55
<PropertyGroup>
6-
<TargetFrameworks>net46;netcoreapp2.0</TargetFrameworks>
6+
<TargetFramework>netcoreapp2.0</TargetFramework>
77
<OutputType>Exe</OutputType>
88
<ServerGarbageCollection>true</ServerGarbageCollection>
99
</PropertyGroup>

samples/HotAddSample/Startup.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,8 @@ public void ConfigureServices(IServiceCollection services)
2323

2424
public HttpSysOptions ServerOptions { get; set; }
2525

26-
public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory)
26+
public void Configure(IApplicationBuilder app)
2727
{
28-
loggerfactory.AddConsole(LogLevel.Information);
29-
3028
var addresses = ServerOptions.UrlPrefixes;
3129
addresses.Add("http://localhost:12346/pathBase/");
3230

@@ -101,6 +99,7 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory)
10199
public static void Main(string[] args)
102100
{
103101
var host = new WebHostBuilder()
102+
.ConfigureLogging(factory => factory.AddConsole())
104103
.UseStartup<Startup>()
105104
.UseHttpSys()
106105
.Build();

samples/SelfHostServer/SelfHostServer.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<Import Project="..\..\build\dependencies.props" />
44

55
<PropertyGroup>
6-
<TargetFrameworks>net46;netcoreapp2.0</TargetFrameworks>
6+
<TargetFramework>netcoreapp2.0</TargetFramework>
77
<OutputType>Exe</OutputType>
88
<ServerGarbageCollection>true</ServerGarbageCollection>
99
</PropertyGroup>

samples/SelfHostServer/Startup.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,8 @@ public void ConfigureServices(IServiceCollection services)
2020
});
2121
}
2222

23-
public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory)
23+
public void Configure(IApplicationBuilder app)
2424
{
25-
loggerfactory.AddConsole(LogLevel.Debug);
26-
2725
app.Run(async context =>
2826
{
2927
context.Response.ContentType = "text/plain";
@@ -34,6 +32,7 @@ public void Configure(IApplicationBuilder app, ILoggerFactory loggerfactory)
3432
public static void Main(string[] args)
3533
{
3634
var host = new WebHostBuilder()
35+
.ConfigureLogging(factory => factory.AddConsole())
3736
.UseStartup<Startup>()
3837
.UseHttpSys(options =>
3938
{

src/Microsoft.AspNetCore.Server.HttpSys/HttpSysException.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,10 @@ internal HttpSysException(int errorCode, string message)
2525
: base(errorCode, message)
2626
{
2727
}
28-
#if NETSTANDARD1_3
29-
public int ErrorCode
30-
#else
28+
3129
// the base class returns the HResult with this property
3230
// we need the Win32 Error Code, hence the override.
3331
public override int ErrorCode
34-
#endif
3532
{
3633
get
3734
{

src/Microsoft.AspNetCore.Server.HttpSys/Microsoft.AspNetCore.Server.HttpSys.csproj

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<PropertyGroup>
66
<Description>ASP.NET Core HTTP server that uses the Windows HTTP Server API.</Description>
7-
<TargetFrameworks>net46;netstandard1.3</TargetFrameworks>
7+
<TargetFramework>netcoreapp2.0</TargetFramework>
88
<NoWarn>$(NoWarn);CS1591</NoWarn>
99
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
1010
<GenerateDocumentationFile>true</GenerateDocumentationFile>
@@ -13,13 +13,9 @@
1313

1414
<ItemGroup>
1515
<PackageReference Include="Microsoft.AspNetCore.Hosting" Version="$(AspNetCoreVersion)" />
16-
<PackageReference Include="Microsoft.Extensions.RuntimeEnvironment.Sources" Version="$(AspNetCoreVersion)" PrivateAssets="All" />
1716
<PackageReference Include="Microsoft.Extensions.TaskCache.Sources" Version="$(AspNetCoreVersion)" PrivateAssets="All" />
1817
<PackageReference Include="Microsoft.Net.Http.Headers" Version="$(AspNetCoreVersion)" />
19-
<PackageReference Include="System.Threading.Overlapped" Version="$(CoreFxVersion)" />
20-
</ItemGroup>
21-
22-
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard1.3' ">
18+
<PackageReference Include="Microsoft.Win32.Registry" Version="$(CoreFxVersion)" />
2319
<PackageReference Include="System.Security.Principal.Windows" Version="$(CoreFxVersion)" />
2420
</ItemGroup>
2521

src/Microsoft.AspNetCore.Server.HttpSys/NativeInterop/AddressFamily.cs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,11 @@
33

44
namespace Microsoft.AspNetCore.Server.HttpSys
55
{
6-
#if NET46
7-
/// <devdoc>
8-
/// <para>
9-
/// Specifies the address families that an instance of the <see cref="System.Net.Sockets.Socket"/>
10-
/// class can use.
11-
/// </para>
12-
/// </devdoc>
13-
#else
146
/// <devdoc>
157
/// <para>
168
/// Specifies the address families.
179
/// </para>
1810
/// </devdoc>
19-
#endif
2011
internal enum AddressFamily
2112
{
2213
/// <devdoc>

src/Microsoft.AspNetCore.Server.HttpSys/NativeInterop/ComNetOS.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,15 @@ namespace Microsoft.AspNetCore.Server.HttpSys
88
{
99
internal static class ComNetOS
1010
{
11+
// Windows is assumed based on HttpApi.Supported which is checked in the HttpSysListener constructor.
1112
// Minimum support for Windows 7 is assumed.
1213
internal static readonly bool IsWin8orLater;
1314

1415
static ComNetOS()
1516
{
1617
var win8Version = new Version(6, 2);
1718

18-
#if NETSTANDARD1_3
19-
IsWin8orLater = (new Version(RuntimeEnvironment.OperatingSystemVersion) >= win8Version);
20-
#else
2119
IsWin8orLater = (Environment.OSVersion.Version >= win8Version);
22-
#endif
2320
}
2421
}
2522
}

src/Microsoft.AspNetCore.Server.HttpSys/NativeInterop/HttpSysSettings.cs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,13 @@
66
using System.Globalization;
77
using System.IO;
88
using System.Security;
9-
#if !NETSTANDARD1_3
109
using Microsoft.Win32;
11-
#endif
1210

1311
namespace Microsoft.AspNetCore.Server.HttpSys
1412
{
1513
internal static class HttpSysSettings
1614
{
17-
#if !NETSTANDARD1_3
1815
private const string HttpSysParametersKey = @"System\CurrentControlSet\Services\HTTP\Parameters";
19-
#endif
2016
private const bool EnableNonUtf8Default = true;
2117
private const bool FavorUtf8Default = true;
2218
private const string EnableNonUtf8Name = "EnableNonUtf8";
@@ -41,10 +37,6 @@ internal static bool FavorUtf8
4137
}
4238

4339
private static void ReadHttpSysRegistrySettings()
44-
#if NETSTANDARD1_3
45-
{
46-
}
47-
#else
4840
{
4941
try
5042
{
@@ -117,6 +109,5 @@ private static void LogWarning(string methodName, string message, params object[
117109
// TODO: log
118110
// Logging.PrintWarning(Logging.HttpListener, typeof(HttpSysSettings), methodName, SR.GetString(message, args));
119111
}
120-
#endif
121112
}
122113
}

src/Microsoft.AspNetCore.Server.HttpSys/NativeInterop/NclUtilities.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,7 @@ internal static bool HasShutdownStarted
1212
get
1313
{
1414
return Environment.HasShutdownStarted
15-
#if !NETSTANDARD1_3
16-
|| AppDomain.CurrentDomain.IsFinalizingForUnload()
17-
#endif
18-
;
15+
|| AppDomain.CurrentDomain.IsFinalizingForUnload();
1916
}
2017
}
2118
}

src/Microsoft.AspNetCore.Server.HttpSys/NativeInterop/UnsafeNativeMethods.cs

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ namespace Microsoft.AspNetCore.Server.HttpSys
99
{
1010
internal static unsafe class UnsafeNclNativeMethods
1111
{
12-
#if NETSTANDARD1_3
1312
private const string sspicli_LIB = "sspicli.dll";
1413
private const string api_ms_win_core_processthreads_LIB = "api-ms-win-core-processthreads-l1-1-1.dll";
1514
private const string api_ms_win_core_io_LIB = "api-ms-win-core-io-l1-1-0.dll";
@@ -18,10 +17,7 @@ internal static unsafe class UnsafeNclNativeMethods
1817
private const string api_ms_win_core_heap_LIB = "api-ms-win-core-heap-L1-2-0.dll";
1918
private const string api_ms_win_core_heap_obsolete_LIB = "api-ms-win-core-heap-obsolete-L1-1-0.dll";
2019
private const string api_ms_win_core_kernel32_legacy_LIB = "api-ms-win-core-kernel32-legacy-l1-1-0.dll";
21-
#else
22-
private const string KERNEL32 = "kernel32.dll";
23-
private const string SECUR32 = "secur32.dll";
24-
#endif
20+
2521
private const string TOKENBINDING = "tokenbinding.dll";
2622

2723
// CONSIDER: Make this an enum, requires changing a lot of types from uint to ErrorCodes.
@@ -39,18 +35,10 @@ internal static class ErrorCodes
3935
internal const uint ERROR_CONNECTION_INVALID = 1229;
4036
}
4137

42-
#if NETSTANDARD1_3
4338
[DllImport(api_ms_win_core_io_LIB, ExactSpelling = true, CallingConvention = CallingConvention.StdCall, SetLastError = true)]
44-
#else
45-
[DllImport(KERNEL32, ExactSpelling = true, CallingConvention = CallingConvention.StdCall, SetLastError = true)]
46-
#endif
4739
internal static unsafe extern uint CancelIoEx(SafeHandle handle, SafeNativeOverlapped overlapped);
4840

49-
#if NETSTANDARD1_3
5041
[DllImport(api_ms_win_core_kernel32_legacy_LIB, ExactSpelling = true, CallingConvention = CallingConvention.StdCall, SetLastError = true)]
51-
#else
52-
[DllImport(KERNEL32, ExactSpelling = true, CallingConvention = CallingConvention.StdCall, SetLastError = true)]
53-
#endif
5442
internal static unsafe extern bool SetFileCompletionNotificationModes(SafeHandle handle, FileCompletionNotificationModes modes);
5543

5644
[Flags]
@@ -71,54 +59,29 @@ public static extern int TokenBindingVerifyMessage(
7159
[Out] out HeapAllocHandle resultList);
7260

7361
// http://msdn.microsoft.com/en-us/library/windows/desktop/aa366569(v=vs.85).aspx
74-
#if NETSTANDARD1_3
7562
[DllImport(api_ms_win_core_heap_LIB, CallingConvention = CallingConvention.Winapi, SetLastError = true)]
76-
#else
77-
[DllImport(KERNEL32, CallingConvention = CallingConvention.Winapi, SetLastError = true)]
78-
#endif
7963
internal static extern IntPtr GetProcessHeap();
8064

8165
// http://msdn.microsoft.com/en-us/library/windows/desktop/aa366701(v=vs.85).aspx
82-
#if NETSTANDARD1_3
8366
[DllImport(api_ms_win_core_heap_LIB, CallingConvention = CallingConvention.Winapi, SetLastError = true)]
84-
#else
85-
[DllImport(KERNEL32, CallingConvention = CallingConvention.Winapi, SetLastError = true)]
86-
#endif
8767
internal static extern bool HeapFree(
8868
[In] IntPtr hHeap,
8969
[In] uint dwFlags,
9070
[In] IntPtr lpMem);
9171

9272
internal static class SafeNetHandles
9373
{
94-
#if NETSTANDARD1_3
9574
[DllImport(sspicli_LIB, ExactSpelling = true, SetLastError = true)]
96-
#else
97-
[DllImport(SECUR32, ExactSpelling = true, SetLastError = true)]
98-
#endif
9975
internal static extern int FreeContextBuffer(
10076
[In] IntPtr contextBuffer);
10177

102-
#if NETSTANDARD1_3
10378
[DllImport(api_ms_win_core_handle_LIB, ExactSpelling = true, SetLastError = true)]
104-
#else
105-
[DllImport(KERNEL32, ExactSpelling = true, SetLastError = true)]
106-
#endif
10779
internal static extern bool CloseHandle(IntPtr handle);
10880

109-
#if NETSTANDARD1_3
11081
[DllImport(api_ms_win_core_heap_obsolete_LIB, EntryPoint = "LocalAlloc", SetLastError = true)]
111-
#else
112-
[DllImport(KERNEL32, EntryPoint = "LocalAlloc", SetLastError = true)]
113-
#endif
114-
11582
internal static extern SafeLocalFreeChannelBinding LocalAllocChannelBinding(int uFlags, UIntPtr sizetdwBytes);
11683

117-
#if NETSTANDARD1_3
11884
[DllImport(api_ms_win_core_heap_obsolete_LIB, ExactSpelling = true, SetLastError = true)]
119-
#else
120-
[DllImport(KERNEL32, ExactSpelling = true, SetLastError = true)]
121-
#endif
12285
internal static extern IntPtr LocalFree(IntPtr handle);
12386
}
12487

src/Microsoft.AspNetCore.Server.HttpSys/RequestProcessing/OpaqueStream.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public override int ReadByte()
8989
{
9090
return _requestStream.ReadByte();
9191
}
92-
#if !NETSTANDARD1_3
92+
9393
public override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback callback, object state)
9494
{
9595
return _requestStream.BeginRead(buffer, offset, count, callback, state);
@@ -99,7 +99,7 @@ public override int EndRead(IAsyncResult asyncResult)
9999
{
100100
return _requestStream.EndRead(asyncResult);
101101
}
102-
#endif
102+
103103
public override Task<int> ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
104104
{
105105
return _requestStream.ReadAsync(buffer, offset, count, cancellationToken);
@@ -123,7 +123,7 @@ public override void WriteByte(byte value)
123123
{
124124
_responseStream.WriteByte(value);
125125
}
126-
#if !NETSTANDARD1_3
126+
127127
public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, object state)
128128
{
129129
return _responseStream.BeginWrite(buffer, offset, count, callback, state);
@@ -133,7 +133,7 @@ public override void EndWrite(IAsyncResult asyncResult)
133133
{
134134
_responseStream.EndWrite(asyncResult);
135135
}
136-
#endif
136+
137137
public override Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken)
138138
{
139139
return _responseStream.WriteAsync(buffer, offset, count, cancellationToken);

src/Microsoft.AspNetCore.Server.HttpSys/RequestProcessing/RequestStream.cs

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -190,11 +190,7 @@ internal void UpdateAfterRead(uint statusCode, uint dataRead)
190190
}
191191
}
192192

193-
#if NETSTANDARD1_3
194-
public unsafe IAsyncResult BeginRead(byte[] buffer, int offset, int size, AsyncCallback callback, object state)
195-
#else
196193
public override unsafe IAsyncResult BeginRead(byte[] buffer, int offset, int size, AsyncCallback callback, object state)
197-
#endif
198194
{
199195
ValidateReadBuffer(buffer, offset, size);
200196
if (_closed)
@@ -281,11 +277,7 @@ public override unsafe IAsyncResult BeginRead(byte[] buffer, int offset, int siz
281277
return asyncResult;
282278
}
283279

284-
#if NETSTANDARD1_3
285-
public int EndRead(IAsyncResult asyncResult)
286-
#else
287280
public override int EndRead(IAsyncResult asyncResult)
288-
#endif
289281
{
290282
if (asyncResult == null)
291283
{
@@ -416,20 +408,12 @@ public override void Write(byte[] buffer, int offset, int size)
416408
throw new InvalidOperationException(Resources.Exception_ReadOnlyStream);
417409
}
418410

419-
#if NETSTANDARD1_3
420-
public IAsyncResult BeginWrite(byte[] buffer, int offset, int size, AsyncCallback callback, object state)
421-
#else
422411
public override IAsyncResult BeginWrite(byte[] buffer, int offset, int size, AsyncCallback callback, object state)
423-
#endif
424412
{
425413
throw new InvalidOperationException(Resources.Exception_ReadOnlyStream);
426414
}
427415

428-
#if NETSTANDARD1_3
429-
public void EndWrite(IAsyncResult asyncResult)
430-
#else
431416
public override void EndWrite(IAsyncResult asyncResult)
432-
#endif
433417
{
434418
throw new InvalidOperationException(Resources.Exception_ReadOnlyStream);
435419
}

src/Microsoft.AspNetCore.Server.HttpSys/RequestProcessing/ResponseBody.cs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,6 @@ public override int Read([In, Out] byte[] buffer, int offset, int count)
374374
throw new InvalidOperationException(Resources.Exception_WriteOnlyStream);
375375
}
376376

377-
#if !NETSTANDARD1_3
378377
public override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback callback, object state)
379378
{
380379
throw new InvalidOperationException(Resources.Exception_WriteOnlyStream);
@@ -384,7 +383,6 @@ public override int EndRead(IAsyncResult asyncResult)
384383
{
385384
throw new InvalidOperationException(Resources.Exception_WriteOnlyStream);
386385
}
387-
#endif
388386

389387
#endregion
390388

@@ -477,19 +475,12 @@ private void CheckWriteCount(long? count)
477475
}
478476
}
479477

480-
#if NETSTANDARD1_3
481-
public IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, object state)
482-
#else
483478
public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, object state)
484-
#endif
485479
{
486480
return WriteAsync(buffer, offset, count).ToIAsyncResult(callback, state);
487481
}
488-
#if NETSTANDARD1_3
489-
public void EndWrite(IAsyncResult asyncResult)
490-
#else
482+
491483
public override void EndWrite(IAsyncResult asyncResult)
492-
#endif
493484
{
494485
if (asyncResult == null)
495486
{

0 commit comments

Comments
 (0)