public void HasCustomAttribute() { Assert.Equal(0, CodedIndex.HasCustomAttribute(default(MethodDefinitionHandle))); Assert.Equal((0xffffff << 5) | 21, CodedIndex.HasCustomAttribute(MetadataTokens.MethodSpecificationHandle(0xffffff))); Assert.Equal(0x20 | 0, CodedIndex.HasCustomAttribute(MetadataTokens.MethodDefinitionHandle(1))); Assert.Equal(0x20 | 1, CodedIndex.HasCustomAttribute(MetadataTokens.FieldDefinitionHandle(1))); Assert.Equal(0x20 | 2, CodedIndex.HasCustomAttribute(MetadataTokens.TypeReferenceHandle(1))); Assert.Equal(0x20 | 3, CodedIndex.HasCustomAttribute(MetadataTokens.TypeDefinitionHandle(1))); Assert.Equal(0x20 | 4, CodedIndex.HasCustomAttribute(MetadataTokens.ParameterHandle(1))); Assert.Equal(0x20 | 5, CodedIndex.HasCustomAttribute(MetadataTokens.InterfaceImplementationHandle(1))); Assert.Equal(0x20 | 6, CodedIndex.HasCustomAttribute(MetadataTokens.MemberReferenceHandle(1))); Assert.Equal(0x20 | 7, CodedIndex.HasCustomAttribute(EntityHandle.ModuleDefinition)); Assert.Equal(0x20 | 8, CodedIndex.HasCustomAttribute(MetadataTokens.DeclarativeSecurityAttributeHandle(1))); Assert.Equal(0x20 | 9, CodedIndex.HasCustomAttribute(MetadataTokens.PropertyDefinitionHandle(1))); Assert.Equal(0x20 | 10, CodedIndex.HasCustomAttribute(MetadataTokens.EventDefinitionHandle(1))); Assert.Equal(0x20 | 11, CodedIndex.HasCustomAttribute(MetadataTokens.StandaloneSignatureHandle(1))); Assert.Equal(0x20 | 12, CodedIndex.HasCustomAttribute(MetadataTokens.ModuleReferenceHandle(1))); Assert.Equal(0x20 | 13, CodedIndex.HasCustomAttribute(MetadataTokens.TypeSpecificationHandle(1))); Assert.Equal(0x20 | 14, CodedIndex.HasCustomAttribute(EntityHandle.AssemblyDefinition)); Assert.Equal(0x20 | 15, CodedIndex.HasCustomAttribute(MetadataTokens.AssemblyReferenceHandle(1))); Assert.Equal(0x20 | 16, CodedIndex.HasCustomAttribute(MetadataTokens.AssemblyFileHandle(1))); Assert.Equal(0x20 | 17, CodedIndex.HasCustomAttribute(MetadataTokens.ExportedTypeHandle(1))); Assert.Equal(0x20 | 18, CodedIndex.HasCustomAttribute(MetadataTokens.ManifestResourceHandle(1))); Assert.Equal(0x20 | 19, CodedIndex.HasCustomAttribute(MetadataTokens.GenericParameterHandle(1))); Assert.Equal(0x20 | 20, CodedIndex.HasCustomAttribute(MetadataTokens.GenericParameterConstraintHandle(1))); Assert.Equal(0x20 | 21, CodedIndex.HasCustomAttribute(MetadataTokens.MethodSpecificationHandle(1))); }
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)); }