/VarDump

VarDump is a utility for serialization runtime objects to C# or Visual Basic string.

Primary LanguageC#Apache License 2.0Apache-2.0

VarDump is a utility for serialization of runtime objects to C# or Visual Basic string.

Developed as a free alternative of ObjectDumper.NET, which is not free for commercial use.

nuget version nuget downloads

C# & VB Dumper:

Run .NET fiddle

using System;
using VarDump;

var anonymousObject = new { Name = "Name", Surname = "Surname" };
var cs = new CSharpDumper().Dump(anonymousObject);
Console.WriteLine(cs);
var vb = new VisualBasicDumper().Dump(anonymousObject);
Console.WriteLine(vb);

C# & VB Dumper, how to use DumpOptions:

Run .NET fiddle

using System;
using System.ComponentModel;
using VarDump;
using VarDump.Visitor;

var person = new Person { Name = "Nick", Age = 23 };
var dumpOptions = new DumpOptions { SortDirection = ListSortDirection.Ascending };

var csDumper = new CSharpDumper(dumpOptions);
var cs = csDumper.Dump(person);

var vbDumper = new VisualBasicDumper(dumpOptions);
var vb = vbDumper.Dump(person);

// C# string
Console.WriteLine(cs);
// VB string
Console.WriteLine(vb);

class Person
{
	public string Name {get; set;}
	public int Age {get; set;}
}

Object Extension methods:

Run .NET fiddle

using System;
using System.Linq;
using VarDump.Extensions;
using VarDump.Visitor;

var dictionary = new[]
{
    new
    {
        Name = "Name1",
        Surname = "Surname1"
    }
}.ToDictionary(x => x.Name, x => x);

Console.WriteLine(dictionary.Dump(DumpOptions.Default));

Object Extension methods, how to switch default dumper to VB:

Run .NET fiddle

using System;
using System.Linq;
using VarDump.Extensions;
using VarDump.Visitor;

VarDumpExtensions.VarDumpFactory = VarDumpFactories.VisualBasic;

var dictionary = new[]
{
    new
    {
        Name = "Name1",
        Surname = "Surname1"
    }
}.ToDictionary(x => x.Name, x => x);

Console.WriteLine(dictionary.Dump(DumpOptions.Default));

For more examples see Unit Tests

Powered By

Repository License
Heavily customized version of System.CodeDom MIT

Privacy Notice: No personal data is collected at all.

This tool has been working well for my personal needs, but outside that its future depends on your feedback. Feel free to open an issue.

PayPal

Any donations during this time will be directed to local charities at my own discretion.