Beispiel #1
0
        public void ResolutionScope()
        {
            Assert.Equal(0, CodedIndex.ResolutionScope(default(ModuleDefinitionHandle)));
            Assert.Equal((0xffffff << 2) | 3, CodedIndex.ResolutionScope(MetadataTokens.TypeReferenceHandle(0xffffff)));

            Assert.Equal(0x04 | 0, CodedIndex.ResolutionScope(EntityHandle.ModuleDefinition));
            Assert.Equal(0x04 | 1, CodedIndex.ResolutionScope(MetadataTokens.ModuleReferenceHandle(1)));
            Assert.Equal(0x04 | 2, CodedIndex.ResolutionScope(MetadataTokens.AssemblyReferenceHandle(1)));
            Assert.Equal(0x04 | 3, CodedIndex.ResolutionScope(MetadataTokens.TypeReferenceHandle(1)));
        }
Beispiel #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));
        }