From bef743d6088eaaa9a0a2f8bd144319e89dec8d0d Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 26 Nov 2025 11:10:14 +0000 Subject: [PATCH 1/3] Initial plan From 7f8db4345c04ee6420975ecb3aa5f898a27b58b6 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 26 Nov 2025 11:17:10 +0000 Subject: [PATCH 2/3] Lower analyzer diagnostics from Warning to Info severity Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com> --- .../Diagnostics.cs | 4 ++-- .../XmlToDescriptionGeneratorTests.cs | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/ModelContextProtocol.Analyzers/Diagnostics.cs b/src/ModelContextProtocol.Analyzers/Diagnostics.cs index e2c70412b..57a8f623d 100644 --- a/src/ModelContextProtocol.Analyzers/Diagnostics.cs +++ b/src/ModelContextProtocol.Analyzers/Diagnostics.cs @@ -16,7 +16,7 @@ internal static class Diagnostics title: "Invalid XML documentation for MCP method", messageFormat: "XML comment for method '{0}' is invalid and cannot be processed to generate [Description] attributes.", category: "mcp", - defaultSeverity: DiagnosticSeverity.Warning, + defaultSeverity: DiagnosticSeverity.Info, isEnabledByDefault: true, description: "The XML documentation comment contains invalid XML and cannot be processed to generate Description attributes."); @@ -25,7 +25,7 @@ internal static class Diagnostics title: "MCP method must be partial to generate [Description] attributes", messageFormat: "Method '{0}' has XML documentation that could be used to generate [Description] attributes, but the method is not declared as partial.", category: "mcp", - defaultSeverity: DiagnosticSeverity.Warning, + defaultSeverity: DiagnosticSeverity.Info, isEnabledByDefault: true, description: "Methods with MCP attributes should be declared as partial to allow the source generator to emit Description attributes from XML documentation comments."); } diff --git a/tests/ModelContextProtocol.Analyzers.Tests/XmlToDescriptionGeneratorTests.cs b/tests/ModelContextProtocol.Analyzers.Tests/XmlToDescriptionGeneratorTests.cs index 2439f894f..fe8bec492 100644 --- a/tests/ModelContextProtocol.Analyzers.Tests/XmlToDescriptionGeneratorTests.cs +++ b/tests/ModelContextProtocol.Analyzers.Tests/XmlToDescriptionGeneratorTests.cs @@ -381,7 +381,7 @@ public static string TestMethod(string input) // Should report MCP002 diagnostic var diagnostic = Assert.Single(result.Diagnostics, d => d.Id == "MCP002"); - Assert.Equal(DiagnosticSeverity.Warning, diagnostic.Severity); + Assert.Equal(DiagnosticSeverity.Info, diagnostic.Severity); Assert.Contains("TestMethod", diagnostic.GetMessage()); Assert.Contains("partial", diagnostic.GetMessage()); } @@ -412,7 +412,7 @@ public static string TestMethod(string input) // Should report MCP002 diagnostic because parameter has documentation var diagnostic = Assert.Single(result.Diagnostics, d => d.Id == "MCP002"); - Assert.Equal(DiagnosticSeverity.Warning, diagnostic.Severity); + Assert.Equal(DiagnosticSeverity.Info, diagnostic.Severity); } [Fact] @@ -441,7 +441,7 @@ public static string TestMethod(string input) // Should report MCP002 diagnostic because return has documentation var diagnostic = Assert.Single(result.Diagnostics, d => d.Id == "MCP002"); - Assert.Equal(DiagnosticSeverity.Warning, diagnostic.Severity); + Assert.Equal(DiagnosticSeverity.Info, diagnostic.Severity); } [Fact] @@ -559,7 +559,7 @@ public static string TestMethod(string input) // Should report MCP002 diagnostic because parameter description would be generated var diagnostic = Assert.Single(result.Diagnostics, d => d.Id == "MCP002"); - Assert.Equal(DiagnosticSeverity.Warning, diagnostic.Severity); + Assert.Equal(DiagnosticSeverity.Info, diagnostic.Severity); } [Fact] @@ -590,7 +590,7 @@ public static string TestPrompt(string input) // Should report MCP002 diagnostic for prompts too var diagnostic = Assert.Single(result.Diagnostics, d => d.Id == "MCP002"); - Assert.Equal(DiagnosticSeverity.Warning, diagnostic.Severity); + Assert.Equal(DiagnosticSeverity.Info, diagnostic.Severity); } [Fact] @@ -621,7 +621,7 @@ public static string TestResource(string input) // Should report MCP002 diagnostic for resources too var diagnostic = Assert.Single(result.Diagnostics, d => d.Id == "MCP002"); - Assert.Equal(DiagnosticSeverity.Warning, diagnostic.Severity); + Assert.Equal(DiagnosticSeverity.Info, diagnostic.Severity); } [Fact] @@ -721,9 +721,9 @@ partial class TestTools AssertGeneratedSourceEquals(expected, result.GeneratedSources[0].SourceText.ToString()); - // Should report a warning diagnostic + // Should report an info diagnostic var diagnostic = Assert.Single(result.Diagnostics, d => d.Id == "MCP001"); - Assert.Equal(DiagnosticSeverity.Warning, diagnostic.Severity); + Assert.Equal(DiagnosticSeverity.Info, diagnostic.Severity); Assert.Contains("invalid", diagnostic.GetMessage(), StringComparison.OrdinalIgnoreCase); } From dc5a2db76f187d4df3242f62b6ba10502e4432f3 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 26 Nov 2025 14:06:16 +0000 Subject: [PATCH 3/3] MCP001: Keep Warning severity, only report for partial methods Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com> --- .../Diagnostics.cs | 2 +- .../XmlToDescriptionGenerator.cs | 17 ++++++++++------- .../XmlToDescriptionGeneratorTests.cs | 4 ++-- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/ModelContextProtocol.Analyzers/Diagnostics.cs b/src/ModelContextProtocol.Analyzers/Diagnostics.cs index 57a8f623d..99f868f88 100644 --- a/src/ModelContextProtocol.Analyzers/Diagnostics.cs +++ b/src/ModelContextProtocol.Analyzers/Diagnostics.cs @@ -16,7 +16,7 @@ internal static class Diagnostics title: "Invalid XML documentation for MCP method", messageFormat: "XML comment for method '{0}' is invalid and cannot be processed to generate [Description] attributes.", category: "mcp", - defaultSeverity: DiagnosticSeverity.Info, + defaultSeverity: DiagnosticSeverity.Warning, isEnabledByDefault: true, description: "The XML documentation comment contains invalid XML and cannot be processed to generate Description attributes."); diff --git a/src/ModelContextProtocol.Analyzers/XmlToDescriptionGenerator.cs b/src/ModelContextProtocol.Analyzers/XmlToDescriptionGenerator.cs index a5dff0c70..0110ac018 100644 --- a/src/ModelContextProtocol.Analyzers/XmlToDescriptionGenerator.cs +++ b/src/ModelContextProtocol.Analyzers/XmlToDescriptionGenerator.cs @@ -72,7 +72,7 @@ private static void Execute(Compilation compilation, ImmutableArray methodsToGenerate = new(methods.Length); foreach (var methodModel in methods) { - var xmlDocs = ExtractXmlDocumentation(methodModel.MethodSymbol, context); + var xmlDocs = ExtractXmlDocumentation(methodModel.MethodSymbol, methodModel.MethodDeclaration, context); // Generate implementation for partial methods. if (methodModel.MethodDeclaration.Modifiers.Any(SyntaxKind.PartialKeyword)) @@ -97,7 +97,7 @@ private static void Execute(Compilation compilation, ImmutableArray d.Id == "MCP001"); - Assert.Equal(DiagnosticSeverity.Info, diagnostic.Severity); + Assert.Equal(DiagnosticSeverity.Warning, diagnostic.Severity); Assert.Contains("invalid", diagnostic.GetMessage(), StringComparison.OrdinalIgnoreCase); }