The Dumpify NuGet package (0.7.0) renders .NET objects as coloured console tables and can write them to the debug or trace streams. The article covers TruncationConfig, MembersConfig and StringWriter redirection for shorter, more readable debug output.
Key points
- Dump() is an extension method that writes the object to the console in the best presentation it can find; package version 0.7.0.
- TruncationConfig with MaxCollectionCount and the Head, Tail, HeadAndTail modes shortens long array output.
- TableConfig switches ShowTableHeaders and ShowArrayIndices off so header rows and index columns disappear.
- DumpConfig.Default sets one global default for every dump instead of repeating parameters per call.
- MembersConfig selects which fields appear via IncludeFields, IncludeNonPublicMembers and MemberFilter; ShowMemberTypes adds a type column.
- DumpOutput(new StringWriter()) captures the dump as a string, and ColorConfig.NoColors strips escape codes.
- DumpDebug(), DumpTrace() and DumpText() route output to the Visual Studio debug and trace streams or plain text.
Why it matters
Most teams still print object state with Console.WriteLine or raw ToString() in console apps and background workers; Dumpify fills that gap, but it does not replace structured logging with Serilog on production paths. Two details matter before adopting it: escape codes leak into redirected output unless you pass ColorConfig.NoColors, and DumpConfig.Default is a single global object, so several output profiles mean handing config instances to Dump by hand. The package is at 0.7.0, pre-1.0, so keep it in debug and test code where a breaking API change is cheap to absorb.
Real-world use
- Inspecting the fields of a complex object graph at a glance while debugging a console app
- Writing dumps as visual tables when log storage is cheap, so output is faster to analyse on screen and on paper
- Capturing the dump into a StringWriter and forwarding it to another sink or log writer
This summary was generated by the agent from the original post on dotnetpro (de). The full text and all rights belong to its author and publisher. Go to original