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
/// <summary>/// threats empty string as default(TValue)./// E.g if TValue is a string or a class, it returns null;/// </summary>publicclassInputSelectNullable<TValue>:InputSelect<TValue>whereTValue:class{protectedoverrideboolTryParseValueFromString(string?value,outTValueresult,outstringvalidationErrorMessage){if(string.IsNullOrEmpty(value)){validationErrorMessage="";result=default(TValue);returntrue;}returnbase.TryParseValueFromString(value,outresult!,outvalidationErrorMessage!);}protectedoverridestring?FormatValueAsString(TValue?value){if(value==null){returnstring.Empty;}returnbase.FormatValueAsString(value);}}
However, I'm getting warning CS8601: Possible null reference assignment:
It's because the base method is marked with [MaybeNullWhen(false)] attribute:
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Scenario:
I want to let user to choose "empty" option from an InputSelect, which is represented by null value
I have a project with Enable
Attempt
I've tried to create custom component derived from SelectInput that would parse empty string as null:
However, I'm getting warning CS8601: Possible null reference assignment:

It's because the base method is marked with [MaybeNullWhen(false)] attribute:
Beta Was this translation helpful? Give feedback.
All reactions