How can I create a dependency graph in Visual Studio programmatically? - c#

In Visual Studio 2012 Ultimate (and also 2010 and 2013), one can generate a dependency graph using ARCHITECTURE -> For Solution. I would like to access this functionality programmatically, perhaps using the Visual Studio SDK.
How can this be done?
P.S.
I'm aware of GraphCmd.exe. However, I need to be able to generate graphs for C/C++/C# projects and make certain modifications and calculations on said graphs.
EDIT:
I would specifically like to access the graph data structure produced by the dependency graph tool in VS.

Related

Programmatically alter SSAS SSDT-BI (BIDS) project

I am writing a C# application that needs to alter a SSAS cube project. The alterations are mainly adding dimension members and measures, but could potentially go beyond that.
I can use Analysis Management Objects (AMO) to add new dimensions, measures etc. after the project has been deployed, but I am looking for a way to do this in a dwproj project on disc.
I could go through the project XML files and alter them directly, but this could be a likely source of errors, and it would be extremely sensitive to product updates from Microsoft.
Alternatively, I could deploy the project to an SSAS server temporarely, do the alteration via AMO, and then regenerate the project from the server. Is there a way to generate a dwproj from a SSAS server database programmatically? (Not via the SSDT-BI project template).
I would highly recommend you use AMO against the deployed database on the server then create the SSDT-BI project as needed. I don't know of a way to create the project files programmatically.
You could of course build a Visual Studio add-in to add dimensions and measures to the project inside Visual Studio like BIDS Helper does (example feature source code here) but that is overkill in my opinion and you will spend half of your time on Visual Studio add-in plumbing not your core business need.

How do I make a MVC project appear properly in Visual Studio?

How do I make a MVC project appear properly in Visual Studio? I understand the logic of this sort of structure. I have seen some blogs and explanations and even code segments explaining how a program can use MVC. But I want to know what is a good way to represent a Model-View-Controller program in the Visual Studio.
For example, in an ASP.NET program, the asp.net file is associated with a C# file. THey have the same name and, in the Solution Explorer window of the Visual Studio development environment, they are shown linked together where one is a tree branch of the other. Should the same sort of thing be done for a MVC solution? I can remember a few years ago, I worked on a MVVM project, and a developer who first put the solution file together actually had view and the view-model files arranged like this. In order to make this happen, he had to download some sort of patch that allowed him to edit the .sln (solution) file.
Is that the way to go for a Model-View-Controller program? Should each be its own workspace in the solution, or should the solution file be edited such that each Model-View-Controller coupling be handled as a tree structure file representation kind of like it is done for an ASP.NET solution?
Here is another question. What is a good template to use in Visual Studio to create an example of a Model-View-Controller program? I tried this route but when I clicked to "get new templates", it did not work:
http://i67.photobucket.com/albums/h292/Athono/Embedded/Capture_02_zps6vn4ri07.png
http://i67.photobucket.com/albums/h292/Athono/Embedded/Capture_zpscdczk1b4.png
From your screenshots, it looks like you're using an old version of Visual Studio (either 2008 or 2010, there isn't enough showing to be sure, but I see the default .NET framework listed as 3.5 up there).
The latest versions of the ASP.NET MVC framework requires .NET 4.5. Visual Studio 2010 doesn't support this, so the solution is to upgrade to a newer version of Visual Studio which includes support and project templates specifically for the latest versions of ASP.NET MVC.

Text file diff library (MS licensed)

Does anyone know if there a way to tap into visual studios diff libraries to extend the functionality of my projects?
I know that there are open source solutions for file diffing that I will consider if I cant find an adequate Microsoft implementation of it. Visual Studio comes with nice diff feature that it uses to compare source files.
I want to use code that is MS licensed. It seems that visual studio fulfills that requirement and has the feature I need.
It seems like this would be a useful extension library that maybe .NET should have in it, or already does?
Any ideas?
The Visual Studio diff window (new to Visual Studio 2012) uses the IDifferenceBufferFactoryService to create the IDifferenceBuffer it displays. From there it uses the ITextDifferencingSelectorService to get the appropriate ITextDifferencingService for each side. From there you'll have to do a good bit of reading to understand the API. :)
If you are creating a Visual Studio 2012 extension, the API you are interested is available in the Microsoft.VisualStudio.Text.Differencing namespace.

Project/solution class inheritance tree and dependency graph

Is there any way to get inheritance tree and/or class dependency graph for the whole Visual Studio project/solution from code? I know that it's possible to iterate through all classes and check keywords but I'm looking for easier way.
There is a Dependency graph feature in Visual Studio 2010. It is a new architecture tool available in VS2010.
The generated graph looks something like this,
Similar question
Dependency graph of Visual Studio projects
You can right click on your project and select View Class Diagram. Is that what looking for?
Visual Studio 2010 Ultimate can do this, using the Architecture functionality. In Professional/Express you can generate a class-diagram, but that's probably not what you want.
You can also used the tool NDepend to get a custom inheritance graph over a VS project, a VS solution or even multiple VS solutions. The graph would look like that:

Importing UML Diagrams into Visual Studio

In school I have learned that creating UML Diagrams/Models is great design practice before taking on a project. I have found it quite useful myself, in doing so I tackle projects much faster, and my overall design tends to be better.
I've noticed a basic redundancy issue when it comes to writing code. In Visio you can be very descriptive in your Models. Your basic outlines for your classes can include C# variable types/methods. They are detailed enough that Visio has you choose whether it is C# or VB.
My Question is, with this much detail, does there exist an importing technique between Visio and Visual Studio 2008? It seems like you could import that simple model as an outline for classes in Visual Studio, with everything declared except for the actual code within Methods. This would be very useful, especially when it comes to design steps for creating a program. My classes/variables/methods would already be declared for me. I would just have to go back and write the meat of the code.
I've done some searching on the subject and haven't turned up much, it seems like Microsoft would have included a feature to do this.
From the Visual Studio Team System 2008 and Visio FAQ:
Can I Migrate Visio UML Diagrams to
Visual Studio 2008? Visual Studio
2008 does not include support for
migrating UML diagrams directly. If
you have static structure UML
diagrams, you can use Visio for
Enterprise Architects to generate code
based on the model. Then you can open
the code in Visual Studio Team System
2008 Architecture edition and create
class diagrams from the generated
code. For more information, see
Working with Class Diagrams.
Other UML diagram types are not
supported for migrating model
information to Visual Studio 2008.
You might want to post in the VS 2010 arch forum to ask about support for this in a future release for Visual Studio 2010 Ultimate. It won't be in the RTM version, but the product team should provide you an update about this feature:
Visual Studio 2010 Architectural Discovery & Modeling Tools forum at http://social.msdn.microsoft.com/Forums/en-US/vsarch/threads

Categories