Skip to content

Commit 0a55c5c

Browse files
Copilotstephentoub
andcommitted
Fix net472 build: use TaskCompletionSource<bool> instead of non-generic TaskCompletionSource in test
The non-generic TaskCompletionSource doesn't exist in .NET Framework 4.7.2 / .NET Standard 2.0. Use TaskCompletionSource<bool> for compatibility. Co-authored-by: stephentoub <[email protected]>
1 parent 9d1fb9f commit 0a55c5c

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

tests/ModelContextProtocol.Tests/Server/McpServerTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1007,15 +1007,15 @@ await transport.SendClientMessageAsync(new JsonRpcNotification
10071007
public async Task RunAsync_WaitsForInFlightHandlersBeforeReturning()
10081008
{
10091009
// Arrange: Create a tool handler that blocks until we release it.
1010-
var handlerStarted = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
1011-
var releaseHandler = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
1010+
var handlerStarted = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);
1011+
var releaseHandler = new TaskCompletionSource<bool>(TaskCreationOptions.RunContinuationsAsynchronously);
10121012
bool handlerCompleted = false;
10131013

10141014
await using var transport = new TestServerTransport();
10151015
var options = CreateOptions(new ServerCapabilities { Tools = new() });
10161016
options.Handlers.CallToolHandler = async (request, ct) =>
10171017
{
1018-
handlerStarted.SetResult();
1018+
handlerStarted.SetResult(true);
10191019
await releaseHandler.Task;
10201020
handlerCompleted = true;
10211021
return new CallToolResult { Content = [new TextContentBlock { Text = "done" }] };
@@ -1046,7 +1046,7 @@ await transport.SendClientMessageAsync(
10461046
_ = Task.Run(async () =>
10471047
{
10481048
await Task.Delay(200, ct);
1049-
releaseHandler.SetResult();
1049+
releaseHandler.SetResult(true);
10501050
}, ct);
10511051

10521052
// Wait for RunAsync to complete.

0 commit comments

Comments
 (0)