Skip to content

AssemblyAnalyzer

Namespace: Dotsider.Core.Analysis

Assembly: Dotsider.Core.dll

Core analyzer that reads .NET assemblies, Webcil app assemblies, native binaries, and raw Wasm modules. It uses BCL metadata/PE readers where possible and routes runtime-native formats through dotsider’s format readers for IL, strings, symbols, disassembly, and size data.

public sealed class AssemblyAnalyzer : IDisposable

ObjectAssemblyAnalyzer

AssemblyAnalyzer(byte[], string, string?, string?, string?, string?)

Section titled “AssemblyAnalyzer(byte[], string, string?, string?, string?, string?)”

Creates an analyzer from raw module bytes with resolution context inherited from its manifest assembly.

Parameters:

  • bytes (Byte[]): The raw module bytes.
  • filePath (String): The authenticated sibling-module path.
  • sourceBundlePath (String): The source bundle path, or null.
  • displayName (String): The logical name of the analyzed module.
  • targetFrameworkOverride (String): The manifest’s target-framework context.
  • preferredRuntimePackOverride (String): The manifest’s preferred runtime pack.

Exceptions:

public AssemblyAnalyzer(byte[] bytes, string filePath, string? sourceBundlePath, string? displayName, string? targetFrameworkOverride, string? preferredRuntimePackOverride)

AssemblyAnalyzer(byte[], string, string?, string?)

Section titled “AssemblyAnalyzer(byte[], string, string?, string?)”

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

Parameters:

  • bytes (Byte[]): The raw assembly bytes.
  • filePath (String): On-disk path for physical operations (tracing, save checks).
  • sourceBundlePath (String): If this assembly was extracted from a single-file bundle, the path to the bundle file. Used for assembly resolution context.
  • displayName (String): Logical name of the analyzed artifact for UI display (e.g. “SelfContainedConsole.dll” when the entry assembly is extracted from a bundle). If null, defaults to the file name portion of filePath.

Exceptions:

public AssemblyAnalyzer(byte[] bytes, string filePath, string? sourceBundlePath = null, string? displayName = null)

Opens and analyzes the specified .NET assembly file.

Parameters:

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

Exceptions:

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; }

Coarse classification of the analyzed binary.

Returns: BinaryKind

public BinaryKind BinaryKind { get; }

Whether in-place hex save is supported. Returns false for bundle-backed analyzers because writing extracted entry bytes back over the bundle would corrupt it.

Returns: Boolean

public bool CanSaveInPlace { 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; }

Gets the PE debug directory entries.

Returns: IReadOnlyList<DebugDirectoryInfo>

public IReadOnlyList<DebugDirectoryInfo> DebugDirectory { get; }

The ILC dependency graph found next to a Native AOT binary, or null when this is not a Native AOT binary or no readable DGML sidecar sits beside it. Graphs run to hundreds of thousands of links, so touch this only when a dependency question is actually being asked. The value is assigned before the probed flag, so a rare concurrent first read costs at most a second parse of immutable data.

Returns: DgmlGraph

public DgmlGraph? Dgml { get; }

The path of the DGML sidecar next to a Native AOT binary — the codegen graph when present (its node names match the mstat’s exactly), else the scan graph — or null when this is not a Native AOT binary or neither file is present.

Returns: String

public string? DgmlPath { get; }

Logical display name for the analyzed artifact. For bundle-backed analyzers this is the entry assembly file name (e.g. “SelfContainedConsole.dll”) while FilePath points to the bundle executable on disk. For file-backed analyzers, equals FileName.

Returns: String

public string DisplayName { get; }

Gets the native export table: PE exports, or the defined global symbols of an ELF or Mach-O image. Needs no CLR header; empty when the image exports nothing.

Returns: IReadOnlyList<ExportedFunctionInfo>

public IReadOnlyList<ExportedFunctionInfo> Exports { get; }

Gets the FieldDef metadata table entries.

Returns: IReadOnlyList<FieldDefInfo>

public IReadOnlyList<FieldDefInfo> FieldDefs { 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; }

Frozen String literals recovered from a Native AOT binary’s frozen object region — the AOT counterpart of the #US heap. Empty when this is not a Native AOT binary, or on Linux where the region is filled at startup and has no file backing (the raw UTF-16 scan surfaces that text instead).

Returns: IReadOnlyList<StringEntry>

public IReadOnlyList<StringEntry> FrozenStrings { get; }

Whether this image has precompiled native method bodies mapped to managed methods.

Returns: Boolean

public bool HasEmbeddedNativeCode { get; }

Whether this image carries ECMA-335 metadata (managed or ReadyToRun).

Returns: Boolean

public bool HasManagedMetadata { get; }

Whether the PE file contains .NET metadata.

Returns: Boolean

public bool HasMetadata { get; }

Gets whether a portable PDB was opened.

Returns: Boolean

public bool HasPortablePdb { get; }

Gets the native import table: PE import descriptors, ELF needed libraries and undefined dynamic symbols, or Mach-O loaded dylibs and undefined symbols. ELF symbols whose GNU version requirements are absent or malformed are grouped under (unversioned) rather than attributed to untrusted metadata. Needs no CLR header.

Returns: IReadOnlyList<ImportedModuleInfo>

public IReadOnlyList<ImportedModuleInfo> Imports { get; }

Whether this analyzer was created from bytes extracted from a single-file bundle.

Returns: Boolean

public bool IsBundleBacked { get; }

Whether the file is read-only on disk.

Returns: Boolean

public bool IsReadOnly { get; }

Whether this is a crossgen2 ReadyToRun image.

Returns: Boolean

public bool IsReadyToRun { get; }

The last modification time in UTC.

Returns: DateTime

public DateTime LastModified { get; }

The path to launch when tracing this assembly. For bundle-backed analyzers this is the bundle executable; for file-backed analyzers this is FilePath.

Returns: String

public string LaunchPath { get; }

Gets the parsed load configuration directory, or null when absent or not a PE.

Returns: LoadConfigInfo

public LoadConfigInfo? LoadConfig { get; }

The managed↔native correlation index over the attached companion set, built lazily on first access; null before AttachPreIlcCompanions. A build that races a detach or dispose abandons its result: it captures the generation up front, materializes inputs under an ObjectDisposedException guard, and publishes only when the generation is unchanged.

Returns: ManagedNativeIndex

