-
Notifications
You must be signed in to change notification settings - Fork 549
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix broken tests when running Config Schema Generator on .NET 9 #6312
Fix broken tests when running Config Schema Generator on .NET 9 #6312
Conversation
tests/ConfigurationSchemaGenerator.Tests/ConfigurationSchemaGenerator.Tests.csproj
Outdated
Show resolved
Hide resolved
Hello @bart-vmware, thanks for the contribution. This PR is currently set to target release/9.0-rc.1 which is no longer an active branch. Assuming you are okay with me re-targeting it against |
@joperezr It probably won't work with Can I update this PR to make it compatible with |
We are pretty locked down at this point for release/9.0 branch, so unfortunately wouldn't be able to take this into there. |
Given the above, I'm retargeting this to go against main as the rc.1 branch is frozen anyway. |
src/Tools/ConfigurationSchemaGenerator/ConfigurationSchemaGenerator.csproj
Outdated
Show resolved
Hide resolved
(Sorry for the late response. We were busy locking down for .NET Aspire 9.0, which will be released next week.) |
Instead, always use System.Text.Json v9, even on net8.0.
src/Tools/ConfigurationSchemaGenerator/ConfigurationSchemaGenerator.csproj
Outdated
Show resolved
Hide resolved
Thanks for the PR here @bart-vmware. I've pushed some updates to make this ready for review. I took your suggestion of always using System.Text.Json |
…rator.csproj Co-authored-by: Eric Erhardt <[email protected]>
…d Microsoft.Extensions.Hosting v8.0.1
@eerhardt Thanks for doing the updates, this is basically what I had in mind, so LGTM from me. I've renamed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks
{ | ||
// In System.Text.Json v9, the casing of the new key is not adapted. See https://github.com/dotnet/runtime/issues/108790. | ||
// So instead, remove the existing node and insert a new one with the updated key. | ||
var index = jsonObject.IndexOf(key); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This workaround requires dual lookup if the key is missing, which suggests to me that a JsonObject.TryAdd
method similar to the one in dotnet/runtime#107947 might be necessary.
Is this PR ready to be merged? |
The Microsoft.Extensions.Hosting version used should be based on TFM.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Thanks for the contribution @bart-vmware!
Description
Adapt the Config Schema Generator logic to deal with the breaking change in
System.Text.Json
v9, reported at dotnet/runtime#108790.More specifically, this PR fixes the
JsonNode
handling inside Config Schema Generator to work with STJ v9. The generator project still targets .NET 8, but now references STJ v9 explicitly. Its test project now multi-targets against .NET 8 and 9.Before this PR, the generator and its tests only ran on .NET 8 (referencing STJ v8), which is why there were no test failures.
Checklist
<remarks />
and<code />
elements on your triple slash comments?/cc @eerhardt
Microsoft Reviewers: Open in CodeFlow