Stub Generation for No-Maps
To ease the compilation process, the Visual Basic Upgrade Companion generates an empty declaration (stub) in a stub-dedicated source code file and into the converted project for each library element which occurs in the original application and does not have an equivalent in .NET. All the references to these not-converted elements are translated into references to their corresponding stub declarations.
This strategy does not fully resolve the lack of .NET equivalent elements, since the stubs will require manual implementation. However, it saves an important amount of time by achieving the following goals:
- All not-supported elements will accomplish compilation, avoiding a considerable quantity of compilation errors and providing the user a way to understand the required manual effort.
- Every not-supported element will have a unique stub declaration which is used by all its original references. The user can solve the not-supported issue in a unique location by implementing the stub body, instead of making multiple changes for all the references.
In the following example, the original VB6 code contains the LeftB function which is not supported by the migration tools.
Original VB6 code:
Public Sub method1()
LeftB "teststring", 5
End Sub
The Upgrade Wizard will add an Upgrade Warning about the not supported function but the resulting source code remains using this function.
VB.NET code generated by the Upgrade Wizard
Public Sub method1()
'UPGRADE_ISSUE: LeftB function is not supported.’
LeftB("teststring", 5)
End Sub
The Visual Basic Upgrade Companion resulting source code will contain an EWI about the lack of support for the LeftB function, and if the Stub generation feature is enabled, will create a stub declaration for this function. The reference to the stub declaration is shown below.
VB.NET code generated by the Visual Basic Upgrade Companion:
Public Sub method1()
method2()
'UPGRADE_ISSUE: (1040) LeftB function is not supported.
UpgradeStubs.VBA_Strings.LeftB("teststring", 5)
End Sub