Search Issue Tracker
By Design
By Design in 2023.2.X
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
- Cancelling a Package installation leads to invisible compilation errors preventing the user to enter Play Mode when the “Cancel” button is clicked, and does not actually cancel the package install as it appears in the Project after the Editor is restarted
- NullReferenceException occurs when searching presets in “Select Preset” window after selecting a GLTF Importer preset
- Dynamic TMP_Font asset shows up as modified in source control when TextMeshPro text using it is changed
- “Output value ‘outMotionVec’ is not complete” warning logged after creating Canvas Shader Graph Asset
- SVG Image Component loses Source SVG Image field references when upgrading to a different Vector Graphics package version
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; }
}
```
Resolution Note (2023.2.X):
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; }
}
```