Closed LeftofZen closed 3 weeks ago
thanks .
You didn't make any changes though?
You didn't make any changes though?
In the next few days, I will submit a new version, which will enable nullable support, and I will do some special unit tests for the issue you raised. Please be patient and wait for a few days.
You didn't make any changes though?
public EnumValueWrapper(Enum value)
{
Debug.Assert(value != null);
Value = value;
var fieldInfo = value.GetType().GetField(value.ToString());
var attr = fieldInfo?.GetCustomAttribute<EnumDisplayNameAttribute>();
DisplayName = attr?.DisplayName ?? value.ToString();
}
This code here: https://github.com/bodong1987/Avalonia.PropertyGrid/blob/5753f10423dba995c37c0ca940971b2130e84a51/PropertyModels/ComponentModel/EnumDisplayNameAttribute.cs#L56
assumes that
GetField
will always return a non-null value. This is not always the case, for example in an enum that does not have a value of 0 in the enum definition, or in general whenvalue
has a value that is not defined in the enum.I believe in this case, setting
DisplayName
tovalue.ToString()
, similar to line 60, would be appropriate here.