Exemplo n.º 1
0
        /// <summary>
        /// Emit an arbitrary type specification.
        /// </summary>
        /// <param name="typeSpecHandle">Type specification handle</param>
        /// <param name="namespaceQualified">When set to true, include namespace information</param>
        private string EmitTypeSpecificationName(TypeSpecificationHandle typeSpecHandle, bool namespaceQualified)
        {
            TypeSpecification           typeSpec       = _metadataReader.GetTypeSpecification(typeSpecHandle);
            DisassemblingGenericContext genericContext = new DisassemblingGenericContext(Array.Empty <string>(), Array.Empty <string>());

            return(typeSpec.DecodeSignature <string, DisassemblingGenericContext>(this, genericContext));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Decodes a type specification.
        /// </summary>
        /// <param name="handle">The type specification handle.</param>
        /// <param name="provider">The type provider.</param>
        /// <returns>The decoded type.</returns>
        /// <exception cref="System.BadImageFormatException">The type specification has an invalid signature.</exception>
        private static TType DecodeTypeSpecification <TType>(TypeSpecificationHandle handle, ISignatureTypeProvider <TType> provider)
        {
            BlobHandle blobHandle = provider.Reader.GetTypeSpecification(handle).Signature;
            BlobReader blobReader = provider.Reader.GetBlobReader(blobHandle);

            return(DecodeType(ref blobReader, provider));
        }
        internal TypeSpecification(MetadataReader reader, TypeSpecificationHandle handle)
        {
            Debug.Assert(reader != null);
            Debug.Assert(!handle.IsNil);

            _reader = reader;
            _rowId  = handle.RowId;
        }
Exemplo n.º 4
0
 public NetType GetTypeFromSpecification(
     MetadataReader reader,
     object genericContext,
     TypeSpecificationHandle handle,
     byte rawTypeKind)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 5
0
        internal TypeSpecification(MetadataReader reader, TypeSpecificationHandle handle)
        {
            Debug.Assert(reader != null);
            Debug.Assert(!handle.IsNil);

            _reader = reader;
            _rowId = handle.RowId;
        }
Exemplo n.º 6
0
        private TypeSpecificationHandle Import(TypeSpecificationHandle srcHandle) =>
        ImportEntity(srcHandle, _typeSpecificationCache, _reader.GetTypeSpecification,
                     src =>
        {
            var dstSignature = ImportTypeSignature(src.Signature);

            return(dstSignature.IsNil ? default : _builder.AddTypeSpecification(dstSignature));
        }, _reader.ToString, IsNil);
Exemplo n.º 7
0
 public TypeSpecEntry(PEFile module, TypeSpecificationHandle handle)
 {
     this.metadataOffset = module.Reader.PEHeaders.MetadataStartOffset;
     this.module         = module;
     this.metadata       = module.Metadata;
     this.handle         = handle;
     this.typeSpec       = metadata.GetTypeSpecification(handle);
 }
Exemplo n.º 8
0
            public EntityHandle GetTypeFromSpecification(MetadataReader reader, TypeSpecificationHandle handle)
            {
                // Create a decoder to process the type specification (which happens with
                // instantiated generics).  It will call back into us to get the first handle
                // for the type def or type ref that the specification starts with.
                var sigReader = reader.GetBlobReader(reader.GetTypeSpecification(handle).Signature);

                return(new SignatureDecoder <EntityHandle, object>(this, reader, genericContext: null).DecodeType(ref sigReader));
            }
Exemplo n.º 9
0
        } // Read

        public static uint Read(this NativeReader reader, uint offset, out TypeSpecificationHandle handle)
        {
            uint value;

            offset = reader.DecodeUnsigned(offset, out value);
            handle = new TypeSpecificationHandle((int)value);
            handle._Validate();
            return(offset);
        } // Read
Exemplo n.º 10
0
        //
        // Main routine to parse a metadata type specification signature.
        //
        private static RuntimeTypeInfo TryResolveTypeSignature(this TypeSpecificationHandle typeSpecHandle, MetadataReader reader, TypeContext typeContext, ref Exception exception)
        {
            TypeSpecification      typeSpec        = reader.GetTypeSpecification(typeSpecHandle);
            ReflectionTypeProvider refTypeProvider = new ReflectionTypeProvider(throwOnError: false);
            RuntimeTypeInfo        result          = typeSpec.DecodeSignature <RuntimeTypeInfo, TypeContext>(refTypeProvider, typeContext);

            exception = refTypeProvider.ExceptionResult;
            return(result);
        }
