From aaf65f5e0fea7fbb5c2e8c6b116826b455ea2c5f Mon Sep 17 00:00:00 2001 From: PhyxionNL <7643972+PhyxionNL@users.noreply.github.com> Date: Sat, 20 Dec 2025 14:25:42 +0100 Subject: [PATCH] Add .NET 10 build Also drops WMI provider as this is no longer working with .NET 10. --- .github/workflows/master.yml | 9 +- .github/workflows/pull requests.yml | 9 +- .../LibreHardwareMonitor.csproj | 26 ++-- LibreHardwareMonitor/UI/MainForm.cs | 5 - LibreHardwareMonitor/WMI/Hardware.cs | 35 ----- LibreHardwareMonitor/WMI/IWmiObject.cs | 17 -- LibreHardwareMonitor/WMI/Sensor.cs | 52 ------- LibreHardwareMonitor/WMI/WmiProvider.cs | 145 ------------------ .../LibreHardwareMonitorLib.csproj | 32 ++-- 9 files changed, 51 insertions(+), 279 deletions(-) delete mode 100644 LibreHardwareMonitor/WMI/Hardware.cs delete mode 100644 LibreHardwareMonitor/WMI/IWmiObject.cs delete mode 100644 LibreHardwareMonitor/WMI/Sensor.cs delete mode 100644 LibreHardwareMonitor/WMI/WmiProvider.cs diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index 4cc490a..71ccf17 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -39,13 +39,20 @@ jobs: - name: Build application run: dotnet build LibreHardwareMonitor\LibreHardwareMonitor.csproj -c Release --no-restore -p:Platform=x64 - - name: Publish application + - name: Publish net472 application uses: actions/upload-artifact@v4 with: name: LibreHardwareMonitor path: | bin/Release/net472 + - name: Publish net10.0 application + uses: actions/upload-artifact@v4 + with: + name: LibreHardwareMonitor (.NET 10) + path: | + bin/Release/net10.0-windows + - name: Restore library packages run: dotnet restore LibreHardwareMonitorLib\LibreHardwareMonitorLib.csproj diff --git a/.github/workflows/pull requests.yml b/.github/workflows/pull requests.yml index 90af518..1e6661e 100644 --- a/.github/workflows/pull requests.yml +++ b/.github/workflows/pull requests.yml @@ -39,13 +39,20 @@ jobs: - name: Build application run: dotnet build LibreHardwareMonitor\LibreHardwareMonitor.csproj -c Release --no-restore -p:Platform=x64 - - name: Publish application + - name: Publish net472 application uses: actions/upload-artifact@v4 with: name: LibreHardwareMonitor path: | bin/Release/net472 + - name: Publish net10.0 application + uses: actions/upload-artifact@v4 + with: + name: LibreHardwareMonitor (.NET 10) + path: | + bin/Release/net10.0-windows + - name: Restore library packages run: dotnet restore LibreHardwareMonitorLib\LibreHardwareMonitorLib.csproj diff --git a/LibreHardwareMonitor/LibreHardwareMonitor.csproj b/LibreHardwareMonitor/LibreHardwareMonitor.csproj index 27fc9b3..1934074 100644 --- a/LibreHardwareMonitor/LibreHardwareMonitor.csproj +++ b/LibreHardwareMonitor/LibreHardwareMonitor.csproj @@ -1,11 +1,9 @@ - - true - x64;x86;ARM64 - WinExe - net472 + net472;net10.0-windows + x64;x86;ARM64 + win-x64;win-x86;win-arm64 LibreHardwareMonitor Libre Hardware Monitor LibreHardwareMonitor @@ -17,26 +15,31 @@ ..\bin\$(Configuration)\ latest true - win-x64 + $(NoWarn);WFO1000 + full + none + - - - + + + + - + + AboutBox.cs @@ -54,6 +57,7 @@ InterfacePortForm.cs + AboutBox.cs @@ -71,10 +75,12 @@ InterfacePortForm.cs + + diff --git a/LibreHardwareMonitor/UI/MainForm.cs b/LibreHardwareMonitor/UI/MainForm.cs index 5c3df5d..1b410cf 100644 --- a/LibreHardwareMonitor/UI/MainForm.cs +++ b/LibreHardwareMonitor/UI/MainForm.cs @@ -17,10 +17,8 @@ using Aga.Controls.Tree; using Aga.Controls.Tree.NodeControls; using LibreHardwareMonitor.Hardware; using LibreHardwareMonitor.Hardware.Storage; -using LibreHardwareMonitor.PawnIo; using LibreHardwareMonitor.UI.Themes; using LibreHardwareMonitor.Utilities; -using LibreHardwareMonitor.Wmi; namespace LibreHardwareMonitor.UI; @@ -56,7 +54,6 @@ public sealed partial class MainForm : Form private readonly SystemTray _systemTray; private readonly UnitManager _unitManager; private readonly UpdateVisitor _updateVisitor = new(); - private readonly WmiProvider _wmiProvider; private int _delayCount; private Form _plotForm; @@ -153,7 +150,6 @@ public sealed partial class MainForm : Form treeView.RowHeight = Math.Max(treeView.Font.Height + 1, 18); _gadget = new SensorGadget(_computer, _settings, _unitManager); _gadget.HideShowCommand += HideShowClick; - _wmiProvider = new WmiProvider(_computer); } treeView.ShowNodeToolTips = true; @@ -933,7 +929,6 @@ public sealed partial class MainForm : Form treeView.Invalidate(); _systemTray.Redraw(); _gadget?.Redraw(); - _wmiProvider?.Update(); if (!backgroundUpdater.IsBusy) backgroundUpdater.RunWorkerAsync(); diff --git a/LibreHardwareMonitor/WMI/Hardware.cs b/LibreHardwareMonitor/WMI/Hardware.cs deleted file mode 100644 index da7a4ac..0000000 --- a/LibreHardwareMonitor/WMI/Hardware.cs +++ /dev/null @@ -1,35 +0,0 @@ -// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. -// If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. -// Copyright (C) LibreHardwareMonitor and Contributors. -// Partial Copyright (C) Michael Möller and Contributors. -// All Rights Reserved. - -using System.Management.Instrumentation; -using LibreHardwareMonitor.Hardware; - -namespace LibreHardwareMonitor.Wmi; - -[InstrumentationClass(InstrumentationType.Instance)] -public class Hardware : IWmiObject -{ - #region WMI Exposed - - public string HardwareType { get; } - public string Identifier { get; } - public string Name { get; } - public string Parent { get; } - - #endregion - - public Hardware(IHardware hardware) - { - Name = hardware.Name; - Identifier = hardware.Identifier.ToString(); - HardwareType = hardware.HardwareType.ToString(); - Parent = (hardware.Parent != null) - ? hardware.Parent.Identifier.ToString() - : ""; - } - - public void Update() { } -} \ No newline at end of file diff --git a/LibreHardwareMonitor/WMI/IWmiObject.cs b/LibreHardwareMonitor/WMI/IWmiObject.cs deleted file mode 100644 index ba90b93..0000000 --- a/LibreHardwareMonitor/WMI/IWmiObject.cs +++ /dev/null @@ -1,17 +0,0 @@ -// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. -// If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. -// Copyright (C) LibreHardwareMonitor and Contributors. -// Partial Copyright (C) Michael Möller and Contributors. -// All Rights Reserved. - -namespace LibreHardwareMonitor.Wmi; - -interface IWmiObject -{ - // Both of these get exposed to WMI - string Name { get; } - string Identifier { get; } - - // Not exposed. - void Update(); -} \ No newline at end of file diff --git a/LibreHardwareMonitor/WMI/Sensor.cs b/LibreHardwareMonitor/WMI/Sensor.cs deleted file mode 100644 index 2fb2389..0000000 --- a/LibreHardwareMonitor/WMI/Sensor.cs +++ /dev/null @@ -1,52 +0,0 @@ -// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. -// If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. -// Copyright (C) LibreHardwareMonitor and Contributors. -// Partial Copyright (C) Michael Möller and Contributors. -// All Rights Reserved. - -using System.Management.Instrumentation; -using LibreHardwareMonitor.Hardware; - -namespace LibreHardwareMonitor.Wmi; - -[InstrumentationClass(InstrumentationType.Instance)] -public class Sensor : IWmiObject -{ - private readonly ISensor _sensor; - - #region WMI Exposed - - public string SensorType { get; } - public string Identifier { get; } - public string Parent { get; } - public string Name { get; } - public float Value { get; private set; } - public float Min { get; private set; } - public float Max { get; private set; } - public int Index { get; } - - #endregion - - public Sensor(ISensor sensor) - { - Name = sensor.Name; - Index = sensor.Index; - - SensorType = sensor.SensorType.ToString(); - Identifier = sensor.Identifier.ToString(); - Parent = sensor.Hardware.Identifier.ToString(); - - _sensor = sensor; - } - - public void Update() - { - Value = _sensor.Value ?? 0; - - if (_sensor.Min != null) - Min = (float)_sensor.Min; - - if (_sensor.Max != null) - Max = (float)_sensor.Max; - } -} \ No newline at end of file diff --git a/LibreHardwareMonitor/WMI/WmiProvider.cs b/LibreHardwareMonitor/WMI/WmiProvider.cs deleted file mode 100644 index 94bcfa3..0000000 --- a/LibreHardwareMonitor/WMI/WmiProvider.cs +++ /dev/null @@ -1,145 +0,0 @@ -// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. -// If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/. -// Copyright (C) LibreHardwareMonitor and Contributors. -// Partial Copyright (C) Michael Möller and Contributors. -// All Rights Reserved. - -using System; -using System.Collections.Generic; -using System.Management.Instrumentation; -using LibreHardwareMonitor.Hardware; - -[assembly: Instrumented("root/LibreHardwareMonitor")] - -[System.ComponentModel.RunInstaller(true)] -public class InstanceInstaller : DefaultManagementProjectInstaller -{ } - -namespace LibreHardwareMonitor.Wmi -{ - /// - /// The WMI Provider. - /// This class is not exposed to WMI itself. - /// - public class WmiProvider : IDisposable - { - private readonly object _activeInstancesLock = new(); - private readonly List _activeInstances; - - public WmiProvider(IComputer computer) - { - _activeInstances = new List(); - foreach (IHardware hardware in computer.Hardware) - OnHardwareAdded(hardware); - - computer.HardwareAdded += OnHardwareAdded; - computer.HardwareRemoved += OnHardwareRemoved; - } - - public void Update() - { - lock (_activeInstancesLock) - { - foreach (IWmiObject instance in _activeInstances) - instance.Update(); - } - } - - private void OnHardwareAdded(IHardware hardware) - { - lock (_activeInstancesLock) - { - if (!_activeInstances.Exists(h => h.Identifier == hardware.Identifier.ToString())) - { - foreach (ISensor sensor in hardware.Sensors) - OnSensorAdded(sensor); - - hardware.SensorAdded += OnSensorAdded; - hardware.SensorRemoved += HardwareSensorRemoved; - - Hardware hw = new(hardware); - _activeInstances.Add(hw); - - try - { - Instrumentation.Publish(hw); - } - catch - { } - } - } - - foreach (IHardware subHardware in hardware.SubHardware) - OnHardwareAdded(subHardware); - } - - private void OnSensorAdded(ISensor data) - { - Sensor sensor = new(data); - - lock (_activeInstancesLock) - _activeInstances.Add(sensor); - - try - { - Instrumentation.Publish(sensor); - } - catch - { } - } - - private void OnHardwareRemoved(IHardware hardware) - { - hardware.SensorAdded -= OnSensorAdded; - hardware.SensorRemoved -= HardwareSensorRemoved; - - foreach (ISensor sensor in hardware.Sensors) - HardwareSensorRemoved(sensor); - - foreach (IHardware subHardware in hardware.SubHardware) - OnHardwareRemoved(subHardware); - - RevokeInstance(hardware.Identifier.ToString()); - } - - private void HardwareSensorRemoved(ISensor sensor) - { - RevokeInstance(sensor.Identifier.ToString()); - } - - private void RevokeInstance(string identifier) - { - lock (_activeInstancesLock) - { - int instanceIndex = _activeInstances.FindIndex(item => item.Identifier == identifier); - if (instanceIndex == -1) - return; - - try - { - Instrumentation.Revoke(_activeInstances[instanceIndex]); - } - catch - { } - - _activeInstances.RemoveAt(instanceIndex); - } - } - - public void Dispose() - { - lock (_activeInstancesLock) - { - foreach (IWmiObject instance in _activeInstances) - { - try - { - Instrumentation.Revoke(instance); - } - catch - { } - } - } - } - } -} diff --git a/LibreHardwareMonitorLib/LibreHardwareMonitorLib.csproj b/LibreHardwareMonitorLib/LibreHardwareMonitorLib.csproj index d8f27f9..72fd66b 100644 --- a/LibreHardwareMonitorLib/LibreHardwareMonitorLib.csproj +++ b/LibreHardwareMonitorLib/LibreHardwareMonitorLib.csproj @@ -1,6 +1,8 @@  net472;netstandard2.0;net8.0;net9.0;net10.0 + x64;x86;ARM64 + win-x64;win-x86;win-arm64 LibreHardwareMonitorLib LibreHardwareMonitor true @@ -18,44 +20,46 @@ latest packageicon.png true - x64;x86;ARM64 - win-x64;win-x86;win-arm64 + true $(NoWarn);CA1416 + AnyCPU true false + ..\bin\Debug\$(Platform)\ + ..\bin\Release\$(Platform)\ - - true - + - - - - - - + + + + + + + - - + + + @@ -68,10 +72,12 @@ + True +