You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When writing wrappers around MudTextField and MudNumericField, it's a bit frustrating that passing a null value to Converter parameter throws, instead of using the DefaultConverter<T>.
The odd thing about it is that if you don't assign this property (that is, you let the default value from the constructor), it does works, so as a consumer I would expect that cleaning this property would return the component to its original converter.
Describe the solution you'd like
I would like it to support passing null values to the property Converter in both MudTextField and MudNumericField components without throwing. Instead, it would use the original value it had at construction (that is: new DefaultConverter<T>()).
I haven't tried to do the actual modification yet, but I think it's just replacing:
_converter=value??thrownew ArgumentNullException(nameof(value));// converter is mandatory at all times
With _converter = value ?? new DefaultConverter<T>().
Also, as a small optimization a public static readonly DefaultConverter<T> Shared field could be added to DefaultConverter<T>, so instead of allocating a converter on each component, we can reuse the same instance.
And modifying documentation API to show they are nullable now.
Have you seen this feature anywhere else?
No response
Describe alternatives you've considered
When writing wrappers of these components for my projects, I could manually assign the new DefaultConverter<T>() to Converter if I don't have any specific converter and want to use the default one.
Pull Request
I would like to do a Pull Request
Code of Conduct
I agree to follow this project's Code of Conduct
The text was updated successfully, but these errors were encountered:
👋 Thanks for wanting to do a PR @Enderlook !
We suggest that you wait for an answer from @MudBlazor/contribution-team @MudBlazor/core-team . Otherwise we can not guarantee that your PR will be merged. As the library grows, we have to be very strict what PRs we can accept.
Hi. Author wants to modify the behavior so that passing a null value would not result in an ArgumentNullException in the Converter parameter. The issue (#6535) you mentioned is just about documenting which fields, arguments, and properties can be null and which cannot. It does not change the actual behavior of the code.
Feature request type
Enhance component
Component name
MudTextField and MudNumericField
Is your feature request related to a problem?
When writing wrappers around
MudTextField
andMudNumericField
, it's a bit frustrating that passing anull
value toConverter
parameter throws, instead of using theDefaultConverter<T>
.The odd thing about it is that if you don't assign this property (that is, you let the default value from the constructor), it does works, so as a consumer I would expect that cleaning this property would return the component to its original converter.
Describe the solution you'd like
I would like it to support passing null values to the property
Converter
in bothMudTextField
andMudNumericField
components without throwing. Instead, it would use the original value it had at construction (that is:new DefaultConverter<T>()
).I haven't tried to do the actual modification yet, but I think it's just replacing:
MudBlazor/src/MudBlazor/Base/MudFormComponent.cs
Line 23 in ffed90e
With
_converter = converter ?? new DefaultConverter<T>()
.MudBlazor/src/MudBlazor/Base/MudFormComponent.cs
Line 88 in ffed90e
With
_converter = value ?? new DefaultConverter<T>()
.Also, as a small optimization a
public static readonly DefaultConverter<T> Shared
field could be added toDefaultConverter<T>
, so instead of allocating a converter on each component, we can reuse the same instance.And modifying documentation API to show they are nullable now.
Have you seen this feature anywhere else?
No response
Describe alternatives you've considered
When writing wrappers of these components for my projects, I could manually assign the
new DefaultConverter<T>()
toConverter
if I don't have any specific converter and want to use the default one.Pull Request
Code of Conduct
The text was updated successfully, but these errors were encountered: