Skip to content

Fix Nullable<T>.ToString()#34014

Merged
maumar merged 4 commits intodotnet:mainfrom
ranma42:fix-nullable-tostring
Jul 16, 2024
Merged

Fix Nullable<T>.ToString()#34014
maumar merged 4 commits intodotnet:mainfrom
ranma42:fix-nullable-tostring

Conversation

@ranma42
Copy link
Copy Markdown
Contributor

@ranma42 ranma42 commented Jun 17, 2024

This PR makes most Nullable<T> types have a string representation that is consistent with C#.

Contributes to #33942.

@ranma42
Copy link
Copy Markdown
Contributor Author

ranma42 commented Jun 17, 2024

This does not tackle the issue for bool? (handled in #33940)
This relies on the improvements to COALESCE optimization (specifically #33938) to avoid regressions.

@ranma42 ranma42 changed the title Improve coalesce-related tests Fix Nullable<T>.ToString() Jun 17, 2024
@ranma42 ranma42 force-pushed the fix-nullable-tostring branch 2 times, most recently from 952cdb9 to c069004 Compare June 18, 2024 20:16
@cincuranet cincuranet requested review from cincuranet, maumar and roji June 24, 2024 12:51
@ranma42 ranma42 force-pushed the fix-nullable-tostring branch from c069004 to d397d71 Compare June 24, 2024 15:40
ranma42 added 3 commits July 2, 2024 22:56
The tests were assuming that `Nullable<T>.ToString()` returns `null` when the
target has no value, while in C# it returns the empty string `""`.
Nullable values convert to an empty string.
@ranma42 ranma42 force-pushed the fix-nullable-tostring branch from d397d71 to 991a25c Compare July 2, 2024 20:57
@ranma42
Copy link
Copy Markdown
Contributor Author

ranma42 commented Jul 2, 2024

Rebased to fix merge conflicts and to make commits more readable now that #33938 is merged.

@ranma42 ranma42 marked this pull request as ready for review July 2, 2024 21:50
@maumar maumar enabled auto-merge (squash) July 16, 2024 01:57
@maumar maumar merged commit 61bb028 into dotnet:main Jul 16, 2024
@maumar
Copy link
Copy Markdown
Contributor

maumar commented Jul 16, 2024

Thanks @ranma42 !

@ranma42 ranma42 deleted the fix-nullable-tostring branch July 16, 2024 06:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants