Class Designer Integration with Source-Code Control

Class Designer Integration with Source-Code Control

                        

Class Designer is built for use with solutions checked into source-code control systems. For those of you using Visual Studio Team System (VSTS), this will mean you are plugged into Team Foundation source control. If you are using a Standard or Professional SKU then you can install Visual Source-Safe which comes bundled with Visual Studio. In this article I will be showing you screenshots from the excellent integration Class Designer has with Visual Studio Team Foundation (VSTF) source control. Let’s discuss the main scenarios.

Check in

Check in scenarios are simple. If you have a solution which contains a Class Designer you can check it in along with the rest of your solution. Here’s a screenshot:

Once you check in the solution you will see an icon next to the Class Diagram file which indicates it is checked in.

Check out

Check out scenarios are more interesting. By default most SCC providers have ‘Check out automatically’ turned on. In this case any changes you make will automatically check out the affected files. If you want to change these settings look in the Visual Studio menus under Tools | Options | Source Control | Environment. I like to see what files I’m editing so I have it set to ‘Prompt for check out’ as shown here:

When you make a change to the diagram you will see a ‘Check Out for Edit’ dialog as each file is modified.

There are three types of changes one can make to the diagram which will cause SCC actions to occur. The first are presentation edits which only check out the CD file. If you have a diagram and would like to make some changes to the appearance of the shapes, lines or members then these changes will only require you to check out the diagram.

The second types of changes are actions on the diagram which check out code-file(s). Changes such as creating an inheritance or association, implementing an interface, deleting a type, or modifying members will cause the code-file to be checked out. You will be prompted to check out the diagram as well if your change affects the presentation of these elements on the diagram.

The third types of changes are actions on the diagram which cause the check out of the project. Creating a new type by dragging it from the Class Designer toolbox can create a new file for this type. This will prompt you to check out the project file and then the diagram file.

What happens if I cancel a check out?

You might make a change to the diagram which attempts to change a file you do not have access to (in the case of exclusive check out), or you can simply decide not to check out a file. If you have ‘Prompt for check out’ turned on than you can click ‘Cancel’ when the ‘Check Out for Edit’ dialog pops-up. In cases where you cancel checking out the first file you won’t need to worry, the change will be aborted immediately. Things are more complicated if you accept the checkout of a code-file or project and then cancel the checkout of the diagram. In this case the diagram can not be updated and will close. The following dialog will appear to let you know what happened. Don’t worry, the diagram will remain intact, just re-open it.

What about merge conflicts?

Class Designer is designed to be a team-working tool. Developers make conflicting changes to their code. Since the diagram is just a representation of the code, it too must be ready to handle these conflicts.

CD files are represented by XML. The format of these files is intentionally easy to read and easy to merge. We also take advantage of the XML merge tool provided with Visual Studio Team Foundation. When a merge conflict is detected the source-code control system will attempt to auto-merge the conflicts. If this can not be done automatically then the user is given the option to manually merge the files. Here is what the XML merge tool looks like:

In this simple example one user has hidden a member and the other has expanded a compartment in the same class. This has resulted in a conflict. As you can see the user has the option to accept one, both or neither changes. Once the user has resolved all conflicts then the file is saved and can be checked in.

Erik Cutts
Visual Studio Class Designer Team

Comments

  • Anonymous
    May 08, 2005
    Visual Studio Team System

    If you’re installing Beta 2 using Virtual PC, you should learn to appreciate...
  • Anonymous
    July 04, 2005
    The comment has been removed
  • Anonymous
    June 15, 2009
    PingBack from http://debtsolutionsnow.info/story.php?id=2185