Skip to content

Commit

Permalink
Simplify platform check.
Browse files Browse the repository at this point in the history
Fixes #4642
  • Loading branch information
Martin Taillefer committed Jan 4, 2024
1 parent 1e5ad82 commit afba67c
Showing 1 changed file with 1 addition and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ private static IServiceCollection AddResourceMonitoringInternal(
#if NETFRAMEWORK
_ = builder.AddWindowsProvider();
#else
if (GetPlatform() == PlatformID.Win32NT)
if (OperatingSystem.IsWindows())
{
_ = builder.AddWindowsProvider();
}
Expand All @@ -77,20 +77,6 @@ private static IServiceCollection AddResourceMonitoringInternal(
return services;
}

#if !NETFRAMEWORK
[ExcludeFromCodeCoverage]
private static PlatformID GetPlatform()
{
var os = Environment.OSVersion;
if (os.Platform != PlatformID.Win32NT && os.Platform != PlatformID.Unix)
{
throw new NotSupportedException("Resource monitoring is not supported on this operating system.");
}

return os.Platform;
}
#endif

private static ResourceMonitorBuilder AddWindowsProvider(this ResourceMonitorBuilder builder)
{
builder.PickWindowsSnapshotProvider();
Expand Down

0 comments on commit afba67c

Please sign in to comment.