Giter VIP home page Giter VIP logo

dumpify's Introduction

Software Engieer at Microsoft | Ex-Azure MVP | Code Jedi | Software Architect | Trainer & Public Speaker. I approach software development as both an art and a profession, advocating for Software Craftsmanship and excellence in every line of code.

  • ๐Ÿง‘๐Ÿปโ€๐Ÿ’ป โŒจEnthusiastic about Neovim and Terminal Tools
  • ๐Ÿ’ป Loves C#, .NET and Azure.
  • ๐Ÿฆ Tweets at @MoaidHathot
  • ๐Ÿง‘๐Ÿป LinkedIn Profile
  • ๐Ÿ“ I Blog at https://moaid.codes
  • ๐Ÿ’ฌ I'm on Mastodon (@Moaid)

dumpify's People

Contributors

aelij avatar empiree avatar hejle avatar hermanussen avatar mburleigh avatar moaidhathot avatar saahilclaypool avatar tcortega avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dumpify's Issues

Property support for Dumping Newtonsoft.Json and System.Text.Json objects

Description

@Hejle has pointed out that our current support for dumping Newtonsoft.Json and System.Text.Json objects are lacking.

Examples/reproduction:

image

Suggested solution:

We can either use DumpConfig.Default.AddCustomTypeHandler(typeof(JValue), (obj, _, _, _) => obj.ToString()); or we can create a custom type renderer for Json objects.

I think we should compile a list of objects of both Newtonsoft.Json and System.Text.Json that we would have to custom render and decide how to render each one of them.
We may start with a simple solution, which is using AddCustomTypeHandler until we implement a proper custom renderer.

Support for positioning the lable at the top of output

In the same way LINQPad will put it's label at the beginning of Dump output.

ยฆ Heading
ยฆ โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
ยฆ โ”‚ "Output Data" โ”‚
ยฆ โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

Virtual Member

When using EF Core Lazy Loading Dump() will load the whole tree.
Using MaxDepth = 1 helps, but then you will see a lot of [Exceeded max depth 1] in the console.
Is there a way to limit the library to ignore virtual members.

.NET Standard

I am running .NET Framework 4.8. No choice due to VSTO not being upgraded by Microsoft.

The package fails on nuget due to 'You are trying to install this package into a project that targets '.NETFramework,Version=v4.8', but the package does not contain any assembly references or content files that are compatible'. Not sure but this should compile to .NET Standard 2.0.

I can download and compile myself. Thanks for introducing me to Spectre.Console. Did not know about that.

Dumping characters is not displaying properly

Dumping a char doesn't display correctly, as a guess it looks like it is supposed to show a table with the character and then it's ascii value but on only the table headers are shown.
image

Transition from MSTest to xUnit for Unit Testing

Dumpify currently uses MSTest for unit testing. However, MSTest is basically an unmaintained unit testing framework. It aggregates with no actual value compared to more up-to-date and robust unit testing frameworks such as xUnit.

It'd be a strategic move that will provide long-term benefits for the project. And will ensure that it stays on top of best practices regarding to unit testing.

Character encoding problem in PowerShell (rare & intermittent)

I'm "re-using" Dumpify as a way to do a quick'n'dirty representation of a 2D array of char values for a BattleShip concept. It's just a temporary usage for a concept presentation. But I've noticed a very rare and unpredictable messing up of the border characters every once in a while when I run my code (even without code changes). Here's what I'm seeing.

image

When it happens, it's not always those incorrect characters - sometimes it's different ones. Again, this is quite rare and hard to reproduce. The code usage is quite simple (.NET 8 console app, running in PowerShell, on Windows 11):

void Concept()
{
    char[,] grid = new char[10,10];
    // Initialize
    for(int row = 0; row < 10; row++)
        for(int col = 0; col < 10; col++)
            grid[row,col] = Random.Shared.Next(10) switch
            {
                < 7 => ' ',
                >= 7 and < 9 => '-',
                _   => Random.Shared.Next(5) switch
                {
                    < 4 => '-',
                    _ => 'H'
                }
            };

    grid.Dump("Player Won");
}

Problem rendering Dictionary classs which implements an Enumerator which is not castable to IEnumerable

I was trying to dump a NewtonSoft Json object, when I ran into the following error:
Unable to cast object of type 'd__64' to type 'System.Collections.IEnumerable'.

I tried the same with System.Text.Json and got a familiar exception:
Unable to cast object of type 'd__18[System.Text.Json.Nodes.JsonNode]' to type 'System.Collections.IEnumerable'.

[Failed to Render Newtonsoft.Json.Linq.JObject - {
  "key1": "value1",
  "key2": "value2"
}]. Unable to cast object of type '<GetEnumerator>d__64' to type 'System.Collections.IEnumerable'.
[Failed to Render System.Text.Json.Nodes.JsonObject - {
  "key1": "value1",
  "key2": "value2"
}]. Unable to cast object of type '<GetEnumerator>d__18[System.Text.Json.Nodes.JsonNode]' to type 'System.Collections.IEnumerable'.

I have created a fix for this which I will create a pullrequest for in a bit.


Note:
Even with the fix, I wouldn't say that Json is Supported.
The output after my Pull Request would look like this:
billede

To get NewtonSofts output to look nice, it is possible to add a CustomRenderer like this, which will format the output nicely:

DumpConfig.Default.AddCustomTypeHandler(typeof(JValue), (obj, _, _, _) => obj.ToString());

       JObject
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ Key    โ”‚ Value    โ”‚
โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
โ”‚ "key1" โ”‚ "value1" โ”‚
โ”‚ "key2" โ”‚ "value2" โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Question: Is there a way to disable line wrapping?

In case there is much to dump on a single line I saw values being continued in next line. It would be good to be able to allow that all stuff is rendered to one line only. Below image shows the issue
image

Dump() does not print out public fields

if you create a public class with public fields like
public class MyClass { public uint MyNumber; }
and call Dump() on it you just get an empty table with the header
but if you change the fields to properties it will work, i.e
public class MyClass { public uint MyNumber { get; set; } }

Support for HTML output?

Dumpify is incredibly useful for dumping out messages for console applications. A great addition would be support for HTML output. The generated markup can be a table with simple classes so it can be easily styled.

DumpifySettings class?

Having just tested the MembersConfig options, i ended up with
myObject.Dump(null, null, null, null, null, null, membersConfig);
Would Dump benefit by a DumpifySettings class similar to XmlSettings and others used in .NET?

Yes I know there is the global setting =)

Support for progress bar

It would be very nice if this lib have an extensions method for enumerable that display a dynamic progressbar.

var list = new List<int> {1,2,3,4};
foreach(var i un list.WithProgess("Caption"))
{
    // Do slow stuff
}

Use columns for properties when dumping collections?

One of the handy things with LinqPad .Dump() is when you use it on a collection, you get a table with columns for each property. e.g. in LinqPad the code:

void Main()
{
	var people = new[] 
	{
		new Person("Marie", "Curie"),   
		new Person("Albert", "Einstein"),
		new Person("Ada", "Lovelace"),
		new Person("Cleopatra", "Philopator"),
		new Person("Nikola", "Tesla")
	};

	people.Dump();
}

record Person(string FirstName, string LastName);

gives:
image

but with Dumpify, it shows:
image

So I'd like to be able to have the more concise column-for-property format with collections.

Special consideration for DirectoryInfo

Dump() does print out DirectoryInfo object but the recursive nature of the references (JsonSerializer just fails on it so that's good!) makes a few references up or down the directory tree make the panels start appearing very squashed.
I don't know if it is the aim of Dumpify to remain generic for all objects of if special consideration be given for certain types?
If so I think there are many improvements that could be made for DirInfo, like not printing all info for recursive reference and just the dirname, maybe put it in a tree instead of nested panels etc..

dumpify nuget manager install error: NU1108: Cycle detected.

error: NU1108: Cycle detected.
error: dumpify -> Dumpify (>= 0.6.5).
info : Package 'Dumpify' is compatible with all the specified frameworks in project 'C:\Users\USER\source\repos\dotnet\dumpify\dumpify.csproj'.
error: Value cannot be null. (Parameter 'path1')

I'm getting this error while trying to install dumpify both in vs code and in visual studio.

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.