How to generate class diagram from project in Visual Studio 2013? - visual-studio

In Visual Studio 2010 I can generate class diagram from my project with 2 clicks. But now in Visual Studio 2013 I don't see the option "View Class Diagram" in project menu. Where did this item disappear? How can I generate class diagram from project now?

Right click on the project in solution explorer or class view window --> "View" --> "View Class Diagram"

For creating real UML class diagrams:
In Visual Studio 2013 Ultimate you can do this without any external tools.
In the menu, click on Architecture, New Diagram
Select UML Class Diagram
This will ask you to create a new Modeling Project if you don't have one already.
You will have a empty UMLClassDiagram.classdiagram.
Again, go to Architecture, Windows, Architecture Explorer.
A window will pop up with your namespaces, Choose Class View.
Then a list of sub-namespaces will appear, if any. Choose one, select the classes and drag them to the empty UMLClassDiagram1.classdiagram window.
Reference: Create UML Class Diagrams from Code

For Visual Studio 2019 and Visual Studio 2017 Users
For People who are missing this old feature in VS2019 (or maybe VS2017) from the old versions of Visual Studio
This feature still available, but it is NOT available by default, you have to install it separately.
Open VS 2019 go to Tools -> Get Tools and Features
Select the Individual components tab and search for Class Designer
Select this Component and Install it, After finish installing this component (you may need to restart visual studio)
Right-click on the project and select Add -> Add New Item
Search for 'class' word and NOW you can see Class Diagram component
see this answer also to see an image associated
https://stackoverflow.com/a/66289543/4390133
(whish that the moderator realized this is the same question and instead of deleting my answer, he could mark one of the questions as duplicated to the other)
Update to create a class-diagram for the whole project
Here is how to generate a diagram for the whole project (after applying the previous steps)
Add class diagram to the project
if the option Preview Selected Items is enabled in the solution explorer, disabled it temporarily, you can re-enable it later
open the class diagram that you created in step 2 (by double-clicking on it)
drag-and-drop the project from the solution explorer to the class diagram

Related

Add ATL Simple Object in Visual Studio 2017

I am working with an old ATL/COM project in Visual Studio 2017.
In previous versions of Visual Studio you could select "Add Class" and then select the option "Add simple ATL object" to add a COM class to the project. This option appears to be completely missing in Visual Studio 2017.
Has the option been moved?
Have I missed an installation option?
Does Visual Studio fail to recognize my project as an ATL project? (It was created with a much older version.)
Or is this the end of the road for ATL?
I'm not sure whether this an answer, but it is too much for a comment and more than just an edit to the question.
I have tested on two systems, with
Visual Studio Community 2017, Version 15.1
Visual Studio Professional 2017, Version 15.3.2
and I believe that the functionality has changed between these two versions. I think it is unlikely to be a difference between the Community and Professional versions.
In both cases I created a new ATL project and tried three ways to add a class:
Add class... from the context menu in the Class View
Add class... from the context menu in the Solution Explorer
Add New Item... from the context menu in the Solution Explorer
With version 15.1, Add Class opens the following dialog, from which I can add an ATL Simple Object.
With version 15.3.2, Add Class opens the following dialog, without any option for an ATL Simple Object.
However, with version 15.3.2, Add New Item opens the following dialog, with a new option to create an ATL Simple Object, which was previously not available in this dialog.
So, it seems that the functionality has been moved. Curiously, it is no longer available in the Class View (which in my opinion is a mistake).
This problem is caused by changes in the project template and code wizard in version 15.3 of Visual Studio 2017.
The operation procedure has changed between version 15.2 or earlier and version 15.3 or later.
The blog article that explained this change is as follows.
Changes to Project Templates and Code Wizards in 15.3
Although it is described as an item in the release notes, there are few people who are watching, and details on how the actual is going on is unknown.
Visual Studio 2017 version 15.3 Release Notes
C++ Language Services
Project and Code Wizard
•We have rewritten several project and code wizards in the signature dialogue style.
•Add Class launches the Add Class wizard directly. All of the other items that were previously here are available under "Add > New Item".
•Win32 projects are under the Windows Desktop category in the New Project dialog.
•The Windows Console and Desktop Application templates now create the projects without displaying a wizard. There's a new Windows Desktop Wizard under the same category that displays the same options as before.
My experience with Visual Studio 2015 version 15.9.2 is that I had to uncheck Security Development Lifecycle (SDL) checks when I added an ATL Project, otherwise when I add the Simple ATL Object I get a messagebox with the error "did not find a .idl file in project name of my project".

