private TypeRef(Resolver resolver, Type type, bool shallow = false) { Requires.NotNull(resolver, nameof(resolver)); Requires.NotNull(type, nameof(type)); this.resolver = resolver; this.resolvedType = type; this.AssemblyName = GetNormalizedAssemblyName(type.GetTypeInfo().Assembly.GetName()); this.assemblyId = resolver.GetStrongAssemblyIdentity(type.GetTypeInfo().Assembly, this.AssemblyName); this.TypeFlags |= type.IsArray ? TypeRefFlags.Array : TypeRefFlags.None; this.TypeFlags |= type.GetTypeInfo().IsValueType ? TypeRefFlags.IsValueType : TypeRefFlags.None; this.ElementTypeRef = PartDiscovery.TryGetElementTypeFromMany(type, out var elementType) ? TypeRef.Get(elementType, resolver) : this; var arrayElementType = this.ArrayElementType; Requires.Argument(!arrayElementType.IsGenericParameter, nameof(type), "Generic parameters are not supported."); this.MetadataToken = arrayElementType.GetTypeInfo().MetadataToken; this.FullName = (arrayElementType.GetTypeInfo().IsGenericType ? arrayElementType.GetGenericTypeDefinition() : arrayElementType).FullName; this.GenericTypeParameterCount = arrayElementType.GetTypeInfo().GenericTypeParameters.Length; this.GenericTypeArguments = arrayElementType.GenericTypeArguments != null && arrayElementType.GenericTypeArguments.Length > 0 ? arrayElementType.GenericTypeArguments.Where(t => !(shallow && t.IsGenericParameter)).Select(t => new TypeRef(resolver, t, shallow: true)).ToImmutableArray() : ImmutableArray <TypeRef> .Empty; if (!shallow) { this.baseTypes = arrayElementType.EnumTypeBaseTypesAndInterfaces().Skip(1).Select(t => new TypeRef(resolver, t, shallow: true)).ToImmutableArray(); } }