Skip to content

Commit ab670e4

Browse files
Replace wildcard pattern with explicit exhaustive pattern
Changed the default wildcard case `_` to an explicit pattern `{ HasId: false, HasMethod: false }` to make the switch expression exhaustive and improve code clarity. All boolean combinations of HasId and HasMethod are now explicitly covered. Co-authored-by: Scooletz <scooletz@users.noreply.github.com> Co-authored-by: eiriktsarpalis <2813363+eiriktsarpalis@users.noreply.github.com> Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com> Co-authored-by: eiriktsarpalis <2813363+eiriktsarpalis@users.noreply.github.com>
1 parent 76def90 commit ab670e4

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/ModelContextProtocol.Core/Protocol/JsonRpcMessage.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,8 @@ public sealed class Converter : JsonConverter<JsonRpcMessage>
124124
Params = union.Params
125125
},
126126

127-
// All other cases are invalid
128-
_ => throw new JsonException("Invalid JSON-RPC message format")
127+
// Messages with neither id nor method are invalid
128+
{ HasId: false, HasMethod: false } => throw new JsonException("Invalid JSON-RPC message format")
129129
};
130130
}
131131

0 commit comments

Comments
 (0)