private static ExtendedType FromType( Type type, Type?source, bool nullable, TypeCache cache) { type = Helper.RemoveNonEssentialTypes(type); if (type.IsGenericType) { Type definition = type.GetGenericTypeDefinition(); if (definition == typeof(NonNullType <>)) { return(FromType(type.GetGenericArguments()[0], type, false, cache)); } if (definition == typeof(ListType <>)) { return(cache.GetOrCreateType( source is not null ? source : type, () => { ExtendedType elementType = FromType(type.GetGenericArguments()[0], null, true, cache); return new ExtendedType( type, ExtendedTypeKind.Schema, typeArguments: new[] { elementType }, source: source, definition: typeof(ListType <>), isNullable: nullable, isList: true, elementType: elementType); })); } } return(cache.GetOrCreateType( source ?? type, () => { Type?definition = type.IsGenericType ? type.GetGenericTypeDefinition() : null; return new ExtendedType( type, ExtendedTypeKind.Schema, typeArguments: SystemType.GetGenericArguments(type, cache), source: source, definition: definition, isNullable: nullable, isNamedType: true); })); }