Table of Contents

Class Extensions

Namespace
AsmResolver
Assembly
AsmResolver.dll

Provides various extensions to AsmResolver related types.

public static class Extensions
Inheritance
Extensions
Inherited Members

Methods

Align(uint, uint)

Rounds the provided unsigned integer up to the nearest multiple of the provided alignment.

public static uint Align(this uint value, uint alignment)

Parameters

value uint

The value to align.

alignment uint

The alignment. Must be a power of 2.

Returns

uint

The aligned value.

Align(ulong, ulong)

Rounds the provided unsigned integer up to the nearest multiple of the provided alignment.

public static ulong Align(this ulong value, ulong alignment)

Parameters

value ulong

The value to align.

alignment ulong

The alignment. Must be a power of 2.

Returns

ulong

The aligned value.

AsPatchedSegment(ISegment)

Wraps the provided segment into a PatchedSegment, making it eligible for applying post-serialization patches.

public static PatchedSegment AsPatchedSegment(this ISegment segment)

Parameters

segment ISegment

The segment to wrap.

Returns

PatchedSegment

The wrapped segment, or segment if it is already an instance of PatchedSegment.

AsPatchedSegment(ISegment, bool)

Wraps the provided segment into a PatchedSegment, making it eligible for applying post-serialization patches.

public static PatchedSegment AsPatchedSegment(this ISegment segment, bool alwaysCreateNew)

Parameters

segment ISegment

The segment to wrap.

alwaysCreateNew bool

Indicates whether the segment should always be wrapped into a new instance of PatchedSegment, regardless of whether segment is already an instance of PatchedSegment or not.

Returns

PatchedSegment

The wrapped segment, or segment if it is already an instance of PatchedSegment and alwaysCreateNew is set to true.

CreateEscapedString(string)

Converts a string into an escaped string literal.

public static string CreateEscapedString(this string literal)

Parameters

literal string

The string to convert.

Returns

string

The escaped string.

CreateReader(IReadableSegment)

Creates a new binary reader that reads the raw contents of the segment.

public static BinaryStreamReader CreateReader(this IReadableSegment segment)

Parameters

segment IReadableSegment

The segment to read from.

Returns

BinaryStreamReader

The created binary reader.

CreateReader(IReadableSegment, ulong)

Creates a new binary reader that reads the raw contents of the segment.

public static BinaryStreamReader CreateReader(this IReadableSegment segment, ulong fileOffset)

Parameters

segment IReadableSegment

The segment to read from.

fileOffset ulong

The starting file offset of the reader.

Returns

BinaryStreamReader

The created binary reader.

Get7BitEncodedSize(uint)

Computes the number of bytes the provided integer would require after compressing it using the integer compression using the 7-bit encoding.

public static uint Get7BitEncodedSize(this uint value)

Parameters

value uint

The integer to determine the compressed size of.

Returns

uint

The number of bytes the value would require.

GetBinaryFormatterSize(string)

Computes the number of bytes required to represent the provided string as a binary formatted string.

public static uint GetBinaryFormatterSize(this string value)

Parameters

value string

The string to measure.

Returns

uint

The number of bytes.

GetBinaryFormatterSize(string, Encoding)

Computes the number of bytes required to represent the provided string as a binary formatted string.

public static uint GetBinaryFormatterSize(this string value, Encoding encoding)

Parameters

value string

The string to measure.

encoding Encoding

The encoding to use.

Returns

uint

The number of bytes.

GetCompressedSize(uint)

Computes the number of bytes the provided integer would require after compressing it using the integer compression as specified in ECMA-335.

public static uint GetCompressedSize(this uint value)

Parameters

value uint

The integer to determine the compressed size of.

Returns

uint

The number of bytes the value would require.

ToArray(IReadableSegment)

Reads the segment and puts the data in a byte array.

public static byte[] ToArray(this IReadableSegment segment)

Parameters

segment IReadableSegment

The segment to read.

Returns

byte[]

The byte array that was read.

ToReference(ISegment)

Constructs a reference to the start of the segment.

public static ISegmentReference ToReference(this ISegment segment)

Parameters

segment ISegment

The segment to reference.

Returns

ISegmentReference

The reference.

ToReference(ISegment, int)

Constructs a reference to an offset within the segment.

public static ISegmentReference ToReference(this ISegment segment, int additive)

Parameters

segment ISegment

The segment to reference.

additive int

The offset within the segment to reference.

Returns

ISegmentReference

The reference.

WriteIntoArray(ISegment)

Serializes the segment by calling Write(IBinaryStreamWriter) and writes the result into a byte array.

public static byte[] WriteIntoArray(this ISegment segment)

Parameters

segment ISegment

The segment to serialize to

Returns

byte[]

The resulting byte array.

WriteIntoArray(ISegment, MemoryStreamWriterPool)

Serializes the segment by calling Write(IBinaryStreamWriter) and writes the result into a byte array.

public static byte[] WriteIntoArray(this ISegment segment, MemoryStreamWriterPool pool)

Parameters

segment ISegment

The segment to serialize to

pool MemoryStreamWriterPool

The memory stream writer pool to rent temporary writers from.

Returns

byte[]

The resulting byte array.