DumpLinq.LINQPad 0.1.3

dotnet add package DumpLinq.LINQPad --version 0.1.3
                    
NuGet\Install-Package DumpLinq.LINQPad -Version 0.1.3
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="DumpLinq.LINQPad" Version="0.1.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="DumpLinq.LINQPad" Version="0.1.3" />
                    
Directory.Packages.props
<PackageReference Include="DumpLinq.LINQPad" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add DumpLinq.LINQPad --version 0.1.3
                    
#r "nuget: DumpLinq.LINQPad, 0.1.3"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package DumpLinq.LINQPad@0.1.3
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=DumpLinq.LINQPad&version=0.1.3
                    
Install as a Cake Addin
#tool nuget:?package=DumpLinq.LINQPad&version=0.1.3
                    
Install as a Cake Tool

DumpLinq

NuGet

DumpLinq is a library for querying .NET memory dumps using familiar LINQ syntax. It is built on top of ClrMD and provides higher-level abstractions that simplify navigating the dump.

Example

Let's say you have the following class in the process you dumped:

class Foo
{
    private List<string> _strings;
    private DateTime _time;
    private string _title;
}

If you wanted to find and print all instances of Foo in the dump, where _strings contains at least one string that is equal to Bar, then you could do that with the following code:

using var dump = Dump.Open(@"d:\ExampleDump.dmp");
var instances = dump.EnumerateHeapObjects("*.Foo")
        .Where(foo => foo
            .GetField("_strings")
            .GetField("_items")
            .EnumerateArrayItems()
            .Any(item => item.AsString() == "Bar"));

foreach (var instance in instances)
{
    Console.WriteLine(instance.ToString());
}

The output is a tree representation of the object graph:

ExampleDump.Foo @ 0x000002E5730ABA90
  _strings: System.Collections.Generic.List<System.String> @ 0x000002E5730ABA38
    _items: System.String[] @ 0x000002E5730ABA58
      [0]: "A"
      [1]: "B"
      [2]: "C"
      [3]: "Bar"
    _size: 4
    _version: 1
  _time: 01/01/2024 00.00.00
  _title: "With Bar"

Getting Started

Let's break down the query above to learn how to build your own.

Enumerating Heap Objects

IEnumerable<DumpObject> Dump.EnumerateHeapObjects(string pattern)

Enumerates all objects that have their own allocation on the managed heap (i.e. reference types and boxed value types, but not value types stored inline within other objects).

EnumerateHeapObjects expects fully qualified type names (including namespace), but it supports wildcards. If your
type name is unique, you can use a pattern like *.Foo.

dump.EnumerateHeapObjects("*.Foo")

This returns a DumpObject for every independently allocated object whose full type name matches *.Foo.

Accessing Fields

DumpObject DumpObject.GetField(string name)

Returns a DumpObject that represents the object stored in the specified field.

In DumpLinq, everything on the heap is represented as a DumpObject, including

  • Reference types
  • Value types
  • Boxed value types
  • Primitive types
  • Arrays
  • Enums

For example:

foo.GetField("_strings")

Gets the _strings field from Foo.

GetField("_items")

Gets the _items backing array from List<string>.

Enumerating Arrays

IEnumerable<DumpObject> EnumerateArrayItems()

Enumerates all elements of a DumpObject when it represents an array.

If the object is not an array, it returns an empty sequence.

Reading Values

DumpObjectValue<string> DumpObject.AsString()

Attempts to read the object as a string

  • If the object represents a string the value is returned
  • If the object represents an enum, the enum's string representation is returned
  • Otherwise, a failed DumpObjectValue<string> is returned

To read primitive or unmanaged value types, you can use:

DumpObjectValue<T> DumpObject.ReadAs<T>()

ReadAs<T> reads the value represented by the DumpObject as type T.

T doesn't have to match the exact type represented by the DumpObject, but the following constraints apply:

  • DumpObject must be a value type (boxed value types also work)
  • T must be an unmanaged type (i.e. a primitive type or a struct that doesn't contain any managed references)
  • The size of T must match the size of the value represented by the DumpObject.
  • Otherwise, a failed DumpObjectValue<T> is returned

To illustrate the use of ReadAs<T> we can modify the previous query to return all Foo instances where _strings contains more than 5 elements:

using var dump = Dump.Open(@"d:\ExampleDump.dmp");
var instances = dump.EnumerateHeapObjects("*.Foo")
        .Where(foo => foo
            .GetField("_strings")
            .GetField("_size")
            .ReadAs<int>() > 5);

Printing Objects

string DumpObject.ToString(int depth = 3, int arrayItems = 5)

Returns a tree-like representation of the object. The depth parameter controls the maximum depth of nested objects to include, and the arrayItems parameter controls the maximum number of elements to include from each array.

LINQPad support

If you want to use DumpLinq with LINQPad, the NuGet package DumpLinq.LINQPad provides a ToDump extension method for DumpObject It converts the object into an ExpandoObject, allowing you to explore it using LINQPad's interactive object viewer instead of DumpLinq's text-based tree output. The returned object is intended for use with LINQPad's Dump method.

LINQPad

Like the DumpObject.ToString method, DumpObject.ToDump takes a depth parameter that controls how many levels are expanded. Unlike the static string representation, in LINQPad objects beyond this level can be expanded lazily by clicking on them.

LINQPad

Lazy expansion requires access to the underlying dump. If the Dump has already been disposed, expanding deferred nodes will fail. For this reason, examples use:

var dump = Dump.Open(@"d:\ExampleDump.dmp");

rather than:

using var dump = Dump.Open(@"d:\ExampleDump.dmp");

Product Compatible and additional computed target framework versions.
.NET net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.1.3 92 2/26/2026
0.1.2 105 2/20/2026