System.IDisposable interface realization for custom class in VS 2010 Ultimate UML Editor - visual-studio-2010

I have designed a class (in UML) which should implement the System.IDisposable interface. How do I do it so that when generating code it get's recognized properly and withou having to draw my own "System" package with some "IDisposable" interface in it?
Thanks for your help! Cheers, David

I discovered to do it as follows:
The clean (slightly overkill) variant:
Open Architecture -> Windows -> Architecture Explorer
Browse thru to find the class/type you need. In this example Saved DGQL Queries -> All Assembly References → mscorlib.dll → IDisposable
Draw IDisprosable onto white ground (The System package will be generated, the IDisposable will be generated inside and all other stuff which is needed from the framework is added to the model tree (but not drawn))
Use the smart connector to connect IDisposable element to your entity
The smart way (if you know in which namespace the desired element is placed and how it "looks" like):
Open Architecture -> Windows -> Architecture Explorer
Right click on "Modelling"
Select "Add -> Package".
Name it "System"
Add an interface underneath and name it "IDisposable"
Add an operation "Dispose()"
Now you have a dummy.
Say if you want to add an attribute to a class that should be of IDisposable, you can select the attribute's property "Type" (Properties window) to be Modelling::System::IDisposable.
In term of "Generating code" I found it clever to place all of my own modelled classes into a package so that it becomes separated from the packages like System. Then you can simply (instead of right clicking on white ground and selecting "Generate code" in order to generate code for all artefacts) right click on your package and select "Generate code" and it will generate code just for your package and not the System stuff (dummies). It becomes valid either way if you have the namespaces set nicely in your model like described in this post.

Related

Looking for constant values for DAO.Field.Type

I have need of using VBS in conjunction with the DAO.Field.Type methods and properties. Since I am using VBS I do not have access to the constants displayed on this page and I can't find a good resource that will tell me what they are.
Most specifically this MSDN article lists the constant names, but I don't know what their values are, and I would appreciate finding out what they are.
Field.Type Property (DAO)
Thanks,
Sean W.
Do you have Microsoft Office? Here's one way you can find them.
Open any Office product.
Hit ALT+F11 to open the VBA editor.
From the Tools menu, select References....
Find the reference entitled Microsoft DAO X.X Object Library, check it, and click OK.
Hit F2 to bring up Object Browser.
In the top drop-down, choose the DAO library.
In the 2nd drop-down, type your constant name (e.g., dbBigInt) and hit [Enter] to search.
Select the proper item from the search results.
Near the status bar is a pane that describes the selected item. It will show you the constant's value.

Can you search in current project and all referenced projects within solution?

I have some memory leaking. I am creating a big object graph and then derefencing it.
var a = MyDomainModel.Create();
a = null;
//GC.Collect();
Console.ReadLine();
There is no unmanaged stuff in there. JustTrace and ANTS (version 6) are both reporting that the objects are held in place by "System.Object[]".
I am assuming that there is a static field (list/dictionary/hashset) hidden somewhere that is using an ArrayList internally. I am planning to do a bit of text searching (probably some regex in there, too).
It is a pretty big solution with 30 projects. Is there any way I can do Visual Studio text search in "current project and all projects within the solution that are referenced directly/indirectly by current project"? The underlying physical file folders are not organized in a way that would meaningfully represent these dependencies.
if you're using Windows 7, create a library and add your project locations to the library. that should get them all organized in one place without actually moving or copying anything. then from Visual Studio do a text search in the library folder.
I assume issue has already been solved. If anyone else is experiencing something similar, JustTrace now handles this scenario through the Root Path view. Here are several paths to it.
Largest Memory Retainers: Find one of the objects being held in memory by object[]. Select the object, then click the Root Paths button in the ribbon.
By Type: select the type then click the Instances button in the ribbon. Select one of the instances, then click Root Paths.
Incoming References by Type: select the type, then click the Instances button in the ribbon. Select one of the instances, then click Root Paths.
The root paths graph shows the member name holding the instance and marks fields/properties that are static. See the image below for an example.

When I am looking at a method that is called on an interface, how do I go to the code the implements the method?

We have lot of code like:
IPerson
{
Eat();
}
Persion : IPerson
{
}
IPerson p;
p.Eat();
As most of our interfaces only have 1 or 2 classes that implement them, there should be a way for me to right click on the “p.Eat()” and be taken to the code the in person class. When there is more than one implementer, I wish to be shown a list to choose from.
There is a new feature in Visual Studio 2010, called View Call Hierarchy (Ctrl+K, Ctrl+T).
Right-click on a symbol in code (method name or properties are good) and select View Call Hierarchy, and you will get a new window with various options. On interface members, you will see an 'Implements [member]' option, dropping this down will show you all instances where the interface member has been implemented.
Similar options appear for virtual / abstract members, showing you where they are overridden or implemented.
As an extra bonus, this window also shows 'Calls To [member]' and 'Calls From [member]'.
Resharper is an extremely valuable refactoring tool which provides the behaviour you describe.
I currently right click on the method name in the interface file and select the option 'Go To Implementation'.
I'm assuming this is a Resharper feature and not just Visual Studio 2010 purely because you aren't aware of it. Try right-clicking and seeing if you have the option. If not - I highly recommend getting a refactoring tool with this kind of functionality.
Edit | Find and Replace | Find Symbol will find definitions and references.
Right click on p.Eat() and choose "Find all references". In the Find Symbol Results windows, you may find all of the implementations of that interface method. Double-clicking each item will show up the reference in code editor.

Finding Sub-Classes and Implementations

My favorite way to find subclasses of class 'X' or implementations of interface 'Y' has been to use Red Gate's Reflector. But I'd like to know if there is a (free) way to do the same thing from VS 2010. Does 2010 already have this ability? Is there a plugin I can add?
The object browser, the place I might expect this feature to be found, does not seem to have this capability. It can tell you about a parent type, but it does not tell you about derived types.
A more non-straight forward but works in all cases is to temporarily change the class/interface that you are modifying to abstract and add a abstract method.property and rebuild the solution :) all the build errors would point you towards the direct/indirect children.
While I've not found a RedGate Reflector level of functionality for this need, I have started using a partial solution. Using the regex search capability in VS, I enter the following:
\:.#<place base class or interface here>
Example:
\:.#MyBase
Any derivative interface or class made from "MyBase," defined in the solution, will be returned.
I've just found free Inheritance Margin Extension.
With this I can view inheritance info right in the code editor and also navigate to base/overridden items (with right mouse click on the inheritance glyph).

Associations in Visual Studio 2008 class diagrams

When I generate class diagram in Visual Studio 2008 using View Class Diagram I always get a bunch of class boxes without methods. The only lines in the diagram are inheritance.
Is it possible, and if so how do I get associations (aggregation and composition might not be possible, but at least an association line indicating they are some how connection. Preferably with an arrow) visualized?
And is it possible to change it so that methods are shown after generating a diagram by default?
To show a property as an association just right click on a property in the diagram editor (not the Class Details panel) and choose either "Show as Association" or "Show as Collection Association". Obviously you will need to make the property visible in the diagram editor first. Typically I only show public properties.
And I don't believe there is a way to always show associations.

Resources