Hardcode the source generator in one remaining location and simplify McpJsonUtilities. (#204)
This commit is contained in:
parent
a04cf6a2f5
commit
1c145a5d52
1 changed files with 32 additions and 34 deletions
28
tests/ModelContextProtocol.Tests/McpJsonUtilitiesTests.cs
Normal file
28
tests/ModelContextProtocol.Tests/McpJsonUtilitiesTests.cs
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
using ModelContextProtocol.Utils.Json;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace ModelContextProtocol.Tests;
|
||||
|
||||
public static class McpJsonUtilitiesTests
|
||||
{
|
||||
[Fact]
|
||||
public static void DefaultOptions_IsSingleton()
|
||||
{
|
||||
var options = McpJsonUtilities.DefaultOptions;
|
||||
|
||||
Assert.NotNull(options);
|
||||
Assert.True(options.IsReadOnly);
|
||||
Assert.Same(options, McpJsonUtilities.DefaultOptions);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public static void DefaultOptions_UseReflectionWhenEnabled()
|
||||
{
|
||||
var options = McpJsonUtilities.DefaultOptions;
|
||||
bool isReflectionEnabled = JsonSerializer.IsReflectionEnabledByDefault;
|
||||
Type anonType = new { Id = 42 }.GetType();
|
||||
|
||||
Assert.True(isReflectionEnabled); // To be disabled once https://github.com/dotnet/extensions/pull/6241 is incorporated
|
||||
Assert.Equal(isReflectionEnabled, options.TryGetTypeInfo(anonType, out _));
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue