Newlines in the Immediate Window

前端 未结 2 1900
自闭症患者
自闭症患者 2021-01-30 13:07

Using Visual Studio 2010 Professional, I have a ToString() method that looks like this:

public override string ToString()
{
    return \"something\"         


        
2条回答
  •  粉色の甜心
    2021-01-30 13:38

    Unfortunately no there is not. What's happening here is an artifact of the design of the debugger APIs.

    The component responsible for processing the ToString() call is the expression evaluator. It's the data source for the majority of the debugger windows (watch, locals, immediate, etc ...).

    For every window but the immediate the value is displayed on a single line. Displaying a multiline string on a single line doesn't make much sense. Hence the expression evaluator makes the string slightly more displayable by escaping newline characters into a displayable version.

    This technique works pretty well for the locals and watch window. But in the immediate window where it makes more sense to display the multiline value it makes a lot less sense. Unfortunately the expression evaluator doesn't know the context of where it's data will be displayed and hence does the safe operation which is to escape the newlines.

提交回复
热议问题