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

ReadFromJsonAsync with nullable value types enabled makes return type look strange #46431

Closed
Eneuman opened this issue Dec 28, 2020 · 2 comments

Comments

@Eneuman
Copy link

Eneuman commented Dec 28, 2020

Using ReadFromJsonAsync in a nullable value type enabled .Net 5 ASP project has som strange behaviours.

For example: the following code return a MyClass? nullable object:
var problemDetails = await response.Content.ReadFromJsonAsync<MyClass>();

This code returns a int (not nullable) (what happens if it is not a a numeric value in the response):
var result = await response.Content.ReadFromJsonAsync<int>();

But this code returns a nullable string:
var result = await response.Content.ReadFromJsonAsync<string>();
Shouldn't it return a none nullable string and throw if it is null?

@pranavkm pranavkm transferred this issue from dotnet/aspnetcore Dec 28, 2020
@Dotnet-GitSync-Bot Dotnet-GitSync-Bot added the untriaged New issue has not been triaged by the area owner label Dec 28, 2020
@Dotnet-GitSync-Bot
Copy link
Collaborator

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

@layomia
Copy link
Contributor

layomia commented Feb 3, 2021

Triage: consider as part of #1256.

@layomia layomia closed this as completed Feb 3, 2021
@layomia layomia removed the untriaged New issue has not been triaged by the area owner label Feb 3, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Mar 5, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants