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 Implementation() { Assert.Equal(0, CodedIndex.Implementation(default(AssemblyFileHandle))); Assert.Equal((0xffffff << 2) | 2, CodedIndex.Implementation(MetadataTokens.ExportedTypeHandle(0xffffff))); Assert.Equal(0x04 | 0, CodedIndex.Implementation(MetadataTokens.AssemblyFileHandle(1))); Assert.Equal(0x04 | 1, CodedIndex.Implementation(MetadataTokens.AssemblyReferenceHandle(1))); Assert.Equal(0x04 | 2, CodedIndex.Implementation(MetadataTokens.ExportedTypeHandle(1))); }
public void SpecificHandleFactories() { Assert.Equal(1, MetadataTokens.GetRowNumber(MetadataTokens.MethodDefinitionHandle(1))); Assert.Equal(1, MetadataTokens.GetRowNumber(MetadataTokens.MethodImplementationHandle(1))); Assert.Equal(1, MetadataTokens.GetRowNumber(MetadataTokens.MethodSpecificationHandle(1))); Assert.Equal(1, MetadataTokens.GetRowNumber(MetadataTokens.TypeDefinitionHandle(1))); Assert.Equal(1, MetadataTokens.GetRowNumber(MetadataTokens.ExportedTypeHandle(1))); Assert.Equal(1, MetadataTokens.GetRowNumber(MetadataTokens.TypeReferenceHandle(1))); Assert.Equal(1, MetadataTokens.GetRowNumber(MetadataTokens.TypeSpecificationHandle(1))); Assert.Equal(1, MetadataTokens.GetRowNumber(MetadataTokens.InterfaceImplementationHandle(1))); Assert.Equal(1, MetadataTokens.GetRowNumber(MetadataTokens.MemberReferenceHandle(1))); Assert.Equal(1, MetadataTokens.GetRowNumber(MetadataTokens.FieldDefinitionHandle(1))); Assert.Equal(1, MetadataTokens.GetRowNumber(MetadataTokens.EventDefinitionHandle(1))); Assert.Equal(1, MetadataTokens.GetRowNumber(MetadataTokens.PropertyDefinitionHandle(1))); Assert.Equal(1, MetadataTokens.GetRowNumber(MetadataTokens.StandaloneSignatureHandle(1))); Assert.Equal(1, MetadataTokens.GetRowNumber(MetadataTokens.ParameterHandle(1))); Assert.Equal(1, MetadataTokens.GetRowNumber(MetadataTokens.GenericParameterHandle(1))); Assert.Equal(1, MetadataTokens.GetRowNumber(MetadataTokens.GenericParameterConstraintHandle(1))); Assert.Equal(1, MetadataTokens.GetRowNumber(MetadataTokens.ModuleReferenceHandle(1))); Assert.Equal(1, MetadataTokens.GetRowNumber(MetadataTokens.AssemblyReferenceHandle(1))); Assert.Equal(1, MetadataTokens.GetRowNumber(MetadataTokens.CustomAttributeHandle(1))); Assert.Equal(1, MetadataTokens.GetRowNumber(MetadataTokens.DeclarativeSecurityAttributeHandle(1))); Assert.Equal(1, MetadataTokens.GetRowNumber(MetadataTokens.ConstantHandle(1))); Assert.Equal(1, MetadataTokens.GetRowNumber(MetadataTokens.ManifestResourceHandle(1))); Assert.Equal(1, MetadataTokens.GetRowNumber(MetadataTokens.AssemblyFileHandle(1))); Assert.Equal(1, MetadataTokens.GetRowNumber(MetadataTokens.DocumentHandle(1))); Assert.Equal(1, MetadataTokens.GetRowNumber(MetadataTokens.MethodDebugInformationHandle(1))); Assert.Equal(1, MetadataTokens.GetRowNumber(MetadataTokens.LocalScopeHandle(1))); Assert.Equal(1, MetadataTokens.GetRowNumber(MetadataTokens.LocalVariableHandle(1))); Assert.Equal(1, MetadataTokens.GetRowNumber(MetadataTokens.LocalConstantHandle(1))); Assert.Equal(1, MetadataTokens.GetRowNumber(MetadataTokens.ImportScopeHandle(1))); Assert.Equal(1, MetadataTokens.GetRowNumber(MetadataTokens.CustomDebugInformationHandle(1))); Assert.Equal(1, MetadataTokens.GetHeapOffset(MetadataTokens.UserStringHandle(1))); Assert.Equal(1, MetadataTokens.GetHeapOffset(MetadataTokens.StringHandle(1))); Assert.Equal(1, MetadataTokens.GetHeapOffset(MetadataTokens.BlobHandle(1))); Assert.Equal(1, MetadataTokens.GetHeapOffset(MetadataTokens.GuidHandle(1))); Assert.Equal(1, MetadataTokens.GetHeapOffset((BlobHandle)MetadataTokens.DocumentNameBlobHandle(1))); }
public void Add() { var builder = new MetadataBuilder(); builder.AddModule(default(int), default(StringHandle), default(GuidHandle), default(GuidHandle), default(GuidHandle)); Assert.Equal(1, builder.GetRowCounts()[(int)TableIndex.Module]); builder.AddAssembly(default(StringHandle), new Version(0, 0, 0, 0), default(StringHandle), default(BlobHandle), default(AssemblyFlags), default(AssemblyHashAlgorithm)); Assert.Equal(1, builder.GetRowCounts()[(int)TableIndex.Assembly]); var assemblyReference = builder.AddAssemblyReference(default(StringHandle), new Version(0, 0, 0, 0), default(StringHandle), default(BlobHandle), default(AssemblyFlags), default(BlobHandle)); Assert.Equal(1, builder.GetRowCounts()[(int)TableIndex.AssemblyRef]); Assert.Equal(1, MetadataTokens.GetRowNumber(assemblyReference)); var typeDefinition = builder.AddTypeDefinition(default(TypeAttributes), default(StringHandle), default(StringHandle), default(EntityHandle), default(FieldDefinitionHandle), default(MethodDefinitionHandle)); Assert.Equal(1, builder.GetRowCounts()[(int)TableIndex.TypeDef]); Assert.Equal(1, MetadataTokens.GetRowNumber(typeDefinition)); builder.AddTypeLayout(default(TypeDefinitionHandle), default(ushort), default(uint)); Assert.Equal(1, builder.GetRowCounts()[(int)TableIndex.ClassLayout]); builder.AddInterfaceImplementation(MetadataTokens.TypeDefinitionHandle(1), MetadataTokens.TypeDefinitionHandle(1)); Assert.Equal(1, builder.GetRowCounts()[(int)TableIndex.InterfaceImpl]); builder.AddNestedType(default(TypeDefinitionHandle), default(TypeDefinitionHandle)); Assert.Equal(1, builder.GetRowCounts()[(int)TableIndex.NestedClass]); var typeReference = builder.AddTypeReference(EntityHandle.ModuleDefinition, default(StringHandle), default(StringHandle)); Assert.Equal(1, MetadataTokens.GetRowNumber(typeReference)); Assert.Equal(1, builder.GetRowCounts()[(int)TableIndex.TypeRef]); builder.AddTypeSpecification(default(BlobHandle)); Assert.Equal(1, builder.GetRowCounts()[(int)TableIndex.TypeSpec]); builder.AddStandaloneSignature(default(BlobHandle)); Assert.Equal(1, builder.GetRowCounts()[(int)TableIndex.StandAloneSig]); builder.AddProperty(default(PropertyAttributes), default(StringHandle), default(BlobHandle)); Assert.Equal(1, builder.GetRowCounts()[(int)TableIndex.Property]); builder.AddPropertyMap(default(TypeDefinitionHandle), default(PropertyDefinitionHandle)); Assert.Equal(1, builder.GetRowCounts()[(int)TableIndex.PropertyMap]); builder.AddEvent(default(EventAttributes), default(StringHandle), MetadataTokens.TypeDefinitionHandle(1)); Assert.Equal(1, builder.GetRowCounts()[(int)TableIndex.Event]); builder.AddEventMap(default(TypeDefinitionHandle), default(EventDefinitionHandle)); Assert.Equal(1, builder.GetRowCounts()[(int)TableIndex.EventMap]); builder.AddConstant(MetadataTokens.FieldDefinitionHandle(1), default(object)); Assert.Equal(1, builder.GetRowCounts()[(int)TableIndex.Constant]); builder.AddMethodSemantics(MetadataTokens.EventDefinitionHandle(1), default(ushort), default(MethodDefinitionHandle)); Assert.Equal(1, builder.GetRowCounts()[(int)TableIndex.MethodSemantics]); builder.AddCustomAttribute(MetadataTokens.TypeDefinitionHandle(1), MetadataTokens.MethodDefinitionHandle(1), default(BlobHandle)); Assert.Equal(1, builder.GetRowCounts()[(int)TableIndex.CustomAttribute]); builder.AddMethodSpecification(MetadataTokens.MethodDefinitionHandle(1), default(BlobHandle)); Assert.Equal(1, builder.GetRowCounts()[(int)TableIndex.MethodSpec]); builder.AddModuleReference(default(StringHandle)); Assert.Equal(1, builder.GetRowCounts()[(int)TableIndex.ModuleRef]); builder.AddParameter(default(ParameterAttributes), default(StringHandle), default(int)); Assert.Equal(1, builder.GetRowCounts()[(int)TableIndex.Param]); var genericParameter = builder.AddGenericParameter(MetadataTokens.MethodDefinitionHandle(1), default(GenericParameterAttributes), default(StringHandle), default(int)); Assert.Equal(1, builder.GetRowCounts()[(int)TableIndex.GenericParam]); Assert.Equal(1, MetadataTokens.GetRowNumber(genericParameter)); builder.AddGenericParameterConstraint(default(GenericParameterHandle), MetadataTokens.TypeDefinitionHandle(1)); Assert.Equal(1, builder.GetRowCounts()[(int)TableIndex.GenericParamConstraint]); builder.AddFieldDefinition(default(FieldAttributes), default(StringHandle), default(BlobHandle)); Assert.Equal(1, builder.GetRowCounts()[(int)TableIndex.Field]); builder.AddFieldLayout(default(FieldDefinitionHandle), default(int)); Assert.Equal(1, builder.GetRowCounts()[(int)TableIndex.FieldLayout]); builder.AddMarshallingDescriptor(MetadataTokens.FieldDefinitionHandle(1), default(BlobHandle)); Assert.Equal(1, builder.GetRowCounts()[(int)TableIndex.FieldMarshal]); builder.AddFieldRelativeVirtualAddress(default(FieldDefinitionHandle), default(int)); Assert.Equal(1, builder.GetRowCounts()[(int)TableIndex.FieldRva]); var methodDefinition = builder.AddMethodDefinition(default(MethodAttributes), default(MethodImplAttributes), default(StringHandle), default(BlobHandle), default(int), default(ParameterHandle)); Assert.Equal(1, builder.GetRowCounts()[(int)TableIndex.MethodDef]); Assert.Equal(1, MetadataTokens.GetRowNumber(methodDefinition)); builder.AddMethodImport(MetadataTokens.MethodDefinitionHandle(1), default(MethodImportAttributes), default(StringHandle), default(ModuleReferenceHandle)); Assert.Equal(1, builder.GetRowCounts()[(int)TableIndex.ImplMap]); builder.AddMethodImplementation(default(TypeDefinitionHandle), MetadataTokens.MethodDefinitionHandle(1), MetadataTokens.MethodDefinitionHandle(1)); Assert.Equal(1, builder.GetRowCounts()[(int)TableIndex.MethodImpl]); var memberReference = builder.AddMemberReference(MetadataTokens.TypeDefinitionHandle(1), default(StringHandle), default(BlobHandle)); Assert.Equal(1, builder.GetRowCounts()[(int)TableIndex.MemberRef]); Assert.Equal(1, MetadataTokens.GetRowNumber(memberReference)); builder.AddManifestResource(default(ManifestResourceAttributes), default(StringHandle), MetadataTokens.AssemblyFileHandle(1), default(uint)); Assert.Equal(1, builder.GetRowCounts()[(int)TableIndex.ManifestResource]); builder.AddAssemblyFile(default(StringHandle), default(BlobHandle), default(Boolean)); Assert.Equal(1, builder.GetRowCounts()[(int)TableIndex.File]); builder.AddExportedType(default(TypeAttributes), default(StringHandle), default(StringHandle), MetadataTokens.AssemblyFileHandle(1), default(int)); Assert.Equal(1, builder.GetRowCounts()[(int)TableIndex.ExportedType]); builder.AddDeclarativeSecurityAttribute(MetadataTokens.TypeDefinitionHandle(1), default(DeclarativeSecurityAction), default(BlobHandle)); Assert.Equal(1, builder.GetRowCounts()[(int)TableIndex.DeclSecurity]); builder.AddEncLogEntry(MetadataTokens.TypeDefinitionHandle(1), default(EditAndContinueOperation)); Assert.Equal(1, builder.GetRowCounts()[(int)TableIndex.EncLog]); builder.AddEncMapEntry(MetadataTokens.TypeDefinitionHandle(1)); Assert.Equal(1, builder.GetRowCounts()[(int)TableIndex.EncMap]); var document = builder.AddDocument(default(BlobHandle), default(GuidHandle), default(BlobHandle), default(GuidHandle)); Assert.Equal(1, builder.GetRowCounts()[(int)TableIndex.Document]); Assert.Equal(1, MetadataTokens.GetRowNumber(document)); builder.AddMethodDebugInformation(default(DocumentHandle), default(BlobHandle)); Assert.Equal(1, builder.GetRowCounts()[(int)TableIndex.MethodDebugInformation]); var localScope = builder.AddLocalScope(default(MethodDefinitionHandle), default(ImportScopeHandle), default(LocalVariableHandle), default(LocalConstantHandle), default(int), default(int)); Assert.Equal(1, builder.GetRowCounts()[(int)TableIndex.LocalScope]); Assert.Equal(1, MetadataTokens.GetRowNumber(localScope)); var localVariable = builder.AddLocalVariable(default(LocalVariableAttributes), default(int), default(StringHandle)); Assert.Equal(1, builder.GetRowCounts()[(int)TableIndex.LocalVariable]); Assert.Equal(1, MetadataTokens.GetRowNumber(localVariable)); var localConstant = builder.AddLocalConstant(default(StringHandle), default(BlobHandle)); Assert.Equal(1, builder.GetRowCounts()[(int)TableIndex.LocalConstant]); Assert.Equal(1, MetadataTokens.GetRowNumber(localConstant)); var importScope = builder.AddImportScope(default(ImportScopeHandle), default(BlobHandle)); Assert.Equal(1, builder.GetRowCounts()[(int)TableIndex.ImportScope]); Assert.Equal(1, MetadataTokens.GetRowNumber(importScope)); builder.AddStateMachineMethod(default(MethodDefinitionHandle), default(MethodDefinitionHandle)); Assert.Equal(1, builder.GetRowCounts()[(int)TableIndex.StateMachineMethod]); builder.AddCustomDebugInformation(default(EntityHandle), default(GuidHandle), default(BlobHandle)); Assert.Equal(1, builder.GetRowCounts()[(int)TableIndex.CustomDebugInformation]); }