Tool like magic draw but for generate C# code - c#

It's there a plugin for visual studio or a specific program that allows to draw an UML model and generates the classes for C#?? and more, for example Creates a repository classes from classes entities of the entity framework generates

Visual Studio has had the Class Designer built in since Visual Studio 2005, though not all versions (the Express versions don't have it).

A former co-worker swore by http://www.sparxsystems.com.au/products/ea/index.html. The generated code definitely needed some tweaking though. Or something like http://staruml.sourceforge.net/en/index.php might have plugin's to generate needed c#...or perhaps t4.

Related

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:

How to move a class into another package?

In Visual Studio I have a lot of classes and UserControls that I have to move into another namespace. In eclipse I can do it with updating all the references automatically. In Visual Studio I couldn't find a similar function. How is this possbile in Visual Studio?
If you mean moving between assemblies:
For existing built code you should add:
[assembly:TypeForwardedTo(typeof(SomeNamespace.TheControl))]
to the original assembly (that no longer contains TheControl). Then the CLR will sort everything out for you for existing built code without having to update the references.
However, for building code you will still need to update the references; I don't think vanilla VS has that built in.
There's no such functionality provided in Visual Studio. Resharper has such feature.
Rename is supported in VS for reference update, but not file or class movements
I reccomend Resharper. It's really powerful refactoring tool fos VS. VS becomes even possible to use after installing it;) And it has tool for moving classes, methods, pulling up, pushing down, renaming and many more.

Possible to do UML Diagrams in Visual C# and then have code generated from it?

I'm using Visual Studio 2010 RC. Would it be possible that after doing my UML Diagrams, I could then generate classes with method stubs from it?
Thanks
Microsoft has stated that they intend to extend VS Architect edition to include code generation through the use of plugins but it is not available at this point.
http://social.msdn.microsoft.com/Forums/en-US/vsarch/thread/62eea855-af4a-4821-9843-3ef2377aebc2
Heres an article adding code generation to VS 2010 yourself:
http://www.olegsych.com/2010/01/uml-modeling-and-code-generation-in-visual-studio-2010/
Theres a plug in for VS here:
http://www.visual-paradigm.com/product/sde/vs/
Here are some standalone tools:
http://www.altova.com/umodel/uml-code-generation.html
http://www.tangiblearchitect.net/visual-studio/
Have you found the built-in class designer? Its pretty much UML compliant, and very easy to use.
Quick Start: Add a class, use View|Class View, richt-click the class and "Show in Diagram"
But no other diagram types.

Code stubbing with Visual Studio 2010 UML modeling

Currently I'm exploring my way through all the new features added to the Visual Studio 2010 Beta 1 IDE and I found a feature that will hopefully be of great help to me. The UML Modeling tool in the Architecture Edition. I wanted to create a new test project, nothing special. I started out with creating just a standard UML Logical Class Diagram. Then after I had finished I wanted to export my diagram to C# code with class stubs but I couldn't figure out how to do it. So naturally I consulted MSDN, but I couldn't find any reference to the top down approach of design and sort of gave up on it. Then I happened to be on the Channel 9 website and I watch the Top down architecture video and they alluded to the possibility of Visual Studio 2010 being able to accomplish this task.
So I guess my question is, can Visual Studio 2010 take a Logical Class Diagram and generate code stubs from it?
I'm currently using Visual Studio 2010 Beta 1 Team System on Windows 7 (if that helps any).
Thank you
Try the following topics from the RC docs:
How to: Generate Files from a UML Model
From a UML model, you can generate program code, schemas, documents, resources, and other
artifacts of any kind. One convenient method of generating text files from a UML model is to use
text templates. These let you embed program code inside the text that you want to generate.
Customizing Your Model with Profiles and Stereotypes
You can adapt the standard UML model elements, such as classes and components, to customize them
for specific purposes. You can apply a stereotype to a model element that can change the element's
list of properties. Stereotypes are defined within collections called profiles.
You might also check out this blog post by Tim Fischer helps: "How To: Generate Code from Team System UML Diagrams in VS 2010 Team System Beta 2 (Update 4)"
Here is the first code-snippet about how to generate code from UML-Diagrams using T4 Text-Templates.
(source: msdn.com)
Here's another blog post by Oleg Sych: UML Modeling and Code Generation in Visual Studio 2010
Assuming that reader is already familiar with UML, it focuses on custom UML profiles - an
extensibility mechanism that can be used to tailor UML models to a particular problem
domain. Readers will see an example of such a profile, which extends UML Class Diagrams for
database modeling. Finally, the article shows how code can be generated from UML models using
T4 text templates.
I've posted more links on my profile for more info.
You answer is Visualization and Modeling Feature Pack. This pack gives your what ever you need regarding code generation from Visual Studio 2010 modeling facilities and more.
According to MSFT, the answer is no. Or at least, it is not built in by default though may be delivered by extension. See here

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