static CustomDebugInformationKind GetKind(MetadataReader metadata, GuidHandle h)
            {
                if (h.IsNil)
                {
                    return(CustomDebugInformationKind.None);
                }
                var guid = metadata.GetGuid(h);

                if (KnownGuids.StateMachineHoistedLocalScopes == guid)
                {
                    return(CustomDebugInformationKind.StateMachineHoistedLocalScopes);
                }
                if (KnownGuids.DynamicLocalVariables == guid)
                {
                    return(CustomDebugInformationKind.StateMachineHoistedLocalScopes);
                }
                if (KnownGuids.DefaultNamespaces == guid)
                {
                    return(CustomDebugInformationKind.StateMachineHoistedLocalScopes);
                }
                if (KnownGuids.EditAndContinueLocalSlotMap == guid)
                {
                    return(CustomDebugInformationKind.EditAndContinueLocalSlotMap);
                }
                if (KnownGuids.EditAndContinueLambdaAndClosureMap == guid)
                {
                    return(CustomDebugInformationKind.EditAndContinueLambdaAndClosureMap);
                }
                if (KnownGuids.EmbeddedSource == guid)
                {
                    return(CustomDebugInformationKind.EmbeddedSource);
                }
                if (KnownGuids.SourceLink == guid)
                {
                    return(CustomDebugInformationKind.SourceLink);
                }
                if (KnownGuids.MethodSteppingInformation == guid)
                {
                    return(CustomDebugInformationKind.MethodSteppingInformation);
                }
                if (KnownGuids.CompilationOptions == guid)
                {
                    return(CustomDebugInformationKind.CompilationOptions);
                }
                if (KnownGuids.CompilationMetadataReferences == guid)
                {
                    return(CustomDebugInformationKind.CompilationMetadataReferences);
                }
                if (KnownGuids.TupleElementNames == guid)
                {
                    return(CustomDebugInformationKind.TupleElementNames);
                }
                if (KnownGuids.TypeDefinitionDocuments == guid)
                {
                    return(CustomDebugInformationKind.TypeDefinitionDocuments);
                }

                return(CustomDebugInformationKind.Unknown);
            }
Esempio n. 2
0
        internal Guid GetGuid(GuidHandle handle)
        {
            if (handle.IsNil)
            {
                return default(Guid);
            }

            // Metadata Spec: The Guid heap is an array of GUIDs, each 16 bytes wide. 
            // Its first element is numbered 1, its second 2, and so on.
            return this.Block.PeekGuid((handle.Index - 1) * BlobUtilities.SizeOfGuid);
        }
Esempio n. 3
0
        internal Guid GetGuid(GuidHandle handle)
        {
            if (handle.IsNil)
            {
                return(default(Guid));
            }

            // Metadata Spec: The Guid heap is an array of GUIDs, each 16 bytes wide.
            // Its first element is numbered 1, its second 2, and so on.
            return(this.Block.PeekGuid((handle.Index - 1) * BlobUtilities.SizeOfGuid));
        }
Esempio n. 4
0
        private GuidHandle GetNewGuidHandle()
        {
            // Unlike #Blob, #String and #US streams delta #GUID stream is padded to the
            // size of the previous generation #GUID stream before new GUIDs are added.
            // The first GUID added in a delta will thus have an index that equals the number
            // of GUIDs in all previous generations + 1.

            // Metadata Spec:
            // The Guid heap is an array of GUIDs, each 16 bytes wide.
            // Its first element is numbered 1, its second 2, and so on.
            return(GuidHandle.FromIndex((_guidBuilder.Count >> 4) + 1));
        }
Esempio n. 5
0
        /// <summary>
        /// Creates a new instance of <see cref="AssemblyBuilder"/>.
        /// </summary>
        /// <param name="name">The name of the assembly.</param>
        /// <param name="version">The assembly version. If this is null, the version 0.0.0.0
        /// is used.</param>
        /// <param name="culture">The assembly culture, or null if there is no culture associated
        /// with the assembly.</param>
        /// <param name="flags">A set of bit flags from <see cref="AssemblyFlags"/>.</param>
        /// <param name="hashAlgorithm">The hash algorithm for the assembly. This is ignored for now,
        /// as emitting multi-file assemblies is not supported.</param>
        /// <param name="publicKey">The public key for the assembly, null if there is no public key.</param>
        /// <param name="mainModuleName">The name of the manifest module, null to use the assembly
        /// name.</param>
        /// <param name="moduleVersionId">A GUID that uniquely identifies the current version of
        /// the main module. If not specified, a random value is used.</param>
        public AssemblyBuilder(
            string name,
            Version?version     = null,
            string?culture      = null,
            AssemblyFlags flags = 0,
            AssemblyHashAlgorithm hashAlgorithm = AssemblyHashAlgorithm.None,
            byte[]?publicKey      = null,
            string?mainModuleName = null,
            Guid moduleVersionId  = default
            )
        {
            if (name == null || name.Length == 0)
            {
                throw new ArgumentException("Assembly name must not be null or empty.", nameof(name));
            }

            version ??= new Version(0, 0, 0, 0);

            var metadataBuilder = new MetadataBuilder();

            m_metadataContext = new MetadataContext(metadataBuilder);

            StringHandle nameHandle      = m_metadataContext.getStringHandle(name);
            StringHandle cultureHandle   = m_metadataContext.getStringHandle(culture);
            BlobHandle   publicKeyHandle = m_metadataContext.getBlobHandle(publicKey);

            metadataBuilder.AddAssembly(nameHandle, version, cultureHandle, publicKeyHandle, flags, hashAlgorithm);

            StringHandle moduleNameHandle = (mainModuleName != null && mainModuleName.Length != 0)
                ? metadataBuilder.GetOrAddString(mainModuleName)
                : nameHandle;

            if (moduleVersionId.Equals(default(Guid)))
            {
                moduleVersionId = Guid.NewGuid();
            }

            GuidHandle mvid = metadataBuilder.GetOrAddGuid(moduleVersionId);

            metadataBuilder.AddModule(0, moduleNameHandle, mvid, MetadataTokens.GuidHandle(0), MetadataTokens.GuidHandle(0));

            // <Module> should be the first row in TypeDef
            metadataBuilder.AddTypeDefinition(
                attributes: TypeAttributes.Class,
                @namespace: m_metadataContext.getStringHandle(null),
                name: m_metadataContext.getStringHandle("<Module>"),
                baseType: MetadataTokens.TypeDefinitionHandle(0),
                fieldList: MetadataTokens.FieldDefinitionHandle(1),
                methodList: MetadataTokens.MethodDefinitionHandle(1)
                );
        }
Esempio n. 6
0
        /// <summary>
        /// Given a path to an assembly, returns its MVID (Module Version ID).
        /// May throw.
        /// </summary>
        /// <exception cref="IOException">If the file at <paramref name="filePath"/> does not exist or cannot be accessed.</exception>
        /// <exception cref="BadImageFormatException">If the file is not an assembly or is somehow corrupted.</exception>
        public static Guid ReadMvid(string filePath)
        {
            Debug.Assert(filePath != null);
            Debug.Assert(PathUtilities.IsAbsolute(filePath));

            using (PEReader reader = new PEReader(FileUtilities.OpenRead(filePath)))
            {
                MetadataReader metadataReader = reader.GetMetadataReader();
                GuidHandle     mvidHandle     = metadataReader.GetModuleDefinition().Mvid;
                Guid           fileMvid       = metadataReader.GetGuid(mvidHandle);

                return(fileMvid);
            }
        }