public ManagedNativeIndex? ManagedNativeIndex { 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 ILC size report found next to a Native AOT binary, or null when this is not a Native AOT binary or no readable .mstat sidecar sits beside it. The value is assigned before the probed flag, so a rare concurrent first read costs at most a second parse of immutable data.

Returns: MstatData

public MstatData? Mstat { get; }

The path of the .mstat sidecar next to a Native AOT binary, or null when this is not a Native AOT binary or the file is absent.

Returns: String

public string? MstatPath { get; }

Facts from the embedded ReadyToRun header when this is a Native AOT binary, or null. Only probed for metadata-less files — a managed ReadyToRun assembly also embeds the header, but there it accompanies metadata rather than replacing it.

Returns: NativeAotInfo

public NativeAotInfo? NativeAotInfo { get; }

The native symbols of this binary — function names, addresses, and sizes read from its PDB, DWARF, or dSYM, or function boundaries from unwind data when no symbols exist. Null for managed assemblies. Parsed on demand; the value is assigned before the probed flag, so a rare concurrent first read costs at most a second parse of immutable data.

Returns: NativeSymbolInfo

public NativeSymbolInfo? NativeSymbols { get; }

The symbol file the native symbols were read from (PDB, .dbg, or dSYM), or null.

Returns: String

public string? NativeSymbolsPath { get; }

Portable PDB provenance for the analyzed assembly.

Returns: PdbProvenance

public PdbProvenance PdbProvenance { get; }

The parsed PE headers.

Returns: PeHeaders

public PeHeaders? PeHeaders { get; }

The preferred .NET runtime pack for this assembly, detected from its assembly references. Returns “Microsoft.WindowsDesktop.App” for WPF/WinForms assemblies, “Microsoft.AspNetCore.App” for ASP.NET Core assemblies, or “Microsoft.NETCore.App” otherwise.

Returns: String

public string PreferredRuntimePack { get; }

The attached pre-ILC companion set, or null before AttachPreIlcCompanions succeeds. Owned by this analyzer — see PreIlcCompanionSet for the ownership contract.

Returns: PreIlcCompanionSet

public PreIlcCompanionSet? PreIlcCompanions { get; }

The pre-ILC build outputs probed for a Native AOT binary — its managed input, portable PDB, and intermediate-tree mstat/DGML sidecars — or null when this is not a Native AOT binary or nothing was found. The value is assigned before the probed flag, so a rare concurrent first read costs at most a second probe.

Returns: PreIlcSidecars

public PreIlcSidecars? PreIlcSidecars { 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; }

The analyzer whose bytes hold this image’s precompiled native code — itself for a non-composite or composite image, or the resolved owner composite for a composite component. Null when this is not a ReadyToRun image or the code image cannot be resolved.

Returns: AssemblyAnalyzer

public AssemblyAnalyzer? ReadyToRunCodeImage { get; }

The component assemblies of a composite ReadyToRun image, each with its resolution state, or an empty list for a non-composite image or before resolution.

Returns: IReadOnlyList<ReadyToRunComponent>

public IReadOnlyList<ReadyToRunComponent> ReadyToRunComponents { get; }

The queryable index over this image’s precompiled methods, or null when the image is not ReadyToRun or its method-map tables are unavailable, malformed, or over budget. Built lazily from ReadyToRunMethods.

Returns: ReadyToRunIndex

public ReadyToRunIndex? ReadyToRunIndex { get; }

The crossgen2 ReadyToRun header facts, or null when the image does not claim to be ReadyToRun. Present (with a diagnostic Status) even for a corrupt or unsupported header, so a broken image is surfaced rather than hidden. Probed lazily regardless of HasMetadata (composite images have no own metadata).

Returns: ReadyToRunInfo

public ReadyToRunInfo? ReadyToRunInfo { get; }

The distinct metadata providers backing this ReadyToRun image — itself for a non-composite one, or the resolved component assemblies for a composite. Used to find a method that is present in a component’s metadata but absent from the precompiled map. Empty when this is not a ReadyToRun image.

Returns: IReadOnlyList<AssemblyAnalyzer>

public IReadOnlyList<AssemblyAnalyzer> ReadyToRunMetadataProviders { get; }

The precompiled methods of a ReadyToRun image joined to their native code ranges, or an empty list when this is not a usable ReadyToRun image or its method-map tables are malformed or exceed their traversal budget. The remaining ReadyToRun header, section, and managed metadata remain available. Built lazily from the entry-point tables. For a non-composite image the code lives in this file; composite resolution is layered on in ReadyToRunImageReader.

Returns: IReadOnlyList<ReadyToRunMethodEntry>

public IReadOnlyList<ReadyToRunMethodEntry> ReadyToRunMethods { get; }

The ReadyToRun section table — the Native AOT module sections for a Native AOT binary, or the crossgen2 sections (ids 100–126) for a classic ReadyToRun image — or an empty list otherwise. Both feed the PE/Metadata “R2R Sections” tab.

Returns: IReadOnlyList<RtrSection>

public IReadOnlyList<RtrSection> ReadyToRunSections { get; }

Types and method names recovered from a Native AOT binary’s embedded NativeFormat metadata (ReadyToRun section 313, or the reduced stack-trace metadata in 326). Empty when this is not a Native AOT binary or the binary carries no readable metadata. Malformed, cyclic, or excessively large metadata yields the fully decoded prefix.

Returns: IReadOnlyList<RecoveredType>

public IReadOnlyList<RecoveredType> RecoveredTypes { 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; }

If this assembly was loaded from a single-file bundle, the path to the bundle file. Used as resolution context when probing for referenced assemblies.

Returns: String

public string? SourceBundlePath { get; }

Gets decoded Source Link information from the portable PDB.

Returns: SourceLinkInfo

public SourceLinkInfo SourceLink { 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; }

Parsed WebAssembly module facts when this file is a raw .wasm module, or null for PE, ELF, and Mach-O inputs. The main .NET browser-wasm native module is dotnet.native.wasm. Malformed modules preserve the safely decoded prefix and report the reason through Diagnostic.

Returns: WasmModuleInfo

public WasmModuleInfo? WasmModuleInfo { get; }

Parsed Webcil provenance when this analyzer opened a Webcil managed assembly directly or unwrapped one from a WebAssembly container. Null for PE, raw Wasm, ELF, and Mach-O inputs.

Returns: WebcilInfo

public WebcilInfo? WebcilInfo { get; }

Opens the probed pre-ILC managed input (and validated local references) as an attached companion set. Idempotent — a second call returns the existing set. Returns null when there is nothing attachable or the companion cannot be opened. The set is owned by this analyzer and disposed with it.

Returns: PreIlcCompanionSet

public PreIlcCompanionSet? AttachPreIlcCompanions()

Detaches and disposes the pre-ILC companion set and drops the correlation index. A concurrent index build observes the generation change and never publishes.

public void DetachPreIlcCompanions()
public void Dispose()

Gets the first embedded source document referenced by a method’s sequence points.

Parameters:

  • method (MethodDefInfo): The method whose source should be resolved.

Returns: EmbeddedSourceInfo

The decoded embedded source, or null when none is available or its data is malformed or exceeds the supported size limit.

public EmbeddedSourceInfo? GetEmbeddedSource(MethodDefInfo method)

Gets embedded source for a portable PDB document path.

Parameters:

  • documentPath (String): The document path from the portable PDB.

Returns: EmbeddedSourceInfo

The decoded embedded source, or null when the document has none or its data is malformed or exceeds the supported size limit.

public EmbeddedSourceInfo? GetEmbeddedSource(string documentPath)

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. The returned block references analyzer-owned storage and must not be used after this analyzer is disposed.

Exceptions:

public MethodBodyBlock? GetMethodBody(MethodDefInfo method)

Gets portable PDB debug information for a method definition.

Parameters:

Returns: MethodDebugInfo

Decoded portable PDB information, or an empty result when no portable PDB is available.

public MethodDebugInfo GetMethodDebugInfo(MethodDefInfo method)

Gets the portable PDB MetadataReader, or null when no portable PDB is available.

Returns: MetadataReader

public MetadataReader? GetPdbReader()

IsFrameworkAssembly(AssemblyProvenance, AssemblyRefInfo, string?, string?)

Section titled “IsFrameworkAssembly(AssemblyProvenance, AssemblyRefInfo, string?, string?)”

Classifies whether an assembly belongs to the .NET framework surface regardless of deployment model. Returns true when the node was located through the shared framework or runtime directory, or when its identity matches a well-known Microsoft framework public key token, or when the shared-framework locator recognizes its simple name for the supplied target framework. This classification is used by the TUI framework-filter toggle so framework assemblies shipped inside a self-contained publish or single-file bundle are filtered consistently with framework assemblies loaded from the shared runtime.

Parameters:

  • provenance (AssemblyProvenance): How the node was located.
  • identity (AssemblyRefInfo): The resolved assembly’s identity.
  • targetFramework (String): The referencing assembly’s target framework moniker.
  • preferredRuntimePack (String): The referencing assembly’s preferred runtime pack.

Returns: Boolean

true if the node represents a framework assembly.

public static bool IsFrameworkAssembly(AssemblyProvenance provenance, AssemblyRefInfo identity, string? targetFramework, string? preferredRuntimePack)

The analyzer whose ECMA-335 metadata backs the given module — this image for a non-composite one, or the resolved component assembly for a composite. Falls back to this analyzer.

Parameters:

  • mvid (Guid): The module version id of the owning assembly.

Returns: AssemblyAnalyzer

public AssemblyAnalyzer ReadyToRunMetadataProviderFor(Guid mvid)

ResolveAssembly(string, string, string?, string?, string?)

Section titled “ResolveAssembly(string, string, string?, string?, string?)”

Resolves a referenced assembly name to a file on disk or bytes from a bundle. Probes: app-local, contained NuGet package assets named by .deps.json, runtime directory, source bundle, host process bundle, adjacent bundles, and .NET shared framework.

Parameters:

  • referencingAssemblyPath (String): Path of the assembly that references the target.
  • assemblyName (String): Assembly name without extension (e.g. “System.Runtime”).
  • targetFramework (String): Target framework moniker for version-matched shared framework probing.
  • preferredRuntimePack (String): Preferred runtime pack to probe first (e.g. “Microsoft.AspNetCore.App”).
  • sourceBundlePath (String): If the referencing assembly came from a bundle, the bundle path.

Returns: ResolvedAssembly

The resolved assembly, or null if not found.

public static ResolvedAssembly? ResolveAssembly(string referencingAssemblyPath, string assemblyName, string? targetFramework = null, string? preferredRuntimePack = null, string? sourceBundlePath = null)

ResolveAssemblyByIdentity(string, AssemblyRefInfo, string?, string?, string?, NetFxBindingContext?)

Section titled “ResolveAssemblyByIdentity(string, AssemblyRefInfo, string?, string?, string?, NetFxBindingContext?)”

Resolves a referenced assembly by full identity (name, version, culture, public key token). Probes every stage of String) and accepts only candidates whose manifest identity matches the requested identity exactly. If no probe produces a full match but at least one probe produces a simple-name match whose identity differs, returns IdentityMismatch with the path of that candidate — the graph does not expand from mismatched files.

