-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Improve enum parsing in config binder generator #89823
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
Conversation
|
Tagging subscribers to this area: @dotnet/area-extensions-configuration Issue DetailsFixes #88873
|
tarekgh
left a comment
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.
Thanks @pedrobsaila. LGTM
layomia
left a comment
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.
LGTM, thanks @pedrobsaila! Pls address these comments in a follow up PR if you get a chance.
| EmitBlankLineIfRequired(); | ||
| EmitPrimitiveParseMethod(type); | ||
|
|
||
| if (type.StringParsableTypeKind == StringParsableTypeKind.Enum) |
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 think the parser should not include enum types in the PrimitivesForHelperGen list. The emitter should have minimal/no post-processing of the input data. The SourceGenerationSpec could have a boolean property indicating whether an enum was part of the input graph.
...libraries/Microsoft.Extensions.Configuration.Binder/gen/Helpers/Emitter/CoreBindingHelper.cs
Show resolved
Hide resolved
| parsedValueExpr = $"({typeDisplayString}){Identifier.Enum}.{Identifier.Parse}(typeof({typeDisplayString}), {Identifier.value}, ignoreCase: true)"; | ||
| } | ||
| break; | ||
| return; |
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 should never fall into this case based on other diffs above.
|
Created #89936 to track the follow-up fixes. |
Fixes #88873