See PRM-1425
Abstract
Question/request: to remove an argument from calls to a local method
Here, "local" means a method declared in the same VBP rather than in an IDF.
This request is based on a possible solution for a project problem.
It is also a request for general help with migrating local symbols..
Background
I am trying to migrate a local method so that one of the arguments is no longer passed to calls. I put together a sample to illustrate the desired effect.
Here is the original VB6:
Public Sub test(arg1 As String, arg2 As String, Optional arg3 As String) writeLog "running test" writeLog "arg1 = " & arg1 writeLog "arg2 = " & arg2 writeLog "arg3 = " & arg3 End Sub Public Sub CallTest() test "A", "B", "C" test "A", "B" End Sub
Here is the desired translation:
public static void test(string arg1,string arg3) // UPGRADE_INFO: hand-coded replacement; removed arg2 { writeLog("running test"); writeLog("arg1 = " + arg1); writeLog("arg3 = " + arg3); } public static void CallTest() { test("A","C"); test("A",String.Empty); }
The test provided to includes four scenarios:
- the method is declared and called locally in a module
- the method is declared and called locally in a class
- the method is declared in a class and called from a module
- the method is declared in a module and called from a class
Solution
<Compile Project="%SrcPath%"> <Refactor> <Remove identifier="LocalMigrateArg.test" migPattern="%1d(%2d,%4o)\c" /> <Remove identifier="LocalMigrateArg.Class1.test" migPattern="%1d(%2d,%4o)\c"/> </Refactor> </Compile> <Refactor> <Reauthor subprogram="LocalMigrateArg.test"><![CDATA[ public static void test(string arg1,string arg3) // UPGRADE_INFO: hand-coded replacement; removed arg2 { writeLog("running test"); writeLog("arg1 = " + arg1); writeLog("arg3 = " + arg3); } ]]></Reauthor> <Reauthor subprogram="LocalMigrateArg.Class1.test"><![CDATA[ public void test(string arg1,string arg3) // UPGRADE_INFO: hand-coded replacement; removed arg2 { modLocalMigrateArg.writeLog("running test"); modLocalMigrateArg.writeLog("arg1 = " + arg1); modLocalMigrateArg.writeLog("arg3 = " + arg3); } ]]></Reauthor> </Refactor>
Another example
<ScriptRule id="Lang.DataField" Condition="%TaskTag%=='upg'"> <PreAnalyse> <Refactor Condition="%SrcName%=='CIMS'"> <Remove identifier="CIMS.CListenerCollection.BindVBFormToADORecordset" migPattern="%1d(%2d,%3d,%4d, this.dataSourcer1)" /> <Remove identifier="CIMS.CListenerCollection.BindADORecordsetToVBForm" migPattern="%1d(%2d,%3d,%4d, this.dataSourcer1)\c" /> <Reauthor subprogram="VBControlHasDataFieldProperty"><![CDATA[ // UPGRADE_INFO: hand-coded. Add DataSourcer object to signature and simplify implementation . public bool BindVBFormToADORecordset(MigrationSupport.DataLib.SqlClient.Recordset rs,System.Windows.Forms.Form obFrm,string strRecordsetKey, MigrationSupport.UI.DataSourcer ds) ... ]]> </Reauthor> <Reauthor subprogram="BindADORecordsetToVBForm"><![CDATA[ // UPGRADE_INFO: hand-coded. Add DataSourcer object to signature and updated some of the code using the "dynamic" keyword. public void BindADORecordsetToVBForm(MigrationSupport.DataLib.SqlClient.Recordset rs,System.Windows.Forms.Form obFrm,string strRecordsetKey, MigrationSupport.UI.DataSourcer ds) ... ]]></Reauthor> </Refactor> </PreAnalyse> </ScriptRule>