Skip to content

Commit 136755f

Browse files
CopilotMackinnonBuckeiriktsarpalisjeffhandley
authored
Remove obsolete APIs from codebase and standardize MCP diagnostic IDs (#985)
Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: MackinnonBuck <[email protected]> Co-authored-by: eiriktsarpalis <[email protected]> Co-authored-by: Mackinnon Buck <[email protected]> Co-authored-by: jeffhandley <[email protected]> Co-authored-by: Jeff Handley <[email protected]>
1 parent 5385c0d commit 136755f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+663
-2674
lines changed

src/Common/Experimentals.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using System.Diagnostics.CodeAnalysis;
2+
3+
namespace ModelContextProtocol;
4+
5+
/// <summary>
6+
/// Defines diagnostic IDs, Messages, and Urls for APIs annotated with <see cref="ExperimentalAttribute"/>.
7+
/// </summary>
8+
/// <remarks>
9+
/// When an experimental API is associated with an experimental specification, the message
10+
/// should refer to the specification version that introduces the feature and the SEP
11+
/// when available. If there is a SEP associated with the experimental API, the Url should
12+
/// point to the SEP issue.
13+
/// <para>
14+
/// Experimental diagnostic IDs are in the format MCP5###.
15+
/// </para>
16+
/// <para>
17+
/// Diagnostic IDs cannot be reused when experimental API are removed or promoted to stable.
18+
/// This ensures that users do not suppress warnings for new diagnostics with existing
19+
/// suppressions that might be left in place from prior uses of the same diagnostic ID.
20+
/// </para>
21+
/// </remarks>
22+
internal static class Experimentals
23+
{
24+
// public const string Tasks_DiagnosticId = "MCP5001";
25+
// public const string Tasks_Message = "The Tasks feature is experimental within specification version 2025-11-25 and is subject to change. See SEP-1686 for more information.";
26+
// public const string Tasks_Url = "https://github.com/modelcontextprotocol/modelcontextprotocol/issues/1686";
27+
}

src/Common/Obsoletions.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
namespace ModelContextProtocol;
2+
3+
/// <summary>
4+
/// Defines diagnostic IDs, Messages, and Urls for APIs annotated with <see cref="ObsoleteAttribute"/>.
5+
/// </summary>
6+
/// <remarks>
7+
/// When a deprecated API is associated with an specification change, the message
8+
/// should refer to the specification version that introduces the change and the SEP
9+
/// when available. If there is a SEP associated with the experimental API, the Url should
10+
/// point to the SEP issue.
11+
/// <para>
12+
/// Obsolete diagnostic IDs are in the format MCP9###.
13+
/// </para>
14+
/// <para>
15+
/// Diagnostic IDs cannot be reused when obsolete APIs are removed or restored.
16+
/// This ensures that users do not suppress warnings for new diagnostics with existing
17+
/// suppressions that might be left in place from prior uses of the same diagnostic ID.
18+
/// </para>
19+
/// </remarks>
20+
internal static class Obsoletions
21+
{
22+
public const string LegacyTitledEnumSchema_DiagnosticId = "MCP9001";
23+
public const string LegacyTitledEnumSchema_Message = "The EnumSchema and LegacyTitledEnumSchema APIs are deprecated as of specification version 2025-11-25 and will be removed in a future major version. See SEP-1330 for more information.";
24+
public const string LegacyTitledEnumSchema_Url = "https://github.com/modelcontextprotocol/modelcontextprotocol/issues/1330";
25+
}
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
#if !NET
5+
namespace System.Diagnostics.CodeAnalysis;
6+
7+
/// <summary>
8+
/// Indicates that an API is experimental and it may change in the future.
9+
/// </summary>
10+
/// <remarks>
11+
/// This attribute allows call sites to be flagged with a diagnostic that indicates that an experimental
12+
/// feature is used. Authors can use this attribute to ship preview features in their assemblies.
13+
/// </remarks>
14+
[AttributeUsage(AttributeTargets.Assembly |
15+
AttributeTargets.Module |
16+
AttributeTargets.Class |
17+
AttributeTargets.Struct |
18+
AttributeTargets.Enum |
19+
AttributeTargets.Constructor |
20+
AttributeTargets.Method |
21+
AttributeTargets.Property |
22+
AttributeTargets.Field |
23+
AttributeTargets.Event |
24+
AttributeTargets.Interface |
25+
AttributeTargets.Delegate, Inherited = false)]
26+
internal sealed class ExperimentalAttribute : Attribute
27+
{
28+
/// <summary>
29+
/// Initializes a new instance of the <see cref="ExperimentalAttribute"/> class, specifying the ID that the compiler will use
30+
/// when reporting a use of the API the attribute applies to.
31+
/// </summary>
32+
/// <param name="diagnosticId">The ID that the compiler will use when reporting a use of the API the attribute applies to.</param>
33+
public ExperimentalAttribute(string diagnosticId)
34+
{
35+
DiagnosticId = diagnosticId;
36+
}
37+
38+
/// <summary>
39+
/// Gets the ID that the compiler will use when reporting a use of the API the attribute applies to.
40+
/// </summary>
41+
/// <value>The unique diagnostic ID.</value>
42+
/// <remarks>
43+
/// The diagnostic ID is shown in build output for warnings and errors.
44+
/// <para>This property represents the unique ID that can be used to suppress the warnings or errors, if needed.</para>
45+
/// </remarks>
46+
public string DiagnosticId { get; }
47+
48+
/// <summary>
49+
/// Gets or sets an optional message associated with the experimental attribute.
50+
/// </summary>
51+
/// <value>The message that provides additional information about the experimental feature.</value>
52+
/// <remarks>
53+
/// This message can be used to provide more context or guidance about the experimental feature.
54+
/// </remarks>
55+
public string? Message { get; set; }
56+
57+
/// <summary>
58+
/// Gets or sets the URL for corresponding documentation.
59+
/// The API accepts a format string instead of an actual URL, creating a generic URL that includes the diagnostic ID.
60+
/// </summary>
61+
/// <value>The format string that represents a URL to corresponding documentation.</value>
62+
/// <remarks>An example format string is <c>https://contoso.com/obsoletion-warnings/{0}</c>.</remarks>
63+
public string? UrlFormat { get; set; }
64+
}
65+
#endif
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
#if !NET
5+
namespace System;
6+
7+
/// <summary>
8+
/// Marks program elements that are no longer in use.
9+
/// </summary>
10+
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum |
11+
AttributeTargets.Interface | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Delegate,
12+
Inherited = false)]
13+
internal sealed class ObsoleteAttribute : Attribute
14+
{
15+
public ObsoleteAttribute()
16+
{
17+
}
18+
19+
public ObsoleteAttribute(string? message)
20+
{
21+
Message = message;
22+
}
23+
24+
public ObsoleteAttribute(string? message, bool error)
25+
{
26+
Message = message;
27+
IsError = error;
28+
}
29+
30+
public string? Message { get; }
31+
32+
public bool IsError { get; }
33+
34+
public string? DiagnosticId { get; set; }
35+
36+
public string? UrlFormat { get; set; }
37+
}
38+
#endif

src/ModelContextProtocol.Analyzers/Diagnostics.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@
99
namespace ModelContextProtocol.Analyzers;
1010

1111
/// <summary>Provides the diagnostic descriptors used by the assembly.</summary>
12+
/// <remarks>
13+
/// Analyzer diagnostic IDs are in the format MCP### (or MCP1### if ever needed).
14+
/// <para>
15+
/// Diagnostic IDs cannot be reused if an analyzer is removed.
16+
/// This ensures that users do not suppress warnings for new diagnostics with existing
17+
/// suppressions that might be left in place from prior uses of the same diagnostic ID.
18+
/// </para>
19+
/// </remarks>
1220
internal static class Diagnostics
1321
{
1422
public static DiagnosticDescriptor InvalidXmlDocumentation { get; } = new(

src/ModelContextProtocol.Core/Client/IMcpClient.cs

Lines changed: 0 additions & 50 deletions
This file was deleted.

src/ModelContextProtocol.Core/Client/McpClient.Methods.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@ namespace ModelContextProtocol.Client;
1010
/// <summary>
1111
/// Represents an instance of a Model Context Protocol (MCP) client session that connects to and communicates with an MCP server.
1212
/// </summary>
13-
#pragma warning disable CS0618 // Type or member is obsolete
14-
public abstract partial class McpClient : McpSession, IMcpClient
15-
#pragma warning restore CS0618 // Type or member is obsolete
13+
public abstract partial class McpClient : McpSession
1614
{
1715
/// <summary>Creates an <see cref="McpClient"/>, connecting it to the specified server.</summary>
1816
/// <param name="clientTransport">The transport instance used to communicate with the server.</param>

src/ModelContextProtocol.Core/Client/McpClient.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@ namespace ModelContextProtocol.Client;
55
/// <summary>
66
/// Represents an instance of a Model Context Protocol (MCP) client session that connects to and communicates with an MCP server.
77
/// </summary>
8-
#pragma warning disable CS0618 // Type or member is obsolete
9-
public abstract partial class McpClient : McpSession, IMcpClient
10-
#pragma warning restore CS0618 // Type or member is obsolete
8+
public abstract partial class McpClient : McpSession
119
{
1210
/// <summary>
1311
/// Gets the capabilities supported by the connected server.

0 commit comments

Comments
 (0)