|
3 | 3 |
|
4 | 4 | using System;
|
5 | 5 | using System.IO;
|
6 |
| -using System.Runtime.InteropServices; |
7 | 6 |
|
8 | 7 | namespace NewRelic.Agent.Core
|
9 | 8 | {
|
@@ -75,20 +74,22 @@ private static string GetOSVersion()
|
75 | 74 |
|
76 | 75 | private static string GetFreeBSDVersion()
|
77 | 76 | {
|
| 77 | +#if NETSTANDARD2_0 |
78 | 78 | // This is same as sysctl kern.version
|
79 | 79 | // FreeBSD 11.0-RELEASE-p1 FreeBSD 11.0-RELEASE-p1 #0 r306420: Thu Sep 29 01:43:23 UTC 2016 [email protected]:/usr/obj/usr/src/sys/GENERIC
|
80 | 80 | // What we want is major release as minor releases should be compatible.
|
81 |
| - String version = RuntimeInformation.OSDescription; |
| 81 | + String version = System.Runtime.InteropServices.RuntimeInformation.OSDescription; |
82 | 82 | try
|
83 | 83 | {
|
84 | 84 | // second token up to first dot
|
85 |
| - return RuntimeInformation.OSDescription.Split()[1].Split('.')[0]; |
| 85 | + return System.Runtime.InteropServices.RuntimeInformation.OSDescription.Split()[1].Split('.')[0]; |
86 | 86 | }
|
87 | 87 | catch (Exception ex)
|
88 | 88 | {
|
89 | 89 | log4net.ILog logger = log4net.LogManager.GetLogger(typeof(RuntimeEnvironmentInfo));
|
90 | 90 | logger.Debug($"Unable to report Operating System: Unexpected exception in GetFreeBSDVersion: {ex}");
|
91 | 91 | }
|
| 92 | +#endif |
92 | 93 | return string.Empty;
|
93 | 94 | }
|
94 | 95 |
|
@@ -185,24 +186,28 @@ private static DistroInfo NormalizeDistroInfo(DistroInfo distroInfo)
|
185 | 186 |
|
186 | 187 | private static Platform DetermineOSPlatform()
|
187 | 188 | {
|
188 |
| - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) |
| 189 | +#if NETSTANDARD2_0 |
| 190 | + if (System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(System.Runtime.InteropServices.OSPlatform.Windows)) |
189 | 191 | {
|
190 | 192 | return Platform.Windows;
|
191 | 193 | }
|
192 |
| - if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) |
| 194 | + if (System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(System.Runtime.InteropServices.OSPlatform.Linux)) |
193 | 195 | {
|
194 | 196 | return Platform.Linux;
|
195 | 197 | }
|
196 |
| - if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX)) |
| 198 | + if (System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(System.Runtime.InteropServices.OSPlatform.OSX)) |
197 | 199 | {
|
198 | 200 | return Platform.Darwin;
|
199 | 201 | }
|
200 |
| - if (RuntimeInformation.IsOSPlatform(OSPlatform.Create("FREEBSD"))) |
| 202 | + if (System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(System.Runtime.InteropServices.OSPlatform.Create("FREEBSD"))) |
201 | 203 | {
|
202 | 204 | return Platform.FreeBSD;
|
203 | 205 | }
|
204 | 206 |
|
205 | 207 | return Platform.Unknown;
|
| 208 | +#else |
| 209 | + return Platform.Windows; |
| 210 | +#endif |
206 | 211 | }
|
207 | 212 | }
|
208 | 213 | }
|
0 commit comments