This is kind of a silly question, but is it possible to get the name of the method that is currently being executed from within that method?
Public Sub SomeMetho
Another approach would be to use CallerMemberNameAttribute from the System.Runtime.CompilerServices namespace to populate an optional parameter. For example ...
Private Function GetMethodName(
Optional memberName As String = Nothing) As String
Return memberName
End Function
The function would be invoked as you would expect...
Public Sub DoSomeWork()
Dim methodName As String = GetMethodName()
Console.WriteLine($"Entered {methodName}")
' Do some work
End Sub
Rather than 'just' retrieving the method name, the function might also make use of the method name retrieved to further simplify code. For example...
Private Sub TraceEnter(
Optional memberName As String = Nothing)
Console.WriteLine($"Entered {memberName}")
End Sub
... which might be used like this ...
Public Sub DoSomeWork()
TraceEnter()
' Do some work
End Sub
Other attributes in the CompilerServices namespace may be used in similar fashion to retrieve the full path (at compile time) of the source file and/or the line number of the call. See the CallerMemberNameAttribute documentation for sample code.