Skip to content

Commit

Permalink
removed rando Microsoft.Win32.Registry dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
phillip-haydon committed Nov 27, 2023
1 parent 44575b6 commit 4e22df1
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 29 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
#nullable enable
using System;
using System.Diagnostics;
using System.Linq;
using System.Runtime.InteropServices;
using Microsoft.Win32;

namespace Mindscape.Raygun4Net.EnvironmentProviders
{
Expand Down Expand Up @@ -38,19 +36,7 @@ public static string GetOSInformation()

private static string? GetForWindows()
{
string? productName = null;

var registryKey =
Registry.LocalMachine.OpenSubKey("Software\\Microsoft\\Windows NT\\CurrentVersion");
var result = registryKey?.GetValue("productName") as string;

if (result != null)
{
var osVersion = Environment.OSVersion.VersionString;
productName = $"{result} ({osVersion})";
}

return productName;
return RuntimeInformation.OSDescription;
}

private static string? GetForLinux()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#nullable enable
using System;
using System.Diagnostics;
using System.IO;
using System.Runtime.InteropServices;
using Microsoft.Win32;

namespace Mindscape.Raygun4Net.EnvironmentProviders
{
Expand Down Expand Up @@ -37,18 +37,7 @@ internal static class ProcessorProvider

private static string? GetOnWindows()
{
string? cpuName = null;

var processorNameKey = Registry.LocalMachine.OpenSubKey(@"HARDWARE\DESCRIPTION\System\CentralProcessor\0",
RegistryKeyPermissionCheck.ReadSubTree);

if (processorNameKey != null)
{
cpuName = (string)processorNameKey.GetValue("ProcessorNameString");
processorNameKey.Close();
}

return cpuName;
return Environment.GetEnvironmentVariable("PROCESSOR_IDENTIFIER");
}

private static string? GetOnLinux()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,5 @@
<ItemGroup>
<PackageReference Include="System.Runtime.Serialization.Primitives" Version="4.3.0"/>
<PackageReference Include="System.Management" Version="4.7.0" />
<PackageReference Include="Microsoft.Win32.Registry" Version="4.7.0" />
</ItemGroup>
</Project>

0 comments on commit 4e22df1

Please sign in to comment.