Skip to content

Instantly share code, notes, and snippets.

@noseratio
Created June 22, 2020 11:10
Show Gist options
  • Save noseratio/bbc35b4e18250040a5ff4518d1b0d030 to your computer and use it in GitHub Desktop.
Save noseratio/bbc35b4e18250040a5ff4518d1b0d030 to your computer and use it in GitHub Desktop.
Double-click the output in Visual Studio Output Window to go to that source file and line
public static class Diags
{
public static void Log(
string message,
[System.Runtime.CompilerServices.CallerMemberName] string callerName = "",
[System.Runtime.CompilerServices.CallerLineNumber] int lineNumber = 0,
[System.Runtime.CompilerServices.CallerFilePath] string filePath = "")
{
// trim trailing new line characters
var trimmedMessage = message.TrimEnd(Environment.NewLine.ToCharArray());
Debug.WriteLine(string.Format($"{filePath}({lineNumber}): {trimmedMessage}"));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment