Example #1
0
        /// <summary>
        /// </summary>
        /// <param name="typeSymbol">
        /// </param>
        /// <param name="genericContext">
        /// </param>
        /// <returns>
        /// </returns>
        internal static IType ResolveGeneric(this TypeSymbol typeSymbol, IGenericContext genericContext, bool isByRef = false, bool isPinned = false)
        {
            if (genericContext != null && !genericContext.IsEmpty)
            {
                if (typeSymbol.IsTypeParameter())
                {
                    return(genericContext.ResolveTypeParameter(new MetadataTypeAdapter(typeSymbol, isByRef, isPinned), isByRef, isPinned));
                }

                var arrayType = typeSymbol as ArrayTypeSymbol;
                if (arrayType != null)
                {
                    return(arrayType.ElementType.ResolveGeneric(genericContext, isByRef, isPinned).ToArrayType(arrayType.Rank));
                }

                var namedTypeSymbol = typeSymbol as NamedTypeSymbol;
                if (namedTypeSymbol != null)
                {
                    var metadataType = new MetadataTypeAdapter(namedTypeSymbol, isByRef, isPinned);
                    if (metadataType.IsGenericTypeDefinition && !genericContext.IsEmpty)
                    {
                        return(new MetadataTypeAdapter(namedTypeSymbol, genericContext, isByRef, isPinned));
                    }
                }
            }

            return(new MetadataTypeAdapter(typeSymbol, genericContext, isByRef, isPinned));
        }
        /// <summary>
        /// </summary>
        /// <param name="setUseAsClass">
        /// </param>
        /// <param name="value">
        /// </param>
        /// <returns>
        /// </returns>
        public IType Clone(bool setUseAsClass = false, bool value = false)
        {
            var typeAdapter = new MetadataTypeAdapter(this.typeDef, this.IsByRef, this.IsPinned);

            if (setUseAsClass)
            {
                typeAdapter.UseAsClass = value;
            }

            return(typeAdapter);
        }
Example #3
0
        /// <summary>
        /// </summary>
        /// <param name="typeSymbol">
        /// </param>
        /// <param name="genericContext">
        /// </param>
        /// <returns>
        /// </returns>
        internal static IType ResolveGeneric(this TypeSymbol typeSymbol, IGenericContext genericContext, bool isByRef = false, bool isPinned = false)
        {
            if (genericContext != null && !genericContext.IsEmpty)
            {
                if (typeSymbol.IsTypeParameter())
                {
                    return genericContext.ResolveTypeParameter(new MetadataTypeAdapter(typeSymbol, isByRef, isPinned), isByRef, isPinned);
                }

                var arrayType = typeSymbol as ArrayTypeSymbol;
                if (arrayType != null)
                {
                    return arrayType.ElementType.ResolveGeneric(genericContext, isByRef, isPinned).ToArrayType(arrayType.Rank);
                }

                var namedTypeSymbol = typeSymbol as NamedTypeSymbol;
                if (namedTypeSymbol != null)
                {
                    var metadataType = new MetadataTypeAdapter(namedTypeSymbol, isByRef, isPinned);
                    if (metadataType.IsGenericTypeDefinition && !genericContext.IsEmpty)
                    {
                        return new MetadataTypeAdapter(namedTypeSymbol, genericContext, isByRef, isPinned);
                    }
                }
            }

            return new MetadataTypeAdapter(typeSymbol, genericContext, isByRef, isPinned);
        }
Example #4
0
        /// <summary>
        /// </summary>
        /// <param name="setUseAsClass">
        /// </param>
        /// <param name="value">
        /// </param>
        /// <returns>
        /// </returns>
        public IType Clone(bool setUseAsClass = false, bool value = false, bool isByRef = false, bool isPinned = false)
        {
            var typeAdapter = new MetadataTypeAdapter(this.typeDef, this.GenericContext, isByRef, isPinned);
            if (setUseAsClass)
            {
                typeAdapter.UseAsClass = value;
            }

            return typeAdapter;
        }
        /// <summary>
        /// </summary>
        /// <param name="rank">
        /// </param>
        /// <returns>
        /// </returns>
        public IType ToArrayType(int rank)
        {
            var containingAssembly = MetadataTypeAdapter.GetBareTypeSymbol(this.typeDef).ContainingAssembly;

            return(new MetadataTypeAdapter(new ArrayTypeSymbol(containingAssembly, this.typeDef, rank: rank), this.IsByRef, this.IsPinned));
        }