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

Generic Deserialize method should return nullable reference type #669

Closed
rcdailey opened this issue Jan 16, 2022 · 1 comment
Closed

Generic Deserialize method should return nullable reference type #669

rcdailey opened this issue Jan 16, 2022 · 1 comment

Comments

@rcdailey
Copy link

The method IDeserializer.Deserialize<T>() returns just T, but is capable of returning null. So the signature should be:

T? Deserialize<T>(string input);

Without this change, users must invoke this method with a nullable type, like myDeserializer.Deserialize<MyObject?>(theData), which is weird because the fact that this method can return null is part of its contract and an implementation detail, so I shouldn't have to specify a nullable type in the generic parameter.

@EdwardCooke
Copy link
Collaborator

Changing the method return type would introduce a potentially breaking change. At the very least it would most likely introduce a number of compiler warnings for a lot of people. I have been toying with the idea of creating a new entry point in to the platform in the next major release and deprecating the current builders (not remove, just mark them as obsolete). Partly to make the method signatures for both the serializer and deserializer more consistent, but also to make the serializer/deserializer namespace only have a couple of types in it, namely the builders and the actual deserializer/serializer interfaces.

I'm going to close this for now and re-look at it when/if that happens. But we're not going to introduce this kind of change in the current versions.

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