-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
NotSupportedException when Deserializing object that has default values for constructor parameters #30854
Comments
This is a known limitation of the built-in serializer and requires a feature to support custom ctors. The fact that the custom ctor has default parameters and semantically can be thought of as being parameter-less doesn't affect the serializer logic (which only looks at the ctor that takes 0 arguments). cc @steveharter |
cc @layomia PTAL along with similar support for probing for collection ctors (typically immutable) |
Closing as duplicate of https://github.com/dotnet/corefx/issues/38569 which considers parameterless/custom constructor support. We shouldn't do any unguided probing here - the constructor to use should be explicitly marked with an attribute. |
Hello i have the same error message , and i can't deserialize even if i put a parameterless constructor !
The error trace is the following;
|
The following code throws exception.
Response class is considered not having a parameterless constructor, but actually it does use default values for parameters, that can be used just like a parameterless constructor, like this:
Could the new JSON API check if the constructor parameters have default values before consider it not paremeterless?
Related Issues:
https://github.com/dotnet/corefx/issues/37537
PR:
dotnet/corefx#38061
The text was updated successfully, but these errors were encountered: