ISSUE #2068

    <class1> <prop1> was not upgraded.

    Description

    The VBUC is capable of mapping VB6 library members to .NET equivalents. These equivalents are chosen to provide maximum functional equivalence on the target platform.

     

    In specific scenarios, some class properties may not have a direct equivalent, because there is no equivalent in the .NET libraries or because no mapping association exists in VBUC.

    Recommendations 

    There is no unique solution for this issue because some class properties may not have an equivalent in .NET at all.

     

    The entire set of not-mapped elements requires manual implementation of the missing member. The Stub Generation feature will assess the manual effort needed to reach functional equivalence by isolating all not-upgraded class properties in a single source file.

     

    For more information please refer to Stub generation.

    Sample VB6

    PrivateSub Command1_Click()

    Dim objBag AsNew PropertyBag

    ' Attempt with empty PropertyBag, default value

    GetMaskProperty objBag

    objBag.WriteProperty "Mask", "Zorro"

    ' Atempt with PropertyBag with mask value

    GetMaskProperty objBag

    EndSub

     

    PublicSub GetMaskProperty(ByVal PropBag As PropertyBag)

    Dim mask AsString

    mask = PropBag.ReadProperty("Mask", "none")

    MsgBox ("Mask is: " & mask)

    EndSub

    Generated VB.NET

    PrivateSub Command1_Click(ByVal eventSender AsObject, ByVal eventArgs As EventArgs) Handles Command1.Click

    'UPGRADE_ISSUE: (2068) PropertyBag object was not upgraded.

    Dim objBag AsNew UpgradeStubs.VBRUN_PropertyBag

    ' Attempt with empty PropertyBag, default value

    GetMaskProperty(objBag)

    'UPGRADE_ISSUE: (2069) PropertyBag method objBag.WriteProperty was not upgraded.

    objBag.WriteProperty("Mask", "Zorro")

    ' Atempt with PropertyBag with mask value

    GetMaskProperty(objBag)

    EndSub

     

    'UPGRADE_ISSUE: (2068) PropertyBag object was not upgraded.

    PublicSub GetMaskProperty(ByVal PropBag As UpgradeStubs.VBRUN_PropertyBag)

    'UPGRADE_ISSUE: (2069) PropertyBag method PropBag.ReadProperty was not upgraded.

    'UPGRADE_WARNING: (1068) PropBag.ReadProperty() of type Variant is being forced to String.

    Dim mask AsString = CStr(PropBag.ReadProperty("Mask", "none"))

    MessageBox.Show("Mask is: " & mask, Application.ProductName)

    EndSub

     

    'Stub Generated for PropertyBag

    PublicClass VBRUN_PropertyBag

     

    PublicSub WriteProperty(ByVal Name_Renamed AsString, ByVal Value AsObject, OptionalByVal DefaultValue AsObject = Nothing)

    ThrowNew System.Exception("The method or operation is not implemented.")

    EndSub

     

    PublicFunction ReadProperty(ByVal Name_Renamed AsString, OptionalByVal DefaultValue AsObject = Nothing) AsObject

    ThrowNew System.Exception("The method or operation is not implemented.")

    EndFunction

     

    EndClass

    Expected VB.NET

    For this example we ve turned on the Stub Generation feature of the VBUC, and we ll be using the generated stub to provide functional equivalence for our code.

     

    Our main concern becomes implementing the PropertyBag and its methods in the VBRUN_PropertyBag class. You can later rename this class if so desired using Visual Studio s Refactor -> Rename context-menu option, but for now we ll keep it as is. The example is straightforward, as we use the VBRUN_PropertyBag as a wrapper around the generic Dictionary(Of TKey, TValue) collection.

     

    PrivateSub Command1_Click(ByVal eventSender AsObject, ByVal eventArgs As EventArgs) Handles Command1.Click

    Dim objBag AsNew UpgradeStubs.VBRUN_PropertyBag

    ' Attempt with empty PropertyBag, default value

    GetMaskProperty(objBag)

    objBag.WriteProperty("Mask", "Zorro")

    ' Atempt with PropertyBag with mask value

    GetMaskProperty(objBag)

    EndSub

     

    PublicSub GetMaskProperty(ByVal PropBag As UpgradeStubs.VBRUN_PropertyBag)

    Dim mask AsString = CStr(PropBag.ReadProperty("Mask", "none"))

    MessageBox.Show("Mask is: " & mask, Application.ProductName)

    EndSub

     

    'Stub Generated for PropertyBag

    PublicClass VBRUN_PropertyBag

     

    Private bag As Dictionary(OfString, String) = New Dictionary(OfString, String)

     

    PublicSub WriteProperty(ByVal Name AsString, ByVal Value AsObject, OptionalByVal DefaultValue AsObject = Nothing)

    If IsNothing(Value) Then

    bag.Add(Name, DefaultValue)

    Else

    bag.Add(Name, Value)

    EndIf

    EndSub

     

    PublicFunction ReadProperty(ByVal Name AsString, OptionalByVal DefaultValue AsObject = Nothing) AsObject

    IfNot bag.ContainsKey(Name) Then

    Return DefaultValue

    Else

    Return bag(Name)

    EndIf

    EndFunction

     

    EndClass

    Generated C#

    privatevoid Command1_Click(Object eventSender, EventArgs eventArgs)

    {

    //UPGRADE_ISSUE: (2068) PropertyBag object was not upgraded.

    UpgradeStubs.VBRUN_PropertyBag objBag = new UpgradeStubs.VBRUN_PropertyBag();

    // Attempt with empty PropertyBag, default value

    GetMaskProperty(objBag);

    //UPGRADE_ISSUE: (2069) PropertyBag method objBag.WriteProperty was not upgraded.

    objBag.WriteProperty("Mask", "Zorro", null);

    // Atempt with PropertyBag with mask value

    GetMaskProperty(objBag);

    }

     

    //UPGRADE_ISSUE: (2068) PropertyBag object was not upgraded.

    publicvoid GetMaskProperty(UpgradeStubs.VBRUN_PropertyBag PropBag)

    {

    //UPGRADE_ISSUE: (2069) PropertyBag method PropBag.ReadProperty was not upgraded.

    //UPGRADE_WARNING: (1068) PropBag.ReadProperty() of type Variant is being forced to string.

    string mask = Convert.ToString(PropBag.ReadProperty("Mask", "none"));

    MessageBox.Show("Mask is: " + mask, Application.ProductName);

    }

     

    publicclassVBRUN_PropertyBag

    {

    publicvoid WriteProperty(string Name_Renamed, object Value, object DefaultValue)

    {

    thrownew System.Exception("The method or operation is not implemented.");

    }

    publicobject ReadProperty(string Name_Renamed, object DefaultValue)

    {

    thrownew System.Exception("The method or operation is not implemented.");

    }

    }

    Expected C#

    For this example we ve turned on the Stub Generation feature of the VBUC, and we ll be using the generated stub to provide functional equivalence for our code.

     

    Our main concern becomes implementing the PropertyBag and its methods in the VBRUN_PropertyBag class. You can later rename this class if so desired using Visual Studio s Refactor -> Rename context-menu option, but for now we ll keep it as is. The example is straight-forward, as we use the VBRUN_PropertyBag as a wrapper around the generic Dictionary(Of TKey, TValue) collection.

     

    privatevoid Command1_Click( Object eventSender, EventArgs eventArgs)

    {

    UpgradeStubs.VBRUN_PropertyBag objBag = new UpgradeStubs.VBRUN_PropertyBag();

    // Attempt with empty PropertyBag, default value

    GetMaskProperty(objBag);

    objBag.WriteProperty("Mask", "Zorro", null);

    // Atempt with PropertyBag with mask value

    GetMaskProperty(objBag);

    }

     

    publicvoid GetMaskProperty( UpgradeStubs.VBRUN_PropertyBag PropBag)

    {

    string mask = Convert.ToString(PropBag.ReadProperty("Mask", "none"));

    MessageBox.Show("Mask is: " + mask, Application.ProductName);

    }

     

    publicclassVBRUN_PropertyBag

    {

    privateDictionary<string, object> bag = newDictionary<string, object>();

    publicvoid WriteProperty(string name, object value, object defaultValue)

    {

    if (value == null)

    {

    bag.Add(name, defaultValue);

    }

    else

    {

    bag.Add(name, value);

    }

    }

    publicobject ReadProperty(string name, object defaultValue)

    {

    if (bag.ContainsKey(name) == false)

    return defaultValue;

    elsereturn bag[name];

    }

    }


    Download VBUC Free Trial
    Download VBUC Now

    It's time to eradicate VB6
    ROI of eradicating VB6

    8 Proven Tips for
    Planning a Successful Migration

    8 Tips for migration