ObjectDumper.NET 3.4.6

.NET Standard 1.2 .NET Framework 4.5
There is a newer prerelease version of this package available.
See the version list below for details.
Install-Package ObjectDumper.NET -Version 3.4.6
dotnet add package ObjectDumper.NET --version 3.4.6
<PackageReference Include="ObjectDumper.NET" Version="3.4.6" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add ObjectDumper.NET --version 3.4.6
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: ObjectDumper.NET, 3.4.6"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install ObjectDumper.NET as a Cake Addin
#addin nuget:?package=ObjectDumper.NET&version=3.4.6

// Install ObjectDumper.NET as a Cake Tool
#tool nuget:?package=ObjectDumper.NET&version=3.4.6
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

ObjectDumper.NET

Version Downloads

ObjectDumper is a utility which aims to serialize C# objects to string for debugging and logging purposes.

Download and Install ObjectDumper.NET

This library is available on NuGet: https://www.nuget.org/packages/ObjectDumper.NET/ Use the following command to install ObjectDumper using NuGet package manager console:

PM> Install-Package ObjectDumper.NET

You can use this library in any .NET project which is compatible to PCL (e.g. Xamarin Android, iOS, Windows Phone, Windows Store, Universal Apps, etc.)

The Purpose of ObjectDumper

Serialization, the process of converting a complex object to a machine-readable or over-the-wire transmittable string, is a technique often used in software engineering. A well-known serializer is Newtonsoft.JSON which serializes .NET objects to the data representation format JSON.

ObjectDumper.NET provides two excellent ways to visualize in-memory .NET objects:

  • DumpStyle.Console: serialize objects to human-readable strings, often used to write complex C# objects to log files.
  • DumpStyle.CSharp: serialize objects to C# initializer code, which can be used to compile a C# object again.

API Usage

Dumping C# Objects to Console.WriteLine

The following sample program uses DumpStyle.Console to write C# objects to the console output:

static void Main(string[] args)
{
    var persons = new List<Person>
    {
        new Person { Name = "John", Age = 20, },
        new Person { Name = "Thomas", Age = 30, },
    };

    var personsDump = ObjectDumper.Dump(persons);

    Console.WriteLine(personsDump);
    Console.ReadLine();
}

//CONSOLE OUTPUT:
{ObjectDumperSample.Netfx.Person}
  Name: "John"
  Age: 20
{ObjectDumperSample.Netfx.Person}
  Name: "Thomas"
  Age: 30
Dumping C# initializer code from in-memory objects to Console.WriteLine

The following sample program uses DumpStyle.CSharp to write C# initializer code from in-memory to the console output:

static void Main(string[] args)
{
    var persons = new List<Person>
    {
        new Person { Name = "John", Age = 20, },
        new Person { Name = "Thomas", Age = 30, },
    };

    var personsDump = ObjectDumper.Dump(persons, DumpStyle.CSharp);

    Console.WriteLine(personsDump);
    Console.ReadLine();
}

//CONSOLE OUTPUT:
var listOfPersons = new List<Person>
{
  new Person
  {
    Name = "John",
    Age = 20
  },
  new Person
  {
    Name = "Thomas",
    Age = 30
  }
};

Links

C# Escape / Unescape https://codebeautify.org/csharp-escape-unescape

License

This project is Copyright © 2022 Thomas Galliker. Free for non-commercial use. For commercial use please contact the author.

