ObjectDumper.NET
4.3.0-pre
See the version list below for details.
dotnet add package ObjectDumper.NET --version 4.3.0-pre
NuGet\Install-Package ObjectDumper.NET -Version 4.3.0-pre
<PackageReference Include="ObjectDumper.NET" Version="4.3.0-pre" />
paket add ObjectDumper.NET --version 4.3.0-pre
#r "nuget: ObjectDumper.NET, 4.3.0-pre"
// Install ObjectDumper.NET as a Cake Addin #addin nuget:?package=ObjectDumper.NET&version=4.3.0-pre&prerelease // Install ObjectDumper.NET as a Cake Tool #tool nuget:?package=ObjectDumper.NET&version=4.3.0-pre&prerelease
ObjectDumper.NET
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
}
};
Strong-named assembly
This assembly is signed with the key ObjectDumper.snk in this repository.
Public key (hash algorithm: sha1):
00240000048000009400000006020000002400005253413100040000010001008da06ec8c6bd242c52102a9fc293b7af32f183da0d069f7c9522f063cacc3cc584668dfd6cf0560577380822b0c46fdb19e44fc78fad5e8d15b2c24a8766e2769c942705442926b3dcce385eac263893a4b6916976324544792ba1fb4697ab0d1bf28f3c8f0512234fa0a7b732141f7dc4b4a340bdaa95a6c1460c6a699e65c3
Public key token is fcc359471136d8b8
.
In order to get these values, run following commands:
- Extract public key of snk:
sn -p ObjectDumper.snk public.key
- Display public key:
sn -tp public.key
Links
- Standard numeric format strings https://learn.microsoft.com/en-us/dotnet/standard/base-types/standard-numeric-format-strings
- Standard date and time format strings https://learn.microsoft.com/en-us/dotnet/standard/base-types/standard-date-and-time-format-strings
- Standard timespan format strings https://learn.microsoft.com/en-us/dotnet/standard/base-types/standard-timespan-format-strings
- C# Record Types https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/record
- C# Escape / Unescape https://codebeautify.org/csharp-escape-unescape
License
This project is Copyright © 2023 Thomas Galliker. Free for non-commercial use. For commercial use please contact the author.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. 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 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. |
.NET Core | netcoreapp1.0 was computed. netcoreapp1.1 was computed. netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard1.2 is compatible. netstandard1.3 was computed. netstandard1.4 was computed. netstandard1.5 was computed. netstandard1.6 was computed. netstandard2.0 is compatible. netstandard2.1 is compatible. |
.NET Framework | net451 was computed. net452 was computed. net46 was computed. net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 is compatible. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen30 was computed. tizen40 was computed. tizen60 was computed. |
Universal Windows Platform | uap was computed. uap10.0 was computed. |
Windows Phone | wpa81 was computed. |
Windows Store | netcore451 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETFramework 4.8
- No dependencies.
-
.NETStandard 1.2
- NETStandard.Library (>= 1.6.1)
-
.NETStandard 2.0
- No dependencies.
-
.NETStandard 2.1
- No dependencies.
-
net7.0
- No dependencies.
-
net8.0
- No dependencies.
NuGet packages (8)
Showing the top 5 NuGet packages that depend on ObjectDumper.NET:
Package | Downloads |
---|---|
MercadoPagoCore
The inofficial MercadoPagoCore SDK for .NetCoreApps |
|
SunamoReflection
Advanced reflection for faster development |
|
CraxShared
Package Description |
|
KarambaCommon
An interactive, parametric Finite Element program for beams and shells. |
|
klefki
An ASP.NET core client for the Klefki API |
GitHub repositories (5)
Showing the top 5 popular GitHub repositories that depend on ObjectDumper.NET:
Repository | Stars |
---|---|
CodeMazeBlog/CodeMazeGuides
The main repository for all the Code Maze guides
|
|
ahmedayman4a/Linkedin-Learning-Courses-Downloader
Download LinkedIn Learning Courses in mp4 format and in the video quality you like with an intuitive UI
|
|
thexeondev/WutheringWaves
Wuthering Waves ps (0.9.0)
|
|
winsecurity/Offensive-C-Sharp
|
|
Sanae6/SmoOnlineServer
Official server for Super Mario Odyssey: Online
|
Version | Downloads | Last updated |
---|---|---|
4.3.4-pre | 117 | 10/6/2024 |
4.3.2 | 16,604 | 9/14/2024 |
4.3.1-pre | 494 | 6/17/2024 |
4.3.0-pre | 258 | 5/24/2024 |
4.2.7 | 44,664 | 5/13/2024 |
4.2.6-pre | 109 | 5/13/2024 |
4.2.2-pre | 104 | 5/13/2024 |
4.2.1-pre | 113 | 5/9/2024 |
4.1.17 | 26,194 | 3/26/2024 |
4.1.16-pre | 1,465 | 3/11/2024 |
4.1.15 | 45,119 | 1/24/2024 |
4.1.13-pre | 4,379 | 10/29/2023 |
4.1.12-pre | 826 | 10/29/2023 |
4.1.11-pre | 806 | 10/29/2023 |
4.1.6-pre | 771 | 10/29/2023 |
4.1.4-pre | 844 | 10/19/2023 |
4.1.3 | 125,138 | 6/20/2023 |
4.1.2-pre | 1,093 | 6/20/2023 |
4.1.1-pre | 1,138 | 6/17/2023 |
4.0.6 | 45,597 | 3/19/2023 |
4.0.5-pre | 1,149 | 3/16/2023 |
4.0.4-pre | 1,299 | 2/24/2023 |
4.0.3-pre | 1,188 | 2/24/2023 |
3.5.6 | 49,809 | 1/31/2023 |
3.5.5-pre | 1,197 | 12/31/2022 |
3.5.3-pre | 1,345 | 10/15/2022 |
3.5.2 | 100,832 | 9/23/2022 |
3.5.1-pre | 1,287 | 7/30/2022 |
3.4.6 | 196,056 | 6/24/2022 |
3.4.5-pre | 1,169 | 6/2/2022 |
3.4.1-pre | 1,113 | 6/2/2022 |
3.3.25-pre | 1,188 | 6/1/2022 |
3.3.23-pre | 1,168 | 5/31/2022 |
3.3.22-pre | 1,234 | 5/7/2022 |
3.3.20 | 32,642 | 4/27/2022 |
3.3.19-pre | 1,167 | 4/17/2022 |
3.3.18-pre | 1,183 | 4/17/2022 |
3.3.16-pre | 3,266 | 1/9/2022 |
3.3.15-pre | 2,994 | 11/11/2021 |
3.3.13 | 142,025 | 10/7/2021 |
3.3.12-pre | 1,408 | 10/2/2021 |
3.3.11-pre | 1,369 | 10/2/2021 |
3.3.10-pre | 1,496 | 8/30/2021 |
3.3.7 | 33,536 | 8/29/2021 |
3.3.6-pre | 1,235 | 8/29/2021 |
3.3.5-pre | 1,263 | 8/29/2021 |
3.3.4-pre | 1,245 | 8/29/2021 |
3.3.3-pre | 1,233 | 8/29/2021 |
3.3.2-pre | 1,278 | 8/29/2021 |
3.2.1-pre | 1,291 | 8/25/2021 |
3.1.21178.1 | 54,429 | 6/27/2021 |
3.1.21144.2-pre | 1,892 | 5/24/2021 |
3.1.21143.2-pre | 1,238 | 5/23/2021 |
3.1.21142.1-pre | 1,387 | 5/22/2021 |
3.0.20251.2-pre | 3,621 | 9/7/2020 |
3.0.20251.1 | 184,652 | 9/7/2020 |
3.0.20243.2-pre | 1,472 | 8/30/2020 |
3.0.20243.1-pre | 1,437 | 8/30/2020 |
3.0.20235.2-pre | 1,544 | 8/22/2020 |
3.0.20235.1-pre | 1,490 | 8/22/2020 |
3.0.20232.1-pre | 1,444 | 8/19/2020 |
3.0.20229.11-pre | 1,462 | 8/16/2020 |
3.0.20229.6-pre | 1,399 | 8/16/2020 |
3.0.20229.3-pre | 1,493 | 8/16/2020 |
3.0.20228.2-pre | 1,503 | 8/15/2020 |
3.0.20228.1-pre | 1,578 | 8/15/2020 |
2.5.20228.1 | 14,909 | 8/15/2020 |
2.5.20158.1-pre | 2,228 | 6/6/2020 |
2.5.20155.1 | 92,088 | 6/3/2020 |
2.5.20143.3-pre | 1,501 | 5/22/2020 |
2.5.20131.1-pre | 1,528 | 5/10/2020 |
2.5.20033.1 | 45,694 | 2/2/2020 |
2.5.20023.4-pre | 1,478 | 1/23/2020 |
2.5.20023.3-pre | 1,409 | 1/23/2020 |
2.5.20023.1-pre | 1,381 | 1/23/2020 |
2.4.20008.4-pre | 1,520 | 1/8/2020 |
2.4.20008.1 | 5,075 | 1/8/2020 |
2.4.20007.2-pre | 1,509 | 1/7/2020 |
2.4.19323.7-pre | 2,179 | 11/19/2019 |
2.4.19323.6-pre | 1,405 | 11/19/2019 |
2.4.19323.4-pre | 1,456 | 11/19/2019 |
2.4.19292.2-pre | 1,642 | 10/19/2019 |
2.4.19292.1-pre | 1,387 | 10/19/2019 |
2.4.19286.1-pre | 1,466 | 10/13/2019 |
2.4.19218.1 | 35,545 | 8/6/2019 |
2.4.19204.1-pre | 1,552 | 7/23/2019 |
2.4.19166.1 | 8,259 | 6/15/2019 |
2.4.19138.1 | 70,426 | 5/18/2019 |
2.4.19119.1-pre | 1,742 | 4/29/2019 |
2.3.19050.6 | 77,438 | 2/19/2019 |
2.3.19050.4-pre | 1,603 | 2/19/2019 |
2.3.19050.3-pre | 1,597 | 2/19/2019 |
2.3.19049.4-pre | 1,652 | 2/18/2019 |
2.3.19046.3 | 5,677 | 2/15/2019 |
2.3.19046.1-pre | 1,639 | 2/15/2019 |
2.2.19044.3-pre | 1,547 | 2/13/2019 |
2.2.19021.1 | 3,085 | 1/21/2019 |
2.2.19011.1 | 2,590 | 1/11/2019 |
2.2.19007.1 | 1,962 | 1/7/2019 |
2.1.18332.7 | 3,136 | 11/29/2018 |
2.0.18317.1 | 2,988 | 11/13/2018 |
2.0.18311.1 | 1,952 | 11/7/2018 |
2.0.18282.1 | 4,837 | 10/9/2018 |
1.0.7 | 25,852 | 8/27/2018 |
1.0.6 | 2,260 | 8/3/2018 |
1.0.4 | 1,996 | 7/22/2018 |
1.0.3 | 2,988 | 7/2/2018 |
1.0.2 | 3,147 | 2/21/2018 |
1.0.1 | 3,785 | 6/19/2017 |
1.0.0 | 2,246 | 6/9/2017 |
4.2
- Bug fix for circular references in collections
- Internal refactoring to handle collection dumping more efficiently
- Print element count for IEnumerables for DumpStyle.Console
4.1
- Raise minimum .NET framework version from net45 to net48
- Remove support for net5.0
- Bug fix for constructorless record types
4.0
- Add support for C# record types
- Add assembly strong-naming
3.4
- Improve circular reference detection
3.3
- Bug fix for generic default value creation
- Bug fix for anonymous object dumping
3.2
- New versioning schema
3.1
- 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
- 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
- Handle CultureInfo formatting
- Extend GetFormattedName to handle nested generics and multi-dimensional arrays
- Optimize variable naming for generic types
2.4
- Handle Guid formatting
- Handle DateTimeOffset formatting
- Handle TimeSpan formatting
- Set LineBreakChar default to Environment.NewLine
2.3
- Fix escape sequences in string values
2.2
- 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
- Migration to netstandard1.2
- Bug fixes
1.0
- Initial release
- Bugfix for .NET Standard: CSharp initializer code generation for KeyValuePairs is currently disabled in this release
- Change DateTime formatting to ISO 8601 standard
- Add formatting for IDictionary<TKey, TValue> and KeyValuePair<TKey, TValue>
- Replace long suffix 'l' with 'L'
- Optimization for DateTime.MinValue and DateTime.MaxValue serialization
- Bug fix: Use default dump options if not specified
- Add support for .NET Standard
- Add DumpOptions several serialization options, e.g. C#-like DumpStyle
- Bug fix: Filter COM objects
- Bug fix: Catch exceptions if properties/fields cannot be accessed
- Bug fix: Ignore non-public properties