DataGrid nullable enum filter exception after Publish

Hello,

I've recently updated from v11.4.0 to the latest v12.1.4 and noticed a thing that worked and now stopped working...
If my model contains nullable enum type and the column is filterable the DataGrid will throw exception and won't render:

System.ArgumentException: NotAMemberOfType, Value, <>f__AnonymousType8`2[System.Object,System.String] Arg_ParamName_Name, propertyOrFieldName
   at System.Linq.Expressions.Expression.PropertyOrField(Expression expression, String propertyOrFieldName)
   at Radzen.PropertyAccess.<CreateGetter>g__AccessNoInterface|4_0[Object,Object](Expression instance, String memberName)
   at Radzen.PropertyAccess.<CreateGetter>g__AccessWithNullPropagation|4_2[Object,Object](Expression instance, String memberName)
   at Radzen.PropertyAccess.CreateGetter[Object,Object](String propertyName, Type type, Boolean nullToNull)
   at Radzen.PropertyAccess.<>c__DisplayClass2_0`2[[System.Object, System.Private.CoreLib, Version=10.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.Object, System.Private.CoreLib, Version=10.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].<Getter>b__0(ValueTuple`4 _)
   at System.Collections.Concurrent.ConcurrentDictionary`2[[System.ValueTuple`4[[System.Type, System.Private.CoreLib, Version=10.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.Type, System.Private.CoreLib, Version=10.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.String, System.Private.CoreLib, Version=10.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.Type, System.Private.CoreLib, Version=10.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]], System.Private.CoreLib, Version=10.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.Delegate, System.Private.CoreLib, Version=10.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].GetOrAdd(ValueTuple`4 key, Func`2 valueFactory)
   at Radzen.PropertyAccess.Getter[Object,Object](String propertyName, Type type)
   at Radzen.DropDownBase`1[[System.Object, System.Private.CoreLib, Version=10.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].GetGetter(String propertyName, Type type)
   at Radzen.DropDownBase`1[[System.Object, System.Private.CoreLib, Version=10.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].OnParametersSet()
   at Microsoft.AspNetCore.Components.ComponentBase.CallOnParametersSetAsync()
   at Microsoft.AspNetCore.Components.ComponentBase.RunInitAndSetParametersAsync()
   at Radzen.RadzenComponent.SetParametersAsync(ParameterView parameters)
   at Radzen.DataBoundFormComponent`1.<SetParametersAsync>d__94[[System.Object, System.Private.CoreLib, Version=10.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].MoveNext()
   at Radzen.DropDownBase`1.<SetParametersAsync>d__152[[System.Object, System.Private.CoreLib, Version=10.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].MoveNext()
   at Radzen.Blazor.RadzenDropDown`1.<SetParametersAsync>d__97[[System.Object, System.Private.CoreLib, Version=10.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].MoveNext()

Key findings:

  • it works fine with mentioned v11
  • it works fine in v12 IF the enum is not nullable
  • it works fine in VS in Debug but does not work in published binaries on the server in either Release or Debug (some kind of trimming error?)
  • DataGrid works fine if the column is Filterable="false" and thus doesn't need to render the usual DropDown that represents the enum filter
  • column is defined in usual way: <RadzenDataGridColumn TItem="T" Property="@nameof(DTO.NullableEnumProp)" Title="example" />
  • DTO model defines property as:
public MyEnum? NullableEnumProp { get; set; }
  • enum is defined as:
public enum MyEnum
{
	[Display(ResourceType = typeof(Loc), Description = nameof(Loc.AAA))]
	AAA	= 0,
	[Display(ResourceType = typeof(Loc), Description = nameof(Loc.BBB))]
	BBB	= 1,
}

Looks like regression related to trimming. Fix will be published immediately.

1 Like