Dumpy.Console
1.1.1
dotnet add package Dumpy.Console --version 1.1.1
NuGet\Install-Package Dumpy.Console -Version 1.1.1
<PackageReference Include="Dumpy.Console" Version="1.1.1" />
<PackageVersion Include="Dumpy.Console" Version="1.1.1" />
<PackageReference Include="Dumpy.Console" />
paket add Dumpy.Console --version 1.1.1
#r "nuget: Dumpy.Console, 1.1.1"
#:package Dumpy.Console@1.1.1
#addin nuget:?package=Dumpy.Console&version=1.1.1
#tool nuget:?package=Dumpy.Console&version=1.1.1
Dumpy.Console
A fast object dumper that renders rich formatted output directly to your terminal. Ideal for data visualization, debugging and diagnostics: inspect objects, collections, tuples, DataTables, and more without writing custom pretty-printers.
Supports: netstandard2.1, net6.0 and later
Installation
.NET CLI
dotnet add package Dumpy.Console
Package Manager
Install-Package Dumpy.Console
PackageReference
<ItemGroup>
<PackageReference Include="Dumpy.Console" Version="1.0.0"/>
</ItemGroup>
🛈 This package depends on Spectre.Console for rich console visuals.
Quick start
Dump any object to the console
using Dumpy.Console;
var person = new { Name = "Ada", Age = 37 };
person.Dump();
Add a title
person.Dump("Person");
Customize rendering via options
using Dumpy.Console;
var options = new ConsoleDumpOptions
{
MaxDepth = 3,
ReferenceLoopHandling = ReferenceLoopHandling.IgnoreAndSerializeCyclicReference,
TableOptions = new TableOptions
{
ShowTitles = false,
}
};
person.Dump("Person", options);
Options
Default options:
new ConsoleDumpOptions
{
// Choose what to do with cyclic references, options:
// Error, Ignore, IgnoreAndSerializeCyclicReference, Serialize
ReferenceLoopHandling = ReferenceLoopHandling.Error,
// Limit traversal depth to avoid overly deep graphs.
MaxDepth = 5,
// Limit the number of items to dump from a collection. Set if you dump large lists, arrays...etc.
MaxCollectionItems = int.MaxValue,
// Whether to include dump instance fields.
IncludeFields = false,
// Whether to include non public properties and fields.
IncludeNonPublicMembers = false,
// Filter which member (property of field) will be included in the output.
MemberFilter = m => true,
// Register custom ConsoleConverter instances to control how specific types are rendered.
Converters = { new MyConsoleConverter() },
// If true, will wrap string values with double quotes (") and char values with single quotes (').
ShowTextQuotes = false,
// Control table visuals (titles, headers, row separators, expand behavior).
Tables = new TableOptions
{
ShowTitles = true, // Show table titles
ShowHeaders = true, // Show table headers
ShowRowSeparators = true, // Show table row line separators
Expand = false, // Expand the table width to fill available space
},
// Customize output styling.
Styles = new StyleOptions
{
Border = new Style(Color.PaleTurquoise4),
TitleText = new Style(decoration: Decoration.Bold | Decoration.Underline),
TableTitleText = new Style(decoration: Decoration.Bold | Decoration.Dim),
TableHeaderText = new Style(decoration: Decoration.Bold),
TableBorderType = TableBorder.Rounded,
String = new Style(Color.LightSalmon1),
Char = new Style(Color.LightSalmon1),
Boolean = new Style(Color.Cyan1),
Enum = new Style(Color.Yellow4_1),
Guid = new Style(Color.Plum3),
DateAndTime = new Style(Color.Gold3),
Numeric = new Style(Color.SkyBlue2),
Null = new Style(decoration: Decoration.Dim),
EmptyCollection = new Style(decoration: Decoration.Dim | Decoration.Bold),
}
}
API overview
The main utility class is the ConsoleDumper static class, which provides the following extension methods.
// Dumps the value directly to the console, and returns the same value. The second one has an option "title" parameter.
T DumpConsole(this T value, ConsoleDumpOptions? options = null)
T DumpConsole(this T value, string? title, ConsoleDumpOptions? options = null)
// Converts the value to a "Spectre.Console" `IRenderable`.
IRenderable DumpToRenderable(this T value, ConsoleDumpOptions? options = null)
IRenderable DumpToRenderable(this T value, Type valueType, ConsoleDumpOptions? options = null)
Usage
Dump to the console directly:
person.Dump(); // <== using the extension method, or
ConsoleDumper.Dump(person); // <== using the ConsoleDumper static class
Annotate the output with a title:
person.Dump("John Doe");
Dump to a IRenderable and then write it to the console yourself:
var renderable = person.DumpToRenderable();
AnsiConsole.Write(renderable);
Supported types
You can dump almost any .NET object or value, including:
- Primitives, anonymous types, POCOs
- Enumerables and collections (including multidimensional arrays)
- Tuples and ValueTuples
- DataTable and DataSet
- JsonDocuments and JsonElements
- XmlNodes and XNodes
Custom converters
To add your own converter, create a ConsoleConverter or a factory and register it via ConsoleDumpOptions.Converters
var options = new ConsoleDumpOptions();
options.Converters.Add(new MyCustomTypeConsoleConverter());
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. 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 was computed. 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 was computed. 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 was computed. 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. |
| .NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.1 is compatible. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- Dumpy.Abstractions (>= 1.1.1)
- Spectre.Console (>= 0.50.0)
- Spectre.Console.Json (>= 0.50.0)
-
net6.0
- Dumpy.Abstractions (>= 1.1.1)
- Spectre.Console (>= 0.50.0)
- Spectre.Console.Json (>= 0.50.0)
-
net7.0
- Dumpy.Abstractions (>= 1.1.1)
- Spectre.Console (>= 0.50.0)
- Spectre.Console.Json (>= 0.50.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories (1)
Showing the top 1 popular GitHub repositories that depend on Dumpy.Console:
| Repository | Stars |
|---|---|
|
tareqimbasher/NetPad
A cross-platform C# editor and playground.
|