Git Product home page Git Product logo

objectdumper's Introduction

💬 About

C# software developer for customers in various industries. Recent projects include mobile apps, backend services and web APIs.

Working Skills

C# .NET .NET MAUI Xamarin.Forms WPF .NET ASPNET Core SQL EntityFramework Core Software Architecture

Tools

Visual Studio Visual Studio Code MSSQL Android Studio XCode Notepad++

Social

LinkedIn Stackoverflow

GitHub stats

objectdumper's People

Contributors

blaikic avatar ericnewton76 avatar jaundice avatar kcaswick avatar lofcz avatar thomasgalliker avatar vincentremond avatar workgroupengineering 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

objectdumper's Issues

Recommendation: Change license to less restrictive

Would you consider changing your code to be less restrictive? I ask unfortunately after I've tweaked some of the namespaces and stuff for an upcoming PR.

Like LGPL or similar that allows for commercial use with some attribution?

I usually use Apache 2.0 or LGPL or MIT depending on how broadly I would love seeing basic building blocks of projects like this get used widespread.

[Bug] Cannot Work

It's a great thing. but I'm having some trouble
I install this library and run the sample. And there were no details on the console
image

I don't know if I'm using it incorrectly

OS:Macos 11.6
IDE:Rider

[Enhancement]Improved way to exclude (readonly) properties

Summary

Currently the only way to exclude (readonly) properties is by using DumpOptions.ExcludeProperties.
It excludes all properties matching the names in the to-dump-object(-tree).
There might be use cases, where this is not preferred.

Intended Use Case

Let say, you want to dump an object with a readonly property, my current approach to produce compilable output would be by using 'ExcludeProperties'

var point = new System.Drawing.Point() { X = 1, Y = 0 };

var str = ObjectDumper.Dump(point, new DumpOptions()
{
    IndentChar = '\t',
    IndentSize = 1,
    LineBreakChar = Environment.NewLine,
    DumpStyle = DumpStyle.CSharp,
    ExcludeProperties = new string[]
    {
        nameof(Point.IsEmpty)
    }
});
Console.WriteLine(str);

However, if you've a more complex object (tree), where property names are duplicated, this lead to 'all or nothing':

var expection = new Expection() 
{ 
    Operands = Enumerable.Range(1, 5).ToArray(),
    Result = 15
};
var tester = new Tester(expection);

var str = ObjectDumper.Dump(tester, new DumpOptions()
{
    IndentChar = '\t',
    IndentSize = 1,
    LineBreakChar = Environment.NewLine,
    DumpStyle = DumpStyle.CSharp,
    ExcludeProperties = new string[]
    {
        //"Result"
    }
});

Console.WriteLine(str);

public class Tester
{
    public Tester(Expection expection)
    {
        Expection = expection;
        Actual = (Actual)expection;
    }

    public Expection Expection { get; }
    public Actual Actual { get; }
}

public class Expection
{
    public int Result { get; set; }
    public int[] Operands { get; set; }
    public static explicit operator Actual(Expection e) => new() { Operands = e.Operands };
}

public struct Actual
{
    public int Result => Operands.Sum();
    public int[] Operands { get; init; }
}

API Changes

I can think of three solutions for this

full qualified property names of the tree

Add an string interpretation which might point to the exact property
e.g. "Expection.Result" of the to-dump Tester object
Disadvantage: The '.' of object separation is very c#-specific and might lead to confusions

ExcludeReadonlyProperties

Add this to the DumpOptions to auto exclude all properties, which are readonly.
Disadvantage 1: what is readonly? everything which hasn't a public setter? what about objects with protect setter?
Disadvantage 2: You might include some readonly properties in the console-output, but exclude the rest of readonly members - this leads to the initial problem

Provide an interface for excluding

Something like

public interface IPropertyExcluder
{
    public bool ShouldExcludeProperty(in object obj, in string propertyName);
}

And an respective array on DumpOptions

So it could be used depending on the use case:

public class ActualPropertyExcluder : IPropertyExcluder
{
    public bool ShouldExcludeProperty(in object obj, in string propertyName)
        => (obj is Actual) && propertyName == nameof(Actual.Result);
}

