File tree Expand file tree Collapse file tree
src/NuGet.Core/NuGet.Common Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -34,9 +34,6 @@ public static class RuntimeEnvironmentHelper
3434 process => process . Equals ( currentProcessName , StringComparison . OrdinalIgnoreCase ) ) ;
3535 } ) ;
3636
37- [ DllImport ( "libc" ) ]
38- static extern int uname ( IntPtr buf ) ;
39-
4037 public static bool IsWindows
4138 {
4239 get => _isWindows . Value ;
@@ -95,51 +92,8 @@ public static bool IsMacOSX
9592
9693 private static bool GetIsMacOSX ( )
9794 {
98- #if IS_CORECLR
99- // This API does work on full framework but it requires a newer nuget client (RID aware)
100- if ( System . Runtime . InteropServices . RuntimeInformation . IsOSPlatform ( System . Runtime . InteropServices . OSPlatform . OSX ) )
101- {
102- return true ;
103- }
104-
105- return false ;
106- #else
107- // On Windows, return false immediately to avoid first-chance exception from uname() P/Invoke
108- if ( IsWindows )
109- {
110- return false ;
111- }
112-
113- var buf = IntPtr . Zero ;
114-
115- try
116- {
117- buf = Marshal . AllocHGlobal ( 8192 ) ;
118-
119- // This is a hacktastic way of getting sysname from uname ()
120- if ( uname ( buf ) == 0 )
121- {
122- var os = Marshal . PtrToStringAnsi ( buf ) ;
123-
124- if ( os == "Darwin" )
125- {
126- return true ;
127- }
128- }
129- }
130- catch
131- {
132- }
133- finally
134- {
135- if ( buf != IntPtr . Zero )
136- {
137- Marshal . FreeHGlobal ( buf ) ;
138- }
139- }
140-
141- return false ;
142- #endif
95+ // RuntimeInformation.IsOSPlatform is available on .NET Framework 4.7.1+ and .NET Core
96+ return System . Runtime . InteropServices . RuntimeInformation . IsOSPlatform ( System . Runtime . InteropServices . OSPlatform . OSX ) ;
14397 }
14498
14599 public static bool IsLinux
You can’t perform that action at this time.
0 commit comments