xml层级工具_.NET的类型层次查看工具,ClassHierarchyViewer,0.3.0.1
上周為了快速了解一個.NET的庫而需要查看其類型層次。假如要在文章中表示一個類型層次,還是用文本比較舒服,截圖始終是不方便。Reflector雖然能夠顯示類型層次,但我無法方便的把顯示出來的類型層次轉換為文本形式。而且,Reflector在顯示基類和派生類的時候都會使用類型的全名,但有時候我只需要看到類型的簡單名字。我也找過另外幾個工具,例如.NET Framework SDK以前自帶的Windows 窗體類查看器(Wincv.exe),但它只顯示類型自身的信息以及基類的信息,而不顯示派生類的信息,還是不夠用。
沒找到現成合用的工具,只好自己寫一個了。于是就用C#/WinForms寫了一個簡單的GUI程序,只是用來顯示類型層次信息,并且能把類型層次以文本形式復制到剪貼板。
截圖一張:
對應這張截圖得到的文本表示:
IList
Collection
KeyedCollection
List
ReadOnlyCollection
開源形式:
該程序采用MIT形式的許可證開放源代碼。程序與源碼可在下面鏈接的壓縮包中獲得。
下載地址
運行環境:
由于使用了LINQ,這個程序需要.NET Framework 3.5才能正常運行。如果需要移植到.NET Framework 2.0的話,可以使用Mono的System.Core.dll的實現。
使用方法:
可以從命令行提供參數來打開assembly,格式為:
ClassHierarchyViewer
或者直接啟動程序,并通過以下三種方式的任意一種來打開assembly:
1、在文本框中輸入assembly的完整名稱(Name,Version,Culture,PublicKeyToken),并按回車或點擊“Load By Name”按鈕;
2、按“Open File...”按鈕通過對話框選取assembly;
3、從文件瀏覽器把assembly拖放到該程序的窗口里。
同一時間只會有一個assembly顯示在窗口中。
其它功能應該不言而喻了,我就直接把readme文件的內容帖出來吧:
Name: ClassHierarchyViewer
Author: RednaxelaFX (Kris Mok,rednaxela0607@hotmail.com)
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
- 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 "") 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).[/quote]
許可證:
The MIT License
Copyright (c) 2008 RednaxelaFX (Kris Mok,rednaxela0607@hotmail.com)
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,只是用戶會辛苦一點了。預先放在文本框的下拉列表里的名稱應該能滿足一般使用需要了吧。
如果有什么意見和建議,歡迎提出。有需要請通過站內短信或者電子郵件聯系,謝謝 ^ ^
總結
以上是生活随笔為你收集整理的xml层级工具_.NET的类型层次查看工具,ClassHierarchyViewer,0.3.0.1的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: idea启动tomcat没有加载项目_震
- 下一篇: c# 低功耗蓝牙_c# - 如何使用C#