Skip to content

Commit 406aab3

Browse files
committed
Undo some commenting
1 parent 479c95c commit 406aab3

File tree

7 files changed

+4
-303
lines changed

7 files changed

+4
-303
lines changed

src/Common/Throw.cs

+1-34
Original file line numberDiff line numberDiff line change
@@ -9,22 +9,6 @@ internal static class Throw
99
// NOTE: Most of these should be replaced with extension statics for the relevant extension
1010
// type as downlevel polyfills once the C# 14 extension everything feature is available.
1111

12-
/// <summary>
13-
/// Throws an <see cref="ArgumentNullException"/> if the specified argument is null.
14-
/// </summary>
15-
/// <param name="arg">The argument to check for null.</param>
16-
/// <param name="parameterName">The name of the parameter being checked. This value is automatically provided by the compiler.</param>
17-
/// <exception cref="ArgumentNullException">Thrown when <paramref name="arg"/> is null.</exception>
18-
/// <example>
19-
/// <code>
20-
/// public void ProcessData(DataObject data)
21-
/// {
22-
/// Throw.IfNull(data); // Throws ArgumentNullException if data is null
23-
///
24-
/// // Process the data
25-
/// }
26-
/// </code>
27-
/// </example>
2812
public static void IfNull([NotNull] object? arg, [CallerArgumentExpression(nameof(arg))] string? parameterName = null)
2913
{
3014
if (arg is null)
@@ -33,23 +17,6 @@ public static void IfNull([NotNull] object? arg, [CallerArgumentExpression(nameo
3317
}
3418
}
3519

36-
/// <summary>
37-
/// Throws an <see cref="ArgumentException"/> if the specified string is null, empty, or consists only of white-space characters.
38-
/// </summary>
39-
/// <param name="arg">The string argument to check.</param>
40-
/// <param name="parameterName">The name of the parameter being checked. This value is automatically provided by the compiler.</param>
41-
/// <exception cref="ArgumentNullException">Thrown when <paramref name="arg"/> is null.</exception>
42-
/// <exception cref="ArgumentException">Thrown when <paramref name="arg"/> is empty or consists only of white-space characters.</exception>
43-
/// <example>
44-
/// <code>
45-
/// public void ProcessMessage(string messageId)
46-
/// {
47-
/// Throw.IfNullOrWhiteSpace(messageId); // Throws if messageId is null, empty, or whitespace
48-
///
49-
/// // Process the message
50-
/// }
51-
/// </code>
52-
/// </example>
5320
public static void IfNullOrWhiteSpace([NotNull] string? arg, [CallerArgumentExpression(nameof(arg))] string? parameterName = null)
5421
{
5522
if (arg is null || arg.AsSpan().IsWhiteSpace())
@@ -71,4 +38,4 @@ private static void ThrowArgumentNullOrWhiteSpaceException(string? parameterName
7138

7239
[DoesNotReturn]
7340
private static void ThrowArgumentNullException(string? parameterName) => throw new ArgumentNullException(parameterName);
74-
}
41+
}

src/ModelContextProtocol/Configuration/McpServerOptionsSetup.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public void Configure(McpServerOptions options)
3131
McpServerPrimitiveCollection<McpServerTool> toolCollection = options.Capabilities?.Tools?.ToolCollection ?? [];
3232
foreach (var tool in serverTools)
3333
{
34-
toolCollection.TryAdd(tool); // Use TryAdd to avoid exceptions if a tool with the same name already exists
34+
toolCollection.TryAdd(tool);
3535
}
3636

3737
if (!toolCollection.IsEmpty)
@@ -48,7 +48,7 @@ public void Configure(McpServerOptions options)
4848
McpServerPrimitiveCollection<McpServerPrompt> promptCollection = options.Capabilities?.Prompts?.PromptCollection ?? [];
4949
foreach (var prompt in serverPrompts)
5050
{
51-
promptCollection.TryAdd(prompt); // Use TryAdd to avoid exceptions if a prompt with the same name already exists
51+
promptCollection.TryAdd(prompt);
5252
}
5353

5454
if (!promptCollection.IsEmpty)

src/ModelContextProtocol/Logging/Log.cs

-196
Original file line numberDiff line numberDiff line change
@@ -229,35 +229,6 @@ public static partial void TransportEndpointEventParseFailed(
229229
string data,
230230
Exception exception);
231231

232-
/// <summary>
233-
/// Logs an error that occurred during JSON-RPC message handling.
234-
/// </summary>
235-
/// <param name="logger">The logger to write the error message to.</param>
236-
/// <param name="endpointName">The name of the endpoint where the error occurred.</param>
237-
/// <param name="messageType">The type name of the message that was being processed.</param>
238-
/// <param name="payload">The serialized JSON content of the message for debugging.</param>
239-
/// <param name="exception">The exception that was thrown during message handling.</param>
240-
/// <remarks>
241-
/// <para>
242-
/// This method logs at Error level (EventId 7008) and captures details about unexpected exceptions
243-
/// that occur during the processing of JSON-RPC messages that aren't handled by more specific
244-
/// error logging methods.
245-
/// </para>
246-
/// <para>
247-
/// Example usage:
248-
/// </para>
249-
/// <code>
250-
/// try
251-
/// {
252-
/// await HandleMessageAsync(message, cancellationToken);
253-
/// }
254-
/// catch (Exception ex) when (ex is not OperationCanceledException)
255-
/// {
256-
/// var payload = JsonSerializer.Serialize(message, McpJsonUtilities.JsonContext.Default.IJsonRpcMessage);
257-
/// _logger.MessageHandlerError(EndpointName, message.GetType().Name, payload, ex);
258-
/// }
259-
/// </code>
260-
/// </remarks>
261232
[LoggerMessage(
262233
EventId = 7008,
263234
Level = LogLevel.Error,
@@ -279,15 +250,6 @@ public static partial void TransportWritingMessageToChannel(
279250
this ILogger logger,
280251
IJsonRpcMessage message);
281252

282-
/// <summary>
283-
/// Logs when a message has been successfully written to a transport channel.
284-
/// </summary>
285-
/// <param name="logger">The logger to write the message to.</param>
286-
/// <remarks>
287-
/// This method logs at Trace level and is primarily used for debugging transport-level
288-
/// message flow. The message contains no parameters and simply indicates that a message
289-
/// was written to the channel.
290-
/// </remarks>
291253
[LoggerMessage(
292254
EventId = 7010,
293255
Level = LogLevel.Trace,
@@ -305,29 +267,6 @@ public static partial void TransportMessageRead(
305267
string endpointName,
306268
string messageType);
307269

308-
/// <summary>
309-
/// Logs a warning when no handler is found for a JSON-RPC request method.
310-
/// </summary>
311-
/// <param name="logger">The logger to write the warning message to.</param>
312-
/// <param name="endpointName">The name of the endpoint that received the request.</param>
313-
/// <param name="method">The method name in the request that has no registered handler.</param>
314-
/// <remarks>
315-
/// <para>
316-
/// This method logs at Warning level (EventId 7012) when a JSON-RPC request is received
317-
/// but no handler has been registered for the requested method. This typically indicates
318-
/// a client is requesting a capability that the server doesn't support.
319-
/// </para>
320-
/// <para>
321-
/// Example usage:
322-
/// </para>
323-
/// <code>
324-
/// if (!_requestHandlers.TryGetValue(request.Method, out var handler))
325-
/// {
326-
/// _logger.NoHandlerFoundForRequest(EndpointName, request.Method);
327-
/// throw new McpException("The method does not exist or is not available.", ErrorCodes.MethodNotFound);
328-
/// }
329-
/// </code>
330-
/// </remarks>
331270
[LoggerMessage(
332271
EventId = 7012,
333272
Level = LogLevel.Warning,
@@ -338,29 +277,6 @@ public static partial void NoHandlerFoundForRequest(
338277
string endpointName,
339278
string method);
340279

341-
/// <summary>
342-
/// Logs at trace level when a response message has been successfully matched to a pending request by its message ID.
343-
/// </summary>
344-
/// <param name="logger">The logger to write the trace message to.</param>
345-
/// <param name="endpointName">The name of the endpoint that received the response message.</param>
346-
/// <param name="messageId">The unique identifier of the message that was matched to a pending request.</param>
347-
/// <remarks>
348-
/// <para>
349-
/// This method logs at Trace level (EventId 7013) when the JSON-RPC message correlation system
350-
/// successfully identifies a response message that corresponds to a previously sent request.
351-
/// This is part of the request/response tracking mechanism in the MCP framework.
352-
/// </para>
353-
/// <para>
354-
/// Example usage:
355-
/// </para>
356-
/// <code>
357-
/// if (_pendingRequests.TryRemove(messageWithId.Id, out var tcs))
358-
/// {
359-
/// _logger.ResponseMatchedPendingRequest(EndpointName, messageWithId.Id.ToString());
360-
/// tcs.TrySetResult(message);
361-
/// }
362-
/// </code>
363-
/// </remarks>
364280
[LoggerMessage(
365281
EventId = 7013,
366282
Level = LogLevel.Trace,
@@ -371,14 +287,6 @@ public static partial void ResponseMatchedPendingRequest(
371287
string endpointName,
372288
string messageId);
373289

374-
/// <summary>
375-
/// Logs a warning when an endpoint handler receives a message with an unexpected type.
376-
/// This occurs when a message doesn't match any of the expected JSON-RPC message types
377-
/// (request, notification, or message with ID).
378-
/// </summary>
379-
/// <param name="logger">The logger to use.</param>
380-
/// <param name="endpointName">The name of the endpoint that received the message.</param>
381-
/// <param name="messageType">The type name of the unexpected message.</param>
382290
[LoggerMessage(
383291
EventId = 7014,
384292
Level = LogLevel.Warning,
@@ -389,28 +297,6 @@ public static partial void EndpointHandlerUnexpectedMessageType(
389297
string endpointName,
390298
string messageType);
391299

392-
/// <summary>
393-
/// Logs a debug message when a request has been sent and the system is waiting for a response.
394-
/// </summary>
395-
/// <param name="logger">The logger to write the message to.</param>
396-
/// <param name="endpointName">The name of the endpoint the request was sent to.</param>
397-
/// <param name="method">The method name in the request.</param>
398-
/// <param name="id">The ID of the request being tracked.</param>
399-
/// <remarks>
400-
/// <para>
401-
/// This method logs at Debug level and tracks that a request has been successfully sent through
402-
/// the transport layer and the system is now awaiting a response.
403-
/// </para>
404-
/// <para>
405-
/// Example usage:
406-
/// </para>
407-
/// <code>
408-
/// await _transport.SendMessageAsync(request, cancellationToken).ConfigureAwait(false);
409-
///
410-
/// _logger.RequestSentAwaitingResponse(EndpointName, request.Method, request.Id.ToString());
411-
/// var response = await tcs.Task.WaitAsync(cancellationToken).ConfigureAwait(false);
412-
/// </code>
413-
/// </remarks>
414300
[LoggerMessage(
415301
EventId = 7015,
416302
Level = LogLevel.Debug,
@@ -422,35 +308,6 @@ public static partial void RequestSentAwaitingResponse(
422308
string method,
423309
string id);
424310

425-
/// <summary>
426-
/// Logs an error when a server initialization attempt is made while the server is already initializing.
427-
/// </summary>
428-
/// <param name="logger">The logger to write the error message to.</param>
429-
/// <param name="endpointName">The name of the endpoint that is already initializing.</param>
430-
/// <remarks>
431-
/// <para>
432-
/// This method logs at Error level (EventId 7016) when a second attempt is made to initialize
433-
/// a server that is already in the initialization process. This typically occurs when multiple
434-
/// initialization requests are sent to the same server endpoint concurrently.
435-
/// </para>
436-
/// <para>
437-
/// During the initialization sequence, a server can only process one initialization request at a time.
438-
/// Attempting to start initialization when it's already in progress indicates a potential race condition
439-
/// or improper sequencing of client-server communication.
440-
/// </para>
441-
/// <para>
442-
/// Example usage:
443-
/// </para>
444-
/// <code>
445-
/// if (_isInitializing)
446-
/// {
447-
/// _logger.ServerAlreadyInitializing(EndpointName);
448-
/// throw new McpException("Server is already initializing", ErrorCodes.ServerAlreadyInitialized);
449-
/// }
450-
///
451-
/// _isInitializing = true;
452-
/// </code>
453-
/// </remarks>
454311
[LoggerMessage(
455312
EventId = 7016,
456313
Level = LogLevel.Error,
@@ -460,33 +317,6 @@ public static partial void ServerAlreadyInitializing(
460317
this ILogger logger,
461318
string endpointName);
462319

463-
/// <summary>
464-
/// Logs an error that occurs during server initialization.
465-
/// </summary>
466-
/// <param name="logger">The logger to write the error message to.</param>
467-
/// <param name="endpointName">The name of the endpoint where the initialization error occurred.</param>
468-
/// <param name="e">The exception that was thrown during server initialization.</param>
469-
/// <remarks>
470-
/// <para>
471-
/// This method logs at Error level (EventId 7017) when an error occurs during the initialization
472-
/// of a server endpoint. This typically indicates a problem with establishing the initial connection
473-
/// or handshake with the server component.
474-
/// </para>
475-
/// <para>
476-
/// Example usage:
477-
/// </para>
478-
/// <code>
479-
/// try
480-
/// {
481-
/// await InitializeServerAsync(cancellationToken).ConfigureAwait(false);
482-
/// }
483-
/// catch (Exception ex) when (ex is not OperationCanceledException)
484-
/// {
485-
/// _logger.ServerInitializationError(EndpointName, ex);
486-
/// throw;
487-
/// }
488-
/// </code>
489-
/// </remarks>
490320
[LoggerMessage(
491321
EventId = 7017,
492322
Level = LogLevel.Error,
@@ -497,32 +327,6 @@ public static partial void ServerInitializationError(
497327
string endpointName,
498328
Exception e);
499329

500-
/// <summary>
501-
/// Logs at debug level when a POST request to the SSE transport has been accepted by the server.
502-
/// </summary>
503-
/// <param name="logger">The logger to write the debug message to.</param>
504-
/// <param name="endpointName">The name of the endpoint that sent the POST request.</param>
505-
/// <param name="messageId">The unique identifier of the message that was accepted.</param>
506-
/// <remarks>
507-
/// <para>
508-
/// This method logs at Debug level (EventId 7018) when a JSON-RPC message sent via HTTP POST
509-
/// to an SSE endpoint has been accepted by the server. The server responds with "accepted"
510-
/// to indicate that it has received the message and will process it asynchronously.
511-
/// </para>
512-
/// <para>
513-
/// The actual response to the message will be delivered later via the Server-Sent Events (SSE) stream.
514-
/// This logging helps track the asynchronous message flow in the SSE transport implementation.
515-
/// </para>
516-
/// <para>
517-
/// Example usage:
518-
/// </para>
519-
/// <code>
520-
/// if (responseContent.Equals("accepted", StringComparison.OrdinalIgnoreCase))
521-
/// {
522-
/// _logger.SSETransportPostAccepted(EndpointName, messageId);
523-
/// }
524-
/// </code>
525-
/// </remarks>
526330
[LoggerMessage(
527331
EventId = 7018,
528332
Level = LogLevel.Debug,

src/ModelContextProtocol/Protocol/Types/UnsubscribeRequestParams.cs

-24
Original file line numberDiff line numberDiff line change
@@ -17,30 +17,6 @@ namespace ModelContextProtocol.Protocol.Types;
1717
/// for the same resource without causing errors, even if there is no active subscription.
1818
/// </para>
1919
/// </remarks>
20-
/// <example>
21-
/// <code>
22-
/// // First subscribe to a resource
23-
/// await client.SubscribeToResourceAsync("resource://documents/123", cancellationToken);
24-
///
25-
/// // When updates are no longer needed
26-
/// await client.UnsubscribeFromResourceAsync("resource://documents/123", cancellationToken);
27-
///
28-
/// // Server-side handler implementation
29-
/// server.WithUnsubscribeFromResourcesHandler((context, cancellationToken) =>
30-
/// {
31-
/// var resourceUri = context.Params?.Uri;
32-
/// if (!string.IsNullOrEmpty(resourceUri))
33-
/// {
34-
/// // Remove the subscription from the server's tracking system
35-
/// _subscriptionManager.RemoveSubscription(context.ClientId, resourceUri);
36-
/// }
37-
/// return Task.FromResult(new EmptyResult());
38-
/// });
39-
/// </code>
40-
/// </example>
41-
/// <seealso cref="SubscribeRequestParams"/>
42-
/// <seealso cref="ResourceUpdatedNotificationParams"/>
43-
/// <seealso href="https://github.com/modelcontextprotocol/specification/blob/main/schema/">See the schema for details</seealso>
4420
public class UnsubscribeRequestParams : RequestParams
4521
{
4622
/// <summary>

src/ModelContextProtocol/Shared/RequestHandlers.cs

-9
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,6 @@ internal sealed class RequestHandlers : Dictionary<string, Func<JsonRpcRequest,
2828
/// a response object that will be serialized back to the client.
2929
/// </para>
3030
/// </remarks>
31-
/// <example>
32-
/// <code>
33-
/// RequestHandlers.Set(
34-
/// RequestMethods.LoggingSetLevel, // Method name from protocol
35-
/// MyLoggingLevelHandler, // Handler function
36-
/// JsonContext.Default.SetLevelRequestParams, // Request type info
37-
/// JsonContext.Default.EmptyResult); // Response type info
38-
/// </code>
39-
/// </example>
4031
public void Set<TRequest, TResponse>(
4132
string method,
4233
Func<TRequest?, CancellationToken, Task<TResponse>> handler,

0 commit comments

Comments
 (0)