Skip to content

Commit ff5e1dc

Browse files
Copilotstephentoub
andcommitted
Use existing MCPEXP001 diagnostic and add proper pragma warning restore
Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
1 parent 2d5f569 commit ff5e1dc

File tree

8 files changed

+11
-25
lines changed

8 files changed

+11
-25
lines changed

docs/list-of-diagnostics.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,4 @@ If you use experimental APIs, you will get one of the diagnostics shown below. T
2323

2424
| Diagnostic ID | Description |
2525
| :------------ | :---------- |
26-
| `MCPEXP001` | MCP experimental APIs including Tasks and Extensions. Tasks provide a mechanism for asynchronous long-running operations that can be polled for status and results (see [MCP Tasks specification](https://modelcontextprotocol.io/specification/draft/basic/utilities/tasks)). Extensions provide a framework for extending the Model Context Protocol while maintaining interoperability (see [SEP-2133](https://github.com/modelcontextprotocol/modelcontextprotocol/pull/2133)). |
27-
| `MCPEXP002` | Subclassing `McpClient` and `McpServer` is experimental and subject to change. |
26+
| `MCPEXP001` | MCP experimental APIs including Tasks and Extensions. Tasks provide a mechanism for asynchronous long-running operations that can be polled for status and results (see [MCP Tasks specification](https://modelcontextprotocol.io/specification/draft/basic/utilities/tasks)). Extensions provide a framework for extending the Model Context Protocol while maintaining interoperability (see [SEP-2133](https://github.com/modelcontextprotocol/modelcontextprotocol/pull/2133)). |

src/Common/Experimentals.cs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -56,19 +56,4 @@ internal static class Experimentals
5656
/// URL for the experimental MCP Extensions feature.
5757
/// </summary>
5858
public const string Extensions_Url = "https://github.com/modelcontextprotocol/csharp-sdk/blob/main/docs/list-of-diagnostics.md#mcpexp001";
59-
60-
/// <summary>
61-
/// Diagnostic ID for experimental subclassing of McpClient and McpServer.
62-
/// </summary>
63-
public const string Subclassing_DiagnosticId = "MCPEXP002";
64-
65-
/// <summary>
66-
/// Message for experimental subclassing of McpClient and McpServer.
67-
/// </summary>
68-
public const string Subclassing_Message = "Subclassing McpClient and McpServer is experimental and subject to change.";
69-
70-
/// <summary>
71-
/// URL for experimental subclassing of McpClient and McpServer.
72-
/// </summary>
73-
public const string Subclassing_Url = "https://github.com/modelcontextprotocol/csharp-sdk/blob/main/docs/list-of-diagnostics.md#mcpexp002";
7459
}

src/ModelContextProtocol.Core/Client/McpClient.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public abstract partial class McpClient : McpSession
1111
/// <summary>
1212
/// Initializes a new instance of the <see cref="McpClient"/> class.
1313
/// </summary>
14-
[Experimental(Experimentals.Subclassing_DiagnosticId, UrlFormat = Experimentals.Subclassing_Url)]
14+
[Experimental(Experimentals.Tasks_DiagnosticId, UrlFormat = Experimentals.Tasks_Url)]
1515
protected McpClient()
1616
{
1717
}

src/ModelContextProtocol.Core/Client/McpClientImpl.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@
66
namespace ModelContextProtocol.Client;
77

88
/// <inheritdoc/>
9-
#pragma warning disable MCPEXP002 // Subclassing McpClient is experimental
9+
#pragma warning disable MCPEXP001
1010
internal sealed partial class McpClientImpl : McpClient
1111
{
12+
#pragma warning restore MCPEXP001
1213
private static Implementation DefaultImplementation { get; } = new()
1314
{
1415
Name = AssemblyNameHelper.DefaultAssemblyName.Name ?? nameof(McpClient),

src/ModelContextProtocol.Core/Server/DestinationBoundMcpServer.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33

44
namespace ModelContextProtocol.Server;
55

6-
#pragma warning disable MCPEXP002 // Subclassing McpServer is experimental
6+
#pragma warning disable MCPEXP001
77
internal sealed class DestinationBoundMcpServer(McpServerImpl server, ITransport? transport) : McpServer
8-
#pragma warning restore MCPEXP002
8+
#pragma warning restore MCPEXP001
99
{
1010
public override string? SessionId => transport?.SessionId ?? server.SessionId;
1111
public override string? NegotiatedProtocolVersion => server.NegotiatedProtocolVersion;

src/ModelContextProtocol.Core/Server/McpServer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public abstract partial class McpServer : McpSession
1111
/// <summary>
1212
/// Initializes a new instance of the <see cref="McpServer"/> class.
1313
/// </summary>
14-
[Experimental(Experimentals.Subclassing_DiagnosticId, UrlFormat = Experimentals.Subclassing_Url)]
14+
[Experimental(Experimentals.Tasks_DiagnosticId, UrlFormat = Experimentals.Tasks_Url)]
1515
protected McpServer()
1616
{
1717
}

src/ModelContextProtocol.Core/Server/McpServerImpl.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@
99
namespace ModelContextProtocol.Server;
1010

1111
/// <inheritdoc />
12-
#pragma warning disable MCPEXP002 // Subclassing McpServer is experimental
12+
#pragma warning disable MCPEXP001
1313
internal sealed partial class McpServerImpl : McpServer
1414
{
15+
#pragma warning restore MCPEXP001
1516
internal static Implementation DefaultImplementation { get; } = new()
1617
{
1718
Name = AssemblyNameHelper.DefaultAssemblyName.Name ?? nameof(McpServer),

tests/ModelContextProtocol.Tests/Server/McpServerTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -943,9 +943,9 @@ private static async Task InitializeServerAsync(TestServerTransport transport, C
943943
await tcs.Task.WaitAsync(TestConstants.DefaultTimeout, cancellationToken);
944944
}
945945

946-
#pragma warning disable MCPEXP002 // Subclassing McpServer is experimental
946+
#pragma warning disable MCPEXP001
947947
private sealed class TestServerForIChatClient(bool supportsSampling) : McpServer
948-
#pragma warning restore MCPEXP002
948+
#pragma warning restore MCPEXP001
949949
{
950950
public override ClientCapabilities? ClientCapabilities =>
951951
supportsSampling ? new ClientCapabilities { Sampling = new SamplingCapability() } :

0 commit comments

Comments
 (0)