Skip to content

Commit 63ede02

Browse files
authored
Add netstandard2.0 compatibility to Microsoft.Extensions.Telemetry and dependencies (#6218)
1 parent e79652f commit 63ede02

File tree

4 files changed

+6
-3
lines changed

4 files changed

+6
-3
lines changed

src/Libraries/Microsoft.Extensions.AmbientMetadata.Application/Microsoft.Extensions.AmbientMetadata.Application.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<RootNamespace>Microsoft.Extensions.AmbientMetadata</RootNamespace>
4+
<TargetFrameworks>$(NetCoreTargetFrameworks);netstandard2.0;net462</TargetFrameworks>
45
<Description>Runtime information provider for application-level ambient metadata.</Description>
56
<Workstream>Telemetry</Workstream>
67
</PropertyGroup>

src/Libraries/Microsoft.Extensions.DependencyInjection.AutoActivation/Microsoft.Extensions.DependencyInjection.AutoActivation.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<RootNamespace>Microsoft.Extensions.DependencyInjection</RootNamespace>
4+
<TargetFrameworks>$(NetCoreTargetFrameworks);netstandard2.0;net462</TargetFrameworks>
45
<Description>Extensions to auto-activate registered singletons in the dependency injection system.</Description>
56
<Workstream>Fundamentals</Workstream>
67
</PropertyGroup>

src/Libraries/Microsoft.Extensions.Telemetry/Microsoft.Extensions.Telemetry.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<RootNamespace>Microsoft.Extensions.Diagnostics</RootNamespace>
4+
<TargetFrameworks>$(NetCoreTargetFrameworks);netstandard2.0;net462</TargetFrameworks>
45
<Description>Provides canonical implementations of telemetry abstractions.</Description>
56
<Workstream>Telemetry</Workstream>
67
<!-- disable "Published symbols cannot be deleted to maintain compatibility" because we have different APIs for different TFMs -->

src/Libraries/Microsoft.Extensions.Telemetry/Sampling/RandomProbabilisticSampler.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
using System;
55
using System.Linq;
6-
#if !NETFRAMEWORK
6+
#if !NETFRAMEWORK && !NETSTANDARD
77
using System.Security.Cryptography;
88
#endif
99
using Microsoft.Extensions.Logging;
@@ -22,7 +22,7 @@ internal sealed class RandomProbabilisticSampler : LoggingSampler, IDisposable
2222
{
2323
internal RandomProbabilisticSamplerFilterRule[] LastKnownGoodSamplerRules;
2424

25-
#if NETFRAMEWORK
25+
#if NETFRAMEWORK || NETSTANDARD
2626
private static readonly System.Threading.ThreadLocal<Random> _randomInstance = new(() => new Random());
2727
#endif
2828

@@ -50,7 +50,7 @@ public override bool ShouldSample<TState>(in LogEntry<TState> logEntry)
5050
return true;
5151
}
5252

53-
#if NETFRAMEWORK
53+
#if NETFRAMEWORK || NETSTANDARD
5454
return _randomInstance.Value!.Next(int.MaxValue) < int.MaxValue * probability;
5555
#else
5656
return RandomNumberGenerator.GetInt32(int.MaxValue) < int.MaxValue * probability;

0 commit comments

Comments
 (0)