aspnetcore
aspnetcore copied to clipboard
Use JSON source generator in WebApplicationFactory
Use JSON source generator in WebApplicationFactory
Use JSON source generator to deserialize dictionary.
Description
Use JSON source generator to deserialize JSON to prevent InvalidOperationException
in a test project with JsonSerializerIsReflectionEnabledByDefault=false
.
I wasn't sure how to test this without having to add an entirely new test project - happy to add something if someone can give a suggestion on how to go about that in a way that would be acceptable to the team.
Fixes #55586
Thanks for your PR, @martincostello. Someone from the team will get assigned to your PR shortly and we'll get it reviewed.
Just noticed that the old labels were set manually. Why networking, @mkArtakMSFT?
FYI @captainsafia
@martincostello TY for the PR.
We reference the Mvc.Testing package in other tests in the repo (Identity.FunctionalTests, MvcFunctionalTest, for example). We can probably verify whether or not this fix applies by setting the JsonSerializerIsReflectionEnabledByDefault
property in those projects and checking if the change resolves any IOE.
Playing around with Microsoft.AspNetCore.Mvc.FunctionalTests locally I get the following results:
JSON source generator? | JsonSerializerIsReflectionEnabledByDefault | Passed | Failed |
---|---|---|---|
No | true |
1579 | 2 |
No | false |
4 | 1577 |
Yes | true |
1579 | 2 |
Yes | false |
1469 | 112 |
The tests that fail for me regardless of the settings are from AntiforgeryMiddlewareTest
for Works_WithAntiforgeryMetadata_ValidToken
and Works_WithAntiforgeryMetadata_ValidToken_DisableRequestSizeLimits
- I'm not sure why.
The tests that fail for me regardless of the settings are from
AntiforgeryMiddlewareTest
forWorks_WithAntiforgeryMetadata_ValidToken
andWorks_WithAntiforgeryMetadata_ValidToken_DisableRequestSizeLimits
- I'm not sure why.
#55779
@captainsafia Anything more you need me to do here?
/azp run
Azure Pipelines successfully started running 3 pipeline(s).
Mvc.TemplateTests are skipped and OpenAPI test fix is merged. Hopefully this goes through smoothly 🤞🏽
Edit: to that end I'll optimistically set auto-merge on this.
build-ops; CI post-merge failure, but nothing to do with this PR; I'll try and poke some things
(CI failure is about changing "shipped" files inappropriately, which this PR does not even remotely do)
also an unrelated secondary failure about feel failures; I guess CI is having a very bad day