Skip to content

Instantly share code, notes, and snippets.

@Slackwise
Created August 20, 2018 21:35
Show Gist options
  • Save Slackwise/684d80b1db36c9801e55f9d722a48e0f to your computer and use it in GitHub Desktop.
Save Slackwise/684d80b1db36c9801e55f9d722a48e0f to your computer and use it in GitHub Desktop.
Print the current method name for debugging purposes.(In my case, the debugger is crashing due to rogue pointers accessing the wrong address, but I don't know *where* it's occurring.
public void pmn()
{
try
{
var methodName = (new System.Diagnostics.StackTrace()).GetFrame(1).GetMethod();
System.Diagnostics.Debug.WriteLine(methodName);
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine($"Failed to print method name: ${ex.Message}");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment