Improved Default Property Resolution

Currently the VBUC contains, as an optional migration feature, a helper designed to resolve several late binding issues that are not solved by the typing mechanism.

But, sometimes this solution doesn’t work because the property name in .NET is different. Version 4.0 includes several improvements that increase the effectiveness of this feature.

VB6 Code

Private Sub Command1_Click()
        MsgBox FormMDI.ActiveForm.TextBox1.SelText
End Sub

.NET Code: Without the Default Property Resolution

private void  Command1_Click( Object eventSender,  EventArgs eventArgs){
   //UPGRADE_ISSUE: (2072) Control TextBox1 could not be resolved because 
   it was within the generic namespace ActiveMdiChild. 
   MessageBox.Show(Convert.ToString(FormMDI.DefInstance.ActiveMdiChild.
                   TextBox1.SelText), Application.ProductName);
}

.NET Code: With Default Property Resolution

private void  Command1_Click( Object eventSender,  EventArgs eventArgs) {
   //UPGRADE_ISSUE: (2072) Control TextBox1 could not be resolved because   
   it was within the generic namespace ActiveMdiChild
   MessageBox.Show(ReflectionHelper.GetMember<string>(ReflectionHelper.
              GetMember(FormMDI.DefInstance.ActiveMdiChild, "TextBox1"), 
              "SelText"), Application.ProductName);

In the previous example the VBUC was unable to determine the type of the TextBox control because the ActiveMdiChild property is of type Object.

Without Default Property Resolution the generated code will produce a compilation error. This can be resolved by manually changing the SelText property to SelectedText, as shown below:

(FormChild)FormMDI.DefInstance.ActiveMdiChild).TextBox1.SelectedText

With Default Property Resolution a helper class will determine the type of the TextBox at runtime and will change the SelText to SelectedText. The converted code will compile and works without any problem.