I would like to be able to call Dump from my DLL and code below returns raw HTML result. How can I render it, or what is the correct approach?
Method
public static string Dump<T>(this T obj)
{
var writer = LINQPad.Util.CreateXhtmlWriter();
writer.Write(obj);
return writer.ToString();
}
Call
Debug.WriteLine(myObject.Dump());
Result on LINQPad
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<meta name="Generator" content="LINQ to XML, baby!" />
<style type='text/css'>
...
</style>
</head>
<body>
<div>
...
</div>
</body>
</html>
Thanks to Joe Albahari, adding LinqPad.exe as reference allows us to use Dump function from the library so no implementation is needed.