Normalize CallToolResult.StructuredContent to JsonElement? (#1357)

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
Co-authored-by: Stephen Toub <stoub@microsoft.com>
This commit is contained in:
Copilot 2026-02-23 18:04:09 -05:00 • committed by GitHub
commit 0a0a575a3d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -654,11 +654,11 @@ public partial class McpServerToolTests
}
}
private static void AssertMatchesJsonSchema(JsonElement schemaDoc, JsonNode? value)
private static void AssertMatchesJsonSchema(JsonElement schemaDoc, JsonElement? value)
{
JsonSchema schema = JsonSerializer.Deserialize(schemaDoc, JsonContext2.Default.JsonSchema)!;
EvaluationOptions options = new() { OutputFormat = OutputFormat.List };
EvaluationResults results = schema.Evaluate(JsonSerializer.SerializeToElement(value, JsonContext2.Default.JsonNode), options);
EvaluationResults results = schema.Evaluate(value!.Value, options);
if (!results.IsValid)
{
IEnumerable<string> errors = (results.Details ?? [])
@ -670,7 +670,7 @@ public partial class McpServerToolTests
Schema:
{JsonSerializer.Serialize(schema)}
Instance:
{value?.ToJsonString() ?? "null"}
{value?.ToString() ?? "null"}
Errors:
{string.Join(Environment.NewLine, errors)}
""");