Product Versions
.NET net5.0 net5.0-windows net6.0 net6.0-android net6.0-ios net6.0-maccatalyst net6.0-macos net6.0-tvos net6.0-windows
.NET Core netcoreapp1.0 netcoreapp1.1 netcoreapp2.0 netcoreapp2.1 netcoreapp2.2 netcoreapp3.0 netcoreapp3.1
.NET Standard netstandard1.2 netstandard1.3 netstandard1.4 netstandard1.5 netstandard1.6 netstandard2.0 netstandard2.1
.NET Framework net45 net451 net452 net46 net461 net462 net463 net47 net471 net472 net48
MonoAndroid monoandroid
MonoMac monomac
MonoTouch monotouch
Tizen tizen30 tizen40 tizen60
Universal Windows Platform uap uap10.0
Windows Phone wpa81
Windows Store netcore451
Xamarin.iOS xamarinios
Xamarin.Mac xamarinmac
Xamarin.TVOS xamarintvos
Xamarin.WatchOS xamarinwatchos
Compatible target framework(s)
Additional computed target framework(s)
Learn more about Target Frameworks and .NET Standard.
  • .NETFramework 4.5

    • No dependencies.
  • .NETStandard 1.2

  • .NETStandard 2.0

    • No dependencies.
  • .NETStandard 2.1

    • No dependencies.

NuGet packages (4)

Showing the top 4 NuGet packages that depend on ObjectDumper.NET:

Package Downloads
MercadoPagoCore

The inofficial MercadoPagoCore SDK for .NetCoreApps

klefki

An ASP.NET core client for the Klefki API

ppioli.MercadoPago-SDK

Fork of Mercado Pago SDK targeting .Net Core

Cutlass

Lightweight Razor parsing library

GitHub repositories (2)

Showing the top 2 popular GitHub repositories that depend on ObjectDumper.NET:

Repository Stars
ahmedayman4a/Linkedin-Learning-Courses-Downloader
Download LinkedIn Learning Courses in mp4 format and in the video quality you like with an intuitive UI
CodeMazeBlog/CodeMazeGuides
The main repository for all the Code Maze guides
Version Downloads Last updated
3.5.1-pre 46 7/30/2022
3.4.6 10,979 6/24/2022
3.4.5-pre 85 6/2/2022
3.4.1-pre 52 6/2/2022
3.3.25-pre 55 6/1/2022
3.3.23-pre 64 5/31/2022
3.3.22-pre 112 5/7/2022
3.3.20 12,356 4/27/2022
3.3.19-pre 84 4/17/2022
3.3.18-pre 60 4/17/2022
3.3.16-pre 1,132 1/9/2022
3.3.15-pre 506 11/11/2021
3.3.13 70,020 10/7/2021
3.3.12-pre 299 10/2/2021
3.3.11-pre 305 10/2/2021
3.3.10-pre 403 8/30/2021
3.3.7 17,826 8/29/2021
3.3.6-pre 161 8/29/2021
3.3.5-pre 153 8/29/2021
3.3.4-pre 163 8/29/2021
3.3.3-pre 119 8/29/2021
3.3.2-pre 129 8/29/2021
3.2.1-pre 161 8/25/2021
3.1.21178.1 41,449 6/27/2021
3.1.21144.2-pre 794 5/24/2021
3.1.21143.2-pre 195 5/23/2021
3.1.21142.1-pre 316 5/22/2021
3.0.20251.2-pre 2,175 9/7/2020
3.0.20251.1 95,467 9/7/2020
3.0.20243.2-pre 312 8/30/2020
3.0.20243.1-pre 285 8/30/2020
3.0.20235.2-pre 315 8/22/2020
3.0.20235.1-pre 309 8/22/2020
3.0.20232.1-pre 246 8/19/2020
3.0.20229.11-pre 310 8/16/2020
3.0.20229.6-pre 250 8/16/2020
3.0.20229.3-pre 297 8/16/2020
3.0.20228.2-pre 368 8/15/2020
3.0.20228.1-pre 364 8/15/2020
2.5.20228.1 5,894 8/15/2020
2.5.20158.1-pre 1,087 6/6/2020
2.5.20155.1 42,890 6/3/2020
2.5.20143.3-pre 300 5/22/2020
2.5.20131.1-pre 387 5/10/2020
2.5.20033.1 33,928 2/2/2020
2.5.20023.4-pre 317 1/23/2020
2.5.20023.3-pre 366 1/23/2020
2.5.20023.1-pre 305 1/23/2020
2.4.20008.4-pre 401 1/8/2020
2.4.20008.1 3,293 1/8/2020
2.4.20007.2-pre 337 1/7/2020
2.4.19323.7-pre 1,060 11/19/2019
2.4.19323.6-pre 279 11/19/2019
2.4.19323.4-pre 299 11/19/2019
2.4.19292.2-pre 415 10/19/2019
2.4.19292.1-pre 310 10/19/2019
2.4.19286.1-pre 331 10/13/2019
2.4.19218.1 30,088 8/6/2019
2.4.19204.1-pre 419 7/23/2019
2.4.19166.1 5,864 6/15/2019
2.4.19138.1 46,911 5/18/2019
2.4.19119.1-pre 569 4/29/2019
2.3.19050.6 50,790 2/19/2019
2.3.19050.4-pre 433 2/19/2019
2.3.19050.3-pre 444 2/19/2019
2.3.19049.4-pre 439 2/18/2019
2.3.19046.3 4,055 2/15/2019
2.3.19046.1-pre 430 2/15/2019
2.2.19044.3-pre 422 2/13/2019
2.2.19021.1 1,441 1/21/2019
2.2.19011.1 1,275 1/11/2019
2.2.19007.1 603 1/7/2019
2.1.18332.7 1,286 11/29/2018
2.0.18317.1 1,563 11/13/2018
2.0.18311.1 607 11/7/2018
2.0.18282.1 3,513 10/9/2018
1.0.7 24,010 8/27/2018
1.0.6 829 8/3/2018
1.0.4 725 7/22/2018
1.0.3 1,654 7/2/2018
1.0.2 1,873 2/21/2018
1.0.1 2,258 6/19/2017
1.0.0 846 6/9/2017

