.NET的类型层次查看工具

上周为了快速了解一个.NET的库而需要查看其类型层次。假如要在文章中表示一个类型层次,还是用文本比较舒服,截图始终是不方便。Reflector虽然能够显示类型层次,但我无法方便的把显示出来的类型层次转换为文本形式。而且,Reflector在显示基类和派生类的时候都会使用类型的全名,但有时候我只需要看到类型的简单名字。我也找过另外几个工具,例如.NET Framework SDK以前自带的Windows 窗体类查看器(Wincv.exe),但它只显示类型自身的信息以及基类的信息,而不显示派生类的信息,还是不够用。

没找到现成合用的工具,只好自己写一个了。于是就用C#/WinForms写了一个简单的GUI程序,只是用来显示类型层次信息,并且能把类型层次以文本形式复制到剪贴板。

截图一张:

对应这张截图得到的文本表示:

Java代码  

  1. IList<T>
  2. Collection<T>
  3. KeyedCollection<TKey, TItem>
  4. List<T>
  5. ReadOnlyCollection<T>

===========================================================================

开源形式

该程序采用MIT形式的许可证开放源代码。程序与源码可在本帖附件的压缩包中获得。

运行环境

由于使用了LINQ,这个程序需要.NET Framework 3.5才能正常运行。如果需要移植到.NET Framework 2.0的话,可以使用Mono的System.Core.dll的实现。

===========================================================================

使用方法

可以从命令行提供参数来打开assembly,格式为:

ClassHierarchyViewer <assembly-path>

或者直接启动程序,并通过以下三种方式的任意一种来打开assembly:

1、在文本框中输入assembly的完整名称(Name,Version,Culture,PublicKeyToken),并按回车或点击“Load By Name”按钮;

2、按“Open File...”按钮通过对话框选取assembly;

3、从文件浏览器把assembly拖放到该程序的窗口里。

同一时间只会有一个assembly显示在窗口中。

其它功能应该不言而喻了,我就直接把readme文件的内容帖出来吧:

引用

////////////////////////////////////////////////////////////////

Name: ClassHierarchyViewer

Author: RednaxelaFX (Kris Mok, [email protected])

Version: 0.3.0.1

Release Date: 2008-09-23

License: MIT style license. See License.txt.

////////////////////////////////////////////////////////////////

Description:

A simple tool that shows the class hierarchy within a given

.NET assembly.

Required Environment:

Windows XP or Vista, with .NET Framework 3.5 or above installed.

////////////////////////////////////////////////////////////////

Usage:

1. Start program from command line:

usage: ClassHierarchyViewer <assembly-path>

- or -

2. Start program from GUI:

Assemblies can be loaded by one of:

* enter the assembly‘s full name in the combobox, then click

"Load By Name" button;

* enter the assembly‘s full name in the combobox, and hit

Enter;

* Click "Open File..." button, and choose an assembly file;

* Drag and drop a assembly file from Explorer.

Only one assembly is active at a time.

A few commonly used BCL assemblies‘ names are added to the

combox already, including:

mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089

System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089

System.AddIn, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089

System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a

System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089

System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089

System.Data.Entity, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089

System.Data.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089

System.Deployment, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a

System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a

System.DirectoryServices, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a

System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a

System.Drawing.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a

System.Messaging, Version=2.0.0.0, Culture=neutral, PublicKeyToken=969db8053d3322ac

System.Net, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a

System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089

System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a

System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089

System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089

////////////////////////////////////////////////////////////////

Functions:

The GUI window is divided into 3 major components:

1. Class List Window (on the left)

Displays all types (except "<Module>") in the given assembly,

grouped by their namespaces, sorted by the type‘s name.

Types that are not visible outside the assembly are marked gray.

2. Class Hierarchy Window (on the upper right)

When a type is selected in the Class List Window, its type

hierarchy will be shown in this window.

The hierarchy shown includes the type itself, its base type (up

to System.Object), and all its derived types.

Checking/unchecking the "Full Name" checkbox will cause this

window to reload, showing types with their simple name/full name.

Clicking "Copy to Clipboard" button will copy the type hierarchy

to the clipboard, in text representaion.

3. Class Member Window (on the lower right)

When a type is selected in the Class Hierarchy Window, its

members will be shown in this window. This does not include

a type‘s nested types.

Checking/unchecking the "Use Alias" checkbox will cause this

window to reload, showing types with their alias/name.

////////////////////////////////////////////////////////////////

Known Issues:

1. TreeViews flicker when mouse moves over them rapidly.

Haven‘t found any solution to this, maybe that‘s just how

WinForms behaves.

2. Copying the type hierarchy causes flickering.

This is because of the way data is loaded: derived types are

added onto the tree when a node is expanded. To make sure

derived types are added correctly, the whole tree is expanded

before its text representation can be gathered. This will be

improved in later versions with M-V-VM pattern.

3. Properties‘ getter and setter methods aren‘t associated with

the properties‘ nodes.

Due to the lack of developing time, certain useful functions

such as this one is not implemented yet. Will be fixed in

later versions.

4. Doesn‘t show what interfaces a type implements.

Same as above. Will be fixed.

5. Cannot load an assembly from GAC just by browsing in the open

file dialog.

I know. That‘s why there‘s an alternative, to load assemblies

with their full names. Later on I might add a dialog to select

assemblies from GAC.

////////////////////////////////////////////////////////////////

Note:

The icons used in this program originated from Microsoft Visual

Studio 2008‘s image libraries, Visual Studio Image Library:

24bit Objects and Objects (WinVista style, .png).

许可证:

引用

The MIT License

Copyright (c) 2008 RednaxelaFX (Kris Mok, [email protected])

Permission is hereby granted, free of charge, to any person obtaining a copy

of this software and associated documentation files (the "Software"), to deal

in the Software without restriction, including without limitation the rights

to use, copy, modify, merge, publish, distribute, sublicense, and/or sell

copies of the Software, and to permit persons to whom the Software is

furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in

all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR

IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,

FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE

AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER

LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,

OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN

THE SOFTWARE.

现在这个简陋的程序最大的限制就是无法自如的打开GAC里的assembly,因为在Windows上安装.NET
Framework之后,GAC目录默认会被Fusion管理起来,需要通过修改注册表来禁用这个功能才能看到GAC里的assembly的路径。当然,
我可以扫描%WINDOWS%\Assembly\下的所有assembly,不过这个功能还没做进来;别的类似程序在扫描GAC时非常慢,所以我不太肯
定要不要把这个功能做进来。现在通过强名称一样能打开GAC里的assembly,只是用户会辛苦一点了。预先放在文本框的下拉列表里的名称应该能满足一
般使用需要了吧。

如果有什么意见和建议,欢迎提出。有需要请通过站内短信或者电子邮件联系,谢谢 ^ ^

时间: 2024-11-25 07:04:24

.NET的类型层次查看工具的相关文章

Atitit.java&#160;虚拟机的构成&#160;与指令分类&#160;与&#160;指令集合&#160;以及字节码查看工具javjap

Atitit.java 虚拟机的构成 与指令分类 与 指令集合 以及字节码查看工具javjap 1.1. 虚拟机的构成 java虚拟机--处理器.堆栈.寄存器.指令系统. 1 1.2. 虚拟机执行过程1 1.3. 约有250个指令2 2. JVM指令助记符 分类2 2.1. 变量到操作数栈:2 2.2. 算数指令3 2.3. 移位指令3 2.4. 逻辑指令4 2.5. 流程跳转指令4 2.6. Oo指令4 2.7. 运算指令 5 3. 查看指令反编译工具6 3.1.   分析java语言特性的一

Java 8的类型注解:工具和机会