Exemplo n.º 11
0
        private Object ResolveTypeSpecification(TypeSpecificationHandle handle)
        {
            TypeSpecification typeSpecification = _metadataReader.GetTypeSpecification(handle);

            BlobReader          signatureReader = _metadataReader.GetBlobReader(typeSpecification.Signature);
            EcmaSignatureParser parser          = new EcmaSignatureParser(this, signatureReader);

            return(parser.ParseType());
        }
Exemplo n.º 12
0
 private void ReadCustomAttributeTypeNameWithoutResolving(EntityHandle customAttributeConstructorHandle, out string customAttributeTypeNamespace, out string customAttributeTypeName)
 {
     /**
      * It is possible that the assembly that defines the attribute is not provided as a reference assembly.
      *
      * Most the time, as long as the custom attribute is not accessed or the reference assembly is available at runtime, the code will work just fine.
      *
      * If we used _module.GetMethod(customAttributeConstructorHandle), we should have caused an exception and failing the compilation.
      *
      * Therefore, we have this alternate path to obtain the type namespace and name.
      */
     if (customAttributeConstructorHandle.Kind == HandleKind.MethodDefinition)
     {
         MethodDefinitionHandle customAttributeConstructorDefinitionHandle     = (MethodDefinitionHandle)customAttributeConstructorHandle;
         MethodDefinition       customAttributeConstructorDefinition           = _module.MetadataReader.GetMethodDefinition(customAttributeConstructorDefinitionHandle);
         TypeDefinitionHandle   customAttributeConstructorTypeDefinitionHandle = customAttributeConstructorDefinition.GetDeclaringType();
         GetTypeNameFromTypeDefinitionHandle(customAttributeConstructorTypeDefinitionHandle, out customAttributeTypeNamespace, out customAttributeTypeName);
     }
     else if (customAttributeConstructorHandle.Kind == HandleKind.MemberReference)
     {
         MemberReferenceHandle customAttributeConstructorReferenceHandle       = (MemberReferenceHandle)customAttributeConstructorHandle;
         MemberReference       customAttributeConstructorReference             = _module.MetadataReader.GetMemberReference(customAttributeConstructorReferenceHandle);
         EntityHandle          customAttributeConstructorReferenceParentHandle = customAttributeConstructorReference.Parent;
         if (customAttributeConstructorReferenceParentHandle.Kind == HandleKind.TypeReference)
         {
             TypeReferenceHandle customAttributeConstructorTypeReferenceHandle = (TypeReferenceHandle)customAttributeConstructorReferenceParentHandle;
             GetTypeNameFromTypeReferenceHandle(customAttributeConstructorTypeReferenceHandle, out customAttributeTypeNamespace, out customAttributeTypeName);
         }
         else
         {
             Debug.Assert(customAttributeConstructorReferenceParentHandle.Kind == HandleKind.TypeSpecification);
             TypeSpecificationHandle  customAttributeConstructorTypeSpecificationHandle = (TypeSpecificationHandle)customAttributeConstructorReferenceParentHandle;
             TypeSpecification        customAttributeConstructorTypeSpecification       = _module.MetadataReader.GetTypeSpecification(customAttributeConstructorTypeSpecificationHandle);
             FirstTypeHandleExtractor fakeSignatureTypeProvider = new FirstTypeHandleExtractor();
             customAttributeConstructorTypeSpecification.DecodeSignature(fakeSignatureTypeProvider, new DummyGenericContext());
             EntityHandle firstTypeHandle = fakeSignatureTypeProvider.FirstTypeHandle;
             if (firstTypeHandle.Kind == HandleKind.TypeDefinition)
             {
                 TypeDefinitionHandle customAttributeConstructorTypeDefinitionHandle = (TypeDefinitionHandle)firstTypeHandle;
                 GetTypeNameFromTypeDefinitionHandle(customAttributeConstructorTypeDefinitionHandle, out customAttributeTypeNamespace, out customAttributeTypeName);
             }
             else
             {
                 Debug.Assert(firstTypeHandle.Kind == HandleKind.TypeReference);
                 TypeReferenceHandle customAttributeConstructorTypeReferenceHandle = (TypeReferenceHandle)firstTypeHandle;
                 GetTypeNameFromTypeReferenceHandle(customAttributeConstructorTypeReferenceHandle, out customAttributeTypeNamespace, out customAttributeTypeName);
             }
         }
     }
     else
     {
         Debug.Assert(false);
         customAttributeTypeNamespace = null;
         customAttributeTypeName      = null;
     }
 }
Exemplo n.º 13
0
        public static FullTypeName GetFullTypeName(this TypeSpecificationHandle handle, MetadataReader reader)
        {
            if (handle.IsNil)
            {
                throw new ArgumentNullException(nameof(handle));
            }
            var ts = reader.GetTypeSpecification(handle);

            return(ts.DecodeSignature(new Metadata.FullTypeNameSignatureDecoder(reader), default(Unit)));
        }
Exemplo n.º 14
0
        XSharpType ISignatureTypeProvider <XSharpType, object> .GetTypeFromSpecification(
            MetadataReader reader,
            object genericContext,
            TypeSpecificationHandle handle,
            byte rawTypeKind)
        {
            TypeSpecification typeSpec = _reader.GetTypeSpecification(handle);

            return(typeSpec.DecodeSignature(this, genericContext));
        }
 public MetadataType GetTypeFromSpecification(
     MetadataReader reader,
     GenericContext genericContext,
     TypeSpecificationHandle handle,
     byte rawTypeKind)
 {
     return(reader
            .GetTypeSpecification(handle)
            .DecodeSignature(this, genericContext));
 }
Exemplo n.º 16
0
        public static string GetFullName(this TypeSpecificationHandle typeSpecHandle, MetadataReader reader)
        {
            var typeSpec = typeSpecHandle.GetTypeSpecification(reader);

            if (typeSpec.Signature.IsNull(reader))
            {
                return(null);
            }

            return(typeSpec.Signature.GetFullName(reader));
        }
Exemplo n.º 17
0
        private Object ResolveTypeSpecification(TypeSpecificationHandle handle)
        {
            TypeSpecification typeSpecification = _metadataReader.GetTypeSpecification(handle);

            BlobReader          signatureReader = _metadataReader.GetBlobReader(typeSpecification.Signature);
            EcmaSignatureParser parser          = new EcmaSignatureParser(this, signatureReader, NotFoundBehavior.ReturnResolutionFailure);

            TypeDesc parsedType = parser.ParseType();

            if (parsedType == null)
            {
                return(parser.ResolutionFailure);
            }
            else
            {
                return(parsedType);
            }
        }
        public MemberMetadataInfo GetTypeFromSpecification(MetadataReader reader, TypeSpecificationHandle handle, byte rawTypeKind)
        {
            var entityHandle = (EntityHandle)handle;

            switch (entityHandle.Kind)
            {
            case HandleKind.TypeDefinition:
                return(GetTypeFromDefinition((TypeDefinitionHandle)entityHandle));

            case HandleKind.TypeReference:
                return(GetFullName((TypeReferenceHandle)entityHandle));

            case HandleKind.TypeSpecification:
                var specification = reader.GetTypeSpecification((TypeSpecificationHandle)entityHandle);

                return(specification.DecodeSignature(this));

            default:
                throw new NotSupportedException("This kind is not supported!");
            }
        }
 public Mapping<TypeSpecificationHandle> MapTypeSpecification(TypeSpecificationHandle handle)
 {
     return _typeSpecifications.GetOrAdd(handle, MapTypeSpecificationImpl);
 }
Exemplo n.º 20
0
 public string GetTypeFromSpecification(MetadataReader reader, object genericContext, TypeSpecificationHandle handle, byte rawTypeKind)
 {
     return(string.Empty);
 }
 private Mapping<TypeSpecificationHandle> MapTypeSpecificationImpl(TypeSpecificationHandle handle)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 22
0
 public virtual string GetTypeFromSpecification(MetadataReader reader, TypeSpecificationHandle handle, SignatureTypeHandleCode code = SignatureTypeHandleCode.Unresolved)
 {
     return(reader.GetTypeSpecification(handle).DecodeSignature(this));
 }
Exemplo n.º 23
0
        /// <summary>
        /// Emit an arbitrary type specification.
        /// </summary>
        /// <param name="typeSpecHandle">Type specification handle</param>
        /// <param name="namespaceQualified">When set to true, include namespace information</param>
        private void EmitTypeSpecificationName(TypeSpecificationHandle typeSpecHandle, bool namespaceQualified)
        {
            TypeSpecification typeSpec = _metadataReader.GetTypeSpecification(typeSpecHandle);

            EmitTypeName(typeSpec.Signature, namespaceQualified);
        }
Exemplo n.º 24
0
 public DummyType GetTypeFromSpecification(MetadataReader reader, DummyGenericContext genericContext, TypeSpecificationHandle handle, byte rawTypeKind)
 {
     return(DummyType.Instance);
 }
Exemplo n.º 25
0
 public TypeSpecification GetTypeSpecification(TypeSpecificationHandle handle)
 {
     return new TypeSpecification(this, handle);
 }
