Add production-ready incremental source generator for automatic Description attributes from XML comments (#899)
Co-authored-by: Stephen Toub <stoub@microsoft.com>
This commit is contained in:
parent
83098e7cc0
commit
ad86b53347
1 changed files with 2080 additions and 2 deletions
31
src/ModelContextProtocol.Analyzers/Diagnostics.cs
Normal file
31
src/ModelContextProtocol.Analyzers/Diagnostics.cs
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
using Microsoft.CodeAnalysis;
|
||||
using Microsoft.CodeAnalysis.CSharp;
|
||||
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
||||
using Microsoft.CodeAnalysis.Text;
|
||||
using System.Collections.Immutable;
|
||||
using System.Text;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace ModelContextProtocol.Analyzers;
|
||||
|
||||
/// <summary>Provides the diagnostic descriptors used by the assembly.</summary>
|
||||
internal static class Diagnostics
|
||||
{
|
||||
public static DiagnosticDescriptor InvalidXmlDocumentation { get; } = new(
|
||||
id: "MCP001",
|
||||
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,
|
||||
isEnabledByDefault: true,
|
||||
description: "The XML documentation comment contains invalid XML and cannot be processed to generate Description attributes.");
|
||||
|
||||
public static DiagnosticDescriptor McpMethodMustBePartial { get; } = new(
|
||||
id: "MCP002",
|
||||
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,
|
||||
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.");
|
||||
}
|
||||
Loading…
Reference in a new issue