QuickWatch is not work correctly for show “.ToString()” of Nullable properties

余生长醉 提交于 2019-11-30 12:37:10

Confirmed, this is indeed a bug in the debugger. I searched connect.microsoft.com and could not find anything similar, this is not a bug that strikes many VB.NET programmers. Not entirely surprising, this only goes wrong when you append .ToString() to the nullable variable name. Nobody ever does that.

It is not the kind of bug you can get any help with at this site, it is a bug that Microsoft needs to fix.

Characterizing the bug a bit, this appears to go wrong in the VB.NET specific expression parser built into the debugger. The reason that you can't repro this in a C# project. And why the bitness of the process doesn't matter, the 64-bit debugger also shows bad values. This is in general a fickle piece of code that Microsoft has been working on to retire. Basic problem is that they had to build the equivalent of the VB.NET compiler into the debugger so that these expressions could be parsed. Limited though, that parser does not nearly support the entire language. Side-effect is that the code that debugger runs can be different than the code your program runs.

The code-generation for Nullable(Of T).ToString() is fairly tricky, it requires a conditional boxing conversion. The parser flubs it for any such expression, note how MyNumber.GetHashCode() produces the wrong value as well. And MyNumber.Equals(5456.0). The kind of expressions that require that boxing conversion.

You can technically report this bug at connect.microsoft.com as well but I would not recommend spending the time. As noted, Microsoft has been working on retiring this parser and that finally happened. Powered by Roslyn, a compile service that's usable anywhere. It was integrated into VS2015 and as far as know the debugger uses it as well. Not 100% sure, I'll know in 9 days when VS2015 is released. Maybe somebody that has the beta/RC edition installed can confirm with a comment.

UPDATE: confirmed fixed on VS2015.

Meanwhile, until you can update, the workaround is to just stop using ToString() on nullable variables in your quick/watch expressions. It is buggy.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!