Skip to content

Commit 86ceafd

Browse files
committed
make a test compatible with runtime async.
1 parent 8b1621a commit 86ceafd

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

src/libraries/System.Runtime/tests/System.Threading.Tasks.Tests/System.Runtime.CompilerServices/AsyncTaskMethodBuilderTests.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -670,8 +670,12 @@ public void AsyncTaskMethodBuilder_Completed_RemovedFromTracking()
670670
t.Wait();
671671
}
672672

673-
int activeCount = ((dynamic)typeof(Task).GetField("s_currentActiveTasks", BindingFlags.NonPublic | BindingFlags.Static).GetValue(null)).Count;
674-
Assert.InRange(activeCount, 0, 10); // some other tasks may be created by the runtime, so this is just using a reasonably small upper bound
673+
object activeTasks = typeof(Task).GetField("s_currentActiveTasks", BindingFlags.NonPublic | BindingFlags.Static).GetValue(null);
674+
if (activeTasks is not null)
675+
{
676+
int activeCount = ((dynamic)activeTasks).Count;
677+
Assert.InRange(activeCount, 0, 10); // some other tasks may be created by the runtime, so this is just using a reasonably small upper bound
678+
}
675679
}).Dispose();
676680
}
677681

testOut5.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
Determining projects to restore...
2+
Tool 'coverlet.console' (version '6.0.4') was restored. Available commands: coverlet
3+
Tool 'dotnet-reportgenerator-globaltool' (version '5.4.3') was restored. Available commands: reportgenerator
4+
Tool 'microsoft.dotnet.xharness.cli' (version '10.0.0-prerelease.25475.1') was restored. Available commands: xharness
5+
Tool 'microsoft.visualstudio.slngen.tool' (version '12.0.15') was restored. Available commands: slngen
6+
7+
Restore was successful.
8+
All projects are up-to-date for restore.
9+
Determining projects to restore...

0 commit comments

Comments
 (0)