View Class Diagram Missing - c#

In Visual Studio 2015, the view option is missing class diagram as represented in the following image.
I have tried Enterprise Architect but that software is unable to detect C# 6 syntax. For example whenever there's public static String readonlyText => "123";, it skips the class.
What's the solution to generate class diagram based on ASP.Net Core code?

In Class View (Ctrl+Shift+C) Right click a namespace or class, and you should see the 'View Class Diagram' option. Useless tho, nothing happens when you click it.

This was probably not working in previous versions, Now in 'Class View' (Ctrl-Shift-C), right click a namespace or class, then click 'View Class Diagram' which creates a new class diagram in the root folder of your project.
Contextual menu in the 'Class View pane'
This works at least in the last edition of VS community edition:
Version in which the feature is working
The new class diagram file, starts empty though.

Related

How to use class from other project in visual studio C#

I have a Xamarin.Forms project and a C# console app project. I want to use one class from the console app in my Xamarin.Forms project.
I added the console app project to the solutions explorer of the Xamarin.Forms project.
Unfortunately, I can't figure out how to use the class from the console app in one of the Xamarin files.
I always get the error message:
The name 'MyClass' does not exist in the current context.
I tried to press alt+enter to show potential fixes but it does not offer me the option of importing/using the class.
I also wrote manual using directives in various forms but it still does not seem to make the class accessible.
The only way I was able to use the class was by adding the class directly to the Xamarin project by adding it with add->existing item. The problem with this is that it imports a copy of the class. Since I'm still working on the class within the other project the added class is fast outdated and I have to manually copy its contents over.
How can I use a class from an external project without making a copy of the file?
Instead of access class from console app(its exe) try creating new reusable library add that class and use in both projects also you can write wrapper class in both projects
Try to add a reference to the second project in your first project. To do this, right-click on your project, select Add Reference then select the project in your solution. Once your main project references the second project, then you can access its public types.

New class does not show in reference object browser

I added a new class to my Class Library Domain called SongPlayDaily.cs but for some reason it does not display in my reference object browser. See image and correlated numbers:
Observe that the new class exists in my Domain class library
See that I reference this Class Library in my Unearth project.
Upon double clicking the Domain in the references dropdown below Unearth the object browser opens and you can see that SongPlayDaily is not referenced here
This is the console error I experience.
Right clicking on the SongPlayDaily.cs in the Class Library I can confirm that the Build Action: Compile
What other things can I check to see why this new class may not be showing up?
Thanks!
So dumb, I switched my Domain Class Library framework from 4.6.1 to 4.0 back to 4.6.1, rebuilt my solution and it is now referenced....

How to create a class diagram for class library in VS2017?

I have a C# class library project in Visual Studio 2017 that I would like to create a class diagram for. The Class Designer is installed. Looking at the context menu for the namespace or any of the classes in the Class View I see the "View Class Diagram" option and also the button for same on the view's menu bar.
However, when I click either the button or the context menu item nothing seems to happen! Flipping back to the Solution Explorer view I can see a ClassDiagram1.cd file has been added to the project. Attempting to open this file though results in an error message:
Class diagrams are not supported by this project type.
Add the class diagram file to a C#, VB or C++ project and try opening it again.
I'd be happy enough to be able to add a diagram myself rather than have it generated if generation is not possible. But I also cannot add a blank class diagram file to the project as that file type does not appear in the file types list in the Add New Item form.
How can I create a class diagram for classes contained in a class library? Or maybe class diagrams are not available for libraries? If the latter is the case is there any info from Microsoft to A) confirm this and B) explain why classes in a program can be diagrammed but not classes in a library. (I did already spend some time googling this matter but did not find anything specific to class libraries)
Since this is the Google #1 link for problems with the Class Designer and surprisingly nobody cared to answer so far (especially the part "Class diagrams are not supported by this project type"), let me chime in:
Close VS and open the file at
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\Microsoft\VisualStudio\Managed\Microsoft.CSharp.DesignTime.targets
Search for the line
<ProjectCapability Include="CSharp;Managed"/>
Write "ClassDesigner" as a capability like this:
<ProjectCapability Include="CSharp;Managed;ClassDesigner"/>
Save the file and re-open VS. Your class diagram should work now. You should even be able to add new ones (at least I can in my .NET Standard 2.0 Class Library project in VS2017.5.3).
Actually, the correct answer is to use the Visual Studio Installer as described here in the Microsoft Documentation. And it works!
how-to-add-class-diagrams-to-projects
As far as I can tell, Class Diagrams are not currently supported in .Net Standard and .Net Core projects (they share the same project type) in VS 2017. There are several threads about this on Developer Community, which didn't receive much of a response from Microsoft so far.
You might want to consider creating an issue about this on the dotnet/standard repo.

Type or namespace name 'xxx' could not be found in Umbraco

When I created a class, there is no existing namespace declaration and I need the namespace declaration to access the class from a view (cshtml).
Normally when you create a class, there should be a namespace declaration included right? But for me I don't see any.
I already tried to add a namespace declaration, but I still can't access it from another class.
I hope you could help me with this.
Screenshots: https://drive.google.com/open?id=0B5TGcf9mTeg2V2ZDaldWelp6WXc
ScreenShot
make sure your namespace name is correct .using PRL(Capitalized) .Models .And the good practice is add an empty web application project ,not a website.
Just as what Nico Said (https://stackoverflow.com/users/5685258/nico)
Follow this instructions and this will be resolved:
https://our.umbraco.org/documentation/Getting-Started/Setup/Install/install-umbraco-with-nuget
Although I started all over again.
~I created a new project from Visual Studio 2017 using ASP.NET Web Application
~Selected an empty file
~ Right click on the project
~ Click Manage NuGet Packages and installed Umbraco CMS
~ Run it from VS and install the umbraco platform using the browser
~ As soon as I create a class, a namespace declaration will also be included.
Thanks!
Your model belongs to namespace PRL.Models but you try using Prl.Models - namespaces are case-sensitive. Try using PRL.Models
Edit: and for the class without namespace-declaration: you should always have a class in a namespace. Declare one.

Cant add class to Visual Studio UML Architecture Model

I cant add a class to a Visual Studio UML Architecture Model.
When I drag/drop a class from the Solution Explorer onto the UML model the mouse cursor changes to a "cant drop" icon.
Also in Architecture Explorer its not showing any types or namespaces:
The class definitely has a namespace and types, its a been generated from a wsdl file. I've tried other classes like the ColourObject.cs (full of types) and encounter the same problem.
Video's I've seen show people just dragging classes onto the model and abra-cad-abra.
What am I missing?
Ok I see my mistake, I could built the project fine.
Though when I added vanilla class to the UML model (from the UMLModel Explorer) and generated, then a Lib Project was created. I added my wsdl Proxy Class file to the Lib Project and tried to built and it failed.
It failed due to some missing references like System.Web and System.Web.Services after adding them the project built fine and then Architecture Explorer showed me all the Types and I was able drag/drop them onto the Model.

Categories

Resources