Three methods in Telerik.Blazor.Extensions.ReflectionExtensions call target.GetType() without first checking whether target is null. When a null object reaches any of these methods (e.g. via ConvertToFileEntry receiving a null data item), a NullReferenceException is thrown. Consider adding a null return/guard, which will prevent the exception.
Affected methods:
HasGetter
GetPropertyValue
SetPropertyValue
Proposed change:
Add an early null return/guard for target in each method, consistent with the existing null check for propertyName:
public static bool HasGetter(this object target, string propertyName)
{
if (target == null || propertyName == null)
{
return false;
}
// ...
}
public static object GetPropertyValue(this object target, string propertyName)
{
if (target == null || propertyName == null)
{
return null;
}
// ...
}
public static void SetPropertyValue(this object target, string propertyName, object value)
{
if (target == null)
{
return;
}
// ...
}Expected outcome