Description:
When running tests against an AOT build, calling await VerifyJson(responseBody); fails with:
System.PlatformNotSupportedException : Dynamic code generation is not supported on this platform.
This appears to come from Verify’s default JSON serialization, which relies on dynamic code generation (Emit). That path isn’t available under NativeAOT or trimming.
Repro steps:
- Create a test project referencing Verify.Xunit and Verify.Json.
- Enable AOT:
<PropertyGroup>
<PublishAot>true</PublishAot>
</PropertyGroup>
- Run a test:
[Fact]
public Task Sample()
{
var responseBody = "{\"hello\":\"world\"}";
return VerifyJson(responseBody);
}
- Run under AOT → crash with PlatformNotSupportedException.