Description
In case you create an instance of StackTrace with fNeedFileInfo: true
, it will try to deliver you things like file name, line number, column number. - I focus here on line number.
E.g.:
foreach (var frame in new StackTrace(true).GetFrames())
{
var lineNumber = frame.GetFileLineNumber();
}
There are many known scenarios when GetFileLineNumber()
will return 0
despite the StackTrace(true)
- e.g. there are no .pdb
s present, or portable pdbs pre .NET Framework 4.7.1 and probably more.
Question
Do you have any tests that cover these scenarios and other scenarios when GetFileLineNumber()
should not return 0
? I looked at the tests for System.Diagnostics.StackTrace
and I see some tests that cover line numbers in StackFrameTests.cs but all those create StackFrame
s manually and pass the line number. StackTraceTests.cs only has a case with Assert.Equal(0, stackFrame.GetFileColumnNumber())
.
But you don’t really seem to test when it should be not 0
. Do I see this correctly? Or are there other tests somewhere else?
Context
I’m working on a monitoring tool that reports stack traces, and we also try to show line numbers and of course we want to cover this feature with tests - I thought it’d be nice to see what and how is tested in CoreFX.
I’m not expecting any action on this, it’s more like just a question to answer. Thanks!