Upgrading Duplicated Declarations

    This feature applies just for C# code generation. It occurs because the output could produce a duplication of declarations. This duplication could be generated when an implementing method has the name <Interface>_<Member> and the implementing class already has a member named <Member>, or when there are more than one implemented interfaces and there are two implementing members with the same names.

    For these cases, .NET provides the Explicit Interface Declaration syntax that qualifies the member declaration in order to avoid this conflict. So the upgrading process for an implementing member, which name conflicts with another declaration in the implementing class or in another implemented interface, must be generated using this syntax. It consists in adding a prefix with the qualification of the interface that this member is implementing.

    The second change consists in changing the references to that member using a casting to the interface.

    Original VB6 code

    AnInterface1.cls
    
    Public Function MyFoo()
    End Function
    Public Property Get AProp() As Integer
    End Property
    
    AnInterface2.cls
    
    Public Function MyFoo()
    End Function
    
    AClass.cls
    
    Implements AnInterface1
    Implements AnInterface2
    Public Function AnInterface1_MyFoo()
        Dim i As Integer
        i = AnInterface1_AProp
    End Function
    Public Function AnInterface2_MyFoo()
        ' Code
    End Function
    Public Property Get AnInterface1_AProp() As Integer
        ' Code
    End Property
    Public Property Get AProp() As Integer
        AProp = 0
    End Property
    

    VBUC resulting C#.NET code

    internal class AClass
        : AnInterface1, AnInterface2
        {
        
            object AnInterface1.MyFoo()
            {
                   int i = ((AnInterface1)this).AProp;
                return null;
            }
            object AnInterface2.MyFoo()
            {
                // Code
                return null;
            }
            int AnInterface1.AProp
            {
                get
                {
                    return 0;
                }
            }
            public int AProp
            {
                get
                {
                    return 0;
                }
            }
        }

    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