diff --git a/src/NServiceBus.Metrics.PerformanceCounters.Tests/APIApprovals.cs b/src/NServiceBus.Metrics.PerformanceCounters.Tests/APIApprovals.cs index 2a54f75..2e5dab1 100644 --- a/src/NServiceBus.Metrics.PerformanceCounters.Tests/APIApprovals.cs +++ b/src/NServiceBus.Metrics.PerformanceCounters.Tests/APIApprovals.cs @@ -8,7 +8,7 @@ public class APIApprovals [Test] public void Approve() { - var publicApi = ApiGenerator.GeneratePublicApi(typeof(PerformanceCountersFeature).Assembly); + var publicApi = ApiGenerator.GeneratePublicApi(typeof(PerformanceCountersFeature).Assembly, excludeAttributes: new[] { "System.Runtime.Versioning.TargetFrameworkAttribute" }); Approver.Verify(publicApi); } } \ No newline at end of file diff --git a/src/NServiceBus.Metrics.PerformanceCounters.Tests/ApprovalFiles/APIApprovals.Approve.approved.txt b/src/NServiceBus.Metrics.PerformanceCounters.Tests/ApprovalFiles/APIApprovals.Approve.approved.txt index 51f8702..58d55ca 100644 --- a/src/NServiceBus.Metrics.PerformanceCounters.Tests/ApprovalFiles/APIApprovals.Approve.approved.txt +++ b/src/NServiceBus.Metrics.PerformanceCounters.Tests/ApprovalFiles/APIApprovals.Approve.approved.txt @@ -1,5 +1,4 @@ [assembly: System.Runtime.CompilerServices.InternalsVisibleToAttribute(@"NServiceBus.Metrics.PerformanceCounters.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100D32BC524DCB1205998C155A4F36BF873587D3602822ECD7B49CD775B2E6A006EE6B9164AB2E3103A6A4D1310C6E5C26818A32FE86710141A2D1F02EB564381CD64C88131BCCA478CDB5072F06DB991DE33DAC1C82BAF40D9F61DD6B40300A4673B693B51CD10A8B9B7D8AB64450431FA422514D6DABCAF70DF785B1E4E6E8AAF")] -[assembly: System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.5.2", FrameworkDisplayName=".NET Framework 4.5.2")] namespace NServiceBus.Metrics.PerformanceCounters { [System.AttributeUsageAttribute(System.AttributeTargets.Assembly | System.AttributeTargets.All)] diff --git a/src/NServiceBus.Metrics.PerformanceCounters.Tests/NServiceBus.Metrics.PerformanceCounters.Tests.csproj b/src/NServiceBus.Metrics.PerformanceCounters.Tests/NServiceBus.Metrics.PerformanceCounters.Tests.csproj index addb3b4..b5dc049 100644 --- a/src/NServiceBus.Metrics.PerformanceCounters.Tests/NServiceBus.Metrics.PerformanceCounters.Tests.csproj +++ b/src/NServiceBus.Metrics.PerformanceCounters.Tests/NServiceBus.Metrics.PerformanceCounters.Tests.csproj @@ -1,9 +1,10 @@  - net452 + net452;netcoreapp2.1 true key.snk + true diff --git a/src/NServiceBus.Metrics.PerformanceCounters/NServiceBus.Metrics.PerformanceCounters.csproj b/src/NServiceBus.Metrics.PerformanceCounters/NServiceBus.Metrics.PerformanceCounters.csproj index 533604e..3c84211 100644 --- a/src/NServiceBus.Metrics.PerformanceCounters/NServiceBus.Metrics.PerformanceCounters.csproj +++ b/src/NServiceBus.Metrics.PerformanceCounters/NServiceBus.Metrics.PerformanceCounters.csproj @@ -1,7 +1,7 @@  - net452 + net452;netstandard2.0 true $(SolutionDir)NServiceBus.snk Enables access to performance counters @@ -9,11 +9,6 @@ $(NoWarn);NU5110;NU5111 - - - - - @@ -22,4 +17,14 @@ + + + + + + + + + + \ No newline at end of file diff --git a/src/NServiceBus.Metrics.PerformanceCounters/PerformanceCountersExtensions.cs b/src/NServiceBus.Metrics.PerformanceCounters/PerformanceCountersExtensions.cs index e2c8197..cf0c9a2 100644 --- a/src/NServiceBus.Metrics.PerformanceCounters/PerformanceCountersExtensions.cs +++ b/src/NServiceBus.Metrics.PerformanceCounters/PerformanceCountersExtensions.cs @@ -1,6 +1,5 @@ namespace NServiceBus { - /// /// Exposes windows performance counters configuration on . /// @@ -12,6 +11,12 @@ public static class PerformanceCountersExtensions /// The instance to apply the settings to. public static PerformanceCountersSettings EnableWindowsPerformanceCounters(this EndpointConfiguration endpointConfiguration) { +#if NETSTANDARD + if (!System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(System.Runtime.InteropServices.OSPlatform.Windows)) + { + throw new System.PlatformNotSupportedException("Windows Performance Counters are not supported on this platform."); + } +#endif Guard.AgainstNull(nameof(endpointConfiguration), endpointConfiguration); endpointConfiguration.EnableFeature(); diff --git a/src/NServiceBus.Metrics.PerformanceCounters/PerformanceCountersSettings.cs b/src/NServiceBus.Metrics.PerformanceCounters/PerformanceCountersSettings.cs index fc0033c..52579d9 100644 --- a/src/NServiceBus.Metrics.PerformanceCounters/PerformanceCountersSettings.cs +++ b/src/NServiceBus.Metrics.PerformanceCounters/PerformanceCountersSettings.cs @@ -21,6 +21,12 @@ internal PerformanceCountersSettings(EndpointConfiguration endpointConfiguration /// The SLA to use. Must be greater than . public void EnableSLAPerformanceCounters(TimeSpan sla) { +#if NETSTANDARD + if (!System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(System.Runtime.InteropServices.OSPlatform.Windows)) + { + throw new PlatformNotSupportedException("Windows Performance Counters are not supported on this platform."); + } +#endif Guard.AgainstNegativeAndZero(nameof(sla), sla); endpointConfiguration.GetSettings().Set(SLAMonitoringFeature.EndpointSLAKey, sla);