Table of Contents

Class StringsStreamBuffer

Namespace
AsmResolver.DotNet.Builder.Metadata
Assembly
AsmResolver.DotNet.dll

Provides a mutable buffer for building up a strings stream in a .NET portable executable.

public class StringsStreamBuffer : IMetadataStreamBuffer
Inheritance
StringsStreamBuffer
Implements
Inherited Members

Constructors

StringsStreamBuffer()

Creates a new strings stream buffer with the default strings stream name.

public StringsStreamBuffer()

StringsStreamBuffer(string)

Creates a new strings stream buffer.

public StringsStreamBuffer(string name)

Parameters

name string

The name of the stream.

Properties

IsEmpty

Gets a value indicating whether the metadata stream buffer does not contain any data.

public bool IsEmpty { get; }

Property Value

bool

Name

Gets the name of the stream.

public string Name { get; }

Property Value

string

Methods

CreateStream()

Serializes the strings stream buffer to a metadata stream.

public StringsStream CreateStream()

Returns

StringsStream

The metadata stream.

GetStringIndex(Utf8String?)

Gets the index to the provided string. If the string is not present in the buffer, it will be appended to the end of the stream.

public uint GetStringIndex(Utf8String? value)

Parameters

value Utf8String

The string to lookup or add.

Returns

uint

The index of the string.

ImportStream(StringsStream)

Imports the contents of a strings stream and indexes all present strings.

public void ImportStream(StringsStream stream)

Parameters

stream StringsStream

The stream to import.

Exceptions

InvalidOperationException

Occurs when the stream buffer is not empty.

Optimize()

Optimizes the buffer by removing string entries that have a common suffix with another.

public IDictionary<uint, uint> Optimize()

Returns

IDictionary<uint, uint>

A translation table that maps old offsets to the new ones after optimizing.

Remarks

This method might invalidate all offsets obtained by GetStringIndex(Utf8String?).