Exemplo n.º 26
0
        //
        // Main routine to parse a metadata type specification signature.
        //
        private static RuntimeTypeInfo?TryResolveTypeSignature(this TypeSpecificationHandle typeSpecHandle, MetadataReader reader, TypeContext typeContext, ref Exception?exception)
        {
            Handle typeHandle = typeSpecHandle.GetTypeSpecification(reader).Signature;

            switch (typeHandle.HandleType)
            {
            case HandleType.ArraySignature:
            {
                ArraySignature sig  = typeHandle.ToArraySignatureHandle(reader).GetArraySignature(reader);
                int            rank = sig.Rank;
                if (rank <= 0)
                {
                    throw new BadImageFormatException();         // Bad rank.
                }
                RuntimeTypeInfo?elementType = sig.ElementType.TryResolve(reader, typeContext, ref exception);
                if (elementType == null)
                {
                    return(null);
                }
                return(elementType.GetMultiDimArrayType(rank));
            }

            case HandleType.ByReferenceSignature:
            {
                ByReferenceSignature sig        = typeHandle.ToByReferenceSignatureHandle(reader).GetByReferenceSignature(reader);
                RuntimeTypeInfo?     targetType = sig.Type.TryResolve(reader, typeContext, ref exception);
                if (targetType == null)
                {
                    return(null);
                }
                return(targetType.GetByRefType());
            }

            case HandleType.MethodTypeVariableSignature:
            {
                MethodTypeVariableSignature sig = typeHandle.ToMethodTypeVariableSignatureHandle(reader).GetMethodTypeVariableSignature(reader);
                return(typeContext.GenericMethodArguments[sig.Number]);
            }

            case HandleType.PointerSignature:
            {
                PointerSignature sig        = typeHandle.ToPointerSignatureHandle(reader).GetPointerSignature(reader);
                RuntimeTypeInfo? targetType = sig.Type.TryResolve(reader, typeContext, ref exception);
                if (targetType == null)
                {
                    return(null);
                }
                return(targetType.GetPointerType());
            }

            case HandleType.SZArraySignature:
            {
                SZArraySignature sig         = typeHandle.ToSZArraySignatureHandle(reader).GetSZArraySignature(reader);
                RuntimeTypeInfo? elementType = sig.ElementType.TryResolve(reader, typeContext, ref exception);
                if (elementType == null)
                {
                    return(null);
                }
                return(elementType.GetArrayType());
            }

            case HandleType.TypeDefinition:
            {
                return(typeHandle.ToTypeDefinitionHandle(reader).ResolveTypeDefinition(reader));
            }

            case HandleType.TypeInstantiationSignature:
            {
                TypeInstantiationSignature sig = typeHandle.ToTypeInstantiationSignatureHandle(reader).GetTypeInstantiationSignature(reader);
                RuntimeTypeInfo?           genericTypeDefinition = sig.GenericType.TryResolve(reader, typeContext, ref exception);
                if (genericTypeDefinition == null)
                {
                    return(null);
                }
                LowLevelList <RuntimeTypeInfo> genericTypeArguments = new LowLevelList <RuntimeTypeInfo>();
                foreach (Handle genericTypeArgumentHandle in sig.GenericTypeArguments)
                {
                    RuntimeTypeInfo?genericTypeArgument = genericTypeArgumentHandle.TryResolve(reader, typeContext, ref exception);
                    if (genericTypeArgument == null)
                    {
                        return(null);
                    }
                    genericTypeArguments.Add(genericTypeArgument);
                }
                return(genericTypeDefinition.GetConstructedGenericType(genericTypeArguments.ToArray()));
            }

            case HandleType.TypeReference:
            {
                return(typeHandle.ToTypeReferenceHandle(reader).TryResolveTypeReference(reader, ref exception));
            }

            case HandleType.TypeVariableSignature:
            {
                TypeVariableSignature sig = typeHandle.ToTypeVariableSignatureHandle(reader).GetTypeVariableSignature(reader);
                return(typeContext.GenericTypeArguments[sig.Number]);
            }

            default:
                throw new NotSupportedException();     // Unexpected Type signature type.
            }
        }
 public EntityHandle GetTypeFromSpecification(
     MetadataReader reader,
     object genericContext,
     TypeSpecificationHandle handle,
     byte rawTypeKind
     ) => GetTypeFromSpecification(reader, handle);
Exemplo n.º 28
0
            public DummyTypeInfo GetTypeFromSpecification(MetadataReader reader, ModuleTokenResolver genericContext, TypeSpecificationHandle handle, byte rawTypeKind)
            {
                TypeSpecification typeSpec = reader.GetTypeSpecification(handle);

                typeSpec.DecodeSignature(this, genericContext);
                return(DummyTypeInfo.Instance);
            }
Exemplo n.º 29
0
 public object GetTypeFromSpecification(MetadataReader reader, TypeSpecificationHandle handle, SignatureTypeHandleCode code) => null;
Exemplo n.º 30
0
 public string GetTypeFromSpecification(MetadataReader reader, TypeContext genericContext, TypeSpecificationHandle handle, byte rawTypeKind) => handle.ToTypeString(reader, genericContext);