ObjectDumper.Dump(tester, new DumpOptions()
{
    IndentChar = '\t',
    IndentSize = 1,
    LineBreakChar = Environment.NewLine,
    DumpStyle = DumpStyle.CSharp,
    ExcludeProperties = new IPropertyExcluder[]
    {
        new ActualPropertyExcluder()
    }
});

Advantage 1: The consumer can decide, which property should be excluded (depending on the use case)
Advantage 2: DumpOptions properties 'SetPropertiesOnly' could also be obsoleted
Disadvantage: Breaking Change when used ExcludeProperties with older versions

Recommendation: move ObjectDumper to global namespace

First off, thanks for making this. I usually used the original (braindead) ObjectDumper package, which worked okay but not well.

On this project though, it seems odd to include the System.Diagnostics namespace when I'm using a 3rd party library.

(And btw, Nuget maintainers keeps hinting at disallowing Nuget packages to write into System.* namespaces, reserving that only for Microsoft approved Nuget packages. This will be enforced on publish during the validation step at some point.)

I recommend to just have the type "ObjectDumper" and "DumpOptions" in the global namespace so code like ObjectDumper.Dump(obj) just works.

The rest of your support could be in namespace ObjectDumperSupport

I say this because this is such a nice, elegantly simple package to add to any project and its immediate benefit is its ability to lay in to a lot of code by just peppering ObjectDumper.Dump wherever you need that.

Unfortunately, having to add the using System.Diagnostics to every file is cuts that down. I say this because none of my projects use System.Diagnostics for anything... we use NLog and various other much more well thought out implementations (including this one, lol!)

Ironically the impact will be nil...

Dump ValueTuples does not work properly

Dumping value tuples (e.g. (int, int)) does currently not work as expected. Further investigation is required to get a reasonable result from calls like:

ObjectDumper.Dump(parameters.SupportedPreviewSizes.Select(s => (s.Width, s.Height)), DumpStyle.CSharp);

Currently, this is the (obviously wrong) result:

var selectIListIteratorSizeValueTupleInt32Int32 = new SelectIListIterator<Size, ValueTuple<Int32, Int32>>
{
  new ValueTuple<Int32, Int32>
  {
  },
  new ValueTuple<Int32, Int32>
  {
  },
  new ValueTuple<Int32, Int32>
  {
  },
};

C# 9 / dotnet 5.0 records compatible C# dump style

With the new type record like this :
public record Sprint(int SprintId, DateTimeOffset StartDate, DateTimeOffset EndDate);

When using DumpStyle.CSharp , the generated code is incompatible :

new Sprint
{
	SprintId = 12,
	StartDate = DateTimeOffset.ParseExact("2021-02-18T00:00:00.0000000+01:00", "O", CultureInfo.InvariantCulture, DateTimeStyles.RoundtripKind),
	EndDate = DateTimeOffset.ParseExact("2021-03-03T00:00:00.0000000+01:00", "O", CultureInfo.InvariantCulture, DateTimeStyles.RoundtripKind)
}

It should be using the constructor instead of properties initialiser :

new Sprint(
	SprintId: 12,
	StartDate: DateTimeOffset.ParseExact("2021-02-18T00:00:00.0000000+01:00", "O", CultureInfo.InvariantCulture, DateTimeStyles.RoundtripKind),
	EndDate: DateTimeOffset.ParseExact("2021-03-03T00:00:00.0000000+01:00", "O", CultureInfo.InvariantCulture, DateTimeStyles.RoundtripKind)
)

yaml output

will donate 20 USD for that option (one time, not continuous)

[Enhancement] IEnumerable can display optimization

Summary

Current program output IEnumerable is ...
I would like to know what type and number of variables this variable is, not IEnumerable
while visualStuido debugger, I can see the number and types of lEnumerable from the quick monitor panel

image

image

DumpStyle.HTML Dump Option

I was looking at adding another dump format for html. Is that something you would be interested in bringing into ObjectDumper?

I'm looking to create simple html output that would be useful in debugging web apps / web app error pages. html formatted diagnostic email messages.

Dumping objects with sensitive data

We often have the situation that dumped objects contain sensitive data such a personal information (name, address,...) or security relevant information (password hashes, authentication tokens). ObjectDumper of course cannot automatically detect and obfuscate such information.

