-
Notifications
You must be signed in to change notification settings - Fork 5k
Fix Decimal literal formatting in source generators #93160
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
Fix Decimal literal formatting in source generators #93160
Conversation
Both ConfigurationBinder and Json were not handling decimal values correctly. This shares and updates our workaround method for formatting these.
Tagging subscribers to this area: @dotnet/area-extensions-configuration Issue DetailsFixes #92773 Both ConfigurationBinder and Json were not handling decimal values correctly. This shares and updates our workaround method for formatting these.
|
{ | ||
if (value == null) | ||
{ | ||
return $"default({type.FullyQualifiedName})"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: wouldn't it be preferable to just use null
for the case of nullable types?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am seeing we used null
before.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We used this same default
value before: https://github.com/dotnet/runtime/pull/93160/files#diff-b7da6b90947be2bdebc35f367d9dc2c5bb66dd3be881af8a2d6cbb9c18108a7fL1358
src/libraries/System.Text.Json/tests/Common/TestClasses/TestClasses.Constructor.cs
Outdated
Show resolved
Hide resolved
src/libraries/Common/src/SourceGenerators/CSharpSyntaxUtilities.cs
Outdated
Show resolved
Hide resolved
src/libraries/Common/src/SourceGenerators/CSharpSyntaxUtilities.cs
Outdated
Show resolved
Hide resolved
...libraries/Microsoft.Extensions.Configuration.Binder/tests/Common/ConfigurationBinderTests.cs
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have left a couple of questions. LGTM otherwise.
src/libraries/Common/src/SourceGenerators/CSharpSyntaxUtilities.cs
Outdated
Show resolved
Hide resolved
We might need to service this. Looks like without this we cannot handle enums with default values which is a bit more common than decimal literals. |
/backport to release/8.0-staging |
Started backporting to release/8.0-staging: https://github.com/dotnet/runtime/actions/runs/6660696766 |
Fixes #92773
Both ConfigurationBinder and Json were not handling decimal values correctly. This shares and updates our workaround method for formatting these.