Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to latest version from upstream #2

Open
wants to merge 47 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
534ba32
Merge pull request #47 from Yellow-Dog-Man/master
Jinjinov Jul 7, 2023
d70e2ce
Version 11.1.0.1
Jul 7, 2023
c528cf0
Updated Readme
Jul 8, 2023
d37cfc0
Update issue templates
Jul 11, 2023
5c009ee
Create MonitorExtended model
Geevo Jul 15, 2023
e3f58f8
Implement code to retrieve data from WmiMonitorID class.
Geevo Jul 15, 2023
ac64a4c
Create RefreshMonitorExtendedList method in main entry point.
Geevo Jul 15, 2023
2636ff4
Add benchmark
Geevo Jul 15, 2023
b36f01e
Renamed function for its actual purpose.
Geevo Jul 15, 2023
fe657c1
Remove MonitorExtended and respective methods
Geevo Jul 16, 2023
cd629bc
Remove RefreshMonitorExtendedList benchmark method
Geevo Jul 16, 2023
02c6a2f
Merge pull request #51 from Geevo/add-wmi-monitor-id-class-info
Jinjinov Jul 16, 2023
d8f7261
Version 11.1.1.0
Jul 16, 2023
03bc575
Update HardwareInfoRetrieval.cs
Geevo Jul 19, 2023
eb06474
Merge pull request #52 from Geevo/patch-1
Jinjinov Jul 19, 2023
33bf9e8
Version 11.1.1.1
Jul 19, 2023
3c8a1f7
Version 11.1.1.1
Jul 19, 2023
4d93c6f
Version 100.0.0.0
Sep 16, 2023
c49749a
Version 100.0.0.0
Sep 16, 2023
77fd4ec
Version 100.0.0.0
Sep 17, 2023
708495f
Version 100.0.0.0
Sep 17, 2023
901a311
Version 100.0.0.0
Sep 17, 2023
48e1f83
Version 100.0.0.1
Nov 30, 2023
a9372d1
Version 100.0.1.0
Dec 8, 2023
b934f96
Version 100.0.1.0
Dec 8, 2023
732b59b
Version 100.0.1.0
Dec 8, 2023
5e34147
Generate documentation when building so that it is included in nuget …
Jan 5, 2024
dd0c159
Merge pull request #60 from andreas-eriksson/add-documentation-in-nuget
Jinjinov Jan 5, 2024
346d6e6
Version 100.0.1.1
Jan 5, 2024
91818eb
Version 100.0.1.1
Jan 5, 2024
8ed57f9
Version 100.0.1.1
Jan 5, 2024
7c5ada6
Version 100.0.1.1
Jan 5, 2024
93778b7
Add Source Link.
Jan 13, 2024
71db8f2
Merge pull request #62 from andreas-eriksson/sourcelink
Jinjinov Jan 14, 2024
e928756
Version 100.1.0.0
Jan 20, 2024
130b450
Version 100.1.0.0
Jinjinov Mar 2, 2024
3e97cc0
Version 100.1.0.0
Mar 2, 2024
e793fb1
Version 100.1.0.1
Jul 5, 2024
b96fd17
Version 100.1.1.0
Aug 28, 2024
c62f9e6
Version 100.1.1.0
Jinjinov Aug 29, 2024
14dc04b
Version 100.1.1.0
Aug 29, 2024
067590d
Version 100.1.1.0
Aug 29, 2024
e49f714
Version 100.1.1.0
Aug 29, 2024
a0e1f39
Version 100.1.1.0
Aug 29, 2024
06a47f5
Version 100.1.1.1
Jinjinov Sep 18, 2024
cb4a549
Version 100.1.1.1
Sep 18, 2024
a381328
Version 101.0.0.0
Sep 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ assignees: ''

### Library version

### OS & OS version
### OS, version, architecture (32 bit / 64 bit)

### Describe the bug
<!--
Expand Down
6 changes: 3 additions & 3 deletions Hardware.Info.Benchmark/Hardware.Info.Benchmark.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<LangVersion>10.0</LangVersion>
<TargetFramework>net8.0</TargetFramework>
<LangVersion>12.0</LangVersion>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.13.5" />
<PackageReference Include="BenchmarkDotNet" Version="0.13.11" />
</ItemGroup>

<ItemGroup>
Expand Down
2 changes: 2 additions & 0 deletions Hardware.Info.Benchmark/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ public class Benchmarks
[Benchmark]
public void RefreshBIOSList() => _hardwareInfo.RefreshBIOSList();
[Benchmark]
public void RefreshComputerSystemList() => _hardwareInfo.RefreshComputerSystemList();
[Benchmark]
public void RefreshCPUList() => _hardwareInfo.RefreshCPUList();
[Benchmark]
public void RefreshDriveList() => _hardwareInfo.RefreshDriveList();
Expand Down
33 changes: 18 additions & 15 deletions Hardware.Info.Test/Edid.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,26 +103,29 @@ static void EDID()

static void Monitor()
{
string resolution = null;
string refreshRate = null;
string edidFile = null;
string? resolution = null;
string? refreshRate = null;
string? edidFile = null;

// Get the display resolution and refresh rate using xrandr
var xrandrProcess = Process.Start(new ProcessStartInfo
Process? xrandrProcess = Process.Start(new ProcessStartInfo
{
FileName = "xrandr",
RedirectStandardOutput = true,
UseShellExecute = false
});

if (xrandrProcess == null)
return;

while (!xrandrProcess.StandardOutput.EndOfStream)
{
string line = xrandrProcess.StandardOutput.ReadLine();
string? line = xrandrProcess.StandardOutput.ReadLine();

if (line.Contains("*"))
if (line?.Contains('*') == true)
{
resolution = line.Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries)[0];
refreshRate = line.Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries)[1];
resolution = line.Split(" ", StringSplitOptions.RemoveEmptyEntries)[0];
refreshRate = line.Split(" ", StringSplitOptions.RemoveEmptyEntries)[1];
break;
}
}
Expand All @@ -131,12 +134,12 @@ static void Monitor()
Console.WriteLine($"Monitor refreshRate: {refreshRate}");

