How to get a nice class diagram for built-in .net classes? - visual-studio

To get an overview for the CodeDom classes in .Net I tried to create a class diagramm using Visual Studio 2010 built-in class designer, but I did not find the way how I could feed the .Net built-in classes and types into it, the only I can get is to add my own classes from Class View window.
I also tried it with UML diagramms in VS2010, and I couldn't import the classes. I was looking for a similar option in MS Visio and though it does provide support for class diagramm I could not generate something there.
I found the AutoDiagrammer project on CodeProject webpage and tried to use it as a Reflector Add-In, but with no succcess either. I get only the message "Waiting for assembly" in the top of the add-in window and nothing happends.

I was able to generate a class diagram for the entire namespace by:
creating a new blank class diagram
opening View->Object Explorer
entering "codedom" and search
drag and droping the System.CodeDom namespace to the blank diagram
I hope this is what you meant.

Related

How do I create a VS Extension without adding UI?

I'm writing a Visual Studio 2015 extension that adds messages to the Error List window. It needs no new UI. My code runs correctly if used in a tool window or menu item, but adding UI just for this feels like a sloppy workaround to obtain an IServiceProvider.
How can my code run and obtain an IServiceProvider without adding any UI elements?
Your Package class is an IServiceProvider; you can just call its GetService method.
If you're in a MEF class, you can instead simply import SVsServiceProvider.
For more information, see my blog.

VS 2010 Class Designer not rendering relationships correctly

I'm using the Visual Studio 2010 Class Diagram designer and it does a nice job of showing relationships between a parent class and the classes that make up the properties of the parent. In the below sample, we can see that the IFoo interface has a property named Bar which is of type IBar.
However, if I add existing classes, interfaces, etc... that were created outside the designer it does not show the relationships. See sample below...
The code is all the same; and correct; but the representation on the design surface is different. For existing classes, is there a way to instruct the designer to make the correct links without having to manually recreate the items using the designer?
I wasn't able to find a way to do it for the whole diagram, but I did find a Property level context-menu item (e.g. Show as Association) which fixes it one Property at a time.

Can I create a Visual Studio 2010 Add-In that Uses a WPF Display?

We're working on creating a specialized graphical editor for our enterprise applications. We've looked at and rejected DSLs. Ideally I'd like to have the main interface of the editor be docked like the code windows and use WPF for drawing. Can anyone point me to some documentation to get me on the right path?
Thanks.
Colin.
UPDATE: It's beginning to look like "no." From http://msdn.microsoft.com/en-us/library/bb166228.aspx: "Document windows are created by implementing an editor. The IVsEditorFactory interface creates document windows as part of instantiating an editor. For more information, see Accessing the Editor By Using Legacy Interfaces."
Following the link to http://msdn.microsoft.com/en-us/library/dd885127.aspx gives this this bit of advice: "You can access the Visual Studio editor from legacy interfaces. The Visual Studio SDK includes adapters known as shims, which enable these interfaces to interact with the new editor. Nevertheless, we recommend that you update your legacy code to use the new editor API. Your code will perform better and you can use new technologies such as the Windows Presentation Foundation (WPF) and the Managed Extensibility Framework (MEF)."
So, to sum up: if you want to implement an editor you have to use the legacy interfaces, but you shouldn't use the legacy interfaces because then you can't use WPF or MEF.
Seriously Microsoft, WTF?
UPDATE 2: Now that I have the proper names ("custom editor"), I was able to find the following topic: http://social.msdn.microsoft.com/Forums/en-US/vsxprerelease/thread/9e605d0f-1296-47c9-a534-e54905251ebe
I still don't see why they couldn't have included that somewhere prominent in the MSDN docs. You know, like somewhere near where they tell you that you can't use WPF if you're using the legacy interfaces.
Creating a custom editor doesn't have to be terribly painful. Yes, a custom editor will require implementing a few interfaces, but you can still use WPF to actually create the control that is hosted in the VS document frame.
DiveDeeper's blog has some great resources for learning about creating a custom editor.
Creating a simple custom editor - the basics
Creating a simple custom editor - the first 10 meters
Creating a simple custom editor - under pressure
I'd recommend using a library like VSXtra to do a lot of the work for you. It will provide you with a nice base implementation of an editor factory, editor pane, package, etc. Istvan Novak writes about building a custom editor with his VSXtra library in this blog post.

Can not generate a class diagram from a project referencing a web service in Visual Studio 2008

I have a question concerning the class generation in Visual Studio 2008.
I use a web service which is added using Add Web Reference. It works great and all the classes seem to have been generated successfully. When I try to generate a class diagram using View Class Diagram for the project which uses the web service, I get:
Some of the selected type(s) cannot
be added to the class diagram. Check
the code for errors and ensure that
all required assemblies are
referenced
I have followed both of these suggestions, and the project has no errors or warnings. I get no error for other projects in the same solution which do not use any web service.
The web service http://foo.bar.com/wsdl/ in a bit anonymized form (though it still has the same structure, I just changed some names) can be found here if it is important for the answer: http://pastebin.com/rd7W9BA6
Append
As an example if I double left-click on class Age inside the WebService folder (in the tree) in Class View I get to see the public partial class Age in the file Reference.cs.
I can see the above Age class in Object browser as well.
It really seems like I have all the necessary information to build a class diagram. But when I right click on said class and choose View Class Diagram I get the error message quoted above.
If I right click any other class, which is not in the WebService folder, and choose View Class Diagram I get to see the diagram for the clicked class. So it must have something to do with it being generated from a WSDL-file.
Right click the project and choose Add Existing Item. Add the Reference.cs file to the project.
Now View Class Diagram for the entire project works as the Reference.cs-file may be accessed by the class diagram generator.
The downside is that you have a generated file as part of your project. And that it won't stay up to date as it is being copied when added. Thus this solution is really only to be used when in need of a class diagram, and then the added (copied) Reference.cs should be deleted as you will step in to conflicts if you don't. When you delete it, those classes are marked as unavailable in the class diagram. So export it as a picture first.

VS2010 F# Smart Tag to add open import declarations

EDITS corrected terminology from Intellisense to Smart Tag
OK, I readily admit that Intellisense/Smart Tags have spoiled me. I've grown accustomed C# in Visual Studio notifying you to add using import declarations when typing in a class name for a namespace that has not yet been imported. You get the nice little colored underscore which you can hover over or do or do ctrl-dot to get the context menu for adding the import or fully qualifying the namespace.
I've just started playing with F# in VS2010, and I'm not getting that helpful reminder when I reference a system library class. I type WebRequest and the Smart Tag doesn't kick in to tell me I need to add an open System.Net declaration.
Am I missing something? Is there a VS extension available that beefs up F# Smart Tagging?
You're confusing two features here. Intellisense is the feature that helps complete statements and expressions as you type. The squiggle that appears over WebRequest to tell you that you need to add a using / open for System.Net is a smart tag.
F# unfortunately does not implement this particular smart tag in Visual Studio 2010. I don't know of any extension which provides this behavior either.

Resources