Parameters:

  • referencingAssemblyPath (String): Path of the assembly that references the target.
  • identity (AssemblyRefInfo): The full identity the caller expects to resolve.
  • targetFramework (String): Target framework moniker for shared-framework probing.
  • preferredRuntimePack (String): Preferred runtime pack name.
  • sourceBundlePath (String): Bundle path, when the referencing assembly came from a bundle.
  • netFxBindingContext (NetFxBindingContext): Per-root .NET Framework binding context, or null for non-net48 roots. When supplied, the resolution routes through NetFxBindingContext) instead of the .NET Core probe chain, faithfully modeling the CLR’s framework unification + machine.config
  • publisher policy + app config + GAC + Framework[64] runtime + codeBase + appBase order.

Returns: AssemblyResolution

An AssemblyResolution carrying the resolved assembly, provenance, optional candidate-probe path, and (for net48 roots) the applied policy and loaded identity.

public static AssemblyResolution ResolveAssemblyByIdentity(string referencingAssemblyPath, AssemblyRefInfo identity, string? targetFramework = null, string? preferredRuntimePack = null, string? sourceBundlePath = null, NetFxBindingContext? netFxBindingContext = null)

Backward-compatible wrapper that resolves to a file path only. Returns null for bundle-backed results.

Parameters:

Returns: String

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

Resolves a portable PDB document path through Source Link mappings.

Parameters:

  • documentPath (String): The document path from the portable PDB.

Returns: String

The resolved Source Link URL, or null when no mapping applies.

public string? ResolveSourceLinkUrl(string documentPath)

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. Constructed generic methods include their decoded type arguments; malformed or unsupported metadata is returned as the original hexadecimal token.

public string ResolveToken(int token)