Reverse Engineering a C# Solution - visual-studio-2010

I know Visual Studio 2010 Ultimate has some abilities, and I would normally do this by instinct, but I am on a very tight schedule. I also have Visio 2010 installed and integrated into VS, but its reverse engineer function doesn't seem to do much, and has to be run on a per project basis, and a hindrance here is the solution structure, with several solution folders each holding a multitude of projects.
I would like some advice on how to go about reverse engineering a C# solution into dependency diagrams, sequence diagrams and class diagrams.

If you use Visual Studio, the 2010 Ultimate edition supports 5 commonly-used UML diagrams (class , sequence , use case , activity , and component ). You can generate sequence diagrams and layer diagrams from code . If you also install the Visualization & Modeling Feature Pack with VS 2010 Ultimate, you can create UML class diagrams from code and generate code from UML class diagrams .
You can also explore existing code by using Architecture Explorer and visualize relationships in code by generating dependency graphs , which you can then also use to create layer diagrams.
As alternative, you can use Altova Usemodel or Sparx System's Enterprise Architect

since C# is using JIT compilation, an intermediate code is generated in compilation and there is a way to see that intermediate code.
reverse engineering in C#

This tip is from : http://www.devx.com/tips/Tip/30046
I am just pasting here. You should give credit to the original author if he is on StacOverflow
Open a window in VS.NET. Go to Project—>Visio UML—>Reverse Engineer. This automatically shows you the class diagrams with perfect relationships.
Note: This tip will work with VS.NET Version 1.0.0 and higher.

Related

Visual Studio project generation

Is there any way to auto generate visual studio projects with a, lets say, some kind of UML tool, so I can design project dependencies upfront and it will output the solution and its projects.
Bonus: I can do classical UML design (classes, interfaces, etc.) aswell
I'd appreciate any hint for any tool.
You could try GenMyModel. It lets you doing your model, writing and executing your own template generators directly from your browser.

Is there a tool that can draw architecture diagram of projects from Visual Studio 2010 solution?

Is there a tool that can draw architecture diagram of projects from Visual Studio 2010 solution?
I want a diagram that shows how each project of the solution interacts with eachother grouped by the folder of the solution? Is there a tool that can do it?
If you have Visual Studio 2010 Ultimate, you can use dependency graphs or layer diagrams to help you accomplish this. If you have this version and want to do this for C/C++ code, you'll also need the Visualization & Modeling Feature Pack, which you can get as an MSDN subscriber.
Dependency Graphs
On the Architecture menu, choose Generate Dependency Graph -> By
Assembly. This will give you a dependency graph of the entire solution organized by project. Though their contents are not organized by folders automatically, they are organized by namespaces. You can then organize the contents manually to represent folders.
-or-
Create a blank dependency graph. In Architecture Explorer, go to Solution View to browse the solution, and then drag projects and their items to the dependency graph.
For more information, see How to: Generate Dependency Graphs for .NET Code and How to: Generate Dependency Graphs for C and C++ Code
Layer Diagrams
Create a blank layer diagram, and then drag from Architecture Explorer to create the project layers.
To represent folders, add layers inside the project layers and then drag folders from Architecture Explorer to map them to those nested layers.
To see the dependencies, right-click the diagram, and then choose Generate Dependencies.
For more information, see How to: Create Layer Diagrams from Artifacts
The NDepend tool for .NET developers comes with both a dependency graph and a dependency matrix and integrates in VS. You can download and use the free trial edition of NDepend for a while.
In the NDepend start page you'll see a Analyze VS solutions and VS projects that will let you analyze readily your code.
More on NDepend Dependency Graph
More on NDepend Dependency Matrix:
Disclaimer: I am part of the tool team

Creating custom designer over XML file as VSIX 2010 package

