Consider the following example. It will trigger AmbiguousMatchException, because reflection discovers two SpecialProp properties.
<TelerikGrid TItem="@GridModel"
Data="@GridData"
AutoGenerateColumns="true">
</TelerikGrid>
@code {
List<GridModel> GridData { get; set; } = new();
protected override void OnInitialized()
{
for (int i = 1; i <= 3; i++)
{
GridData.Add(new GridModel()
{
SpecialProp = i,
Text = "Text " + (i * 111)
});
}
}
public record GridModel : Base1 { }
public record Base1 : Base2
{
public new decimal? SpecialProp { get => base.SpecialProp / base.HelperProp.GetValueOrDefault(1); set => base.SpecialProp = value.HasValue ? (int)(value.GetValueOrDefault() * base.HelperProp.GetValueOrDefault(1)) : null; }
}
public record Base2
{
public int? SpecialProp { get; set; }
public string Text { get; set; }
public int? HelperProp = 10;
}
}
Why not replace
private PropertyInfo FieldPropertyInfo => ContainerGenericArgument?.GetProperty(Field);
with something like
PropertyInfo FieldPropertyInfo = ContainerGenericArgument?.GetProperties().FirstOrDefault(p => p.Name == Field);
with the possibility to cache the result from GetProperties()?