Refactor menu missing from Visual Studio 2015

I am having trouble finding the right-click context menu in Visual Studio 2015. I know that nothing is wrong with my project or the file I am working. I can find the right-click context refactor menu in Visual Studio 2013. However, in Visual Studio 2015 there isn't a refactor context menu in the right-click context menu.
Where did it go? How do I get it back?
Your suggestion cannot include menu Edit → Refactor.
I have tried to reset my Visual Studio settings back to default using menu Tools → Import and Export Settings and that didn't bring the menu back either.
Some of the refactoring tools have been relocated or are at least accessible in a different manner than they were previously.
Using the extract method refactor as an example, you can still use this function; it is just not done the same as before:
Right click
Quick actions
Click extract Method
I think they've changed it to feel more "ReSharper"ey. All of the functionality should still be there however.
Here's more information on refactoring in Visual Studio 2015 - hopefully this helps! Refactoring (C#)
You no longer need to access the refactoring using the mouse right click.
It is recommended that you use the keyboard shortcut keys within Visual Studio.
For all possible shortcut keys, see Default Keyboard Shortcuts in Visual Studio, Refactor.
You might need to build the project to get it to work.
See Code Editing ASP.NET Web Forms in Visual Studio 2013 | Microsoft Docs. (If it is missing then the point is that I am using an example provided by Microsoft.). In Refactoring and Renaming see To extract a method in a C# page. When I follow the instructions I cannot find the feature to extract the code to a method. When I tried the Edit menu it said I did not have valid code. Then I built the project and the feature to extract the code was available and worked.
If you change the name of the object you are refactoring, the light bulb then appears to the left which asks if you wish to change the name of the object (i.e. refactor) or generate a new constructor for the new named object.
Ctrl + . is the shortcut key for extracting a method in Visual Studio 2015 and onward.
Ctrl+M, R does not work anymore in new versions.

Generate a class diagram from Visual Studio

I would like to generate a class diagram with relations for my visual studio project. I opened my solution, added a new ModelingProject, added a new .classdiagram file but when i want to drag my folders or my classes onto the diagram layout I get the "not available" sign.
Does anyone has any idea on how to fix this ?
For Visual Studio 2017, 2019 and 2022
This feature is still available, but it is NOT installed by default, you have to install it separately.
From inside Visual Studio go to Tools -> Get Tools and Features
Select the Individual components tab and search for Class Designer
Check this Component and Install it
After finish installing this component
Right-click on the project and select Add -> Add New Item
A. Search for 'class' word and NOW you can see Class Diagram component
Very Important Update From the Comments below
Right-clicking on a folder and selecting Add New Item will NOT show the Class Diagram option.
You could right-click on a project.
Not every project type will support Class Diagram For example,
Right-clicking on Class Library project will DO show Class Diagram option in the Add New Item dialog.
But Right-clicking on ASP.NET project will NOT show Class Diagram option in the Add New Item dialog.
For generating the class diagram visual studio is providing the in-built option please use that, Go to class view window of your project, RightClick -> select View -> click on View Class Diagram. This will generate class diagram for your project.
Ref:
https://msdn.microsoft.com/en-us/library/ff657806.aspx
How to generate class diagram from project in Visual Studio 2013?
Thanks

How to view relationships between classes as a visual diagram?

