QuickWatch无法正常显示“ .ToString()”。可空属性 [英] QuickWatch is not work correctly for show ".ToString()" of Nullable properties

查看:145
本文介绍了QuickWatch无法正常显示“ .ToString()”。可空属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在vb.net中有一个可空整数属性

该属性在代码中具有正确的值,但在 QuickWatch 中始终显示 1 ,除非我以一个值开头,然后显示六个洋地黄数字。

I have a nullable integer property in vb.net.
This property in code has correct value, but in the QuickWatch always display 1, unless I initial it by a value then display a six digitalis numbers.

我的代码是:

Public Property MyNumber As Integer?

MyNumber = 6546

MessageBox.Show(MyNumber.ToString())

对于 QuickWatch 中的可空双属性,始终显示 4 / 94065645841247E-324

我在 .Net 4上对此进行了测试。 4.5 visual studio 2010& 2013 并获得相同结果。但是C#没有这个问题

I test this on .Net 4 & 4.5 on visual studio 2010 & 2013 and get same result. However C# hasn't this problem

编辑:

我附加了我的项目结果也一样,如您在监视窗口中看到的,它们都显示为

I append my project result too, as you see in watch windows both of them is shown

为什么会这样?

编辑:

.Net 4、4.5和4.5.1出现此问题。使用.Net 2.0和3.5没问题

This problem is with .Net 4 and 4.5 and 4.5.1. With .Net 2.0 and 3.5 has no problem

推荐答案

已确认,这确实是调试器中的错误。我搜索了connect.microsoft.com,找不到类似的东西,这不是许多VB.NET程序员都喜欢的错误。并不完全令人惊讶,这仅在将.ToString()附加到可为空的变量名称后才出错。

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.

这不是可以在此站点获得任何帮助的错误,这是Microsoft需要修复的错误。

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.

略微说明了此错误,在调试器中内置的VB.NET特定表达式解析器中,这似乎出错了。您无法在C#项目中对此进行复制的原因。以及为什么该过程的位数无关紧要,64位调试器还显示了错误的值。通常,这是Microsoft一直在努力退休的不固定代码。基本问题是,他们必须将等效的VB.NET编译器构建到调试器中,以便可以解析这些表达式。尽管有限,但该解析器几乎不支持整个语言。副作用是调试器运行的代码可能不同于程序运行的代码。

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.

Nullable(Of T).ToString()的代码生成为相当棘手,它需要有条件的拳击转换。解析器会针对任何此类表达式进行粗化,请注意 MyNumber.GetHashCode()也是如何产生错误值的。还有 MyNumber.Equals(5456.0)

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.

您也可以在connect.microsoft.com上从技术上报告此错误,但我不建议您花时间。如前所述,Microsoft一直在努力淘汰此解析器,但最终还是发生了。由Roslyn提供支持,该编译服务可在任何地方使用。它已集成到VS2015中,据调试器也使用它。不确定100%,我会在9天之内知道VS2015发布的时间。也许安装了beta / RC版本的人可以发表评论进行确认。

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.

更新:已在VS2015上得到确认。

UPDATE: confirmed fixed on VS2015.

同时,直到您可以更新之前,解决方法是仅停止在快速/监视表达式中的可空变量上使用ToString()。这是越野车。

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

这篇关于QuickWatch无法正常显示“ .ToString()”。可空属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