feat: Add Native AOT compilation support for LibreHardwareMonitorLib (#2280)
* feat: Add Native AOT compilation support for LibreHardwareMonitorLib - Replace non-generic Marshal.GetDelegateForFunctionPointer with generic versions (NvApi.cs, NvidiaML.cs, OpCode.cs) - Replace non-generic Marshal.PtrToStructure/SizeOf with generic versions (AtiAdlxx.cs, AmdGpu.cs, Ipmi.cs) - Replace reflection-based Mono.Posix calls with direct Syscall for non-NETFRAMEWORK (OpCode.cs) - Add DynamicallyAccessedMembers annotations for trim-safe generic marshaling (MsiCoreLiquidController.cs, WireViewPro2.cs) - Add IsAotCompatible, IsTrimmable, and AOT/trim analyzers to csproj for net8.0+ - All changes maintain full backward compatibility with net472/netstandard2.0 Tested: dotnet publish with PublishAot=true on net10.0 win-x64 succeeds. AOT binary correctly enumerates all hardware and sensors without errors. * feat: Add conditional compilation for .NET 5.0 or greater in various classes * feat: Add AOT test project and update workflows for AOT compilation * Drop test project * NET5_0_OR_GREATER > NET --------- Co-authored-by: PhyxionNL <7643972+PhyxionNL@users.noreply.github.com>
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.IO;
|
||||
using System.IO.Ports;
|
||||
using System.Runtime.InteropServices;
|
||||
@@ -821,7 +822,11 @@ public sealed class WireViewPro2 : Hardware, IPowerMonitor
|
||||
return offset != size ? null : buffer;
|
||||
}
|
||||
|
||||
private T BytesToStructure<T>(byte[] bytes) where T : struct
|
||||
private T BytesToStructure<
|
||||
#if NET
|
||||
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors | DynamicallyAccessedMemberTypes.NonPublicConstructors)]
|
||||
#endif
|
||||
T>(byte[] bytes) where T : struct
|
||||
{
|
||||
var handle = GCHandle.Alloc(bytes, GCHandleType.Pinned);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user