Mappings Grammar

In the following section, you will find a description and documentation of Mappings Grammar Tool.

Mappings Grammar

Mapping is a crucial concept for our migrators. It means that from a set of values as input, a function is applied to each value, and generates a set with new values.

It's a powerful tool that allows design mappings by using a syntax quite similar to C#, which is used to transform VB6 code to its equivalent in .NET (C# or VB).

This applies to the following statements:

  • Types

  • Members (Methods, properties, subroutines, events, among others)

Also, this tool offers the possibility to generate code for statements that are not supported in .NET (for more information, see Upgrade Stubs), reducing the time to carry out the compilation of a migrated project.

In the code below they are some types like enumAlign and ctTips (ctTips1), including some members like Active, Tag, ToolTipText and Alignment.

Original VB6 Code source

Dim enumVal As enumAlign
...
Private Sub setCtTips()
    ctTips1.Active = True
    ctTips1.Tag = "Display component"
    ctTips1.ToolTipText = "CtTips1"
    ctTips1.Alignment = enumVal
End Sub

By using Mappings Grammar it is possible to migrate classes and their members to their .NET equivalent.

Mappings design using Mappings Grammar

type TipsLib.ctTips => System.Windows.Forms.ToolTip;
type TipsLib.enumAlign => nomap;

member TipsLib.ctTips.Active => Active as boolean;
member TipsLib.ctTips.Container => Container;
member TipsLib.ctTips.Tag => Tag as string;
member TipsLib.ctTips.ToolTipText => ToolTipTitle as string;
member TipsLib.ctTips.Alignment => nomap;

C# Code Generated by VBUC

//UPGRADE_ISSUE: (2068) TipsLib.enumAlign object was not upgraded.
UpgradeStubs.TipsLib_enumAlignEnum enumVal = (UpgradeStubs.TipsLib_enumAlignEnum) 0;
...
private void setCtTips()
{
    ctTips1.Active = true;
    ctTips1.Tag = "Display component";
    ctTips1.ToolTipTitle = "CtTips1";
    //UPGRADE_ISSUE: (2064) TipsLib.ctTips property ctTips1.Alignment was not upgraded.
    ctTips1.setAlignment(enumVal);
}
  • Notes:

    • As shown in the example above, ctTips will be upgraded into System.Windows.Forms.ToolTip.

    • Some members of ctTips class like Active, Container, Tag and ToolTipText will be upgrade to its .NET equivalent.

    • There are some classes and members that are not supported in .NET, so it generates stubs; like the class enumAlign and the member Alignment.

Last updated