Skip to content

Commit

Permalink
Added type conversion null ref fix
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelstaib committed Apr 6, 2020
1 parent e2e8957 commit 68c39a8
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/Core/Types/Utilities/TypeConversion.cs
Expand Up @@ -61,12 +61,20 @@ public object Convert(Type from, Type to, object source)
throw new ArgumentNullException(nameof(to));
}

if (source is null || from == to)
if (from == to)
{
converted = source;
return true;
}

if (source is null)
{
converted = to.IsValueType
? Activator.CreateInstance(to)
: null;
return true;
}

try
{
Type fromInternal = (from == typeof(object) && source != null)
Expand Down

0 comments on commit 68c39a8

Please sign in to comment.