Home
Options

Debugger values out when source includes line separator character (\u2028)

edited February 26

Hi,

I'm noticing that using a verbatim string that includes a line separator character (u2028) seems to throw out the debugger.

In the following screenshot notice that targetInlineWidth is reporting as 0, rather than 4:

The correct value is dumped and in fact, if you put a breakpoint on line 7, then at that point targetInlineWidth reports as 4.

Not sure how well this will make it through markdown, but here's the pasteable code (I hope):

void Main()
{
    string s = @"Giant Ants
A";

    double targetInlineWidth = 4;
    targetInlineWidth.Dump();
}

This is based on v8.1.6 (x64) against the 8.0.2 runtime.

Best regards

John

Comments

  • Options

    Your code is indeed pasteable and shows the bug,

    I think the debugger is pointing to the wrong line because of this character. It you step through the code, you will notice it doesn't stop on the double targetInlineWidth = 4; line and incorrectly points to the next line before it actually sets the value. Then it steps onto the next line (even if the next line is a blank line) and displays the correct value for targetInlineWidth.

    Also the following works

    void Main()
    {
        string s = "Giant Ants\u2028A";
    
        double targetInlineWidth = 4;
        targetInlineWidth.Dump();
    }
    

    even though it is the exact same string.

  • Options

    Ah, good spot I hadn't noticed the line skipping. I was using a verbatim string as I had other characters including CR and LF, and pasting in from Notepad++ you get to see the 'L SEP' glyph which is nice for this scenario. The workaround (using the unicode) works for me. Thanks sg.

Sign In or Register to comment.