We have a set of VS 2008 packages which leverages custom Project/Item templates, designers around XML files for our in house product development using VS. We are planning to move to VS 2010 and looking for migrating our VS 2008 packages to 2010. I see that there has been a rewrite of VS from ground up using WPF/MEF, but still could not figure out how we can leverage it for our packages. I am seeing some guidelines, samples and community material on how we should be extending the VS 2010 WPF based text editor, but could not find any reference implementations on how one should implement a custom designer on top of XML using the WPF/MEF APIs of VS SDK.
Only sample I have come across regards to any custom designer implementation so far was Example.XmlWpfDesigner - http://code.msdn.microsoft.com/Designer-View-Over-XML-20a81f17 which does not talk anything about WPF/MEF way of doing custom designers.
Has anybody come across any reference implementations along these lines? Any help regarding this would be much appreciated.
Thanks,
Siva
The sample you linked to is the right one to be looking at for a designer over an XML file. It is a WPF-design surface that edits VSTemplate XML files.
The only part of the VS API's that moved to MEF in VS 2010 was the core text editor. While you are welcome to use MEF for the implementation details of your designer, you'll still need to talk to the VS COM API's to do things like buffer management, interfacing with Source Control interfaces, etc...

Visual Studio 2010 Ultimate Layer Diagram - Open Source Equivalent?

I really like the feature of having a dependency diagram and preventing certain assemblies from having references to other assemblies - ensuring other developers adhere to good programming practices.
Is there an open source equivolent of Visual Studio 2010 Ultimates Dependency Diagram? I checked out NDepend, however, this is for business use, so I cannot use the free version.
Edit: Perhaps I'm referring to the layer diagram? Whatever diagram that can be used to ensure certain assemblies do not have references to other assemblies
I.E.
Business assembly
Data assembly
Data.EntityFramework assembly
Data.EntityFramework implements interfaces from the Data assembly. The Business assembly only has a reference to the Data assembly, and has an instance from Data.EntityFramework via Unity or another IoC container.
I only have Visual Studio 2010 Professional :(
I haven't found anything that is a full equivalent of the layer diagrams in VS 2010.
ConQAT will let you visualize and analyze architectural conformance, but won't enforce rules at compile time like layer diagrams can. Also, ConQAT doesn't seem to work with VS 2010 solutions, which is a shame because it looks like it could be a very useful tool. It does support VS 2008 solutions.
Gendarme is the closest match to what you want, I think. This is a rule-based tool from the Mono team, and can be integrated into the IDE or your build server. So it will help you identify and enforce good programming practices, but it's not going to generate any diagrams for you.
Out of the box, Gendarme comes with lots of rules for catching bad practices (long methods, lack of cohesion, deep inheritance trees, etc.). You would have to write your own custom rules to enforce your specific architectural constraints - in your case by iterating through the assemblies and checking references.
The rules are written in C# - here's an example.

Does visual studio 2010 unlimited modeling project do reverse engineering?

Does visual studio 2010 unlimited modeling project do reverse engineering? How about code generation from the UML models? I am playing around with it and it makes beautiful UML class diagram but I can't find any options to create code templates based on them.
Take a look at the following links:
http://social.msdn.microsoft.com/Forums/en-US/vsarch/thread/a1ee9393-8f9b-45f2-8277-6e49346a119a
Sneak peek at the first “Feature Pack” for VS2010 Visualization and Modeling Tools
Visualization and Modeling Feature Pack (MSDN Subscribers Only)
Generate code from UML class diagrams.
Create UML class diagrams from code. Import UML class, sequence, and use case elements from XMI 2.1 files.
Create and view links from work items to model elements.
Generate dependency graphs for ASP.NET Web, C, and C++ projects.
Create and validate layer diagrams for C and C++ code.
Write custom code to create, modify, and validate layer diagrams.
Does visual studio 2010 unlimited modeling project do reverse engineering?
VS2010 allows you to reverse engineer from code to UML diagrams. See MSDN
How about code generation?
Again refer to MSDN Visual Studio Code Generation

Resources