This issues serves as bucket to collect ideas of the users of ObjectDumper would like this problem to be solved - or if it even is a problem to be solved.

DumpOptions is not passed into the implementation constructor's.

See the Dump code:

public static string Dump(object element, DumpOptions dumpOptions = default(DumpOptions))
{
if (dumpOptions == default(DumpOptions))
{
dumpOptions = new DumpOptions();
}
if (dumpOptions.DumpStyle == DumpStyle.Console)
{
return ObjectDumperConsole.Dump(element);
}
return ObjectDumperCSharp.Dump(element);
}

The parameter is never passed, so DumpOptions is always set to default.

[Bug] Need a strongly named assembly to use with signed projects

It's recommended to publish strongly named assemblies as they can work with both signed and unsigned projects. In it's current form it can't be used with signed projects as they require a strongly named assembly. The only solution is to rebuild the project from scratch but that defeats the purpose of having nuget

Serialize nested generics

Serializing objects of nested-generic types to DumpStyle.CSharp is obviously not working properly. Sample type: Dictionary<string, List<string>>

Needs further investigation. Could be related to Dictionary<T>.

Print *Id properties first

Print all properties which end with "Id" prior to the rest. Add this behavior as an option in DumpOptions. Id properties are particularly helpful if database entities are being dumped.

[Bug] How to avoid Stack Overflow?

Description

I dump one of my object. I see this message:

