Ejemplo n.º 1
0
        public override IEnumerable GetValues()
        {
            yield return Value("SignatureBlobIdx", row.SignatureBlobIdx);

            TypeSpecSignature signature = new TypeSpecSignature(Metadata, row.SignatureBlobIdx);
            yield return Value("Signature Token", signature.Token);
            yield return Value("Signature Type", signature.Type.ToString());
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Patches the type of the signature.
        /// </summary>
        /// <param name="typemodule"></param>
        /// <param name="token">The token.</param>
        /// <returns></returns>
        SigType IGenericTypePatcher.PatchSignatureType(ITypeModule typemodule, RuntimeType enclosingType, Token token)
        {
            if (typemodule.MetadataModule == null)
                return new ClassSigType(token);

            if (token.Table == TableType.TypeSpec)
            {
                var typespecRow = typemodule.MetadataModule.Metadata.ReadTypeSpecRow(token);
                var signature = new TypeSpecSignature(typemodule.MetadataModule.Metadata, typespecRow.SignatureBlobIdx);

                if (enclosingType is CilGenericType)
                {
                    var enclosingGenericType = enclosingType as CilGenericType;
                    if (signature.Type is VarSigType)
                    {
                        return enclosingGenericType.GenericArguments[(signature.Type as VarSigType).Index];
                    }
                    else if (signature.Type is GenericInstSigType)
                    {
                        var openGenericSigType = (signature.Type as GenericInstSigType);
                        if (openGenericSigType.ContainsGenericParameters)
                        {
                            return new GenericInstSigType(openGenericSigType.BaseType, this.CloseGenericArguments(enclosingGenericType, openGenericSigType));
                        }
                    }
                }

                return signature.Type;
            }
            return new ClassSigType(token);
        }
Ejemplo n.º 3
0
        RuntimeType ITypeSystem.ResolveGenericType(ITypeModule typeModule, TypeSpecSignature typeSpecSignature, Token token)
        {
            var genericInstSigType = typeSpecSignature.Type as GenericInstSigType;

            if (genericInstSigType == null)
                return null;

            RuntimeType genericType = null;
            SigType sigType = genericInstSigType;

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

                case CilElementType.Class:
                    TypeSigType typeSigType = (TypeSigType)sigType;
                    genericType = typeModule.GetType(typeSigType.Token);
                    break;

                case CilElementType.GenericInst:
                    var genericBaseType = typeModule.GetType(genericInstSigType.BaseType.Token);
                    genericType = new CilGenericType(typeModule, token, genericBaseType, genericInstSigType);
                    break;

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

            return genericType;
        }