Skip to content

Commit

Permalink
Add support for AOT compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel15 committed Jan 22, 2024
1 parent 26ea9bb commit 9a44929
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Prometheus.SystemMetrics/Native/WindowsNative.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public class MEMORYSTATUSEX
/// </summary>
public MEMORYSTATUSEX()
{
dwLength = (uint)Marshal.SizeOf(typeof(MEMORYSTATUSEX));
dwLength = (uint)Marshal.SizeOf<MEMORYSTATUSEX>();
}
}
}
5 changes: 3 additions & 2 deletions src/Prometheus.SystemMetrics/Prometheus.SystemMetrics.csproj
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netstandard2.0;net462</TargetFrameworks>
<TargetFrameworks>netstandard2.0;net462;net80</TargetFrameworks>
<Nullable>enable</Nullable>
<LangVersion>latestMajor</LangVersion>
<IsAotCompatible Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net7.0'))">true</IsAotCompatible>
<PackageId>prometheus-net.SystemMetrics</PackageId>
<Product>prometheus-net.SystemMetrics</Product>
<Authors>Daniel Lo Nigro</Authors>
Expand All @@ -30,7 +31,7 @@
<PackageReference Include="System.Diagnostics.PerformanceCounter" Version="8.0.0" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0' Or '$(TargetFramework)' == 'netcoreapp2.1'">
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0' Or '$(TargetFramework)' == 'netcoreapp2.1' Or '$(TargetFramework)' == 'net80'">
<PackageReference Include="Mono.Posix.NETStandard" Version="1.0.0" />
</ItemGroup>

Expand Down
7 changes: 6 additions & 1 deletion src/Prometheus.SystemMetrics/ServiceCollectionExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Microsoft.Extensions.DependencyInjection;
using System.Diagnostics.CodeAnalysis;
using Microsoft.Extensions.DependencyInjection;
using Prometheus.SystemMetrics.Collectors;

namespace Prometheus.SystemMetrics
Expand Down Expand Up @@ -38,7 +39,11 @@ public static IServiceCollection AddSystemMetrics(this IServiceCollection servic
/// Adds a system metric collector to the <see cref="IServiceCollection"/>
/// </summary>
/// <typeparam name="T">Metric to add</typeparam>
#if NET7_0_OR_GREATER
public static IServiceCollection AddSystemMetricCollector<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicConstructors)] T>(this IServiceCollection services)
#else
public static IServiceCollection AddSystemMetricCollector<T>(this IServiceCollection services)
#endif
where T : class, ISystemMetricCollector
{
services.AddSingleton<ISystemMetricCollector, T>();
Expand Down

0 comments on commit 9a44929

Please sign in to comment.