Stack overflow.
   at System.RuntimeMethodHandle.GetStubIfNeeded(System.RuntimeMethodHandleInternal, System.RuntimeType, System.RuntimeType[])
   at System.Reflection.RuntimeMethodInfo.MakeGenericMethod(System.Type[])
   at ObjectDumping.Internal.TypeExtensions.GetDefault(System.Type)
   at ObjectDumping.Internal.TypeExtensions.TryGetDefault(System.Type)
   at ObjectDumping.Internal.PropertyAndValue..ctor(System.Object, System.Reflection.PropertyInfo)
   at ObjectDumping.Internal.ObjectDumperConsole+<>c__DisplayClass2_0.<CreateObject>b__3(System.Reflection.PropertyInfo)        
   at System.Linq.Enumerable+SelectListIterator`2[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].ToList()
   at ObjectDumping.Internal.ObjectDumperConsole.CreateObject(System.Object, Int32)
   at ObjectDumping.Internal.ObjectDumperConsole.FormatValue(System.Object, Int32)
   at ObjectDumping.Internal.ObjectDumperConsole.WriteItems(System.Collections.IEnumerable)
   at ObjectDumping.Internal.ObjectDumperConsole.FormatValue(System.Object, Int32)
   at ObjectDumping.Internal.ObjectDumperConsole.CreateObject(System.Object, Int32)
   at ObjectDumping.Internal.ObjectDumperConsole.FormatValue(System.Object, Int32)
   at ObjectDumping.Internal.ObjectDumperConsole.WriteItems(System.Collections.IEnumerable)
   at ObjectDumping.Internal.ObjectDumperConsole.FormatValue(System.Object, Int32)
   at ObjectDumping.Internal.ObjectDumperConsole.CreateObject(System.Object, Int32)
   at ObjectDumping.Internal.ObjectDumperConsole.FormatValue(System.Object, Int32)

   ...REDACTED... 2000+ lines.

   at ObjectDumping.Internal.ObjectDumperConsole.WriteItems(System.Collections.IEnumerable)
   at ObjectDumping.Internal.ObjectDumperConsole.FormatValue(System.Object, Int32)
   at ObjectDumping.Internal.ObjectDumperConsole.CreateObject(System.Object, Int32)
   at ObjectDumping.Internal.ObjectDumperConsole.FormatValue(System.Object, Int32)
   at ObjectDumping.Internal.ObjectDumperConsole.WriteItems(System.Collections.IEnumerable)
   at ObjectDumping.Internal.ObjectDumperConsole.FormatValue(System.Object, Int32)
   at ObjectDumping.Internal.ObjectDumperConsole.CreateObject(System.Object, Int32)
   at ObjectDumping.Internal.ObjectDumperConsole.FormatValue(System.Object, Int32)
   at ObjectDumping.Internal.ObjectDumperConsole.WriteItems(System.Collections.IEnumerable)
   at ObjectDumping.Internal.ObjectDumperConsole.FormatValue(System.Object, Int32)
   at ObjectDumping.Internal.ObjectDumperConsole.CreateObject(System.Object, Int32)
   at ObjectDumping.Internal.ObjectDumperConsole.FormatValue(System.Object, Int32)
   at ObjectDumping.Internal.ObjectDumperConsole.WriteItems(System.Collections.IEnumerable)
   at ObjectDumping.Internal.ObjectDumperConsole.FormatValue(System.Object, Int32)
   at ObjectDumping.Internal.ObjectDumperConsole.CreateObject(System.Object, Int32)
   at ObjectDumping.Internal.ObjectDumperConsole.FormatValue(System.Object, Int32)
   at ObjectDumping.Internal.ObjectDumperConsole.WriteItems(System.Collections.IEnumerable)
   at ObjectDumping.Internal.ObjectDumperConsole.FormatValue(System.Object, Int32)
   at ObjectDumping.Internal.ObjectDumperConsole.Dump(System.Object, DumpOptions)
   at ObjectDumper.Dump(System.Object, DumpOptions)
   at ObjectDumper.Dump(System.Object)
   at ObjectDumperExtensions.Dump(System.Object)

It seems cause by reference loop.

Basic Information

  • Version with issue: 4.1.3
  • Last known good version: N/A

Screenshots

N/A

Reproduction Link

N/A

No new line after null object

When dumping an object with properties Body and Name using DumpStyle.Console, if Body is null there won't be a new line after that property:

{My.Object}
  Body: { }
    null  Name: "hello"

Question on Licensing

Hi.

On the nuget package page

https://www.nuget.org/packages/ObjectDumper.NET/

the link for "License Info" takes you to : http://opensource.org/licenses/Apache-2.0

and links to that:

_Can Open Source software be used for commercial purposes?
Absolutely. All Open Source software can be used for commercial purpose; the Open Source Definition guarantees this. You can even sell Open Source software.

However, note that commercial is not the same as proprietary. If you receive software under an Open Source license, you can always use that software for commercial purposes, but that doesn't always mean you can place further restrictions on people who receive the software from you.

Can I call my program "Open Source" even if I don't use an approved license?
Please don't do that. If you call it "Open Source" without using an approved license, you will confuse people. This is not merely a theoretical concern — we have seen this confusion happen in the past, and it's part of the reason we have a formal license approval process. See also our page on license proliferation for why this is a problem._

............

However, on the main github repository page:

https://github.com/thomasgalliker/ObjectDumper

It says:

Free for non-commercial use. For commercial use please contact the author.

........

This seems like a discrepancy.

Can this software be using freely as open-source in commercial products ("as-is" is my intention here, not trying to enhance it or anything).

Thank you.

License Clarification. How to support?

Hey, thanks for writing and maintaining this project. I would like to use this for writing tests. I will be using it FOR my company, but it won't be included in any repository. I don't mind paying for it. I don't want to bother my company about it. Your patreon link doesn't work. I know you're not a capitalist. Is this free for me to use in this capacity? Is there a way I could compensate you? ...Buy you cup of coffee?

Thanks again!

Option of excluding lineBreakChar for final property of object

When logging on a single line, the lineBreakChar can currently be set to ',' (for example) to comma separate the properties of the object. However, the final property will then still print the lineBreakChar at the end, which looks incorrect.

e.g.

property1 = "a" , property2 = "b" , property3 = "c" ,

It would be a nice feature to have an option of excluding this linebreakChar for the final property. Which I suppose people might still want even if using newline as the character.

Small sample program never exits

Thomas,

Per our messaging. We wrote a simple console app utilizing ObjectDumper to view an object.

The program never returns in ANY instance when using ObjectDumper.Dump - whether the dummy persons object is being dumped only or the eggTask.

Thanks for any insight.

T.


Here is the sample:

using System;
using System.Collections;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Timers;

namespace AsyncBreakfast
{
class Egg { }
class Bacon { }
class Juice { }
class Toast { }
class Coffee { }

public class Person
{
    // Auto-implemented properties.
    public int Age { get; set; }
    public string Name { get; set; }

    public Person()
    {
    }

    public Person(string name)
    {
        this.Name = name;
    }
}


class Program
{
    static async Task Main(string[] args)
    {
        Coffee cup = PourCoffee();
        Console.WriteLine("coffee is ready");

       

        var eggsTask = FryEggsAsync(2);
        var baconTask = FryBaconAsync(3);
        var toastTask = MakeToastWithButterAndJamAsync(2);

        /*
        List<Person> 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();
        
        
        var dumper = ObjectDumper.Dump(eggsTask);
        Console.WriteLine(dumper);
        Console.ReadLine();
        */

        Console.WriteLine("Going in to while() loop");

        var breakfastTasks = new List<Task> { eggsTask, baconTask, toastTask };
        while (breakfastTasks.Count > 0)
        {
            Console.WriteLine("In while() loop");
            Task finishedTask = await Task.WhenAny(breakfastTasks);
            Console.WriteLine("Obj returned ------> {0}", finishedTask.ToString());
            if (finishedTask == eggsTask)
            {
                Console.WriteLine("eggs are ready");
            }
            else if (finishedTask == baconTask)
            {
                Console.WriteLine("bacon is ready");
            }
            else if (finishedTask == toastTask)
            {
                Console.WriteLine("toast is ready");
            }
            breakfastTasks.Remove(finishedTask);
        }

        Juice oj = PourOJ();
        Console.WriteLine("oj is ready");
        Console.WriteLine("Breakfast is ready!");

        /*
        var dumper = ObjectDumper.Dump(eggsTask);
        Console.WriteLine(dumper);
        Console.ReadLine();
        */
    }

    static async Task<Toast> MakeToastWithButterAndJamAsync(int number)
    {
        var toast = await ToastBreadAsync(number);
        ApplyButter(toast);
        ApplyJam(toast);

        return toast;
    }

    private static Juice PourOJ()
    {
        Console.WriteLine("Pouring orange juice");
        return new Juice();
    }

    private static void ApplyJam(Toast toast) =>
        Console.WriteLine("Putting jam on the toast");

    private static void ApplyButter(Toast toast) =>
        Console.WriteLine("Putting butter on the toast");

    private static async Task<Toast> ToastBreadAsync(int slices)
    {
        for (int slice = 0; slice < slices; slice++)
        {
            Console.WriteLine("Putting a slice of bread in the toaster");
        }
        Console.WriteLine("Start toasting...");
        Console.WriteLine("Toast 1 {0:HH:mm:ss.fff}", DateTime.Now);
        await Task.Delay(3000);
        Console.WriteLine("Toast 2 {0:HH:mm:ss.fff}", DateTime.Now);
        Console.WriteLine("Remove toast from toaster");

        return new Toast();
    }

    private static async Task<Bacon> FryBaconAsync(int slices)
    {
        
        Console.WriteLine($"putting {slices} slices of bacon in the pan");
        
        for (int slice = 0; slice < slices; slice++)
        {
            Console.WriteLine($"flipping {slice} slice of bacon");
            Console.WriteLine("Bacon 1 {0:HH:mm:ss.fff}", DateTime.Now);
            await Task.Delay(3000);
            Console.WriteLine("Bacon 2 {0:HH:mm:ss.fff}", DateTime.Now);
        }
        Console.WriteLine("Put bacon on plate");

        return new Bacon();
    }

    private static async Task<Egg> FryEggsAsync(int howMany)
    {
        Console.WriteLine("Warming the egg pan...");
        Console.WriteLine("Egg 1 {0:HH:mm:ss.fff}", DateTime.Now);
        await Task.Delay(3000);
        Console.WriteLine("Egg 2 {0:HH:mm:ss.fff}", DateTime.Now);
        Console.WriteLine($"cracking {howMany} eggs");
        Console.WriteLine("cooking the eggs ...");
        Console.WriteLine("Egg 3 {0:HH:mm:ss.fff}", DateTime.Now);
        await Task.Delay(3000);
        Console.WriteLine("Egg 4 {0:HH:mm:ss.fff}", DateTime.Now);
        Console.WriteLine("Put eggs on plate");

        return new Egg();
    }

    private static Coffee PourCoffee()
    {
        Console.WriteLine("Pouring coffee");
        return new Coffee();
    }
}

}

Can we dump a csharp struct?

Example of struct:

public struct X509ChainStatus
    {
        
        public X509ChainStatusFlags Status { get; set; }
        
        public string StatusInformation { get; set; }
    }

Dump a list not working, returns empty string:

var listToDump = new List<X509ChainStatus>();
           // populate the list
            var dump = ObjectDumper.Dump(listToDump);
// dump = "System.Security.Cryptography.X509Certificates.X509ChainStatus\r\n"

Dump to CSharp - decimals depands on the culture

Hi,

I work on a computer with a French windows.
While debugging, when I dump an object with decimal properties, I get decimals separator as a comma (',') which is not valid in C#, it should be a point ('.').

MyProp = 2,05m
should be
MyProp = 2.05m

[Bug][4.0.6]ArgumentNullException occurs for records in .Net 7.0

Description

I tried to update to the latest nuget version, but it seems there is an issue with your record handling.

Steps to Reproduce

  1. Create a new C# console application with .NET 7.0 and add the nuget package with version 4.0.6
  2. Execute the following code:

var definition = new SampleData() { Name = "Test" };

var str = ObjectDumper.Dump(definition, new DumpOptions()
{
    IndentChar = '\t',
    IndentSize = 1,
    LineBreakChar = Environment.NewLine,
    DumpStyle = DumpStyle.CSharp
});

Console.WriteLine(str);

public readonly record struct SampleData
{
    public required string Name { get; init; }
}
  1. Exception is thrown.

Expected Behavior

Value of str:

var sampleData = new SampleData
{
Name = "Test"
};

Actual Behavior

ArgumentNullException from ObjectDumperCSharp Line 68 (because 'recordCtor.Parameters' is null)

Basic Information

  • Version with issue: 4.0.6
  • Last known good version: 3.5.6

Option for swallowing exceptions

I was using the nuget package currently out there and dumping some complex objects and where throwing an exception. I forked and coded out a SwallowException = true DumpOption, then noticed the default behavior has changed to swallowing and showing the exception message.

Could you get a new nuget package out? TIA

ExcludeProperties DumpOption doesn't include fields

It's unintuitive, although it's named properly. I had expected my ExcludeProperties list to remove any fields with the same name as well as properties with the name.

I would suggest renaming ExcludeProperties to simply "Exclude" and removing any member at all from the output. Or, add an ExcludeFields option but that seems redundant, though it's the easy/lazy choice.

[Bug] Circular Reference detection issue

        [Fact]
        public void ShouldDumpEnumerable_CorrectCircularReferenceDetection()
        {
            // Arrange 
            var obj = new { Prop = new { SomeInnerProp = "test_test_test" } };
            var enumerable = Enumerable.Range(0, 2).Select(_ => obj);

            // Act
            var dump = ObjectDumperCSharp.Dump(enumerable);

            // Assert
            this.testOutputHelper.WriteLine(dump);
            dump.Should().NotBeNull();
            dump.Should().NotContain("// Circular reference detected");
        }

ObjectDumper produces un-compilable code

Consider the following code snippet where ExecutionReport is a type coming from the QuickFixN framework (the type definition can be found here: ):

var executionReport = new ExecutionReport
{
    ClOrdID = new ClOrdID { Obj = "SomeString", Tag = 11 }
};

var result = ObjectDumper.Dump(executionReport, DumpStyle.CSharp);

Now result contains:

var dumpedReport = new ExecutionReport
{
    { 11, new ClOrdID // => No overload for method 'Add' takes 2 arguments
    {
        Obj = "SomeString",
        Tag = 11
    }
    }
};

In this case the ObjectDumper produces un-compilable code, saying No overload for method 'Add' takes 2 arguments. How can this be fixed?

Dumping a thrown exception fails with InvalidOperationException

Trying to dump a caught exception to console results in error "System.InvalidOperationException : Method may only be called on a Type for which Type.IsGenericParameter is true."

Excluding the TargetSite property appears to be a workaround, as does dumping in CSharp format.

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.