Example #1
0
        public void HasCustomDebugInformation()
        {
            Assert.Equal(0, CodedIndex.HasCustomDebugInformation(default(MethodDefinitionHandle)));
            Assert.Equal((0xffffff << 5) | 26, CodedIndex.HasCustomDebugInformation(MetadataTokens.ImportScopeHandle(0xffffff)));

            Assert.Equal(0x20 | 0, CodedIndex.HasCustomDebugInformation(MetadataTokens.MethodDefinitionHandle(1)));
            Assert.Equal(0x20 | 1, CodedIndex.HasCustomDebugInformation(MetadataTokens.FieldDefinitionHandle(1)));
            Assert.Equal(0x20 | 2, CodedIndex.HasCustomDebugInformation(MetadataTokens.TypeReferenceHandle(1)));
            Assert.Equal(0x20 | 3, CodedIndex.HasCustomDebugInformation(MetadataTokens.TypeDefinitionHandle(1)));
            Assert.Equal(0x20 | 4, CodedIndex.HasCustomDebugInformation(MetadataTokens.ParameterHandle(1)));
            Assert.Equal(0x20 | 5, CodedIndex.HasCustomDebugInformation(MetadataTokens.InterfaceImplementationHandle(1)));
            Assert.Equal(0x20 | 6, CodedIndex.HasCustomDebugInformation(MetadataTokens.MemberReferenceHandle(1)));
            Assert.Equal(0x20 | 7, CodedIndex.HasCustomDebugInformation(EntityHandle.ModuleDefinition));
            Assert.Equal(0x20 | 8, CodedIndex.HasCustomDebugInformation(MetadataTokens.DeclarativeSecurityAttributeHandle(1)));
            Assert.Equal(0x20 | 9, CodedIndex.HasCustomDebugInformation(MetadataTokens.PropertyDefinitionHandle(1)));
            Assert.Equal(0x20 | 10, CodedIndex.HasCustomDebugInformation(MetadataTokens.EventDefinitionHandle(1)));
            Assert.Equal(0x20 | 11, CodedIndex.HasCustomDebugInformation(MetadataTokens.StandaloneSignatureHandle(1)));
            Assert.Equal(0x20 | 12, CodedIndex.HasCustomDebugInformation(MetadataTokens.ModuleReferenceHandle(1)));
            Assert.Equal(0x20 | 13, CodedIndex.HasCustomDebugInformation(MetadataTokens.TypeSpecificationHandle(1)));
            Assert.Equal(0x20 | 14, CodedIndex.HasCustomDebugInformation(EntityHandle.AssemblyDefinition));
            Assert.Equal(0x20 | 15, CodedIndex.HasCustomDebugInformation(MetadataTokens.AssemblyReferenceHandle(1)));
            Assert.Equal(0x20 | 16, CodedIndex.HasCustomDebugInformation(MetadataTokens.AssemblyFileHandle(1)));
            Assert.Equal(0x20 | 17, CodedIndex.HasCustomDebugInformation(MetadataTokens.ExportedTypeHandle(1)));
            Assert.Equal(0x20 | 18, CodedIndex.HasCustomDebugInformation(MetadataTokens.ManifestResourceHandle(1)));
            Assert.Equal(0x20 | 19, CodedIndex.HasCustomDebugInformation(MetadataTokens.GenericParameterHandle(1)));
            Assert.Equal(0x20 | 20, CodedIndex.HasCustomDebugInformation(MetadataTokens.GenericParameterConstraintHandle(1)));
            Assert.Equal(0x20 | 21, CodedIndex.HasCustomDebugInformation(MetadataTokens.MethodSpecificationHandle(1)));
            Assert.Equal(0x20 | 22, CodedIndex.HasCustomDebugInformation(MetadataTokens.DocumentHandle(1)));
            Assert.Equal(0x20 | 23, CodedIndex.HasCustomDebugInformation(MetadataTokens.LocalScopeHandle(1)));
            Assert.Equal(0x20 | 24, CodedIndex.HasCustomDebugInformation(MetadataTokens.LocalVariableHandle(1)));
            Assert.Equal(0x20 | 25, CodedIndex.HasCustomDebugInformation(MetadataTokens.LocalConstantHandle(1)));
            Assert.Equal(0x20 | 26, CodedIndex.HasCustomDebugInformation(MetadataTokens.ImportScopeHandle(1)));
        }
Example #2
0
        public void Errors()
        {
            var badHandleKind = CustomAttributeHandle.FromRowId(1);

            AssertExtensions.Throws <ArgumentException>(null, () => CodedIndex.HasCustomAttribute(badHandleKind));
            AssertExtensions.Throws <ArgumentException>(null, () => CodedIndex.HasConstant(badHandleKind));
            AssertExtensions.Throws <ArgumentException>(null, () => CodedIndex.CustomAttributeType(badHandleKind));
            AssertExtensions.Throws <ArgumentException>(null, () => CodedIndex.HasDeclSecurity(badHandleKind));
            AssertExtensions.Throws <ArgumentException>(null, () => CodedIndex.HasFieldMarshal(badHandleKind));
            AssertExtensions.Throws <ArgumentException>(null, () => CodedIndex.HasSemantics(badHandleKind));
            AssertExtensions.Throws <ArgumentException>(null, () => CodedIndex.Implementation(badHandleKind));
            AssertExtensions.Throws <ArgumentException>(null, () => CodedIndex.MemberForwarded(badHandleKind));
            AssertExtensions.Throws <ArgumentException>(null, () => CodedIndex.MemberRefParent(badHandleKind));
            AssertExtensions.Throws <ArgumentException>(null, () => CodedIndex.MethodDefOrRef(badHandleKind));
            AssertExtensions.Throws <ArgumentException>(null, () => CodedIndex.ResolutionScope(badHandleKind));
            AssertExtensions.Throws <ArgumentException>(null, () => CodedIndex.TypeDefOrRef(badHandleKind));
            AssertExtensions.Throws <ArgumentException>(null, () => CodedIndex.TypeDefOrRefOrSpec(badHandleKind));
            AssertExtensions.Throws <ArgumentException>(null, () => CodedIndex.TypeOrMethodDef(badHandleKind));
            AssertExtensions.Throws <ArgumentException>(null, () => CodedIndex.HasCustomDebugInformation(badHandleKind));
        }