Settings and activity
1 result found
-
6 votes
An error occurred while saving the comment An error occurred while saving the comment Andrew Rutherfurd commentedGreat start, Mark Hurd,
I have a simple extension of your extension:
static class extensionMeth
{
static int offset=0;
public static T DumpLine<T>(this T obj, string description = "", [CallerLineNumber]int lineNumber = 0)
{
if (offset == 0)
offset = lineNumber-1;
return obj.Dump($"Line:{lineNumber-offset}, {description}");
}
}// Usage:
void Main()
{
"TestA".DumpLine("foo");"TestB".DumpLine("bar");
"TestC".DumpLine();
}Output, first DumpLine command gets line number 1:
Line:1, foo
TestA
Line:3, bar
TestB
Line:4,
TestC
Extended extension of the extension, lets you initialize line number:
https://gist.github.com/AndrewR66/1aab13658e2a48586760a054e6b6beea