<PackageReference Include="System.Reflection.Metadata" Version="11.0.0-preview.2.26159.112" />

System.Reflection.Metadata.Ecma335.MetadataBuilder

public sealed class MetadataBuilder
The MetadataBuilder class writes metadata for an assembly in a highly performant manner. It is designed for use by compilers and other assembly generation tools.
public MetadataBuilder(int userStringHeapStartOffset = 0, int stringHeapStartOffset = 0, int blobHeapStartOffset = 0, int guidHeapStartOffset = 0)

Creates a builder for metadata tables and heaps.

public AssemblyFileHandle AddAssemblyFile(StringHandle name, BlobHandle hashValue, bool containsMetadata)

public AssemblyReferenceHandle AddAssemblyReference(StringHandle name, Version version, StringHandle culture, BlobHandle publicKeyOrToken, AssemblyFlags flags, BlobHandle hashValue)

public ConstantHandle AddConstant(EntityHandle parent, object value)

Adds a default value for a parameter, field or property.

Adds a custom attribute.

Adds custom debug information.

Adds a declarative security attribute to a type, method, or assembly.

public DocumentHandle AddDocument(BlobHandle name, GuidHandle hashAlgorithm, BlobHandle hash, GuidHandle language)

Adds document debug information.

public void AddEncMapEntry(EntityHandle entity)

Adds an event definition.

public void AddEventMap(TypeDefinitionHandle declaringType, EventDefinitionHandle eventList)

public ExportedTypeHandle AddExportedType(TypeAttributes attributes, StringHandle namespace, StringHandle name, EntityHandle implementation, int typeDefinitionId)

Adds an exported type.

Adds a field definition.

public void AddFieldLayout(FieldDefinitionHandle field, int offset)

Defines a field layout of a field definition.

Adds a mapping from a field to its initial value stored in the PE image.

Adds a generic parameter definition.

Adds a type constraint to a generic parameter.

Adds local scope debug information.

Adds an interface implementation to a type.

Adds local constant debug information.

public LocalScopeHandle AddLocalScope(MethodDefinitionHandle method, ImportScopeHandle importScope, LocalVariableHandle variableList, LocalConstantHandle constantList, int startOffset, int length)

Adds local scope debug information.

Adds local variable debug information.

Adds a manifest resource.

public void AddMarshallingDescriptor(EntityHandle parent, BlobHandle descriptor)

Adds marshalling information to a field or a parameter.

Adds a MemberRef table row.

Adds method debug information.

public MethodDefinitionHandle AddMethodDefinition(MethodAttributes attributes, MethodImplAttributes implAttributes, StringHandle name, BlobHandle signature, int bodyOffset, ParameterHandle parameterList)

Adds a method definition.

Defines an implementation for a method declaration within a type.

Adds import information to a method definition.

public void AddMethodSemantics(EntityHandle association, MethodSemanticsAttributes semantics, MethodDefinitionHandle methodDefinition)

Associates a method (a getter, a setter, an adder, etc.) with a property or an event.

Adds a method specification (an instantiation).

public ModuleDefinitionHandle AddModule(int generation, StringHandle moduleName, GuidHandle mvid, GuidHandle encId, GuidHandle encBaseId)

public void AddNestedType(TypeDefinitionHandle type, TypeDefinitionHandle enclosingType)

Defines a nesting relationship to specified type definitions.

public ParameterHandle AddParameter(ParameterAttributes attributes, StringHandle name, int sequenceNumber)

Adds a parameter definition.

Adds a property definition.

public void AddPropertyMap(TypeDefinitionHandle declaringType, PropertyDefinitionHandle propertyList)

public void AddStateMachineMethod(MethodDefinitionHandle moveNextMethod, MethodDefinitionHandle kickoffMethod)

Adds state machine method debug information.

Adds a type definition.

public void AddTypeLayout(TypeDefinitionHandle type, ushort packingSize, uint size)

Defines a type layout of a type definition.

Adds a type reference.

Adds the specified blob from an immutable byte array to the Blob heap, if it's not there already.

public BlobHandle GetOrAddBlob(byte[] value)

Adds the specified blob to the Blob heap, if it's not there already.

Adds the specified blob from a byte array to the Blob heap, if it's not there already.

public BlobHandle GetOrAddBlobUTF16(string value)

Encodes a string using UTF16 encoding to a blob and adds it to the Blob heap, if it's not there already.

public BlobHandle GetOrAddBlobUTF8(string value, bool allowUnpairedSurrogates = true)

Encodes a string using UTF8 encoding to a blob and adds it to the Blob heap, if it's not there already.

public BlobHandle GetOrAddConstantBlob(object value)

Encodes a constant value to a blob and adds it to the Blob heap, if it's not there already. Uses UTF16 to encode string constants.

public BlobHandle GetOrAddDocumentName(string value)

Encodes a debug document name and adds it to the Blob heap, if it's not there already.

Adds the specified Guid to the Guid heap, if it's not there already.

public StringHandle GetOrAddString(string value)

Adds the specified string to the string heap, if it's not there already.

public UserStringHandle GetOrAddUserString(string value)

Adds the specified string to the user string heap, if it's not there already.

public int GetRowCount(TableIndex table)

Returns the current number of items in the specified table.

Returns the current number of items in each table.

Reserves space on the Guid heap for a GUID.

Reserves space on the user string heap for a string of the specified length.

public void SetCapacity(TableIndex table, int rowCount)

Sets the capacity of the specified table.

public void SetCapacity(HeapIndex heap, int byteCount)

Sets the capacity of the specified heap.