Esempio n. 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CilGenericType"/> class.
        /// </summary>
        /// <param name="module">The module.</param>
        /// <param name="baseGenericType">Type of the base generic.</param>
        /// <param name="genericTypeInstanceSignature">The generic type instance signature.</param>
        /// <param name="token">The token.</param>
        /// <param name="typeModule">The type module.</param>
        public CilGenericType(ITypeModule module, RuntimeType baseGenericType, GenericInstSigType genericTypeInstanceSignature, Token token, ITypeModule typeModule) :
            base(module, token, baseGenericType.BaseType)
        {
            Debug.Assert(baseGenericType is CilRuntimeType);

            this.signature       = genericTypeInstanceSignature;
            this.baseGenericType = baseGenericType as CilRuntimeType;
            base.Attributes      = baseGenericType.Attributes;
            base.Namespace       = baseGenericType.Namespace;

            if (this.baseGenericType.IsNested)
            {
                // TODO: find generic type

                ;
            }

            // TODO: if this is a nested types, add enclosing type(s) into genericArguments first
            this.genericArguments = signature.GenericArguments;

            base.Name = GetName(typeModule);

            ResolveMethods();
            ResolveFields();

            this.containsOpenGenericArguments = CheckContainsOpenGenericParameters();
        }
Esempio n. 2
0
        /// <summary>
        /// Loads the type specs.
        /// </summary>
        private void LoadTypeSpecs()
        {
            Token maxToken = GetMaxTokenValue(TableType.TypeSpec);

            foreach (Token token in new Token(TableType.TypeSpec, 1).Upto(maxToken))
            {
                TypeSpecRow       row       = metadataProvider.ReadTypeSpecRow(token);
                TypeSpecSignature signature = GetTypeSpecSignature(row.SignatureBlobIdx);

                GenericInstSigType genericSigType = signature.Type as GenericInstSigType;

                if (genericSigType != null)
                {
                    RuntimeType genericType = null;
                    SigType     sigType     = genericSigType;

                    switch (genericSigType.Type)
                    {
                    case CilElementType.ValueType:
                        goto case CilElementType.Class;

                    case CilElementType.Class:
                        TypeSigType typeSigType = (TypeSigType)sigType;
                        genericType = types[typeSigType.Token.RID];                                     // NOTE: Should this be -1
                        break;

                    case CilElementType.GenericInst:
                        GenericInstSigType genericSigType2 = (GenericInstSigType)sigType;
                        RuntimeType        genericBaseType = null;

                        if (genericSigType2.BaseType.Token.Table == TableType.TypeDef)
                        {
                            genericBaseType = types[genericSigType2.BaseType.Token.RID - 1];
                        }
                        else if (genericSigType2.BaseType.Token.Table == TableType.TypeRef)
                        {
                            genericBaseType = typeRef[genericSigType2.BaseType.Token.RID - 1];
                        }

                        genericType = new CilGenericType(this, genericBaseType, genericSigType, token, this);
                        break;

                    default:
                        throw new NotSupportedException(String.Format(@"LoadTypeSpecs does not support CilElementType.{0}", genericSigType.Type));
                    }

                    typeSpecs[token.RID - 1] = genericType;
                }
                else
                {
                    if (signature.Type is MVarSigType)
                    {
                        continue;
                    }
                    else if (signature.Type is SZArraySigType)
                    {
                        continue;
                    }
                    else
                    {
                        continue;
                    }
                }
            }
        }