Exemplo n.º 31
0
            public ParameterTypeInfo GetTypeFromSpecification(MetadataReader reader, object genericContext, TypeSpecificationHandle handle, byte rawTypeKind)
            {
                var sigReader = reader.GetBlobReader(reader.GetTypeSpecification(handle).Signature);

                return(new SignatureDecoder <ParameterTypeInfo, object>(Instance, reader, genericContext).DecodeType(ref sigReader));
            }
Exemplo n.º 32
0
        //
        // Main routine to parse a metadata type specification signature.
        //
        private static RuntimeType TryResolveTypeSignature(this ReflectionDomain reflectionDomain, MetadataReader reader, TypeSpecificationHandle typeSpecHandle, TypeContext typeContext, ref Exception exception)
        {
            Handle typeHandle = typeSpecHandle.GetTypeSpecification(reader).Signature;
            switch (typeHandle.HandleType)
            {
                case HandleType.ArraySignature:
                    {
                        ArraySignature sig = typeHandle.ToArraySignatureHandle(reader).GetArraySignature(reader);
                        int rank = sig.Rank;
                        if (rank <= 0)
                            throw new BadImageFormatException(); // Bad rank.
                        RuntimeType elementType = reflectionDomain.TryResolve(reader, sig.ElementType, typeContext, ref exception);
                        if (elementType == null)
                            return null;
                        return ReflectionCoreNonPortable.GetMultiDimArrayType(elementType, rank);
                    }

                case HandleType.ByReferenceSignature:
                    {
                        ByReferenceSignature sig = typeHandle.ToByReferenceSignatureHandle(reader).GetByReferenceSignature(reader);
                        RuntimeType targetType = reflectionDomain.TryResolve(reader, sig.Type, typeContext, ref exception);
                        if (targetType == null)
                            return null;
                        return ReflectionCoreNonPortable.GetByRefType(targetType);
                    }

                case HandleType.MethodTypeVariableSignature:
                    {
                        MethodTypeVariableSignature sig = typeHandle.ToMethodTypeVariableSignatureHandle(reader).GetMethodTypeVariableSignature(reader);
                        return typeContext.GenericMethodArguments[sig.Number];
                    }

                case HandleType.PointerSignature:
                    {
                        PointerSignature sig = typeHandle.ToPointerSignatureHandle(reader).GetPointerSignature(reader);
                        RuntimeType targetType = reflectionDomain.TryResolve(reader, sig.Type, typeContext, ref exception);
                        if (targetType == null)
                            return null;
                        return ReflectionCoreNonPortable.GetPointerType(targetType);
                    }

                case HandleType.SZArraySignature:
                    {
                        SZArraySignature sig = typeHandle.ToSZArraySignatureHandle(reader).GetSZArraySignature(reader);
                        RuntimeType elementType = reflectionDomain.TryResolve(reader, sig.ElementType, typeContext, ref exception);
                        if (elementType == null)
                            return null;
                        return ReflectionCoreNonPortable.GetArrayType(elementType);
                    }

                case HandleType.TypeDefinition:
                    {
                        return reflectionDomain.ResolveTypeDefinition(reader, typeHandle.ToTypeDefinitionHandle(reader));
                    }

                case HandleType.TypeInstantiationSignature:
                    {
                        TypeInstantiationSignature sig = typeHandle.ToTypeInstantiationSignatureHandle(reader).GetTypeInstantiationSignature(reader);
                        RuntimeType genericTypeDefinition = reflectionDomain.TryResolve(reader, sig.GenericType, typeContext, ref exception);
                        if (genericTypeDefinition == null)
                            return null;
                        LowLevelList<RuntimeType> genericTypeArguments = new LowLevelList<RuntimeType>();
                        foreach (Handle genericTypeArgumentHandle in sig.GenericTypeArguments)
                        {
                            RuntimeType genericTypeArgument = reflectionDomain.TryResolve(reader, genericTypeArgumentHandle, typeContext, ref exception);
                            if (genericTypeArgument == null)
                                return null;
                            genericTypeArguments.Add(genericTypeArgument);
                        }
                        return ReflectionCoreNonPortable.GetConstructedGenericType(genericTypeDefinition, genericTypeArguments.ToArray());
                    }

                case HandleType.TypeReference:
                    {
                        return reflectionDomain.TryResolveTypeReference(reader, typeHandle.ToTypeReferenceHandle(reader), ref exception);
                    }

                case HandleType.TypeVariableSignature:
                    {
                        TypeVariableSignature sig = typeHandle.ToTypeVariableSignatureHandle(reader).GetTypeVariableSignature(reader);
                        return typeContext.GenericTypeArguments[sig.Number];
                    }

                default:
                    throw new NotSupportedException(); // Unexpected Type signature type.
            }
        }
