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
- "Shader warning in 'Hidden/Light2D': implicit truncation of vector type" is thrown when building Universal 2D template
- AI Assistant breaks compilation of packages using System.Runtime.CompilerServices.Unsafe via auto-referencing
- Unity Hub checks the "Documentation" module by default on the 6.4 and 6.5 streams despite that it was unchecked with the previous installs
- Shortcut that toggles between Dopesheet and Curves Views in the Animation Window's Timeline is mislabed
- Property List Items Overlap onto the Property List's top edge when scrolling through a long Property List
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; }
}
```