Open zd08513 opened 1 year ago
Since i don't know what settings you used for the publish mode, i would like to ask you to narrow down the problem space.
First, in case you use AOT compiling, disable it and see whether the json serialization will start behaving. If not, also disable code trimming for publishing and see whether this will help.
If that doesn't seem to make the code behave either, you'll need to tell us more details about your problem: What is the build/platform target you are publishing for? What are the publish settings you are using? What build environment/tools are you using?
The problem found is the use of 'Obfuscar' plugin caused by the bug
I just had a similar problem, I was using JObject.ToString() and was also getting "{}" as the output. Disabling "Trim unused code" in publish options fixed the problem. Publish options were Release | Any CPU, net7.0, Self-Contained, linux-x64, produce single file
User userInfo = new User { id="11011", name="zhangsan", age=12,sex= false,address= "sicuan" }; Console.WriteLine(userInfo.id); string json=JsonConvert.SerializeObject(userInfo); Console.WriteLine(json);