Exemplo n.º 33
0
 public object GetTypeFromSpecification(MetadataReader reader, object genericContext, TypeSpecificationHandle handle, byte rawTypeKind) => null;
Exemplo n.º 34
0
 internal BlobHandle GetSignature(TypeSpecificationHandle handle)
 {
     int rowOffset = (handle.RowId - 1) * this.RowSize;
     return BlobHandle.FromOffset(this.Block.PeekHeapReference(rowOffset + _SignatureOffset, _IsBlobHeapRefSizeSmall));
 }
Exemplo n.º 35
0
        public void IsNil()
        {
            Assert.False(ModuleDefinitionHandle.FromRowId(1).IsNil);
            Assert.False(AssemblyDefinitionHandle.FromRowId(1).IsNil);
            Assert.False(InterfaceImplementationHandle.FromRowId(1).IsNil);
            Assert.False(MethodDefinitionHandle.FromRowId(1).IsNil);
            Assert.False(MethodSpecificationHandle.FromRowId(1).IsNil);
            Assert.False(TypeDefinitionHandle.FromRowId(1).IsNil);
            Assert.False(ExportedTypeHandle.FromRowId(1).IsNil);
            Assert.False(TypeReferenceHandle.FromRowId(1).IsNil);
            Assert.False(TypeSpecificationHandle.FromRowId(1).IsNil);
            Assert.False(MemberReferenceHandle.FromRowId(1).IsNil);
            Assert.False(FieldDefinitionHandle.FromRowId(1).IsNil);
            Assert.False(EventDefinitionHandle.FromRowId(1).IsNil);
            Assert.False(PropertyDefinitionHandle.FromRowId(1).IsNil);
            Assert.False(StandaloneSignatureHandle.FromRowId(1).IsNil);
            Assert.False(MemberReferenceHandle.FromRowId(1).IsNil);
            Assert.False(FieldDefinitionHandle.FromRowId(1).IsNil);
            Assert.False(EventDefinitionHandle.FromRowId(1).IsNil);
            Assert.False(PropertyDefinitionHandle.FromRowId(1).IsNil);
            Assert.False(ParameterHandle.FromRowId(1).IsNil);
            Assert.False(GenericParameterHandle.FromRowId(1).IsNil);
            Assert.False(GenericParameterConstraintHandle.FromRowId(1).IsNil);
            Assert.False(ModuleReferenceHandle.FromRowId(1).IsNil);
            Assert.False(CustomAttributeHandle.FromRowId(1).IsNil);
            Assert.False(DeclarativeSecurityAttributeHandle.FromRowId(1).IsNil);
            Assert.False(ManifestResourceHandle.FromRowId(1).IsNil);
            Assert.False(ConstantHandle.FromRowId(1).IsNil);
            Assert.False(ManifestResourceHandle.FromRowId(1).IsNil);
            Assert.False(AssemblyFileHandle.FromRowId(1).IsNil);
            Assert.False(MethodImplementationHandle.FromRowId(1).IsNil);
            Assert.False(AssemblyReferenceHandle.FromRowId(1).IsNil);

            Assert.False(((EntityHandle)ModuleDefinitionHandle.FromRowId(1)).IsNil);
            Assert.False(((EntityHandle)AssemblyDefinitionHandle.FromRowId(1)).IsNil);
            Assert.False(((EntityHandle)InterfaceImplementationHandle.FromRowId(1)).IsNil);
            Assert.False(((EntityHandle)MethodDefinitionHandle.FromRowId(1)).IsNil);
            Assert.False(((EntityHandle)MethodSpecificationHandle.FromRowId(1)).IsNil);
            Assert.False(((EntityHandle)TypeDefinitionHandle.FromRowId(1)).IsNil);
            Assert.False(((EntityHandle)ExportedTypeHandle.FromRowId(1)).IsNil);
            Assert.False(((EntityHandle)TypeReferenceHandle.FromRowId(1)).IsNil);
            Assert.False(((EntityHandle)TypeSpecificationHandle.FromRowId(1)).IsNil);
            Assert.False(((EntityHandle)MemberReferenceHandle.FromRowId(1)).IsNil);
            Assert.False(((EntityHandle)FieldDefinitionHandle.FromRowId(1)).IsNil);
            Assert.False(((EntityHandle)EventDefinitionHandle.FromRowId(1)).IsNil);
            Assert.False(((EntityHandle)PropertyDefinitionHandle.FromRowId(1)).IsNil);
            Assert.False(((EntityHandle)StandaloneSignatureHandle.FromRowId(1)).IsNil);
            Assert.False(((EntityHandle)MemberReferenceHandle.FromRowId(1)).IsNil);
            Assert.False(((EntityHandle)FieldDefinitionHandle.FromRowId(1)).IsNil);
            Assert.False(((EntityHandle)EventDefinitionHandle.FromRowId(1)).IsNil);
            Assert.False(((EntityHandle)PropertyDefinitionHandle.FromRowId(1)).IsNil);
            Assert.False(((EntityHandle)ParameterHandle.FromRowId(1)).IsNil);
            Assert.False(((EntityHandle)GenericParameterHandle.FromRowId(1)).IsNil);
            Assert.False(((EntityHandle)GenericParameterConstraintHandle.FromRowId(1)).IsNil);
            Assert.False(((EntityHandle)ModuleReferenceHandle.FromRowId(1)).IsNil);
            Assert.False(((EntityHandle)CustomAttributeHandle.FromRowId(1)).IsNil);
            Assert.False(((EntityHandle)DeclarativeSecurityAttributeHandle.FromRowId(1)).IsNil);
            Assert.False(((EntityHandle)ManifestResourceHandle.FromRowId(1)).IsNil);
            Assert.False(((EntityHandle)ConstantHandle.FromRowId(1)).IsNil);
            Assert.False(((EntityHandle)ManifestResourceHandle.FromRowId(1)).IsNil);
            Assert.False(((EntityHandle)AssemblyFileHandle.FromRowId(1)).IsNil);
            Assert.False(((EntityHandle)MethodImplementationHandle.FromRowId(1)).IsNil);
            Assert.False(((EntityHandle)AssemblyReferenceHandle.FromRowId(1)).IsNil);

            Assert.False(StringHandle.FromOffset(1).IsNil);
            Assert.False(BlobHandle.FromOffset(1).IsNil);
            Assert.False(UserStringHandle.FromOffset(1).IsNil);
            Assert.False(GuidHandle.FromIndex(1).IsNil);

            Assert.False(((Handle)StringHandle.FromOffset(1)).IsNil);
            Assert.False(((Handle)BlobHandle.FromOffset(1)).IsNil);
            Assert.False(((Handle)UserStringHandle.FromOffset(1)).IsNil);
            Assert.False(((Handle)GuidHandle.FromIndex(1)).IsNil);

            Assert.True(ModuleDefinitionHandle.FromRowId(0).IsNil);
            Assert.True(AssemblyDefinitionHandle.FromRowId(0).IsNil);
            Assert.True(InterfaceImplementationHandle.FromRowId(0).IsNil);
            Assert.True(MethodDefinitionHandle.FromRowId(0).IsNil);
            Assert.True(MethodSpecificationHandle.FromRowId(0).IsNil);
            Assert.True(TypeDefinitionHandle.FromRowId(0).IsNil);
            Assert.True(ExportedTypeHandle.FromRowId(0).IsNil);
            Assert.True(TypeReferenceHandle.FromRowId(0).IsNil);
            Assert.True(TypeSpecificationHandle.FromRowId(0).IsNil);
            Assert.True(MemberReferenceHandle.FromRowId(0).IsNil);
            Assert.True(FieldDefinitionHandle.FromRowId(0).IsNil);
            Assert.True(EventDefinitionHandle.FromRowId(0).IsNil);
            Assert.True(PropertyDefinitionHandle.FromRowId(0).IsNil);
            Assert.True(StandaloneSignatureHandle.FromRowId(0).IsNil);
            Assert.True(MemberReferenceHandle.FromRowId(0).IsNil);
            Assert.True(FieldDefinitionHandle.FromRowId(0).IsNil);
            Assert.True(EventDefinitionHandle.FromRowId(0).IsNil);
            Assert.True(PropertyDefinitionHandle.FromRowId(0).IsNil);
            Assert.True(ParameterHandle.FromRowId(0).IsNil);
            Assert.True(GenericParameterHandle.FromRowId(0).IsNil);
            Assert.True(GenericParameterConstraintHandle.FromRowId(0).IsNil);
            Assert.True(ModuleReferenceHandle.FromRowId(0).IsNil);
            Assert.True(CustomAttributeHandle.FromRowId(0).IsNil);
            Assert.True(DeclarativeSecurityAttributeHandle.FromRowId(0).IsNil);
            Assert.True(ManifestResourceHandle.FromRowId(0).IsNil);
            Assert.True(ConstantHandle.FromRowId(0).IsNil);
            Assert.True(ManifestResourceHandle.FromRowId(0).IsNil);
            Assert.True(AssemblyFileHandle.FromRowId(0).IsNil);
            Assert.True(MethodImplementationHandle.FromRowId(0).IsNil);
            Assert.True(AssemblyReferenceHandle.FromRowId(0).IsNil);

            Assert.True(((EntityHandle)ModuleDefinitionHandle.FromRowId(0)).IsNil);
            Assert.True(((EntityHandle)AssemblyDefinitionHandle.FromRowId(0)).IsNil);
            Assert.True(((EntityHandle)InterfaceImplementationHandle.FromRowId(0)).IsNil);
            Assert.True(((EntityHandle)MethodDefinitionHandle.FromRowId(0)).IsNil);
            Assert.True(((EntityHandle)MethodSpecificationHandle.FromRowId(0)).IsNil);
            Assert.True(((EntityHandle)TypeDefinitionHandle.FromRowId(0)).IsNil);
            Assert.True(((EntityHandle)ExportedTypeHandle.FromRowId(0)).IsNil);
            Assert.True(((EntityHandle)TypeReferenceHandle.FromRowId(0)).IsNil);
            Assert.True(((EntityHandle)TypeSpecificationHandle.FromRowId(0)).IsNil);
            Assert.True(((EntityHandle)MemberReferenceHandle.FromRowId(0)).IsNil);
            Assert.True(((EntityHandle)FieldDefinitionHandle.FromRowId(0)).IsNil);
            Assert.True(((EntityHandle)EventDefinitionHandle.FromRowId(0)).IsNil);
            Assert.True(((EntityHandle)PropertyDefinitionHandle.FromRowId(0)).IsNil);
            Assert.True(((EntityHandle)StandaloneSignatureHandle.FromRowId(0)).IsNil);
            Assert.True(((EntityHandle)MemberReferenceHandle.FromRowId(0)).IsNil);
            Assert.True(((EntityHandle)FieldDefinitionHandle.FromRowId(0)).IsNil);
            Assert.True(((EntityHandle)EventDefinitionHandle.FromRowId(0)).IsNil);
            Assert.True(((EntityHandle)PropertyDefinitionHandle.FromRowId(0)).IsNil);
            Assert.True(((EntityHandle)ParameterHandle.FromRowId(0)).IsNil);
            Assert.True(((EntityHandle)GenericParameterHandle.FromRowId(0)).IsNil);
            Assert.True(((EntityHandle)GenericParameterConstraintHandle.FromRowId(0)).IsNil);
            Assert.True(((EntityHandle)ModuleReferenceHandle.FromRowId(0)).IsNil);
            Assert.True(((EntityHandle)CustomAttributeHandle.FromRowId(0)).IsNil);
            Assert.True(((EntityHandle)DeclarativeSecurityAttributeHandle.FromRowId(0)).IsNil);
            Assert.True(((EntityHandle)ManifestResourceHandle.FromRowId(0)).IsNil);
            Assert.True(((EntityHandle)ConstantHandle.FromRowId(0)).IsNil);
            Assert.True(((EntityHandle)ManifestResourceHandle.FromRowId(0)).IsNil);
            Assert.True(((EntityHandle)AssemblyFileHandle.FromRowId(0)).IsNil);
            Assert.True(((EntityHandle)MethodImplementationHandle.FromRowId(0)).IsNil);
            Assert.True(((EntityHandle)AssemblyReferenceHandle.FromRowId(0)).IsNil);

            // heaps:
            Assert.True(StringHandle.FromOffset(0).IsNil);
            Assert.True(BlobHandle.FromOffset(0).IsNil);
            Assert.True(UserStringHandle.FromOffset(0).IsNil);
            Assert.True(GuidHandle.FromIndex(0).IsNil);

            Assert.True(((Handle)StringHandle.FromOffset(0)).IsNil);
            Assert.True(((Handle)BlobHandle.FromOffset(0)).IsNil);
            Assert.True(((Handle)UserStringHandle.FromOffset(0)).IsNil);
            Assert.True(((Handle)GuidHandle.FromIndex(0)).IsNil);

            // virtual:
            Assert.False(AssemblyReferenceHandle.FromVirtualIndex(0).IsNil);
            Assert.False(StringHandle.FromVirtualIndex(0).IsNil);
            Assert.False(BlobHandle.FromVirtualIndex(0, 0).IsNil);

            Assert.False(((Handle)AssemblyReferenceHandle.FromVirtualIndex(0)).IsNil);
            Assert.False(((Handle)StringHandle.FromVirtualIndex(0)).IsNil);
            Assert.False(((Handle)BlobHandle.FromVirtualIndex(0, 0)).IsNil);
        }
Exemplo n.º 36
0
 public FullTypeName GetTypeFromSpecification(MetadataReader reader, Unit genericContext, TypeSpecificationHandle handle, byte rawTypeKind)
 {
     return(reader.GetTypeSpecification(handle).DecodeSignature(new FullTypeNameSignatureDecoder(metadata), default(Unit)));
 }