Skip to content
This repository was archived by the owner on Jun 5, 2025. It is now read-only.

Fix JsonSerializerOptions#426

Merged
vineeththomasalex merged 1 commit intomainfrom
user/vineeththomasalex/CanaryBug
Aug 12, 2024
Merged

Fix JsonSerializerOptions#426
vineeththomasalex merged 1 commit intomainfrom
user/vineeththomasalex/CanaryBug

Conversation

@vineeththomasalex
Copy link
Contributor

@vineeththomasalex vineeththomasalex commented Aug 9, 2024

Summary of the pull request

Fixes an issue with JsonSerializerOptions caused by this breaking change in .Net8 that is mysteriously not hitting on Dev builds (not just my computer).

References and relevant issues

microsoft/devhome#3573

Detailed description of the pull request / Additional comments

.Net8 requires explicit declaration of TypeInfoResolver in JsonSerializerOptions for complex objects. The failure stack in Canary build was:
*** WARNING: Unable to verify checksum for C:\Program Files\WindowsApps\Microsoft.Windows.DevHomeGitHubExtension.Canary_0.1700.585.0_x64__8wekyb3d8bbwe\System.Text.Json.dll

Child-SP RetAddr Call Site
00 000000c1197bdfd0 00007ffee916b423 KERNELBASE!RaiseException+0x6c
01 000000c1197be0b0 00007ffee916adc9 coreclr!RaiseTheExceptionInternalOnly+0x26b [D:\a_work\1\s\src\coreclr\vm\excep.cpp @ 2795]
02 000000c1197be1c0 00007ffe89695558 coreclr!IL_Throw+0xb9 [D:\a_work\1\s\src\coreclr\vm\jithelpers.cpp @ 4247]
03 000000c1197be320 00007ffedb1c1e96 System_Text_Json!System.Text.Json.ThrowHelper.ThrowInvalidOperationException_JsonSerializerIsReflectionDisabled()+0x48
04 000000c1197be360 00007ffedb1c102c System_Text_Json!System.Text.Json.JsonSerializerOptions.ConfigureForJsonSerializer()+0x36
05 000000c1197be390 00007ffedba1fae1 System_Text_Json!System.Text.Json.JsonSerializer.GetTypeInfo(System.Text.Json.JsonSerializerOptions, System.Type)+0x2c
06 000000c1197be3d0 00007ffedba1ff7b System_Text_Json!System.Text.Json.JsonSerializer.GetTypeInfo[System.__Canon, System.Private.CoreLib]+0x31
07 000000c1197be420 00007ffedb9f9c20 System_Text_Json!System.Text.Json.JsonSerializer.Serialize[[System.__Canon, System.Private.CoreLib]](System.__Canon, System.Text.Json.JsonSerializerOptions)+0x2b
08 000000c1197be460 00007ffeda92fcd0 GitHubExtension!GitHubExtension.Helpers.Json.Stringify[System.__Canon, System.Private.CoreLib]+0x30
09 000000c1197be4a0 00007ffedaa3bedc GitHubExtension!GitHubExtension.DeveloperId.LoginUIPage.UpdateExtensionAdaptiveCard(Microsoft.Windows.DevHome.SDK.IExtensionAdaptiveCard)+0x30
0a 000000c1197be4f0 00007ff819f77503 Microsoft_Windows_DevHome_SDK_Lib!ABI.Microsoft.Windows.DevHome.SDK.IExtensionAdaptiveCardSession.Do_Abi_Initialize_0(IntPtr, IntPtr, IntPtr*)+0x6c

Fixed using the recommended way in breaking change

Validation steps performed

Ran tests, automated and manually. Couldn't repro original bug on Dev build, but this doesn't break anything on Dev build.

PR checklist

@AmelBawa-msft
Copy link
Contributor

LGTM. Consider adding unit test for the generated vs expected JSON to ensure this does not regress in the future.

@vineeththomasalex
Copy link
Contributor Author

vineeththomasalex commented Aug 10, 2024

LGTM. Consider adding unit test for the generated vs expected JSON to ensure this does not regress in the future.

As I understand, this was technically not a regression. The .Net7 breaking change just made it necessary to explicitly declare the TypeInfoResolver property. There is no change in the JSON.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Area-Account-Sign-In Related to authenticating your GitHub account or anything related to sign-in

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Github sign is does not appear in settings or the repo tool

5 participants