Reference Resolution Between Projects
The VBUC allows the conversion of multiple Visual Basic 6.0 projects, performing a separation between the pre-processing and migration stages in order to fix problems like the use of by-ref parameters, interfaces, renaming and typing among the different projects. The pre-processor environment solves the references among projects and simplifies the overall migration process because those references included in the solution will be calculated and there will be no error messages or warnings about missing members.
The multi-project migration employs a preliminary stage to solve all the possible dependencies between the solution members and to create a common scope among all those items. This situation generates a series of details that needs to be considered by the VBUC to achieve an effective migration of the entire set of projects as a whole unit and not as a series of independent migrations. The most critical details are listed below.
The reference resolution is a joint feature of the Visual Basic Upgrade Companion and the Upgrade Manager. The latter, employing features from the former, does all the resolutions. This process is done in the following way:
- Recognition of all the VB6 and ASP source projects
- Parsing of the *.vbp files and the source code to gather information about references among all the projects
- Automatic classification of all the references by:
- Explicit references in the *.vbp file or dynamically referenced by CreateObject().
- References to a third party library or to an internal project (included in the migration solution)
- List of warnings about references that might have not been properly resolved
- Allowing the user to manually modify the references information to complete any possible missing information
The VBUC needs to analyze all the projects one by one to identify possible modifications to their public declarations. These transformations are exposed during the conversion of the other projects, to take them into consideration at the moment of the symbol resolution. The main purpose of this pre-processing phase is to provide a coherent conversion of each project’s declarations and the references to those declarations from other projects.
The main characteristics at the pre-processing stage are the following:
Since the interface concept was not completely articulated in VB6, there are some extra calculations needed before this pattern can be used in .NET. In Visual Basic 6 interfaces cannot be declared, but a class can implement other classes. The VBUC applies a special transformation for those classes that are implemented. During the pre-processing stage, the tool analyzes all the source files in the entire batch of projects, recognizing all those classes that are implemented from any project in order to apply the special transformation upon these classes.
The VBUC includes some considerations to convert by-ref parameters to by-val when they are not being modified inside the function body (see section 0 Parameters). This transformation has a multi-project scope since methods referenced from other projects should change the way parameters are sent depending on whether the parameter declaration is by-val or by-ref.
During the preprocessing stage, the VBUC can detect some naming issues in methods and variables. For example, it’s possible to use a .NET reserved word as an identifier in VB6, or to define a method with the same name as the class it belongs to, which in .NET is known as the class constructor. If there are renamed public variables or renamed public methods in a single project the preprocessor stage makes sure that all the other projects’ references to the renamed element will be done using the new name to avoid compilation errors in the generated code.
The typing engine is invoked during the preprocessing stage to resolve the data types that will be used in the migrated solution. This process analyzes all the call parameters to a specific method to infer the type to be used in the method declaration and all the castings needed. This analysis is done in all the projects to make sure that the typing will be processed properly during the migration. This feature works pretty much like the renaming feature, but this one resolves specifically the type of the public methods and members and creates a framework for the typing engine to ease the type inference in the inter-project method/member calls.
Shared files and folder distribution
A single project conversion generates all the files included in the original VBP into a new output directory. If there are shared files between several projects converted to .NET, those files would be replicated into several copies, one for each converted project including the original file. The multi-project conversion will reproduce the same “files and folders distribution” of the original VB6 projects in order to avoid the multiplication of the shared files. If there are references to external files, the VBUC will copy the file into a separate folder which name is a modification of the original absolute route.