在以前的Java版本中,开发者只能将注解(Annotation)写在声明中.对于Java 8,注解可以写在使用类型的任何地方,例如声明.泛型和强制类型转换等语句: @Encrypted String data;List strings;myGraph = (@Immutable Graph) tmpGraph; 乍一看,类型注解并不是Java新版本最炫的特性.事实上,注解只是语法!工具决定了注解的的语义(即,它们的含义和行为).本文介绍新的注解语法和实用工具,以提高生产力和构建更高质量的软件.

互联网产品类型与产品工具

一.产品的类型 在现实生活中互联网产品名目繁多,产品到底可以分成哪几类?各产品类型之间有着什么样的关系? 图片来源:网络 下面我们介绍五种主要产品类型 1. 工具型产品 工具指的是为达到.完成或促进某一事物的手段. 典型代表有下载工具:迅雷. 影音播放器:暴风影音. 音乐播放器:酷我. 杀毒工具:360. 词典:金山词霸和有道词典. 图片处理:photoshop等 搜索:百度和谷歌 在线记事本:Evenote等. 2.媒体型产品 所谓媒体,是指传播信息的媒介,能为信息的传播提供平台.通俗点解释,

MySQL之数据库对象查看工具mysqlshow

mysqlshow:数据库对象查看工具,用来快速查找存在哪些数据库.数据库中的表.表中的列或索引. 选项:--count    显示数据库和表的统计信息 -k         显示指定的表中的索引 -i         显示表的状态信息 不带任何参数显示所有数据库 [[email protected] mysql-5.6.30]# mysqlshow +--------------------+ |     Databases      | +--------------------+ | in

mysqlshow(数据库对象查看工具)

mysqlshow是mysql客户端对象查看工具,可以用来查看数据库.数据库中的表.表中的列.索引等. 1.mysqlshow命令的语法 shell > mysqlshow [options] [db_name [tbl_name [column_name]]] 如果不加任何选项,默认就是显示所有数据库. # mysqlshow -uroot -p Enter password: +--------------------+ | Databases | +--------------------

json格式化和查看工具

以前一直以来都觉得xml个可读性要比json的可读性好,后来使用了JSON Viewer这个小工具之后,发现自己错了.之前认为json的可读性差,完全是因为没有很好的查看工具.JSON Viewer这个小工具可以很方便的查看json数据. 点击Format可以方便的将凌乱的json格式化. 如果json格式不正确,能够得到很好的提示. 方便的查看键值对. 对数据内容进行查询.

推荐一个zookeeper信息查看工具

zookeeper信息查看工具 下载地址:https://issues.apache.org/jira/secure/attachment/12436620/ZooInspector.zip 解压,打开: ZooInspector\build\zookeeper-dev-ZooInspector.jar 参考: http://blog.csdn.net/atco/article/details/13628523 转载请标明出处: 2015.6.30 版权声明:本文为博主原创文章,未经博主允许不得

grep文本查看工具及正则表达式

grep文本查看工具及正则表达式 grep:搜索及过滤文本工具: (根据用户所指定的"模式"搜索,过滤条件"对目标文件进行过滤性匹配):grep自带正则表达式引擎工具. 所谓模式:由正则表达式所得元字符及普通文本字符所编写出来的过滤条件"模式" grep:三种支持模式: grep:基本正则表达式 egrep:支持扩展正则表达式 fgrep :不支持正则表达式 三种支持模式因其可以(grep -E:切换扩展,egrep-G:切换基本,分别有以-F切换fgre

一款开源的 Android YUV 格式查看工具

1. YUVDroidTools 最近项目比较忙,好久没有写文章了,也没有为开源社区贡献点啥了,这个周末抽空整理了一下自己一直维护的一份基于 ffmpeg 的 YUV 格式转换代码,写了一个简单的 Android YUV 数据查看工具(代码完全开源),截图如下: 特性如下: (1)支持选择导入本地文件,支持实时显示 YUV 格式的图片,简单易用. (2)支持多种 YUV 格式,包括: YU12.YV12.NV21.NV12.YUYV422.YVYU422.YUV422P.UYVY422 等等.