C# Features
This section covers transformations that are applied to enhance certain elements with C# features.
1. Expression-bodied members.
Expression-bodied members refer to a more concise syntax for defining class members, such as properties or methods, using an expression instead of an entire block of code.
1.1. On
When choosing this option, the VB6 AI Migrator will apply a special pattern recognition mechanism to generate expression-bodied members when necessary.
Original VB6 Code
Public Property Get Name() As String
Name = m_name
End Property
Public Property Let Name(newName As String)
m_name = newName
End Property
Public Property Get Age() As String
Age = m_age
End Property
Public Property Let Age(newValue As String)
Dim newValue2 As Integer
newValue2 = CInt(newValue)
If newValue2 > 0 And newValue2 < 12 Then
m_age = "Enfant"
ElseIf newValue2 >= 12 And newValue2 < 18 Then
m_age = "Teenager"
ElseIf newValue2 >= 18 And newValue2 < 60 Then
m_age = "Adult"
Else
m_age = "Elder"
End If
End Property
Public Property Get Nationality() As String
Nationality = "Costa Rican"
End PropertyC# Code
1.2. Off
Choosing this option, the VB6 AI Migrator will generate blocks of code as default.
Original VB6 Code
C# Code
2. Generate Auto Implemented Properties
2.1. On
Auto-implemented properties will be generated when the original VB6 properties follow the basic standard pattern.
This feature verifies if there is a property defined on a local private field (both shares the same type) and it removes the field declarations and just leaves an auto-implemented property, replacing any reference to the field with a reference to the property in the class.
This feature is available for C# only.
Original VB6 code:
C# code:
2.2. Off
No Auto-Implemented Properties will be generated from the original VB6 ones.
Original VB6 code:
C# code:
3. GoTo/GoSub Conversion
GoSub statements can be transformed to local functions only when C# is the target language.
3.1. Do not convert Go Sub statements
Choosing this option, the VB6 AI Migrator will not apply any special pattern recognition mechanism. GoSub statements are not supported by default in .NET structured code.
Original VB6 code:
C# code:
3.2. Convert only GoSub statements to C# local function
Choosing this option, the VB6 AI Migrator will apply the special pattern recognition mechanism, to support the GoSub statement. This feature will only be applied when generating C# code.
General Description:
Visual Basic 6.0 provides the ability to jump into the code from one portion to another thru "labels" and create code that is not structured, according to the suggested coding patterns.
However, using GoSub and return statements gives the VB6 programmer certain functionality that used with certain restrictions can create "structured code".
By turning this feature on, the VB6 AI Migrator will recognize some of these patterns and will convert them to local functions for C#.
Original VB6 code:
C# code:
3.3. Convert GoTo and GoSub statements to C# local function
Choosing this option, the VB6 AI Migrator will convert, when possible, GoTo and GoSub statements to internal functions. This feature is only available for C#.
Basic GoSub Statement
This feature will select GoSub/Return blocks to convert to functions. The label corresponding to a GoSub call must be at the same level as the Return statement. The GoSub statement will be replaced by a call to the function that checks for its return value to see if an exit condition was met (Exit Function or Exit Sub, for example).
Original VB6 Code
C# Code
Basic GoTo Statement
In order to convert GoTo statements to functions, the VB6 AI Migrator will look for a pattern that starts with the label, and could end in another label, a Return statement, an Exit statement, or another GoTo statement. These blocks will be extracted as internal functions an calls to them placed where the GoTo statements. Since GoTo statements are one-way, they will be replaced with a call to the function followed by a return statement (if it's not the last line of of code), because the code after a GoTo statement should not be executed. Some code after a GoTo statement will be detected as dead code and will be commented.
Original VB6 Code
C# Code
This feature uses boolean return values to control the flow of the code so it is consistent with the original VB6 code. When one of these internal functions returns true, it is because the original method has ended (due to an Exit Sub or Exit Function), and so the return value is used to stop execution all the way back to the initical calling point. The way calls to internal functions are migrated varies depending on if the function is called from the main method, or from within another function.
Original VB6 Code
C# Code
4. Discards
The discard feature was introduced in C# 7.0. It allows you to discard the result of an expression or variable you are not interested in or do not intend to use. Instead of assigning it to a variable you won't use, you can use the _ (underscore) symbol as a placeholder to discard the result.
4.1. On
When choosing this option, the VB6 AI Migrator will apply a special pattern recognition mechanism to apply the discard feature when necessary.
Original VB6 Code
C# Code
4.2. Off
Choosing this option, the VB6 AI Migrator will generate variables even if they are no longer necessary in the migrated code.
Original VB6 Code
C# Code
Last updated
Was this helpful?