Since the interface is already on the diagram I would like to show inheritance reference explicitly. But I can't find how...
Visual Studio 2010/2012/2013, Class Diagram: how to show interface as base class, not as "lillypop"?
Asked
Active
Viewed 3,857 times
19

Kirk Kuykendall
- 822
- 1
- 12
- 26

Roman Pokrovskij
- 9,449
- 21
- 87
- 142
-
2I'm also interested in this, but judging from [this](http://social.msdn.microsoft.com/Forums/da-DK/vsclassdesigner/thread/0866a2d5-ad19-4e5c-a05b-0912eb7f7a13) and other threads it's impossible. Even in VS 2012 RC! – xZ6a33YaYEfmv Jun 20 '12 at 23:53
-
2Still doesn't work even in VS 2013! - "Adding support for showing lines between a class and the interface it implements is one of the highly requested feature that is on top of our list for future versions" - stated MS in 2005 :) - http://social.msdn.microsoft.com/Forums/en-US/0866a2d5-ad19-4e5c-a05b-0912eb7f7a13/showing-interface-implementation?forum=vsclassdesigner. – Piotr Perak Jul 08 '14 at 07:01
-
I like that you have been editing this question over the past 4 year adding new visual studio versions. What about 2015? Any luck there? – Chris Gonzales Mar 09 '16 at 23:09
1 Answers
7
There is a bug in VS 2005 up to 2012 that won't allow it to work. I have a work arround that might trick it into drawing the inheritance for interfaces. Say your interface is called IMyInterface. You have to replace it with an abstract class implementing that interface and use it instead of your interface. The code would make use of the conditional compilation and will look like this:
//to generate class diagram, add 'CLSDIAGRAM' to the conditional symbols on the Build tab, // or add '#define CLSDIAGRAM' at the top of this file #if CLSDIAGRAM #warning CLSDIAGRAM is defined and this build should be used only in the context of class diagram generation //rename your interface by adding _ public interface IMyInterface_ { int MyProperty { get; } void MyMethod(); } //this class will act as an interface in the class diagram ;) public abstract class IMyInterface : IMyInterface_ // tricks other code into using the class instead { //fake implementation public int MyProperty { get { throw new NotImplementedException(); } } public void MyMethod() { throw new NotImplementedException(); } } #else // this is the original interface public interface IMyInterface { int MyProperty { get; } void MyMethod(); } #endif
That's likely to show it as you wish. In your case IMyInterface will become IMedicine.

dmihailescu
- 1,625
- 17
- 15
-
Thank you for your answer. I of course use some additional code specially to make design diagrams more informative, but doing it together with conditional compilation is something new for me. – Roman Pokrovskij Mar 16 '13 at 18:37