开发者

Extract API from code library

Hi is there a technique available to easily extract all of the namespaces and methods etc from a code library compiled in C# for asp.net?

I basically want to be able t开发者_开发技巧o print all available namespaces, methods, etc so that I can decide how to refactor.


I don't know if there is a handy tool or not, but you can select the option to output the xml file when you compile (Project Properties->Output XML documentation file). It will list all the methods in XML that you can import and query. As a bonus, you will also have any xml comments that your developers have provided.


You can get a tree diagram of all classes in the object browser.
The object browser is opened with the shortcut Ctrl+W, J.


There is a commercial tool called NDepend that lets you query code in many ways, and certainly supports the specific examples you mentioned.

If this is a one-time task, perhaps the trial edition would be rich enough in functionality to meet your needs. Or maybe you'll realize how terrific it is and end up buying a copy (: (I don't have any relationship with NDepend, I just like the concepts behind that tool).


.NET Reflector is great for this. It was free until about a week ago. I'm sure you could still find the free version out there somewhere or use the free trial.

From the website:

.NET Reflector is an assembly browser for the Microsoft .NET platform that can be used to explore, analyze, decompile, and debug the contents of any .NET assembly. .NET Reflector combines class browsing, static analysis and high-level decompilation to help .NET developers understand how a library works or how it interacts with other parts of a .NET application. .NET Reflector will decompile to high level C#, VB, IL and some F# features.


Depending on which edition of Visual Studio you are using, you can create a class diagram that is then printable (I think it is available to all editions except Express). In your project, add a new file and select Class Diagram from the General category. Then drag your classes and interface files onto it's design surface.


And I'll throw out the way to do it yourself, via reflection. Again, a lot of this depends on your requirements.

// get assembly from Assembly.LoadFrom or other static overload

var types = assembly.GetTypes();

var typeNames = (from t in types
        select t.FullName);

var namespaces = (from n in types
        select n.Namespace).Distinct();


SandCastle Will build a nice help file for you of classes/methods as well as any comments the developer made using the xml commenting.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