-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
jsRuntime.InvokeAsync can't return null as Nullable<Guid> #30366
Comments
Thanks for contacting us. |
We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process. |
This should be closely related to / encountered within #25677. |
I think this issue could be solved by changing this line to use a safe cast instead of pattern matching, which seems to properly handle the conversion to a nullable value type: Should I create a pull request to change it to
? |
@Regenhardt yes, feel free to send us a PR, if you're still interested in this. |
Looks like this issue has been identified as a candidate for community contribution. If you're considering sending a PR for this issue, look for the |
We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process. |
When a result value is null, and the return type is a nullable value type, Convert.ChangeType throws instead of returning the null value. dotnet#30366
@mkArtakMSFT absolutely, I made a PR. I did realize on the way that my initial idea wouldn't work either because |
When a result value is null, and the return type is a nullable value type, Convert.ChangeType throws instead of returning the null value. dotnet#30366
When a result value is null, and the return type is a nullable value type, Convert.ChangeType throws instead of returning the null value. dotnet#30366
When a result value is null, and the return type is a nullable value type, Convert.ChangeType throws instead of returning the null value. dotnet#30366
When a result value is null, and the return type is a nullable value type, Convert.ChangeType throws instead of returning the null value. dotnet#30366
When a result value is null, and the return type is a nullable value type, Convert.ChangeType throws instead of returning the null value. dotnet#30366
Describe the bug
Looks very similar to !10565 :
I'm trying to read a Guid from local storage, so I go
return jsRuntime.InvokeAsync<Guid?>("localStorage.getItem", key);
.When there is a guid, this works fine.
But if there isn't a guid, I get this exception:
System.InvalidCastException: Null object cannot be converted to a value type.
Am I supposed to box my guid or what?
To Reproduce
Make a Blazor WASM project.
Add
jsRuntime.InvokeAsync<Guid?>("localStorage.getItem", key);
somewhere. init of Index.razor should be fine (in my project it happens somewhere 3 levels down asynchronously).Execute.
Exceptions (if any)
Further technical details
dotnet --info
The text was updated successfully, but these errors were encountered: