Search Issue Tracker
By Design
Votes
1
Found in
2020.3.45f1
2023.1.0b4
2023.2.0a2
Issue ID
UUM-26848
Regression
Yes
Newtonsoft Json doesn't correctly serialize classes inside the Packages folder when in UWP and WebGL Builds
How to reproduce:
- Open the attached project "REMOVE-DATACONTRACT.zip"
- Build the project for UWP
Expected results: "Dictionary Count: 3" is displayed
Actual results: "Dictionary Count: 0" is displayed
Reproducible with: 2020.3.45f1, 2023.1.0a26, 2023.1.0b4, 2023.2.0a2
Not reproducible with: 2021.3.18f1, 2022.2.7f1, 2023.1.0a25
Reproducible on: Windows 10
Add comment
All about bugs
View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.
Latest issues
- Unity CIL Linker fails on Player build when persistent listeners have "<" and ">" in their XML attribute names
- ”Lighting data asset ‘LightingData’ is incompatible with the current Unity version…” warnings are thrown when saving Indoors (URP) and Outdoors (URP) Scenes as Scene Templates
- [iOS] The screen blinks when transitioning from custom to Unity splash screen
- [macOS] ”Ignoring depth surface load action as it is memoryless” warnings are thrown when taking Game View Snapshot
- UI Builder Inspector scrolls back up when changes on an expanded but not fully displayed Inspector tab are saved
Resolution Note:
This is not a bug. This code is doing reflection based serialization. Managed Code stripping cannot track reflection based serialization. The package code must be annotated.
The `[RequiredMember]` attribute is useful here. The following fixes this code.
```
public class AuthorizationCodeRequest
{
[DataMember(Name = "response_type", IsRequired = true)]
public string responseType
{
[RequiredMember]
get
{ return "code"; }
}
[DataMember(Name = "client_id", IsRequired = true)]
public string clientId
{ [RequiredMember] get; [RequiredMember] set; }
[DataMember(Name = "redirect_uri")]
public string redirectUri { [RequiredMember] get; [RequiredMember] set; }
}
```