- INDEX VB TO NET
- VBUC FEATURES
- LANGUAGE TRANSFORMATIONS
- INTERFACES SUPPORT
- SOLVING TYPING PROBLEMS FOR INTERFACES
Solving Typing problems for Interfaces
Visual Basic 6 is an “unrestricted type”, which means types do not need to be declared; they can be solved during runtime.
The VBUC provides a Typer tool that tries to resolve the uses of the references in order to declare their types consistently as they were used originally. The same feature applies for interfaces too, although the complexity is higher because the Typer must take into account uses of the references in the interface and the implementing classes.
Original VB6 code
AnInterface.cls Property Get varStr() varStr = "" End Property Sub foo(arg As Variant) End Sub AClass.cls Implements AnInterface Property Get AnInterface_varStr() AnInterface_varStr = "" End Property Sub AnInterface_foo(arg As Variant) arg = 0 End Sub
VBUC resulting VB.NET code
AnInterface.cls Interface AnInterface ReadOnly Property varStr As String Sub foo(ByRef arg As Byte) End Interface Friend Class AnInterface_CoClass Implements AnInterface Public ReadOnly Property varStr() As String Implements AnInterface.varStr Get Return "" End Get End Property Public Sub foo(ByRef arg As Byte) Implements AnInterface.foo End Sub End Class AClass.cls Implements AnInterface ReadOnly Property AnInterface_varStr() As String Implements AnInterface.varStr Get Return "" End Get End Property Sub AnInterface_foo(ByRef arg As Byte) Implements AnInterface.foo arg = 0 End Sub
VBUC resulting C#.NET code
AnInterface.cls interface AnInterface { string varStr{ get; } void foo(ref byte arg); } internal class AnInterface_CoClass : AnInterface { public string varStr { get { return ""; } } public void foo(ref byte arg) { } } AClass.cls internal class AClass : AnInterface { public string varStr { get { return ""; } } public void foo(ref byte arg) { arg = 0; } }