Table of Contents |
---|
Overview
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
Typically a large, mature code will not meet the assumptions of every migration rule 100% and you should plan to consider alternatives and to refine or extend the rule to deal with variations. This incremental refinement is an important aspect of our iterative methodology.
In this example, the new rule assumes that the type of original argument to Len has a Length property in .NET and that argument is not null at runtime. The first assumption is easy to check using the C# compiler. The second assumption can be checked by static analysis of the code and by runtime testing. We know that the rule will not work for situations where the argument is a struct; in fact the resulting code will not even build. A more appropriate translation of Len(struct), that still avoids using VBNET, is to use System.Runtime.Interop.Marshal.SizeOf().
In this type of situation, a Migration DLL can be used to implement a rule that specifies x.Length is used for strings and Marshal.SizeOf(x) for is used for structs. However, when you encounter exceptions to your coding/upgrade standards, take time to see what the code is actually doing. For example, in the case of code that uses Len with struct you will typically also find Win32 APIs calls or record-based file IO. Both of these things warrant additional redesign as they move to .NET. It may make more sense to rework that section of your code in a different way. Also beware that VB6 language frequently provides high-level services that can only be reproduced by runtime routines that integrate several .NET operations. The check for null in VBNET. Strings.Len is a good example of this.
Tip |
---|
Balancing manual and automated work is a central tenet of the tool-assisted rewrite methodology. You should apply rules in a manner that fits the needs of your application and use a variety of techniques including the using gmStudio to systematically integrate hand-written code with the migration solution. |
Appendix X: Activating a Custom Metalanguage Configuration
This appendix describes how to modify the metalanguage configuration so gmStudio will produce translations that use your custom language replacement rules.
Metalanguage Files
Metalanguage files are XML documents that direct gmStudio as it rewrites your VB6 program for .NET.
Tip |
---|
|
There are two types of Metalanguage files: default Interface Description Files (IDFs) and default Language Files.
...
- Open the Settings dialog by clicking the [Settings] button on the toolbar.
- Click the [Configuration Files] tab
- Select the [Interface Descriptions] button
...
To list and inspect the default Language Files:
- Open the Settings dialog by clicking the [Settings] button on the toolbar.
- Click the [Configuration Files] tab
- Select the [Language] button
Customizing default interface description files
The [Configuration Files] tab on the Settings dialog is designed to help you inspect the metalanguage files and make a working copy in your project workspace. The following instructions explain how this is done for a default IDF.
- Open the Settings dialog by clicking the [Settings] button on the toolbar.
- Click the [Configuration Files] tab
- Copy the desired default IDF to your workspace.
- Click the [Interface Descriptions] button to list the default IDFs
- Click the desired default IDF, for example MigrationSupport.xml
- Click [Save As…] and save a copy of the file in the [workspace]\usr folder.
Tip |
---|
Once a default IDF file exists in your workdspace\usr folder it will take precedence over the default copy. This behavior is governed by gmStudio’s configuration folder search rules: Target before Local before System before Language. |
Customizing default language files
The [Configuration Files] tab on the Settings dialog is designed to help you inspect and manage all the files that play a role in configuring gmStudio. The following instructions explain how to setup gmStudio to do custom language replacement.
Part 1: Activating project-specific metalanguage information
...
...
...
Clicking the [Project] option copies two files into your [workspace]\usr folder.
StartUp File (gmBasic.xml)
...
...
Language Information Script (VB7Lang.xml)
The Language Information Script indicates which default language files should be processed to create the language information file. The Project option uses a version of the script that can be edited to specify that your custom language files should be used instead of the default files.
Tip |
---|
Once you have modified the gmBasic.xml and the VB7Lang.xml files is in your workspace, clicking the [Update Translator Configuration] button will create a new metalanguage information file (VB7Lang.vbi) in your workspace. This customized file will take precedence over the default copy that ships with gmStudio and will be used by the translator instead. of the default copy that ships with gmStudio. |
Part 2: customizing default language files
...
- Click [Language Files] to list the default language files
...
- Click VBASIC.xml
- Click [Save As…] and save a copy of the VBASIC.xml in the [workspace]\usr\lang folder
...
Appendix Y: Migration Dlls
Migration DLLs extend and alter the behavior of the gmStudio translator. Migration DLLs can manipulate the information about the system at the lowest level: symbol tables and operation streams. Migration DLLs can also be used to extend the gmBasic scripting language, for example, to develop specialized analysis, reporting, and code generation tools. Migration DLLs allow migration teams to make the translator do things that cannot be easily specified using the declarative refactoring statements or the gmStudio scripting language.
Migration DLLs contain "handlers". These are subroutines invoked by the translator when various "migration events" occur during processing. There is a large set of predefined migration events as well as a facility for attaching migration events to the specific types and members in COM libraries and to specific application types and variables. There is also an extensive gmStudio API that facilitates interacting with the translator and the system model in migration event handlers.
Migration DLLs can be coded with Visual Studio using C, Managed C++, C#, and VB.NET. The system programming techniques and meta-programming concepts needed to develop migration DLLs are somewhat advanced. We typically develop the Migration DLLs for our customers; but we also offer an SDK and Training Package for teams who want to develop Migration DLLs in house.
Appendix Z: Upgrading System Defaults
From time to time a new release of gmStudio will include changes to the default metalanguage scripts. These changes will be baked" into the system default metalanguage file (vb7lang.vbi) and will be used by default in new translation workspaces. However, if you have a workspace that is using a project-specific metalanguage configuration, you MUST sync up your custom metalanguage scripts to be compatible with gmStudio failing to do this will frequently cause the translator to terminate abnormally lead or produce malformed results.
Syncing up your custom metalanguage scripts with the new system defaults is the same as any other code merging operation:
For each of new system default scripts, check to see if you are using a custom script in your project workspace. If you are not using a custom script, move onto the next script. But, it you have have a custom copy of a script, merge the new system default into your custom copy. The easiest way to do this is with a file comparison/merge tool such as Beyond Compare. Once you have synced all of your custom metalanguage scripts with the new system default script, you should rebuild your project specific metalanguage file using the Settings form.
Warning |
---|
Be careful not to change the system default files when you are doing the merge. Your solution configuration should always be kept under version control, but you may also want make a local backup of your project-specific files before starting the merge so you can use it to restart if you make a mistake and to double check your work. Your migration |
...