The Code Advisor for Visual Basic 6.0

The Code Advisor for Visual Basic 6.0 is an add-in that assists you in making a successful transition to Visual Basic .NET by ensuring that your Visual Basic 6.0 code complies with predetermined coding standards. These standards are based on best practices determined by Microsoft to produce robust and easy-to-maintain code. The Code Advisor enables you to select which set of standards to apply, and one set is focused on addressing upgrade-related problems. You can also add your own rules.

The Code Advisor scans your Visual Basic 6.0 projects, alerting you when issues are present that could prevent a smooth upgrade. Comments are inserted into your code with links to explanatory help topics. The vast majority of upgrade errors and warnings will be prevented if you run the Code Advisor first and follow its recommendations.

The FixIt Report

When you run the Code Advisor on a project, it also generates a FixIt report, which contains information about issues found by the Code Advisor. The FixIt report is placed in the project directory and is in an XML format that gets rendered as HTML using an included XSL style sheet. The report has three sections:

  • Issues: This section contains a list of all issues found, in order of severity. Architectural Issues can be complicated or time consuming; Minor Issues are relatively easy to fix in Visual Basic 6.0.

  • Components: This section of the report contains a list of all modules in the project (forms, classes, .BAS modules) with a count of issues for each module.

  • Rules: Contains a list of all rules that were used by the Code Advisor to check the code, with a count of issues for each rule.

When running the Code Advisor in upgrade mode, concentrate on the Architectural issues first. These are the issues that might require you to re-architect or make major changes to your project. For example, if your application uses DAO data binding, this will be reported as an Architectural upgrade issue. Fixing this either means re-implementing the data binding as ADO data binding in Visual Basic 6.0, re-implementing the data binding as ADO.NET data binding in Visual Basic .NET, or removing data binding altogether. This might represent a major change to the project. Architectural issues alert you to upgrade issues that can influence whether you continue with the upgrade.

Running the Code Advisor

The length of time it takes to scan a project using the Code Advisor depends on the size of the project and the number of issues encountered. If you have a large project, you can scan a single file at a time instead of the whole project. Follow these steps to run the Code Advisor on your Visual Basic 6.0 application, after installing the add-in:

1.
Open the project in Visual Basic 6.0.

2.
Choose File, Make <projectname> where projectname is the name of your project. Run the application to make sure there are no errors. Then stop the project.

3.
Select the Scope drop-down list on the Code Advisor toolbar, and choose Scope: Active Project to scan the entire project or Scope: Active File to scan only the file currently selected in the Project Explorer.

4.
Click the Add FixIts button to have the Code Advisor scan the file, add comments, and generate a FixIt report. A progress bar gives an indication of how long the scan will take, and the Cancel button enables you to abort processing if you become impatient.

5.
Click the View Fixit Report button to view the report in your browser.

6.
Click the Find Next FixIt button to go to the first FixIt comment in your code. Click the FixIt Help button to open the Help topic associated with that FixIt comment, and modify your code accordingly.

Remember to review Severity 1 (architectural) issues first, because they will prevent your project from upgrading.

Some comments suggest optional fixes or fixes that you might choose to ignore. To ignore a FixIt comment and keep from seeing the comment the next time you run the Code Advisor, you can type No in front of the FixIt remark:

' NoFIXIT: Use Option Explicit to avoid ...

You can also filter out a rule by clicking the Filter FixIt Rules button and deselecting the rule in the Filter FixIt dialog box. This can be a way of improving performance when scanning large projects—the help file suggests which rules are the most time consuming.

Click the Add FixIts button to re-scan the project. The Code Advisor will remove the comments from any fixed issues, and the new FixIt Report will reflect the lower issue count.

You can run the Code Advisor iteratively, reducing the issue count each time as you fix a set of problems.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.19.14.243