-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Support nullable enum in InputSelect #19506
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
Support nullable enum in InputSelect #19506
Conversation
Thanks for your PR, @GuillaumeNury. |
I have added some tests. Feel free to tell me if anything needs to be added. |
@@ -18,7 +18,7 @@ public abstract class InputBase<TValue> : ComponentBase, IDisposable | |||
private readonly EventHandler<ValidationStateChangedEventArgs> _validationStateChangedHandler; | |||
private bool _previousParsingAttemptFailed; | |||
private ValidationMessageStore _parsingValidationMessages; | |||
private Type _nullableUnderlyingType; | |||
protected Type _nullableUnderlyingType; |
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.
This is a change to the public API surface and would need to go through an API review. This would mean changing this a property and documenting it, and I still don't think we would want to expose this on the API.
A much cheaper option would be to calculate this as a field in the InputSelect<TValue>
type.
public class InputSelect<TValue> : InputBase<TValue>
{
private readonly Type _nullableUnderlyingType = Nullable.GetUnderlyingType(typeof(TValue));
..
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.
Indeed ! I reverted that and used your solution.
a0c4741
to
000d86e
Compare
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 for the PR!
As
BindConverter
supports Nullable enums (here), call it if the underlying type has type of enum.Addresses #13624