/ObjectDumper

A Visual Studio 2019-2022 and Visual Studio Code extension for exporting in-memory objects during debugging to C#, JSON, VB, XML, and YAML string.

Primary LanguageC#MIT LicenseMIT

Stand With Ukraine

Object Dumper

VS marketplace VS installs VS Code marketplace VS Code installs

License: MIT

Reflection-based Visual Studio and Visual Studio Code extension for exporting in-memory objects during debugging to C# Object Initialization Code, JSON, Visual Basic Object Initialization Code, XML, and YAML string.

Inspired by ObjectExporter.

The closest alternative is proprietary OzCode export functionality.

"Dump as" commands are available via context menu in the Code and Immediate windows.

The result will be printed to a new document window, Output Window -> Object Dumper Pane, or copied to the clipboard, depending on the DumpTo option.

Presentation

Configurable:

image

Quick tips:

  • How to compare two dumped objects:
    1. Enable option "Show Miscellaneous files in Solution Explorer": image
    2. If you use Visual Studio 17.7 or above - just skip this step (it's an embedded), otherwise install a diff extension - I verified the Heku.VsDiff
    3. Select files in Solution Explorer under the Miscellaneous Files folder -> Right click -> Compare Selected(Files): image

Known limitations:

  • C#, F# and VisualBasic project languages are currently supported only.
  • netstandard 2.0+, netcore2.0+, netframework 4.5+
  • if you are debugging the solution in Release mode or debuging DLLs from another source, such as a nuget package, you'll get an error message: "Cannot evaluate expression because the code of the current method is optimized" or "error CS0103: The name 'YellowFlavor' does not exist in the current context". Solution: switch to Debug mode or turn the Tools > Options > Debugging > General > Suppress JIT optimization on module load option on.
  • local debugging only.
  • if you see any encoding-related issues, please select the option: Tools > Options > Environment > Documents > Save documents as Unicode when data cannot be saved in codepage.
  • it doesn't work for UWP applications, because UAP doesn't support Assembly.LoadFrom. You can bypass this restriction by referencing the .nestandard20 version of Serialization lib and calling: YellowFlavor.Serialization.ObjectSerializer.WarmUp(); for loading the serializer into executing assembly. Example

Privacy Notice: No personal data is collected at all.

Powered By

Repository License
ILRepack Apache-2.0
Json.NET MIT
VarDump Apache-2.0
YamlDotNet MIT

❤ Like this project and want to contribute?