// Look up the EDID file based on the display configuration
var drmDirectory = new DirectoryInfo("/sys/class/drm");
foreach (var cardDirectory in drmDirectory.GetDirectories("card*"))
DirectoryInfo drmDirectory = new("/sys/class/drm");
foreach (DirectoryInfo cardDirectory in drmDirectory.GetDirectories("card*"))
{
foreach (var connectorDirectory in cardDirectory.GetDirectories("card*"))
foreach (DirectoryInfo connectorDirectory in cardDirectory.GetDirectories("card*"))
{
var edidPath = Path.Combine(connectorDirectory.FullName, "edid");
string edidPath = Path.Combine(connectorDirectory.FullName, "edid");

if (File.Exists(edidPath))
{
Expand All @@ -154,11 +157,11 @@ static void Monitor()
// Read the EDID file and extract the manufacturer and model information
if (edidFile != null)
{
var edidBytes = File.ReadAllBytes(edidFile);
byte[] edidBytes = File.ReadAllBytes(edidFile);
if (edidBytes.Length > 0)
{
var manufacturerCode = BitConverter.ToUInt16(edidBytes, 0x08);
var modelCode = BitConverter.ToUInt16(edidBytes, 0x0a);
ushort manufacturerCode = BitConverter.ToUInt16(edidBytes, 0x08);
ushort modelCode = BitConverter.ToUInt16(edidBytes, 0x0a);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions Hardware.Info.Test/Hardware.Info.Test.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<LangVersion>10.0</LangVersion>
<TargetFramework>net8.0</TargetFramework>
<LangVersion>12.0</LangVersion>
<Nullable>enable</Nullable>
</PropertyGroup>

Expand Down
81 changes: 43 additions & 38 deletions Hardware.Info.Test/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,49 +5,58 @@ namespace Hardware.Info.Test
{
class Program
{
static readonly IHardwareInfo _hardwareInfo = new HardwareInfo(useAsteriskInWMI: false);

static void Main(string[] _)
{
_hardwareInfo.RefreshOperatingSystem();
_hardwareInfo.RefreshMemoryStatus();
_hardwareInfo.RefreshBatteryList();
_hardwareInfo.RefreshBIOSList();
_hardwareInfo.RefreshCPUList(includePercentProcessorTime: false);
_hardwareInfo.RefreshDriveList();
_hardwareInfo.RefreshKeyboardList();
_hardwareInfo.RefreshMemoryList();
_hardwareInfo.RefreshMonitorList();
_hardwareInfo.RefreshMotherboardList();
_hardwareInfo.RefreshMouseList();
_hardwareInfo.RefreshNetworkAdapterList(includeBytesPerSec: false, includeNetworkAdapterConfiguration: true);
_hardwareInfo.RefreshPrinterList();
_hardwareInfo.RefreshSoundDeviceList();
_hardwareInfo.RefreshVideoControllerList();
Test(true);

Test(false);
}

static void Test(bool test)
{
IHardwareInfo hardwareInfo = new HardwareInfo(useAsteriskInWMI: test);

hardwareInfo.RefreshOperatingSystem();
hardwareInfo.RefreshMemoryStatus();
hardwareInfo.RefreshBatteryList();
hardwareInfo.RefreshBIOSList();
hardwareInfo.RefreshComputerSystemList();
hardwareInfo.RefreshCPUList(includePercentProcessorTime: test);
hardwareInfo.RefreshDriveList();
hardwareInfo.RefreshKeyboardList();
hardwareInfo.RefreshMemoryList();
hardwareInfo.RefreshMonitorList();
hardwareInfo.RefreshMotherboardList();
hardwareInfo.RefreshMouseList();
hardwareInfo.RefreshNetworkAdapterList(includeBytesPerSec: test, includeNetworkAdapterConfiguration: test);
hardwareInfo.RefreshPrinterList();
hardwareInfo.RefreshSoundDeviceList();
hardwareInfo.RefreshVideoControllerList();

//hardwareInfo.RefreshAll();

Console.WriteLine(_hardwareInfo.OperatingSystem);
Console.WriteLine(hardwareInfo.OperatingSystem);

Console.WriteLine(hardwareInfo.MemoryStatus);

Console.WriteLine(_hardwareInfo.MemoryStatus);
foreach (var hardware in hardwareInfo.BatteryList)
Console.WriteLine(hardware);

foreach (var hardware in _hardwareInfo.BatteryList)
foreach (var hardware in hardwareInfo.BiosList)
Console.WriteLine(hardware);

foreach (var hardware in _hardwareInfo.BiosList)
foreach (var hardware in hardwareInfo.ComputerSystemList)
Console.WriteLine(hardware);

foreach (var cpu in _hardwareInfo.CpuList)
foreach (var cpu in hardwareInfo.CpuList)
{
Console.WriteLine(cpu);

foreach (var cpuCore in cpu.CpuCoreList)
Console.WriteLine(cpuCore);
}

Console.ReadLine();

foreach (var drive in _hardwareInfo.DriveList)
foreach (var drive in hardwareInfo.DriveList)
{
Console.WriteLine(drive);

Expand All @@ -60,37 +69,33 @@ static void Main(string[] _)
}
}

Console.ReadLine();

foreach (var hardware in _hardwareInfo.KeyboardList)
foreach (var hardware in hardwareInfo.KeyboardList)
Console.WriteLine(hardware);

foreach (var hardware in _hardwareInfo.MemoryList)
foreach (var hardware in hardwareInfo.MemoryList)
Console.WriteLine(hardware);

foreach (var hardware in _hardwareInfo.MonitorList)
foreach (var hardware in hardwareInfo.MonitorList)
Console.WriteLine(hardware);

foreach (var hardware in _hardwareInfo.MotherboardList)
foreach (var hardware in hardwareInfo.MotherboardList)
Console.WriteLine(hardware);

foreach (var hardware in _hardwareInfo.MouseList)
foreach (var hardware in hardwareInfo.MouseList)
Console.WriteLine(hardware);

foreach (var hardware in _hardwareInfo.NetworkAdapterList)
foreach (var hardware in hardwareInfo.NetworkAdapterList)
Console.WriteLine(hardware);

foreach (var hardware in _hardwareInfo.PrinterList)
foreach (var hardware in hardwareInfo.PrinterList)
Console.WriteLine(hardware);

foreach (var hardware in _hardwareInfo.SoundDeviceList)
foreach (var hardware in hardwareInfo.SoundDeviceList)
Console.WriteLine(hardware);

foreach (var hardware in _hardwareInfo.VideoControllerList)
foreach (var hardware in hardwareInfo.VideoControllerList)
Console.WriteLine(hardware);

Console.ReadLine();

foreach (var address in HardwareInfo.GetLocalIPv4Addresses(NetworkInterfaceType.Ethernet, OperationalStatus.Up))
Console.WriteLine(address);

Expand Down
4 changes: 4 additions & 0 deletions Hardware.Info/Components/BIOS.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ public class BIOS
/// </summary>
public string Version { get; set; } = string.Empty;

/// <summary>
/// Write all property values to a string
/// </summary>
/// <returns>Each property on a new line</returns>
public override string ToString()
{
return
Expand Down
7 changes: 7 additions & 0 deletions Hardware.Info/Components/Battery.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ public class Battery

private string _batteryStatusDescription = string.Empty;

/// <summary>
/// Battery status description
/// </summary>
public string BatteryStatusDescription
{
get => !string.IsNullOrEmpty(_batteryStatusDescription) ? _batteryStatusDescription : BatteryStatus switch
Expand All @@ -82,6 +85,10 @@ public string BatteryStatusDescription
set => _batteryStatusDescription = value;
}

/// <summary>
/// Write all property values to a string
/// </summary>
/// <returns>Each property on a new line</returns>
public override string ToString()
{
return
Expand Down
7 changes: 7 additions & 0 deletions Hardware.Info/Components/CPU.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,15 @@ public class CPU
/// </summary>
public UInt64 PercentProcessorTime { get; set; }

/// <summary>
/// List of <see cref="CpuCore" />
/// </summary>
public List<CpuCore> CpuCoreList { get; set; } = new List<CpuCore>();

/// <summary>
/// Write all property values to a string
/// </summary>
/// <returns>Each property on a new line</returns>
public override string ToString()
{
return
Expand Down
69 changes: 69 additions & 0 deletions Hardware.Info/Components/ComputerSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
using System;

// https://learn.microsoft.com/en-us/windows/win32/cimwin32prov/win32-computersystemproduct

namespace Hardware.Info
{
/// <summary>
/// WMI class: Win32_ComputerSystemProduct
/// </summary>
public class ComputerSystem
{
/// <summary>
/// Short textual description for the product.
/// </summary>
public string Caption { get; set; } = string.Empty;

/// <summary>
/// Textual description of the product.
/// </summary>
public string Description { get; set; } = string.Empty;

/// <summary>
/// Product identification, such as a serial number on software, a die number on a hardware chip, or (for noncommercial products) a project number.
/// </summary>
public string IdentifyingNumber { get; set; } = string.Empty;

/// <summary>
/// Commonly used product name.
/// </summary>
public string Name { get; set; } = string.Empty;

/// <summary>
/// Product's stock-keeping unit (SKU) information.
/// </summary>
public string SKUNumber { get; set; } = string.Empty;

/// <summary>
/// Universally unique identifier (UUID) for this product. A UUID is a 128-bit identifier that is guaranteed to be different from other generated UUIDs. If a UUID is not available, a UUID of all zeros is used.
/// </summary>
public string UUID { get; set; } = string.Empty;

/// <summary>
/// Name of the product's supplier, or the entity selling the product (the manufacturer, reseller, OEM, and so on).
/// </summary>
public string Vendor { get; set; } = string.Empty;

/// <summary>
/// Product version information.
/// </summary>
public string Version { get; set; } = string.Empty;

/// <summary>
/// Write all property values to a string
/// </summary>
/// <returns>Each property on a new line</returns>
public override string ToString()
{
return
"Caption: " + Caption + Environment.NewLine +
"Description: " + Description + Environment.NewLine +
"IdentifyingNumber: " + IdentifyingNumber + Environment.NewLine +
"Name: " + Name + Environment.NewLine +
"SKUNumber: " + SKUNumber + Environment.NewLine +
"UUID: " + UUID + Environment.NewLine +
"Vendor: " + Vendor + Environment.NewLine +
"Version: " + Version + Environment.NewLine;
}
}
}
4 changes: 4 additions & 0 deletions Hardware.Info/Components/CpuCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ public class CpuCore
/// </summary>
public UInt64 PercentProcessorTime { get; set; }

/// <summary>
/// Write all property values to a string
/// </summary>
/// <returns>Each property on a new line</returns>
public override string ToString()
{
return
Expand Down
Loading