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
- Out-of-bounds memory access with multiple CanvasRenderers under a Canvas when using Mesh API
- Package signature validation unexpectedly return an invalid signature status if the validation check is done after the code signing certificate validaty range has passed
- Inspector tries to access file after it was deleted when the file was locked in Inspector window
- Changing Transform values in Search window Inspector loses focus while dragging and stopping mouse without releasing dragging action
- Saving changes on the dirty VFX Graph during the Play mode throws "The referenced script (Unknown) on this Behaviour is missing!" warnings
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; }
}
```