Skip to content

Ref Scan

Benjamin edited this page Oct 5, 2020 · 5 revisions

Ref Scan

A quick reference scan is necessary to ensure improved conversion.

why Refscan?

Consider the following snippet in VB6:

  Value = Reference

Reference may be one of several things:

  • A local Variable
  • A local Function
  • A Control on the current form.
  • A Public Variable in another module
  • A Public Function in another module

While the above code covers all of the above in VB6, C# requires parenthesis for function calls (and module name for calls to modules that haven't explicitly been referenced via using). Additionally, if the Reference is a control, the default property must be appended to the reference (in most cases) which must in turn be based on the control type (another lookup in the ref list).

Additionally, one must consider Forms. Forms automatically have an instance created for them in VB6. While you can create an instance of a form, the most typical use case is to simply reference the object and use the "default instance". Since this doesn't exist in C#, a boilerplate variable of MyForm.instance is automatically pre-pended to each form and included in the converted code. References to forms, then, must have the ...instance... inserted at the appropriate place.

Format

Format is a colon delimited text file. Colons are used instead of commas (,) because function signatures are stored in some cases (which contain commas) and this prevents value escaping.

Speed was not the primary concern when choosing the format. Rather, a light-weight, non-proprietary, easy to use, access, understand, inspect, and debug was the primary consideration.

Layout

Fields:

  1. Module name
  2. Name
  3. Type (Function, Method, Enum, Control)
  4. Signature (for methods) or Control replacement

Example of refs file

modLinter:LintForms:Function:Function LintForms(Optional ByVal Folder As String, Optional ByVal AutoFix As Boolean = False) As Boolean
modLinter:LintFileList:Function:Function LintFileList(ByVal List As String, ByVal AutoFix As Boolean) As Boolean
modLinter:LintFile:Function:Function LintFile(ByVal FileName As String, Optional ByRef ErrStr As String = "#", Optional ByVal AutoFix As Boolean = False) As Boolean
modLinter:LintFileOptions:Function:Function LintFileOptions(ByVal FileName As String, Optional ByRef ErrStr As String) As Boolean
modLinter:LintFileIndent:Function:Function LintFileIndent(ByVal FileName As String, Optional ByRef ErrStr As String, Optional ByVal AutoFix As Boolean = False) As Boolean
modLinter:LintFileBadCode:Function:Function LintFileBadCode(ByVal FileName As String, Optional ByRef ErrStr As String, Optional ByVal AutoFix As Boolean = False) As Boolean
frm:frm:Form:
frm:frm.fra:Control:VB.Frame
frm:frm.cmdSupport:Control:VB.CommandButton
frm:frm.cmdScan:Control:VB.CommandButton
frm:frm.cmdFile:Control:VB.CommandButton
frm:frm.txtFile:Control:VB.TextBox
frm:frm.cmdLint:Control:VB.CommandButton
frm:frm.cmdConfig:Control:VB.CommandButton
frm:frm.txtStats:Control:VB.TextBox
frm:frm.cmdClasses:Control:VB.CommandButton
frm:frm.cmdModules:Control:VB.CommandButton
frm:frm.cmdAll:Control:VB.CommandButton
frm:frm.cmdForms:Control:VB.CommandButton
frm:frm.cmdExit:Control:VB.CommandButton
frm:frm.txtSrc:Control:VB.TextBox
frm:frm.lblPrg:Control:VB.Label
Clone this wiki locally