Table of Contents

Class BundleFile

Namespace
AsmResolver.DotNet.Bundles
Assembly
AsmResolver.DotNet.dll

Represents a single file in a .NET bundle manifest.

public class BundleFile : IOwnedCollectionElement<BundleManifest>
Inheritance
BundleFile
Implements
Derived
Inherited Members

Constructors

BundleFile(string)

Creates a new empty bundle file.

public BundleFile(string relativePath)

Parameters

relativePath string

The path of the file, relative to the root of the bundle.

BundleFile(string, BundleFileType, ISegment)

Creates a new empty bundle file.

public BundleFile(string relativePath, BundleFileType type, ISegment contents)

Parameters

relativePath string

The path of the file, relative to the root of the bundle.

type BundleFileType

The type of the file.

contents ISegment

The contents of the file.

BundleFile(string, BundleFileType, byte[])

Creates a new bundle file.

public BundleFile(string relativePath, BundleFileType type, byte[] contents)

Parameters

relativePath string

The path of the file, relative to the root of the bundle.

type BundleFileType

The type of the file.

contents byte[]

The contents of the file.

Properties

CanRead

Gets a value whether the contents of the file can be read using a BinaryStreamReader.

public bool CanRead { get; }

Property Value

bool

Contents

Gets or sets the raw contents of the file.

public ISegment Contents { get; set; }

Property Value

ISegment

IsCompressed

Gets or sets a value indicating whether the data stored in Contents is compressed or not.

public bool IsCompressed { get; set; }

Property Value

bool

Remarks

The default implementation of the application host by Microsoft only supports compressing files if it is a fully self-contained binary and the file is not the .deps.json nor the .runtmeconfig.json file. This property does not do validation on any of these conditions. As such, if the file is supposed to be compressed with any of these conditions not met, a custom application host template needs to be provided upon serializing the bundle for it to be runnable.

ParentManifest

Gets the parent manifest this file was added to.

public BundleManifest? ParentManifest { get; }

Property Value

BundleManifest

RelativePath

Gets or sets the path to the file, relative to the root directory of the bundle.

public string RelativePath { get; set; }

Property Value

string

Type

Gets or sets the type of the file.

public BundleFileType Type { get; set; }

Property Value

BundleFileType

Methods

Compress()

Marks the file as compressed, compresses the file contents, and replaces the value of Contents with the result.

public void Compress()

Remarks

The default implementation of the application host by Microsoft only supports compressing files if it is a fully self-contained binary and the file is not the .deps.json nor the .runtmeconfig.json file. This method does not do validation on any of these conditions. As such, if the file is supposed to be compressed with any of these conditions not met, a custom application host template needs to be provided upon serializing the bundle for it to be runnable.

Exceptions

InvalidOperationException

Occurs when the file was already compressed.

Decompress()

Marks the file as uncompressed, decompresses the file contents, and replaces the value of Contents with the result.

public void Decompress()

Exceptions

InvalidOperationException

Occurs when the file was not compressed.

GetContents()

Obtains the raw contents of the file.

protected virtual ISegment? GetContents()

Returns

ISegment

The contents.

Remarks

This method is called upon initialization of the Contents property.

GetData()

Reads (and decompresses if necessary) the contents of the file.

public byte[] GetData()

Returns

byte[]

The contents.

GetData(bool)

Reads the contents of the file.

public byte[] GetData(bool decompressIfRequired)

Parameters

decompressIfRequired bool

true if the contents should be decompressed or not when necessary.

Returns

byte[]

The contents.

ToString()

Returns a string that represents the current object.

public override string ToString()

Returns

string

A string that represents the current object.

TryGetReader(out BinaryStreamReader)

Attempts to create a BinaryStreamReader that points to the start of the raw contents of the file.

public bool TryGetReader(out BinaryStreamReader reader)

Parameters

reader BinaryStreamReader

The reader.

Returns

bool

true if the reader was constructed successfully, false otherwise.