LINQPad: Dump with Syntax Highlighting
LINQPad is where I breathe and eat in a typical day at work. I use a lot of extension methods inside that makes my life easy. I decided to share some of the most useful ones here when I get some time to write. Most of them were found online that can be found even now but I thought It'd be helpful if all of them had been on one place and I could just copy them all at the first place! This is the post number 1 of [I don't know how many I'd write] article series.
As the title implies, it is the same old beloved Dump
method with some intelligence in it. Take a piece of code in a string, call this method by specifying the language type in the language
parameter. Violah! the preview pan shows the code with syntax highlighting.
Just copy the following method into your MyExtensions
class, then you will get DumpWithSyntaxHightlighting
alongside the regular Dump
public static string DumpWithSyntaxHightlighting(this string code, SyntaxLanguageStyle language = SyntaxLanguageStyle.XML, string panelTitle = null)
{
if(panelTitle == null)
panelTitle = Enum.GetName(typeof(SyntaxLanguageStyle), language) + "Result";
PanelManager.DisplaySyntaxColoredText(code, language, panelTitle);
return code;
}
an example usage would be
File.ReadAllText(@"C:\some-xml.xml")
.DumpWithSyntaxHightlighting(SyntaxLanguageStyle.XML)