Fixed two reliability issues highlighted by SonarCloud (#44)

This commit is contained in:
Peder Holdgaard Pedersen 2025-03-08 20:21:14 +01:00 • committed by GitHub
commit 967d7a4cc8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 10 additions and 4 deletions

View file

@ -169,9 +169,12 @@ public sealed class StdioServerTransport : TransportBase, IServerTransport
{
_logger.TransportCleaningUp(EndpointName);
_shutdownCts?.Cancel();
_shutdownCts?.Dispose();
_shutdownCts = null;
if (_shutdownCts != null)
{
await _shutdownCts.CancelAsync().ConfigureAwait(false);
_shutdownCts.Dispose();
_shutdownCts = null;
}
if (_readTask != null)
{

View file

@ -5,6 +5,8 @@ using McpDotNet.Server;
using Microsoft.Extensions.Logging;
using Serilog;
namespace McpDotNet.TestServer;
internal static class Program
{
private static ILoggerFactory CreateLoggerFactory()
@ -336,7 +338,7 @@ internal static class Program
Log.Logger.Information("Server started.");
// Run until process is stopped by the client (parent process)
while (true)
while (true) // NOSONAR
{
await Task.Delay(1000);
}

View file

@ -6,6 +6,7 @@
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<AssemblyName>TestServer</AssemblyName>
<RootNamespace>McpDotNet.TestServer</RootNamespace>
</PropertyGroup>
<ItemGroup>