Skip to content

Commit 57b4a93

Browse files
Copilotstephentoub
andcommitted
Update McpJsonUtilitiesTests to reflect new anonymous type support
- Updated test to verify that DefaultOptions now supports anonymous types unconditionally - Test reflects that DefaultJsonTypeInfoResolver is always added to support user-defined types Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
1 parent 6a070b3 commit 57b4a93

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

tests/ModelContextProtocol.Tests/McpJsonUtilitiesTests.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,15 @@ public static void DefaultOptions_IsSingleton()
1818
}
1919

2020
[Fact]
21-
public static void DefaultOptions_UseReflectionWhenEnabled()
21+
public static void DefaultOptions_SupportsAnonymousTypes()
2222
{
23+
// DefaultOptions includes a fallback DefaultJsonTypeInfoResolver to support
24+
// serialization of user-defined types including anonymous types, regardless
25+
// of the IsReflectionEnabledByDefault setting.
2326
var options = McpJsonUtilities.DefaultOptions;
2427
Type anonType = new { Id = 42 }.GetType();
2528

26-
Assert.Equal(JsonSerializer.IsReflectionEnabledByDefault, options.TryGetTypeInfo(anonType, out _));
29+
Assert.True(options.TryGetTypeInfo(anonType, out _));
2730
}
2831

2932
[Fact]

0 commit comments

Comments
 (0)