[Mono-bugs] [Bug 641439] New: System.Diagnostics.StackFrame.GetFileLineNumber is returning the incorrect line number

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Thu Sep 23 13:16:43 EDT 2010



           Summary: System.Diagnostics.StackFrame.GetFileLineNumber is
                    returning the incorrect line number
    Classification: Mono
           Product: Mono: Class Libraries
           Version: 2.6.x
          Platform: x86-64
        OS/Version: Ubuntu
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: Sys.Core
        AssignedTo: jbevain at novell.com
        ReportedBy: dale.ragan at sinesignal.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---
           Blocker: ---

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US)
AppleWebKit/534.3 (KHTML, like Gecko) Chrome/6.0.472.62 Safari/534.3

I have a case where System.Diagnostics.StackFrame.GetFileLineNumber is
returning the incorrect line number.  The value is off by one.

You can use my fork of the project as a test case: 

Reproducible: Always

Steps to Reproduce:
1.  Clone the project I listed in the details.  Commit:
2.  Compile and Run the tests.
3.  Tests.ShoudlyMessageTests.CanGenerateErrorMessage will fail.
Actual Results:  
Tests.ShoudlyMessageTests.CanGenerateErrorMessage failed due to
System.Diagnostics.StackFrame.GetFileLineNumber returning the wrong line
number.  Under .NET the test passes and a line number of 13 is returned by the
call.  Under Mono the test fails and a line number of 14 is returned by the

The call stack is as follows:

new ShouldlyMessage("expected", "actual")
ShouldlyMessage.GenerateShouldMessage(actual, expected)
ShouldlyMessage.GetStackFrameForOriginatingTestMethod() <- Inside this method
is the call to System.Diagnostics.StackFrame.GetFileLineNumber

Expected Results:  
The test to pass without any modifications.

For a work around, I am changing the
Tests.ShoudlyMessageTests.CanGenerateErrorMessage test to this:

var result = new ShouldlyMessage("expected", "actual").ToString();
            result.ShouldBe(@"            var result = new
ShouldlyMessage(""expected"", ""actual"").ToString();
        can generate error message
        but was

Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.

More information about the mono-bugs mailing list