Example #1
0
        internal static TypeReference GetElementType(TypeReference type, IReadOnlyDictionary <GenericParameter, TypeReference> arguments)
        {
            if (type.IsGenericParameter)
            {
                GenericParameter parameter = (GenericParameter)type;
                type = arguments[parameter];
            }
            if (type.IsGenericInstance)
            {
                GenericInstanceType genericInstance = (GenericInstanceType)type;
                if (MonoUtils.HasGenericParameters(genericInstance))
                {
                    type = MonoUtils.ReplaceGenericParameters(genericInstance, arguments);
                }
            }

            if (type.IsArray)
            {
                type = type.GetElementType();
                return(GetElementType(type, arguments));
            }
            if (IsList(type))
            {
                GenericInstanceType generic = (GenericInstanceType)type;
                type = generic.GenericArguments[0];
                return(GetElementType(type, arguments));
            }

            return(type);
        }