Update MEAI version and add regression test for #601. (#628)

This commit is contained in:
Eirik Tsarpalis 2025-07-16 16:17:49 +03:00 • committed by GitHub
commit 3156818d66
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 24 additions and 1 deletions

View file

@ -3,7 +3,7 @@
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
<System9Version>9.0.5</System9Version>
<System10Version>10.0.0-preview.4.25258.110</System10Version>
<MicrosoftExtensionsAIVersion>9.7.0</MicrosoftExtensionsAIVersion>
<MicrosoftExtensionsAIVersion>9.7.1</MicrosoftExtensionsAIVersion>
</PropertyGroup>
<!-- Product dependencies netstandard -->

View file

@ -563,6 +563,27 @@ public partial class McpServerToolTests
Assert.Null(result.StructuredContent);
}
[Theory]
[InlineData(JsonNumberHandling.Strict)]
[InlineData(JsonNumberHandling.AllowReadingFromString)]
public async Task ToolWithNullableParameters_ReturnsExpectedSchema(JsonNumberHandling nunmberHandling)
{
JsonSerializerOptions options = new(JsonContext2.Default.Options) { NumberHandling = nunmberHandling };
McpServerTool tool = McpServerTool.Create((int? x = 42, DateTimeOffset? y = null) => { }, new() { SerializerOptions = options });
JsonElement expectedSchema = JsonDocument.Parse("""
{
"type": "object",
"properties": {
"x": { "type": ["integer", "null"], "default": 42 },
"y": { "type": ["string", "null"], "format": "date-time", "default": null }
}
}
""").RootElement;
Assert.True(JsonElement.DeepEquals(expectedSchema, tool.ProtocolTool.InputSchema));
}
public static IEnumerable<object[]> StructuredOutput_ReturnsExpectedSchema_Inputs()
{
yield return new object[] { "string" };
@ -695,5 +716,7 @@ public partial class McpServerToolTests
[JsonSerializable(typeof(JsonSchema))]
[JsonSerializable(typeof(List<AIContent>))]
[JsonSerializable(typeof(List<string>))]
[JsonSerializable(typeof(int?))]
[JsonSerializable(typeof(DateTimeOffset?))]
partial class JsonContext2 : JsonSerializerContext;
}