密封类和对象浏览器

发布于 2024-08-10 20:54:04 字数 953 浏览 6 评论 0原文

在对象浏览器窗口中检查 .net 对象模型时,我发现缺少有关密封类的信息。

例如,如果导航到 mscorlib 容器 -> 系统命名空间 -> String 类,详细信息窗格将显示以下内容:

公共类字符串
     系统成员

摘要:
将文本表示为一系列 Unicode 字符。

属性:
[System.Runtime.InteropServices.ComVisibleAttribute(true), System.Reflection.DefaultMemberAttribute("Chars")]

看来我只能通过代码定义窗口或者尝试从它派生来确定类是否被密封。

然而,在关注 Andrew Troelsen 的 Apress - Pro C# 2008 和 .Net 3.5 Platform 时,作者在第 188 页上展示了对象浏览器如何显示密封状态:

替代文字

此信息是否已从 Visual Studio 2008 对象浏览器中删除?我能以某种方式取回它吗?

虽然作者在整个文本中提到了 Visual Studio 2008,但该屏幕截图必须来自以前的版本。这本书实际上是第 4 版,早在 2001 年就推出了 .Net 1.0 Beta 2。

While inspecting the the .net object model in the Object Browser window, I came across the lack of information on sealed classes.

If for instance, one navigates to the mscorlib container -> System namespace -> String class, the details pane displays the following:

public class String
     Member of System

Summary:
Represents text as a series of Unicode characters.

Attributes:
[System.Runtime.InteropServices.ComVisibleAttribute(true),
System.Reflection.DefaultMemberAttribute("Chars")]

It seems I can only ascertain if a class is sealed either through the Code Definition Window or, of course, by trying to derive from it.

Yet, while following Apress - Pro C# 2008 and the .Net 3.5 Platform, by Andrew Troelsen, the author shows on page 188 how the object browser display the sealed status:

alt text

Has this information been removed from Visual Studio 2008 object browser? Could I get it back somehow?

Although the author mentions Visual Studio 2008 throughout the text, that screenshot must be from a previous version. The book is in fact in its 4th Edition, and started back in 2001 with .Net 1.0 Beta 2.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

怪我入戏太深 2024-08-17 20:54:04

我知道已经过去几年了,但我只是想确认我可以在 VS2k8 SP1 中看到这一点,但对于String

我认为这是因为 String 是唯一被标记为“特殊”(也许是原始类型?)的 class 以及 Integer、< code>Long 等,它们都是 ValueTypes结构)。

请注意问题中的图像中的 SByteSingleString 在 LHS 树视图中具有相同的图标就像他们现在所做的那样。

编辑:又过了几年,我刚刚注意到 VS2k8 SP1 中的 VB.NET 确实Public NotInheritable Class String我将“对象浏览器浏览”选择设置为“我的项目”或“所有组件”*,但当我选择特定的 .NET Framework 时,只有 Public Class String(并且属性已列出,但它们不在其他浏览选择)。

*正如OP中捕获的显示一样!

注意:仅当您在 LHS 树视图上关闭 String 并再次打开它时,它才会更新显示。 VS2010 SP1 的行为相同。

在 VS2010 中,我看到所有组件将 String 显示为 NotInheritable(对于 .NET 4)以及“空白”(对于 .NET 2 和 Silverlight),但我不能目前正在确认VS2008在类似情况下的显示情况。

I know it's been a couple of years, but I'd just like to confirm I can see this in VS2k8 SP1, but only for String.

I think it is because String is the only class that has been marked as "special" (primitive type perhaps?) along with Integer, Long, etc, which are all ValueTypes (structures).

Note in the image in the question SByte, Single and String do not have the same icon in the LHS treeview where as they do now.

Edit: It's been another couple of years and I've just noticed for VB.NET in VS2k8 SP1 it does say Public NotInheritable Class String when I have the Object Browser Browse selection set to My Project or All Components*, but only Public Class String when I select a specific .NET Framework (and yet Attributes are listed, whereas they're not in the other Browse selections).

*As in the display captured in the OP!

NB It only updates the display if you shift off String and back on it again on the LHS treeview. And VS2010 SP1 behaves identically.

In VS2010 I see All Components showing String as both NotInheritable, for .NET 4, and "blank" for .NET 2 and Silverlight, but I can't currently confirm what VS2008 shows in a similar situation.

潇烟暮雨 2024-08-17 20:54:04

我的Visual Studio 2008似乎没有这个问题。你升级到SP1了吗?您是否有其他工具或插件可以修改对象浏览器的功能?

My Visual Studio 2008 does not seem to have this issue. Are you upgraded to SP1? Do you have other tools or add-ins that modify the Object Browser's functionality?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文