3.4.0
- Improve circular reference detection

3.3.0
- Bug fix for generic default value creation
- Bug fix for anonymous object dumping

3.2.0
- New versioning schema

3.1.0
- Add support for dumping anonymous types
- Add support for .NET 5
- Detect circular references for hash combinations h(value, type)
- Dump warning for circular references
- Performance improvement for property dumps

3.0.0
- New formatting logic for DumpStyle.Console (default)
- Bug fix for dumping decimal numbers in different cultures
- Dump MinValue, MaxValue for built-in types (where available)

2.5.0
- Handle CultureInfo formatting
- Extend GetFormattedName to handle nested generics and multi-dimensional arrays
- Optimize variable naming for generic types

2.4.0
- Handle Guid formatting
- Handle DateTimeOffset formatting
- Handle TimeSpan formatting
- Set LineBreakChar default to Environment.NewLine

2.3.0
- Fix escape sequences in string values

2.2.0
- Add bool property DumpOptions.IgnoreDefaultValues to filter properties which contain default values
- Refactor namespaces: Move ObjectDumper to root namespace
- Add support for netstandard2.0
     
2.0.0
- Migrate to netstandard1.2
- Bug fixes

1.0.8
- Bugfix for .NET Standard: CSharp initializer code generation for KeyValuePairs is currently disabled in this release

1.0.7
- Change DateTime formatting to ISO 8601 standard
- Add formatting for IDictionary&lt;TKey, TValue&gt; and KeyValuePair&lt;TKey, TValue&gt;

1.0.6
- Replace long suffix 'l' with 'L'

1.0.5
- Optimization for DateTime.MinValue and DateTime.MaxValue serialization

1.0.4
- Bug fix: Use default dump options if not specified

1.0.3
- Add support for .NET Standard
- Add DumpOptions several serialization options, e.g. C#-like DumpStyle

1.0.2
- Bug fix: Filter COM objects
- Bug fix: Catch exceptions if properties/fields cannot be accessed

1.0.1
- Bug fix: Ignore non-public properties
     
1.0.0
- Initial release