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

Enforce Constructor Call or Add Nullable Returns #1002

Open
AeonSake opened this issue Oct 28, 2024 · 0 comments
Open

Enforce Constructor Call or Add Nullable Returns #1002

AeonSake opened this issue Oct 28, 2024 · 0 comments

Comments

@AeonSake
Copy link

Is your feature request related to a problem? Please describe.
Currently, the IDeserializer.Deserialize<T> methods return null if the parsed string is empty (or whitespaces). However, because the interface description declares the return type as T and not T? it is not immediately obvious that null can even be a valid return value.

Describe the solution you'd like
I would like the deserializer to always enforce the type construction (optionally via a DeserializerBuilder option like WithEnforceConstructorCall() ?), or change the interface return type to T? to make it clear to the user, that null is a possibility.

Describe alternatives you've considered
Override/ignore compiler info/warning and do a null-check on the returned instance regardless.

Additional context
There may be built-in deserializer options I did not see and this might also be possible with custom type converters, object factories, etc. If that is the case, please let me know.

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

3 participants
@AeonSake and others