Skip to content

Commit 68c39a8

Browse files
committed
Added type conversion null ref fix
1 parent e2e8957 commit 68c39a8

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/Core/Types/Utilities/TypeConversion.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,20 @@ public bool TryConvert(Type from, Type to,
6161
throw new ArgumentNullException(nameof(to));
6262
}
6363

64-
if (source is null || from == to)
64+
if (from == to)
6565
{
6666
converted = source;
6767
return true;
6868
}
6969

70+
if (source is null)
71+
{
72+
converted = to.IsValueType
73+
? Activator.CreateInstance(to)
74+
: null;
75+
return true;
76+
}
77+
7078
try
7179
{
7280
Type fromInternal = (from == typeof(object) && source != null)

0 commit comments

Comments
 (0)