What are Stubs?

A stub is a function that has no definition, so it doesn't do anything but it could be helpful when stabilizing a migrated application.

The VBUC converts library elements to their equivalent when possible, but it is possible some elements could not be uograded because there aren't direct equivalents in the target component. For these non-updated element, the generated code will include a comment indicating that the expression/statement was not converted. The Upgrade Stubs Generation feature creates a dummy (stub) declaration for each kind of these elements.

This approach could be very important as part of a modernization strategy to get a migrated application stable.

Whenever a stub method is executed, it will display a message box like the one below (remember, stubs are dummy methods):

This warning means that you need to fix something (click “No“ to see what is happening and review the Call Stack to know which line must be implemented). Ignoring this, may generate crashes in the business logic, or modify the expected behavior.

However, beyond the fact a component/library element was not upgraded, stubs would be important in your conversion estrategy:

  1. Reduce compilation errors. When there is no equivalent for a method/property, the default behavior of the VBUC is just adding a comment indicating the following expression/statement was not converted and requires manual correction. This might cause a number of compilation errors that might hide other issues that need to be resolved manually.

  2. Encapsulation. It provides a centralized way to provide solutions. Once a stub is implemented, this solution will be available in all places in migrated code using this stub.

The above second point (encapsulation) will require analyze how to implement a funcitonality for a given stub. This imply knowledge in source and target languages (i.e. VB6 and C#/VB.Net) and deep engineering skills. Any implementation for a stub needs to understand what was the purpose of the stub in the original language and how it could be emulated in the target language: A stub exists because it doesn't exists a direct equivalent.

The following questions are a good start point to implement functionality for stubs:

  • What happened before this line?

  • What will happen after this line?

  • What says the Documentation?

  • In which control is used?

In the best scenario, you already know which should be the expected line (it will require .Net knowledge). In other cases, you need to research about the target .Net Control on how to emulate the not-upgraded element. Also, it could be possible stubs can not be fixed until you find a specific workflow that brings context about the purpose of the not-upgraded element.

NOTE: If you want to learn more about the Stubs Generation Upgrade Option this post will be of interest.

Last updated