Esempio n. 7
0
        public Guid GetGuid(GuidHandle handle)
        {
            if (handle.IsNil)
            {
                return(default(Guid));
            }

            int offset = (MetadataTokens.GetHeapOffset(handle) - 1) * GuidSize;

            if (offset + GuidSize > _guidHeapBlob.Length)
            {
                throw new BadImageFormatException();
            }

            return(*(Guid *)(_guidHeapBlob.Pointer + offset));
        }
        private static string DedupeReference(string output, string referencePath)
        {
            if (dedupedReferences.ContainsKey(referencePath))
            {
                return(dedupedReferences[referencePath]);
            }
            using var file   = new FileStream(referencePath, FileMode.Open, FileAccess.Read);
            using var reader = new PEReader(file);
            MetadataReader mdReader = reader.GetMetadataReader();
            GuidHandle     handle   = mdReader.GetModuleDefinition().Mvid;
            Guid           mvid     = mdReader.GetGuid(handle);
            string         refPath  = Path.Join(output, "ref", mvid.ToString("N"), Path.GetFileName(referencePath));

            if (!File.Exists(refPath))
            {
                Directory.CreateDirectory(Path.GetDirectoryName(refPath));
                File.Copy(referencePath, refPath);
            }

            return(dedupedReferences[referencePath] = Path.GetRelativePath(output, refPath));
        }
Esempio n. 9
0
        public DocumentHandle AddDocument(BlobHandle name, GuidHandle hashAlgorithm, BlobHandle hash, GuidHandle language)
        {
            _documentTable.Add(new DocumentRow
            {
                Name = name,
                HashAlgorithm = hashAlgorithm,
                Hash = hash,
                Language = language
            });

            return MetadataTokens.DocumentHandle(_documentTable.Count);
        }
Esempio n. 10
0
 public void AddModule(
     int generation,
     StringHandle moduleName,
     GuidHandle mvid,
     GuidHandle encId,
     GuidHandle encBaseId)
 {
     _moduleTable.Add(new ModuleRow
     {
         Generation = (ushort)generation,
         Name = moduleName,
         ModuleVersionId = mvid,
         EncId = encId,
         EncBaseId = encBaseId,
     });
 }
Esempio n. 11
0
 internal int SerializeHandle(GuidHandle handle) => handle.Index;
Esempio n. 12
0
 private static bool IsNil(GuidHandle x) => x.IsNil;
Esempio n. 13
0
        internal GuidHandle GetLanguage(DocumentHandle handle)
        {
            int rowOffset = (handle.RowId - 1) * RowSize;

            return(GuidHandle.FromIndex(Block.PeekHeapReference(rowOffset + _languageOffset, _isGuidHeapRefSizeSmall)));
        }
Esempio n. 14
0
        internal GuidHandle GetHashAlgorithm(DocumentHandle handle)
        {
            int rowOffset = (handle.RowId - 1) * RowSize;

            return(GuidHandle.FromIndex(Block.PeekHeapReference(rowOffset + _hashAlgorithmOffset, _isGuidHeapRefSizeSmall)));
        }
 public int GetHeapOffset(GuidHandle handle)
 {
     return(MetadataTokens.GetHeapOffset(handle));
 }
Esempio n. 16
0
 public Guid GetGuid(GuidHandle handle)
 {
     return GuidStream.GetGuid(handle);
 }
Esempio n. 17
0
        public ModuleDefinitionHandle AddModule(
            int generation,
            StringHandle moduleName,
            GuidHandle mvid,
            GuidHandle encId,
            GuidHandle encBaseId)
        {
            _moduleTable.Add(new ModuleRow
            {
                Generation = (ushort)generation,
                Name = moduleName,
                ModuleVersionId = mvid,
                EncId = encId,
                EncBaseId = encBaseId,
            });

            return EntityHandle.ModuleDefinition;
        }
Esempio n. 18
0
        public CustomDebugInformationHandle AddCustomDebugInformation(EntityHandle parent, GuidHandle kind, BlobHandle value)
        {
            _customDebugInformationTable.Add(new CustomDebugInformationRow
            {
                Parent = (uint)CodedIndex.ToHasCustomDebugInformation(parent),
                Kind = kind,
                Value = value
            });

            return MetadataTokens.CustomDebugInformationHandle(_customDebugInformationTable.Count);
        }
Esempio n. 19
0
 public static string ToString(this MetadataReader reader, GuidHandle x) => reader.GetGuid(x).ToString();
