We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent d484266 commit 41776b6Copy full SHA for 41776b6
tracer/test/Datadog.Trace.Tests/Util/StopwatchTests.cs
@@ -23,10 +23,15 @@ public void ComputesCorrectTimespan()
23
sw.Stop();
24
25
// Extract the internal ticks
26
+#if NET6_0_OR_GREATER
27
+ // Since at least .NET 6, Stopwatch.GetRawElapsedTicks is directly exposed as ElapsedTicks
28
+ // and in .NET 10+ the GetRawElapsedTicks method doesn't exist
29
+ var stopwatchTicks = sw.ElapsedTicks;
30
+#else
31
var stopwatchTicks = (long)typeof(Stopwatch)
32
.GetMethod("GetRawElapsedTicks", BindingFlags.Instance | BindingFlags.NonPublic)
33
.Invoke(sw, null);
-
34
+#endif
35
var elapsed = StopwatchHelpers.GetElapsed(stopwatchTicks);
36
37
Assert.Equal(sw.Elapsed, elapsed);
0 commit comments