when joining an existing project it can become confusing trying to figure out how all the classes and interfaces are connected to each other. Instead of going to individual classes and following its relationships, is there a way to visually see all the connections in a diagram? Is there anything that can be done in IntelliJ(11 | 12) or Visual Studio(2010 | 2012 - preferably express or pro)?
For example, something like a UML diagram showing class A inherits from class B which extends a certain interface, etc.
Similar functionality is in Eclipse where you can view a graphical representation of a bean config file. Also in Visual Studio you can view the DB relationships
I am not sure what version of Visual studio you are using but in VS 2012 pro (Update 2) you can right click on a project and click the "View Class Diagram" option. This will Create a diagram of all classes in the project.
http://msdn.microsoft.com/en-us/library/6x35cds6.aspx
Looks like capability goes as far back and 2010 and even 2008.
this is old but it's magical in VS2019. right click on project solution or any classes
you want to see dependencies and hit "Show Type Dependency Diagram".

Visual Studio - I want "Go To Definition" to open Object Browser, not "metadata"

In Visual Studio version 2002 and 2003 "Go To Definition" would find the selected type or member in the Object Browser. In 2005 onwards it opens a source window "generated from metadata" instead. How do I configure these newer versions to go to Object Browser? (In other words, I have the opposite problem to this one.)
Installing ReSharper makes this change, so I know it must be possible, but how do I do it without ReSharper?
As workaround you can create the following macro:
Sub GoToDefinitionUsingObjectBrowser()
DTE.ExecuteCommand("Edit.SelectCurrentWord")
DTE.ExecuteCommand("View.ObjectBrowser")
DTE.ExecuteCommand("View.ObjectBrowserSearch", DTE.ActiveDocument.Selection.Text)
End Sub
Then go to Tools/Options/Keyboard and assign hot key for this macro.
Tested in Visual Studio 2010.
I believe what re-sharper is doing is doing some hooks on that click event with the Visual Studio SDK I do not think there is any simple menu or location that can change that setting.
Instructions (pulled from CODE Magazine) edited down a bit to the part that pertainst to making the right click menus.
Creating a VSPackage
...The VS SDK installs a few more project
templates in Visual Studio, one of
them being the Visual Studio
Integration Package (Figure 1),
located under Other Project Types >
Extensibility on the New Project
dialog box.
After this standard dialog box, the
Visual Studio Integration Package
Wizard guides you through creating the
new package project:
Select a programming language. The wizard currently supports Visual
C++ and Visual C#. You can create or
pick a key file to sign the new
package.
Supply basic VSPackage information. The wizard prompts you
for details such as the company name,
VSPackage name, version, icon,
detailed information, and minimum
Visual Studio edition (such as
Professional or Enterprise) that the
package is designed to at this step.
This information goes into the Visual
Studio splash screen and About dialog
box and is also used to request a PLK
for the package (covered later).
Select VSPackage options. A package may add three types of
functionality: Menu Command, Tool
Window, and Custom Editor.
A menu command is a command added either to the menu
at the top of Visual Studio or
to a context menu (right-click).
When the wizard finishes its job, the
VS SDK adds core elements to the
solution to support the new package.
For instance, if you selected Tool
Window as part of the functionality
for the package, the project contains
a user control where you should place
the visual controls for the window.
The project also contains files for
.NET code to handle the functionality
that you will add to the package.
A CtcComponents folder contains
pseudo-C++ files (ctc files) where you
define things like menu, groups,
buttons, etc. Fortunately, Microsoft
is phasing out CTC files and replacing
them with a friendlier, XML-based VSCT
file format (which will ship in the
SDK for Visual Studio 2008).
The wizard creates a few other files
with .NET code required for the
plumbing of the package within Visual
Studio. Some of these files contain
classes that map the C++ constants to
.NET constants and other files contain
configuration information for the
package when it’s installed.
I know it has been a long time, but it appears, at least in newer versions of Visual Studio for the VB (Basic) language, to be an setting in the options.
Text Editor > Basic > Advanced
Under "Go to Definition".
I don't know why they don't have that for other languages...
Place the mouse cursor on the object you want to access on the object browser. Then, use the keyboard shortcut ctrl + alt + j, which will take you directly to the Object Browser window.

Resources