I have a C++ code that I’m trying to migrate to C#. Over there, on C++, i was using the following macros definition for debugging purposes.
#define CODE_LOCATION(FILE_NAME, LINE_NUM, FUNC_NAME) LINE_NUM, FILE_NAME, FUNC_NAME
#define __CODE_LOCATION__ CODE_LOCATION(__FILE__, __LINE__, __FUNCTION__)
Are there similar constructs in C#? I know there are no macros in C#, but is there any other way to get the current file, line and function values during execution?
If you are using .net 4.5 you can use CallerMemberName CallerFilePath CallerLineNumber attributes to retrieve this values.
If you are using older framework and visual 2012 you just need to declare them as they are in framework (same namespace) to make them work.