- INDEX VB TO NET
- HOW TO MODIFY THE WAY THE CODE IS GENERATED
- STUB METHODS GENERATION
Stub Methods Generation
The VBUC converts library elements to their equivalent when possible. When there is no equivalent, the default behavior was just to add a comment indicating that the following expression/statement could not be converted and need manual correction. This might cause a number of compilation errors that might hide other issues that need to be resolved manually.
The Stub Generation feature creates dummy (stub) declarations for those elements that could not be mapped to .NET equivalents. It also changes all the references to the not-supported elements for references to the stub declarations. This technique doesn’t resolve the whole issue since manual work will always be required to implement the functionality which is not present in .NET. However it can save an important amount of time by achieving the following goals:
- It makes all the not supported elements to compile avoiding an important amount of compilation errors and helping to understand the required manual effort.
- A solution can be implemented for each not-supported element in a unique location in the target source code, instead of requiring changes for all its references.
A simple code example:
Original VB6 Code:
Note:
The LeftB function is not supported by the VBUC.
Public Sub method1() LeftB "teststring", 5 End Sub
Resulting VB.NET Code:
Public Sub method1() method2() 'UPGRADE_ISSUE: (1040) LeftB function is not supported. UpgradeStubs.VBA_Strings.LeftB("teststring", 5) End Sub
Resulting C#.NET Code:
public void method1(){ method2(); //UPGRADE_ISSUE: (1040) LeftB function is not supported. UpgradeStubs.VBA_Strings.LeftB("teststring", 5); }