Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

Commit

Permalink
gracefully handle null values in BindingExpression.TryConvert (#15382)
Browse files Browse the repository at this point in the history
  • Loading branch information
thisisthekap authored Jun 1, 2022
1 parent 6fa6d9f commit b2d70cd
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Xamarin.Forms.Core/BindingExpression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,10 @@ void SetupPart(TypeInfo sourceType, BindingExpressionPart part)

internal static bool TryConvert(ref object value, BindableProperty targetProperty, Type convertTo, bool toTarget)
{
if (targetProperty == null)
return false;
if (convertTo == null)
return false;
if (value == null)
return !convertTo.GetTypeInfo().IsValueType || Nullable.GetUnderlyingType(convertTo) != null;
try
Expand Down

0 comments on commit b2d70cd

Please sign in to comment.