c# - Visual Studio Watch 窗口中的 "Non-Public members"节点是什么?

标签 c# debugging visual-studio-debugging vsx

当我在 Visual Studio 的观看窗口。但是后来,我注意到这段代码有一个异常:

   class HashDerived : System.Security.Cryptography.HashAlgorithm { ... }

   HashAlgorithm hash1 = new HashDerived();
   HashAlgorithm hash2 = new System.Security.Cryptography.SHA1Cng();

hash1 的“非公共(public)成员”看起来像这样:

hash1 in Watch Window

hash2 的“非公共(public)成员”看起来像这样:

hash2 in Watch Window

因此对于 hash1,似乎只有 private 字段 (m_bDisposed) 出现在“Non-Public members”节点下,而对于 hash2,甚至 其中出现了 protectedprotected internal 成员,如“HashSizeValue”和“HashValue”。

为什么会这样?这种行为背后的规则是什么?

最佳答案

您在这里看到的行为是一个错误。在这种情况下,C# 调试器不应显示静态成员。我与代码库的当前所有者确认了这一点,他将为下一个版本的 Visual Studio 提交错误。

发生这种情况的具体场景是

  • 仅我的代码已启用
  • 类型定义在确定为非用户程序集的地方
  • 引用和对象实例的类型不同(将hash2切换为SHA1Cnf,问题消失)

请注意,在其他情况下可能会出现这种情况。这是我能够在我所做的调试/实验中缩小范围的行为。

关于c# - Visual Studio Watch 窗口中的 "Non-Public members"节点是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11594725/

相关文章:

c# - 小巧玲珑,带有 SIMPLECrud : GetList with WHERE behaving like LIKE instead of =

javascript - 如何将参数传递给 Google Apps 脚本调试器?

c# - 在 Json.Net 的 JsonConverter<> ReadJson() 中,为什么 reader..Value 为空?

c# - 可移植类库和 WebRequest.ContentLength

android - ADB 未检测到 ZTE V9

java - IntelliJ IDEA 中的 Gradle Java 调试项目

c# - 上下文中不存在变量,但已明确定义

xml - Visual Studio 2015 xsl调试转换失败WebException SocketException

c++ - 为什么我的程序在调试器中运行良好时会崩溃,但在 VS 2010 C++ 中不使用调试器运行时会崩溃?

c# - 异步方法不识别 yield return 方法?