Use explicit type declarations in JsonParser for improved clarity

This commit is contained in:
2025-07-29 04:47:12 +02:00
parent 8ff9e89aff
commit 94b76a1001

View File

@@ -511,11 +511,11 @@ namespace VAR.Json
bool isNullableType = arrayContentType?.IsClass == true;
if (hasSameType && arrayContentType != null && (isNullableType || (hasNulls == false)))
{
var enumerableType = typeof(System.Linq.Enumerable);
var castMethod = enumerableType.GetMethod("Cast")?.MakeGenericMethod(arrayContentType);
var toListMethod = enumerableType.GetMethod("ToList")?.MakeGenericMethod(arrayContentType);
Type enumerableType = typeof(System.Linq.Enumerable);
MethodInfo castMethod = enumerableType.GetMethod("Cast")?.MakeGenericMethod(arrayContentType);
MethodInfo toListMethod = enumerableType.GetMethod("ToList")?.MakeGenericMethod(arrayContentType);
IEnumerable<object> itemsToCast = array;
var castedItems = castMethod?.Invoke(null, new object[] { itemsToCast });
object castedItems = castMethod?.Invoke(null, new object[] { itemsToCast });
result = toListMethod?.Invoke(null, new[] { castedItems });
}