Skip to content

Commit a80c8b4

Browse files
Use conditional namespace to avoid CS0436 type conflicts
Co-authored-by: eiriktsarpalis <2813363+eiriktsarpalis@users.noreply.github.com>
1 parent 1213ce8 commit a80c8b4

3 files changed

Lines changed: 7 additions & 4 deletions

File tree

src/ModelContextProtocol.Core/Server/InMemoryMcpTaskStore.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@
33
using System.Diagnostics.CodeAnalysis;
44
using System.Text.Json;
55

6+
#if MCP_TEST_TIME_PROVIDER
7+
namespace ModelContextProtocol.Tests.Internal;
8+
#else
69
namespace ModelContextProtocol;
10+
#endif
711

812
/// <summary>
913
/// Provides an in-memory implementation of <see cref="IMcpTaskStore"/> for development and testing.

tests/ModelContextProtocol.Tests/ModelContextProtocol.Tests.csproj

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@
1010
<IsTestProject>true</IsTestProject>
1111
<RootNamespace>ModelContextProtocol.Tests</RootNamespace>
1212
<!-- https://github.com/dotnet/sdk/issues/51060 -->
13-
<!-- CS0436: InMemoryMcpTaskStore.cs is linked to enable TimeProvider support for testing.
14-
This shadows the type from ModelContextProtocol.Core, causing CS0436 at all usage sites. -->
15-
<NoWarn>$(NoWarn);NU1903;NU1902;CS0436</NoWarn>
13+
<NoWarn>$(NoWarn);NU1903;NU1902</NoWarn>
1614
<!-- Define for conditional TimeProvider support in InMemoryMcpTaskStore -->
1715
<DefineConstants>$(DefineConstants);MCP_TEST_TIME_PROVIDER</DefineConstants>
1816
</PropertyGroup>

tests/ModelContextProtocol.Tests/Server/InMemoryMcpTaskStoreTests.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using ModelContextProtocol.Server;
44
using ModelContextProtocol.Tests.Utils;
55
using System.Text.Json;
6+
using TestInMemoryMcpTaskStore = ModelContextProtocol.Tests.Internal.InMemoryMcpTaskStore;
67

78
namespace ModelContextProtocol.Tests.Server;
89

@@ -1038,7 +1039,7 @@ public async Task ListTasksAsync_KeysetPaginationWorksWithIdenticalTimestamps()
10381039
{
10391040
// Arrange - Use a fake time provider to create tasks with identical timestamps
10401041
var fakeTime = new FakeTimeProvider(DateTimeOffset.UtcNow);
1041-
using var store = new InMemoryMcpTaskStore(
1042+
using var store = new TestInMemoryMcpTaskStore(
10421043
defaultTtl: null,
10431044
maxTtl: null,
10441045
pollInterval: null,

0 commit comments

Comments
 (0)