ToString method when using .Dump
Hi,
Would it be possible to get a feature implemented in linqpad, where linqpad does not call .ToString() on the objects being dumped.
The reason for this that if you have implemented a ToString() method on a class you don't neccessary want it to be used when calling .Dump().
Example:
----------------------------------------------------
void Main()
{
var c = new ClassWithToString();
c.Dump();
var c2 = new ClassWithoutToString();
c2.Dump();
}
public class ClassWithoutToString
{
public int MyProperty { get; set; }
public int MyProperty2 { get; set; }
public int MyProperty3 { get; set; }
}
public class ClassWithToString : ClassWithoutToString
{
public override string ToString()
{
return $@{MyProperty},
{MyProperty},
{MyProperty}";
}
}
----------------------------------------------------
In this example the result for ClassWithToString in the dump window looks silly, since Dump calls ToString() as part of dumping.
Where for the ClassWithoutToString looks as "expected" - where it just uses the name of the class.
Thanks in advance
Would it be possible to get a feature implemented in linqpad, where linqpad does not call .ToString() on the objects being dumped.
The reason for this that if you have implemented a ToString() method on a class you don't neccessary want it to be used when calling .Dump().
Example:
----------------------------------------------------
void Main()
{
var c = new ClassWithToString();
c.Dump();
var c2 = new ClassWithoutToString();
c2.Dump();
}
public class ClassWithoutToString
{
public int MyProperty { get; set; }
public int MyProperty2 { get; set; }
public int MyProperty3 { get; set; }
}
public class ClassWithToString : ClassWithoutToString
{
public override string ToString()
{
return $@{MyProperty},
{MyProperty},
{MyProperty}";
}
}
----------------------------------------------------
In this example the result for ClassWithToString in the dump window looks silly, since Dump calls ToString() as part of dumping.
Where for the ClassWithoutToString looks as "expected" - where it just uses the name of the class.
Thanks in advance
Comments
Also, you could add ToDump to your own classes:
https://linqpad.net/CustomizingDump.aspx