This repository was archived by the owner on Dec 18, 2018. It is now read-only.
File tree 3 files changed +25
-33
lines changed
src/Microsoft.AspNetCore.Server.Kestrel 3 files changed +25
-33
lines changed Original file line number Diff line number Diff line change 1
1
// Copyright (c) .NET Foundation. All rights reserved.
2
2
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3
3
4
- using Microsoft . Extensions . PlatformAbstractions ;
4
+ using System . Runtime . InteropServices ;
5
5
6
6
namespace Microsoft . AspNetCore . Server . Kestrel . Infrastructure
7
7
{
@@ -28,32 +28,36 @@ internal class Constants
28
28
29
29
private static int ? GetECONNRESET ( )
30
30
{
31
- switch ( PlatformServices . Default . Runtime . OperatingSystemPlatform )
31
+ if ( RuntimeInformation . IsOSPlatform ( OSPlatform . Windows ) )
32
32
{
33
- case Platform . Windows :
34
- return - 4077 ;
35
- case Platform . Linux :
36
- return - 104 ;
37
- case Platform . Darwin :
38
- return - 54 ;
39
- default :
40
- return null ;
33
+ return - 4077 ;
41
34
}
35
+ else if ( RuntimeInformation . IsOSPlatform ( OSPlatform . Linux ) )
36
+ {
37
+ return - 104 ;
38
+ }
39
+ else if ( RuntimeInformation . IsOSPlatform ( OSPlatform . OSX ) )
40
+ {
41
+ return - 54 ;
42
+ }
43
+ return null ;
42
44
}
43
45
44
46
private static int ? GetEADDRINUSE ( )
45
47
{
46
- switch ( PlatformServices . Default . Runtime . OperatingSystemPlatform )
48
+ if ( RuntimeInformation . IsOSPlatform ( OSPlatform . Windows ) )
49
+ {
50
+ return - 4091 ;
51
+ }
52
+ else if ( RuntimeInformation . IsOSPlatform ( OSPlatform . Linux ) )
53
+ {
54
+ return - 98 ;
55
+ }
56
+ else if ( RuntimeInformation . IsOSPlatform ( OSPlatform . OSX ) )
47
57
{
48
- case Platform . Windows :
49
- return - 4091 ;
50
- case Platform . Linux :
51
- return - 98 ;
52
- case Platform . Darwin :
53
- return - 48 ;
54
- default :
55
- return null ;
58
+ return - 48 ;
56
59
}
60
+ return null ;
57
61
}
58
62
}
59
63
}
Original file line number Diff line number Diff line change 3
3
4
4
using System ;
5
5
using System . Runtime . InteropServices ;
6
- using Microsoft . Extensions . PlatformAbstractions ;
7
6
8
7
namespace Microsoft . AspNetCore . Server . Kestrel . Networking
9
8
{
10
9
public static class PlatformApis
11
10
{
12
11
static PlatformApis ( )
13
12
{
14
- #if NETSTANDARD1_3
15
13
IsWindows = RuntimeInformation . IsOSPlatform ( OSPlatform . Windows ) ;
16
14
IsDarwin = RuntimeInformation . IsOSPlatform ( OSPlatform . OSX ) ;
17
- #else
18
- var p = ( int ) Environment . OSVersion . Platform ;
19
- IsWindows = ( p != 4 ) && ( p != 6 ) && ( p != 128 ) ;
20
-
21
- if ( ! IsWindows )
22
- {
23
- // When running on Mono in Darwin OSVersion doesn't return Darwin. It returns Unix instead.
24
- IsDarwin = PlatformServices . Default . Runtime . OperatingSystemPlatform == Platform . Darwin ;
25
- }
26
- #endif
27
15
}
28
16
29
17
public static bool IsWindows { get ; }
Original file line number Diff line number Diff line change 14
14
"dependencies" : {
15
15
"System.Buffers" : " 4.0.0-*" ,
16
16
"System.Numerics.Vectors" : " 4.1.1-*" ,
17
+ "System.Runtime.InteropServices.RuntimeInformation" : " 4.0.0-*" ,
17
18
"System.Threading.Tasks.Extensions" : " 4.0.0-*" ,
18
19
"Libuv" : " 1.9.0-*" ,
19
20
"Microsoft.AspNetCore.Hosting" : " 1.0.0-*" ,
20
- "Microsoft.Extensions.Logging.Abstractions" : " 1.0.0-*" ,
21
- "Microsoft.Extensions.PlatformAbstractions" : " 1.0.0-*"
21
+ "Microsoft.Extensions.Logging.Abstractions" : " 1.0.0-*"
22
22
},
23
23
"frameworks" : {
24
24
"net451" : {
You can’t perform that action at this time.
0 commit comments