Skip to content

Instantly share code, notes, and snippets.

@noseratio
Created October 19, 2021 06:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save noseratio/09871682723e568d7b8abdcf0b75d220 to your computer and use it in GitHub Desktop.
Save noseratio/09871682723e568d7b8abdcf0b75d220 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
internal static partial class Diagnostics
{
/// <summary>
/// Double-click the output in Visual Studio Output Window to go to that source file and line
/// </summary>
[Conditional("DEBUG")]
public static void Log(
string message,
[CallerMemberName] string callerName = "",
[CallerLineNumber] int lineNumber = 0,
[CallerFilePath] string filePath = "")
{
// trim trailing new line characters
var trimmedMessage = message.TrimEnd(Environment.NewLine.ToCharArray());
Debug.WriteLine($"{filePath}({lineNumber}): {trimmedMessage}");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment