Unity Game Engine has a very useful feature in its console, where you can click on any line in the output, and it will take you to the line of source code that produced it.
For example
Debug.Log("test");
(line 20 in Test.cs)
will output
test
double clicking on test, will bring you back to line 20 in Test.cs in the IDE.
I was wondering, is there some way to do this in normal C# development? I'm using Rider IDE, but I suspect this is some kind of hyperlink rather than something IDE dependent. Although perhaps that's not accurate.
I managed to figure this out pretty well. This piggybacks on Jetbrains IDEs parsing the console, and it creates links to paths. I'm not sure this will work in other IDEs, but it actually works super well for what I wanted.
const string ProjectFolder = "MyProject/";
public static void Log(string message,
[CallerMemberName] string callingMethod = "",
[CallerFilePath] string callingFilePath = "",
[CallerLineNumber] int callingFileLineNumber = 0)
{
string pathFromProjectFolder = callingFilePath.Split(ProjectFolder).LastOrDefault();
Console.WriteLine($"{message} {pathFromProjectFolder}:{callingFileLineNumber} ");
}
Calling this method produces something like this in the console for Rider.