dropped support for WinForms and .NET 4.7.2. Refactored to modern .NET and C#

This commit is contained in:
2026-06-10 22:41:05 -05:00
parent 193de6059e
commit e23feff44d
235 changed files with 28 additions and 24958 deletions
+2 -2
View File
@@ -629,10 +629,10 @@ public class Computer : IComputer
cancellationToken.ThrowIfCancellationRequested();
_smbios = Measure(startupTrace, "SMBios", () => new SMBios());
if (Software.OperatingSystem.IsWindows8OrGreater)
if (!Software.OperatingSystem.IsUnix)
Measure(startupTrace, "Mutexes.Open", Mutexes.Open);
else
startupTrace?.Skip("Mutexes.Open", "Operating system is older than Windows 8.");
startupTrace?.Skip("Mutexes.Open", "Operating system is not Windows.");
cancellationToken.ThrowIfCancellationRequested();
Measure(startupTrace, "OpCode.Open", OpCode.Open);
+1 -5
View File
@@ -1,4 +1,4 @@
using System;
using System;
using System.Security.AccessControl;
using System.Security.Principal;
using System.Threading;
@@ -32,11 +32,7 @@ internal static class Mutexes
var mutexSecurity = new MutexSecurity();
mutexSecurity.AddAccessRule(worldRule);
#if NETFRAMEWORK
return new Mutex(false, name, out _, mutexSecurity);
#else
return MutexAcl.Create(false, name, out _, mutexSecurity);
#endif
}
catch (UnauthorizedAccessException)
{
+1 -34
View File
@@ -1,4 +1,4 @@
// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.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 <mmoeller@openhardwaremonitor.org> and Contributors.
@@ -7,11 +7,7 @@
using System;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.InteropServices;
#if !NETFRAMEWORK
using Mono.Unix.Native;
#else
using System.Reflection;
#endif
using Windows.Win32;
using Windows.Win32.System.Memory;
@@ -234,30 +230,9 @@ internal static class OpCode
if (Software.OperatingSystem.IsUnix)
{
#if NETFRAMEWORK
Assembly assembly = Assembly.Load("Mono.Posix, Version=2.0.0.0, Culture=neutral, " + "PublicKeyToken=0738eb9f132ed756");
Type sysCall = assembly.GetType("Mono.Unix.Native.Syscall");
MethodInfo mmap = sysCall.GetMethod("mmap");
Type mmapProts = assembly.GetType("Mono.Unix.Native.MmapProts");
object mmapProtsParam = Enum.ToObject(mmapProts,
(int)mmapProts.GetField("PROT_READ").GetValue(null) |
(int)mmapProts.GetField("PROT_WRITE").GetValue(null) |
(int)mmapProts.GetField("PROT_EXEC").GetValue(null));
Type mmapFlags = assembly.GetType("Mono.Unix.Native.MmapFlags");
object mmapFlagsParam = Enum.ToObject(mmapFlags,
(int)mmapFlags.GetField("MAP_ANONYMOUS").GetValue(null) |
(int)mmapFlags.GetField("MAP_PRIVATE").GetValue(null));
if (mmap != null)
_codeBuffer = (IntPtr)mmap.Invoke(null, [IntPtr.Zero, _size, mmapProtsParam, mmapFlagsParam, -1, 0]);
#else
_codeBuffer = Syscall.mmap(IntPtr.Zero, _size,
MmapProts.PROT_READ | MmapProts.PROT_WRITE | MmapProts.PROT_EXEC,
MmapFlags.MAP_ANONYMOUS | MmapFlags.MAP_PRIVATE, -1, 0);
#endif
}
else
{
@@ -281,15 +256,7 @@ internal static class OpCode
if (Software.OperatingSystem.IsUnix)
{
#if NETFRAMEWORK
Assembly assembly = Assembly.Load("Mono.Posix, Version=2.0.0.0, Culture=neutral, " + "PublicKeyToken=0738eb9f132ed756");
Type sysCall = assembly.GetType("Mono.Unix.Native.Syscall");
MethodInfo method = sysCall.GetMethod("munmap");
method?.Invoke(null, [_codeBuffer, _size]);
#else
Syscall.munmap(_codeBuffer, _size);
#endif
}
else
{
@@ -1,4 +1,4 @@
// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.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) Florian K. (Blacktempel)
// All Rights Reserved.
@@ -74,7 +74,7 @@ public sealed class WireViewPro2 : Hardware, IPowerMonitor
{
var devices = new List<WireViewPro2>();
if (!Software.OperatingSystem.IsWindows8OrGreater)
if (Software.OperatingSystem.IsUnix)
{
return devices; //No Linux implementation yet
}
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net472;netstandard2.0;net8.0;net9.0;net10.0</TargetFrameworks>
<TargetFrameworks>netstandard2.0;net8.0;net9.0;net10.0</TargetFrameworks>
<Platforms>x64;x86;ARM64</Platforms>
<RuntimeIdentifiers>win-x64;win-x86;win-arm64;linux-x64;linux-arm64</RuntimeIdentifiers>
<AssemblyName>LibreHardwareMonitorLib</AssemblyName>
@@ -89,7 +89,6 @@
</PackageReference>
<PackageReference Include="RAMSPDToolkit-NDD" Version="1.5.0" />
<PackageReference Include="System.Management" Version="10.0.8" />
<PackageReference Include="System.Memory" Version="4.6.3" Condition="'$(TargetFramework)' == 'net472'" />
<PackageReference Include="System.Threading.AccessControl" Version="10.0.8" />
</ItemGroup>
@@ -1,4 +1,4 @@
// This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.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 <mmoeller@openhardwaremonitor.org> and Contributors.
@@ -20,13 +20,10 @@ public static class OperatingSystem
{
// The operating system doesn't change during execution so let's query it just one time.
PlatformID platform = Environment.OSVersion.Platform;
Version version = Environment.OSVersion.Version;
IsUnix = platform is PlatformID.Unix or PlatformID.MacOSX;
if (Environment.Is64BitOperatingSystem)
Is64Bit = true;
IsWindows8OrGreater = !IsUnix && ((version.Major == 6 && version.Minor >= 2) || version.Major > 6);
}
/// <summary>
@@ -38,9 +35,4 @@ public static class OperatingSystem
/// Gets information about whether the current system is Unix based.
/// </summary>
public static bool IsUnix { get; }
/// <summary>
/// Returns true if the current system is Windows 8 or a more recent Windows version
/// </summary>
public static bool IsWindows8OrGreater { get; }
}