Coder Social home page Coder Social logo

dumpify's Introduction

Dumpify

Github version example workflow Publish Nuget Nuget Downloads GitHub Repo stars GitHub License

Improve productivity and debuggability by adding .Dump() extension methods to Console Applications. Dump any object in a structured and colorful way into the Console, Trace, Debug events or your own custom output.

How to Install

The library is published as a Nuget

Either run dotnet add package Dumpify, Install-Package Dumpify or use Visual Studio's NuGet Package Manager

Features

  • Dump any object in a structured, colorful way to Console, Debug, Trace or any other custom output
  • Support Properties, Fields and non-public members
  • Support max nesting levels
  • Support circular dependencies and references
  • Support styling and customizations
  • Highly Configurable
  • Support for differnt otuput targets: Console, Trace, Debug, Text, Custom
  • Fast!

Examples:

Anonymous types

new { Name = "Dumpify", Description = "Dump any object to Console" }.Dump();

image

Support nesting and circular references

var moaid = new Person { FirstName = "Moaid", LastName = "Hathot", Profession = Profession.Software };
var haneeni = new Person { FirstName = "Haneeni", LastName = "Shibli", Profession = Profession.Health };

moaid.Spouse = haneeni;
haneeni.Spouse = moaid;

moaid.Dump();
//You can define max depth as well, e.g `moaid.Dump(maxDepth: 2)`

image

Support for Arrays, Dictionaries and Collections

var arr = new[] { 1, 2, 3, 4 }.Dump();

image

var arr2d = new int[,] { {1, 2}, {3, 4} }.Dump();

image

new Dictionary<string, string>
{
   ["Moaid"] = "Hathot",
   ["Haneeni"] = "Shibli",
   ["Eren"] = "Yeager",
   ["Mikasa"] = "Ackerman",
}.Dump();

image

You can turn on or off fields and private members

public class AdditionValue
{
    private readonly int _a;
    private readonly int _b;

    public AdditionValue(int a, int b)
    {
        _a = a;
        _b = b;
    }

    private int Value => _a + _b;
}


new AdditionValue(1, 2).Dump(members: new MembersConfig { IncludeFields = true, IncludeNonPublicMembers = true });

image

You can customize colors

var package = new { Name = "Dumpify", Description = "Dump any object to Console" };
package.Dump(colors: ColorConfig.NoColors);
package.Dump(colors: new ColorConfig { PropertyValueColor = new DumpColor(Color.RoyalBlue)});

image

You can turn on or off type names, headers, lables and much more

var moaid = new Person { FirstName = "Moaid", LastName = "Hathot", Profession = Profession.Software };
var haneeni = new Person { FirstName = "Haneeni", LastName = "Shibli", Profession = Profession.Health };
moaid.Spouse = haneeni;
haneeni.Spouse = moaid;

moaid.Dump(typeNames: new TypeNamingConfig { ShowTypeNames = false }, tableConfig: new TableConfig { ShowTableHeaders = false });

image

There are multiple output options (Console, Trace, Debug, Text) or provide your own

var package = new { Name = "Dumpify", Description = "Dump any object to Console" };
package.Dump(); //Similar to `package.DumpConsole()` and `package.Dump(output: Outputs.Console))`
package.DumpDebug(); //Dump to Visual Studio's Debug source
package.DumpTrace(); //Dump to Trace 
var text = package.DumpText(); //The table in a text format

using var writer = new StringWriter();
package.Dump(output: new DumpOutput(writer)); //Custom output

Every configuration can be defined per-Dump or globally for all Dumps, e.g:

DumpConfig.Default.TypeNamingConfig.UseAliases = true;
DumpConfig.Default.TypeNamingConfig.ShowTypeNames = false;
DumpConfig.Default.ColorConfig.TypeNameColor = Color.Gold;
DumpConfig.Default.MaxDepth = 3;
//Much more...

Features for the future 0.7.0 release

  • Add configuration for formatting Anonymous Objects type names
  • Text renderer
  • Better rendering of Delegates
  • Add the option to write type names as a seperate column in tables
  • Write the Count values of dictionaries and IEnumerables in the name, e.g Dictionary<string, string>(3)
  • Add an option to limit how many elements to render for collections and arrays.
  • consider changing the default color scheme to VsCode's
  • Documentation

To do

  • Live outputs
  • Add custom rendering for more types:
    • Exceptions, AggregateExceptions, etc...
  • Rethink Generators caching keys
  • Consider using Max Depth for Descriptors
  • Refactor Renderers and make it better extendable
  • Add more renderers
    • Text Renderers
    • re-introduce Json
    • CSharp Renderer
  • Consider Decoupling from Spectre.Console
  • Tests
    • More tests
    • Visual (Render) Tests - consider acceptance tests
    • Tests for Nesting
  • More sync between Custom Descriptors and Custom Renderers
    • Think how we can mark type's descriptor as needing special rendering.
    • The current CustomDescriptorGenerator must generate a value
    • Consider ValueTuple
  • Refactor SpectureTableRenderer to share customization code
  • Consider changing the style/view of ObjectDescriptors without properties (currently empty table)

dumpify's People

Contributors

moaidhathot avatar hejle avatar aelij avatar mburleigh avatar saahilclaypool avatar tcortega avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.