Skip to content

AssemblyAnalyzer

Namespace: Dotsider.Core.Analysis

Assembly: Dotsider.Core.dll

Core analyzer that reads a .NET assembly and extracts PE, metadata, IL, and string information. Uses PEReader and MetadataReader from the BCL.

public sealed class AssemblyAnalyzer : IDisposable

ObjectAssemblyAnalyzer

Creates an analyzer from raw bytes in memory. Used as a last-resort fallback when disk I/O is unavailable after a save operation.

Parameters:

public AssemblyAnalyzer(byte[] bytes, string filePath)

Opens and analyzes the specified .NET assembly file.

Parameters:

  • filePath (String): Absolute path to the assembly file.
public AssemblyAnalyzer(string filePath)

The PE architecture description (e.g., “AnyCPU”, “x64”, “ARM64”).

Returns: String

public string Architecture { get; }

The assembly simple name, or null if the file has no assembly manifest.

Returns: String

public string? AssemblyName { get; }

Gets the AssemblyRef metadata table entries.

Returns: IReadOnlyList<AssemblyRefInfo>

public IReadOnlyList<AssemblyRefInfo> AssemblyRefs { get; }

The assembly version string, or null.

Returns: String

public string? AssemblyVersion { get; }

The parsed CLR header, or null if not a .NET assembly.

Returns: ClrHeader

public ClrHeader? ClrHeader { get; }

The creation time in UTC.

Returns: DateTime

public DateTime CreatedTime { get; }

The assembly culture, or null for culture-neutral assemblies.

Returns: String

public string? Culture { get; }

Gets the custom attributes applied to metadata entities.

Returns: IReadOnlyList<CustomAttributeInfo>

public IReadOnlyList<CustomAttributeInfo> CustomAttributes { get; }

The file name without directory path.

Returns: String

public string FileName { get; }

The full path to the analyzed assembly file.

Returns: String

public string FilePath { get; }

The file size in bytes.

Returns: Int64

public long FileSize { get; }

Whether the PE file contains .NET metadata.

Returns: Boolean

public bool HasMetadata { get; }

Whether the file is read-only on disk.

Returns: Boolean

public bool IsReadOnly { get; }

The last modification time in UTC.

Returns: DateTime

public DateTime LastModified { get; }

Gets the MemberRef metadata table entries.

Returns: IReadOnlyList<MemberRefInfo>

public IReadOnlyList<MemberRefInfo> MemberRefs { get; }

Gets the MethodDef metadata table entries.

Returns: IReadOnlyList<MethodDefInfo>

public IReadOnlyList<MethodDefInfo> MethodDefs { get; }

The parsed PE headers.

Returns: PeHeaders

public PeHeaders? PeHeaders { get; }

The public key token as a hex string, or null.

Returns: String

public string? PublicKeyToken { get; }

Gets the raw bytes of the file for hex editor display.

Returns: ReadOnlyMemory<Byte>

public ReadOnlyMemory<byte> RawBytes { get; }

Gets the manifest resources defined in the assembly.

Returns: IReadOnlyList<ResourceInfo>

public IReadOnlyList<ResourceInfo> Resources { get; }

Gets the PE sections.

Returns: IReadOnlyList<SectionInfo>

public IReadOnlyList<SectionInfo> Sections { get; }

The target framework moniker (e.g., ”.NETCoreApp,Version=v10.0”), or null.

Returns: String

public string? TargetFramework { get; }

Gets the TypeDef metadata table entries.

Returns: IReadOnlyList<TypeDefInfo>

public IReadOnlyList<TypeDefInfo> TypeDefs { get; }

Gets the TypeRef metadata table entries.

Returns: IReadOnlyList<TypeRefInfo>

public IReadOnlyList<TypeRefInfo> TypeRefs { get; }

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public void Dispose()

Gets the underlying MetadataReader for advanced queries. Returns null if the file has no .NET metadata.

Returns: MetadataReader

public MetadataReader? GetMetadataReader()

Gets the method body bytes for IL disassembly. Returns null if the method has no IL body (abstract, extern, or native).

Parameters:

  • method (MethodDefInfo): The method definition to get the body for.

Returns: MethodBodyBlock

The method body block, or null.

public MethodBodyBlock? GetMethodBody(MethodDefInfo method)

Attempts to resolve a referenced assembly name to a file path on disk. Searches the same directory as the referencing assembly, then .NET runtime dirs.

Parameters:

Returns: String

public static string? ResolveAssemblyPath(string referencingAssemblyPath, string assemblyName)

Resolves a metadata token to a human-readable name.

Parameters:

  • token (Int32): The metadata token to resolve.

Returns: String

A display string for the token.

public string ResolveToken(int token)