Performance Issue with Visual Source Safe and Perforce

This is the fix for the issue reported in these threads:

Issue Cause

The vsProject.Refresh method is expensive to execute for solutions using integrated source control with a SCCAPI provider (e.g. VSS and Perforce). The IsEnabledFor method can be called many times by GAX, leading to what appears to be an endless loop. You can remove the call to vsProject.Refresh without adverse affects.

Fix

  • 1. Install the factory source code.
  • 2. Open the guidance package solution, GuidancePackage.sln
  • 3. In the SmartClientFactoryPackage project go to the References folder.
  • 4. Open the files ViewTemplateReferenceCS.cs and ViewTemplateReferenceVB.cs.
  • 5. In the ContainsReference method of each file, remove the following line:
    • vsProject.Refresh();
  • 6. Build the solution
  • 7. Register the patched guidance package or install it as follows:
    • a. Click on Tools
    • b. Click on Guidance Package Manager
    • c. Click on Enable / Disable Packages
    • d. Select "Guidance Package Development"
    • e. Right-Click on SmartClientFactoryPackage and select "Register Guidance package" (provided by step 7d)
  • 8. Open your SCSF Solution
  • 9. Click on Tools
  • 10. Guidance Package Manager
  • 11. Click on Enable / Disable Packages
  • 12. Select new "Custom Smart client Factory Guidance package"
  • 13. Deselect the Smart Client Development - April 2008

Background

The classes in the References folder contain logic (in the method named IsEnabledFor) that determines if an unbound recipe is applicable for a given target. For example, you can't add an event subscription/publication to a project, but you can add one to a class. The class AddEventSubscriptionRecipeReference returns true if the target is a C# class. This means that the guidance package will not show recipes in the context menu (or it will gray them out in the Guidance Navigator) if they don't apply to the current context. That's why the guidance package context menu changes depending upon what you have selected in Solution Explorer.

Enabling a Guidance Package

GAT 1.1 introduced the Guidance Navigator. The Guidance Navigator is launched whenever you enable a guidance package. When launched, the Navigator creates a list of all recipes that are valid for at least one element of the solution. To do this, it calls the IsEnabledFor method for each recipe in the package. As soon as it finds a target element for which the recipe is valid, it moves on to the next recipe. If a recipe is not valid for any item in the solution, then the IsEnabledFor method of that recipe will be called for every target element.

Running a recipe from Guidance Navigator

In the Available Guidance tab of the Guidance Navigator, you can see all the recipes for each enabled guidance packages. If you click on a recipe and choose Run this recipe, Guidance Navigator launches a dialog that displays all the potential target elements in the solution, with the ones the ones that are not valid for that recipe grayed-out. To create this list, GAT calls the IsEnabledFor method for every target in the solution. The more elements you have in your solution, the longer this takes.

Running a recipe from the context menu

The IsEnabledFor method is called only once, for the current target in Solution Explorer.

Integrated Source Control

In the case of the View (with presenter) recipe, the IsEnabledFor method checks to make sure the target is a project, and that the project has existing references to CAB, ObjectBuilder, and the Infrastructure.Interface project. Before it checks, it calls vsProject.Refresh. This call is expensive when a solution is enabled with a SCCAPI provider (e.g. VSS and Perforce). Additionally, this call is not necessary - the project references can be sufficiently queried without refereshing the project. Therefore the recommendation is to remove this line.

Note: This content was taken from the contributions made by the users timomsft and BillKrat in the threads the issue was reported.

Last edited May 30, 2008 at 2:51 PM by jonathan, version 3

Comments

No comments yet.