Esempio n. 20
0
 /// <summary>
 /// Returns the offset of metadata heap data that corresponds
 /// to the specified <paramref name="handle"/>.
 /// </summary>
 /// <returns>
 /// Zero based offset, or -1 if <paramref name="handle"/> can only be interpreted in a context of a specific <see cref="MetadataReader"/> or <see cref="MetadataBuilder"/>.
 /// See <see cref="GetHeapOffset(MetadataReader, Handle)"/>.
 /// </returns>
 internal static int GetHeapOffset(GuidHandle handle) => handle.Index;
Esempio n. 21
0
 /// <summary>
 /// Returns the offset of metadata heap data that corresponds
 /// to the specified <paramref name="handle"/>.
 /// </summary>
 /// <returns>
 /// Zero based offset, or -1 if <paramref name="handle"/> can only be interpreted in a context of a specific <see cref="MetadataReader"/> or <see cref="MetadataBuilder"/>.
 /// See <see cref="GetHeapOffset(MetadataReader, Handle)"/>.
 /// </returns>
 public static int GetHeapOffset(GuidHandle handle) => handle.Index;
Esempio n. 22
0
 public void AddCustomDebugInformation(EntityHandle parent, GuidHandle kind, BlobHandle value)
 {
     _customDebugInformationTable.Add(new CustomDebugInformationRow
     {
         Parent = (uint)CodedIndex.ToHasCustomDebugInformation(parent),
         Kind = kind,
         Value = value
     });
 }
Esempio n. 23
0
 public DynamicAnalysisDocument(BlobHandle name, GuidHandle hashAlgorithm, BlobHandle hash)
 {
     Name = name;
     HashAlgorithm = hashAlgorithm;
     Hash = hash;
 }
Esempio n. 24
0
 private GuidHandle ImportValue(GuidHandle src) => _builder.GetOrAddGuid(_reader.GetGuid(src));
Esempio n. 25
0
 public static Guid GetGuid(this GuidHandle handle, MetadataReader reader) => reader.GetGuid(handle);
Esempio n. 26
0
 private string Literal(GuidHandle handle)
 {
     return(Literal(handle, (r, h) => "{" + r.GetGuid((GuidHandle)h) + "}"));
 }
Esempio n. 27
0
 /// <summary>
 /// Returns the offset of metadata heap data that corresponds 
 /// to the specified <paramref name="handle"/>.
 /// </summary>
 /// <returns>
 /// Zero based offset, or -1 if <paramref name="handle"/> can only be interpreted in a context of a specific <see cref="MetadataReader"/> or <see cref="MetadataBuilder"/>.
 /// See <see cref="GetHeapOffset(MetadataReader, Handle)"/>.
 /// </returns>
 public static int GetHeapOffset(GuidHandle handle) => handle.Index;
Esempio n. 28
0
        internal GuidHandle GetKind(CustomDebugInformationHandle handle)
        {
            int rowOffset = (handle.RowId - 1) * RowSize;

            return(GuidHandle.FromIndex(Block.PeekHeapReference(rowOffset + _kindOffset, _isGuidHeapRefSizeSmall)));
        }
Esempio n. 29
0
 public Guid GetGuid(GuidHandle handle)
 {
     return GuidHeap.GetGuid(handle);
 }
Esempio n. 30
0
 public DynamicAnalysisDocument(BlobHandle name, GuidHandle hashAlgorithm, BlobHandle hash)
 {
     Name          = name;
     HashAlgorithm = hashAlgorithm;
     Hash          = hash;
 }
Esempio n. 31
0
        public Guid GetGuid(GuidHandle handle)
        {
            if (handle.IsNil)
            {
                return default(Guid);
            }

            int offset = (MetadataTokens.GetHeapOffset(handle) - 1) * GuidSize;
            if (offset + GuidSize > _guidHeapBlob.Length)
            {
                throw new BadImageFormatException();
            }

            return *(Guid*)(_guidHeapBlob.Pointer + offset);
        }
Esempio n. 32
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);
        }
Esempio n. 33
0
 public GuidHeapEntry(MetadataReader metadata, GuidHandle handle)
 {
     this.metadata = metadata;
     this.handle   = handle;
 }