Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When the value is null the SerializeObject will throw NullReferenceException #248

Open
Mutuduxf opened this issue Oct 30, 2023 · 4 comments

Comments

@Mutuduxf
Copy link

Mutuduxf commented Oct 30, 2023

Because SerializeObject is merely a wrapper around Serialize, the type information is obtained by calling value.GetType(). This is not how json serializers are typically used. (Perhaps I do not have enough experience.)

@rpgmaker
Copy link
Owner

The serialization should does not handle null checks at the moment since it is deferring the usage to the caller. But thanks for mentioning this, I can put a null check in place to avoid the exception.

@rpgmaker
Copy link
Owner

@Mutuduxf , I have pushed the changes to version 1.4.4. Please test again and reopen if it is still an issue. Thanks

@Mutuduxf
Copy link
Author

Mutuduxf commented Apr 2, 2024

@Mutuduxf , I have pushed the changes to version 1.4.4. Please test again and reopen if it is still an issue. Thanks

Hi, @rpgmaker , Thanks for your great work. I upgraded to 1.4.4 and tested it, but something interesting has happened. The new code can pass in Net Core, but Framework 4.8 cannot. I have decompiled the dll file from the nuget package (version 1.4.4, net 6.0) and found that there is no new code in it (but it can pass the test in net core!).
So I debug the unit test code and step into the source code from NetJson (IDE Rider). In Framework 4.8, there is no new code in it (determine whether it is null in the method SerializeObject), so it cannot pass the tests. But in Net Core, there is an error in the code line positioning (it feels like the problem is with the pdb file).
Finally, to verify if there is a problem with my development environment, I launch it in Visual Studio and try it again, and the test results are the same.
I am sorry, I am not the collaborator, so I cannot reopen this issue.

@rpgmaker
Copy link
Owner

rpgmaker commented Apr 2, 2024

That is strange. I wonder if I did not copy the assembly correctly from my machine. I will check it tomorrow. Thanks

@rpgmaker rpgmaker reopened this Apr 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants