Support Statement: Removing a container control (e.g. vsElastic )
Q: We just want to exclude a control that lives in the VB6 code so that it disappears from the resulting C# code.
A:
Controls declared in the property bag have a different lifecycle than symbols declared in logic or COM APIs. They are a bit stubborn to get rid of.
A further problem is that the vsElastic is a container control. You need to retain the contained controls when you remove the elastic. You can try using two preedits to remove it from the source: You have to remove the top of the control declaration/initializations and also remove the End; leaving the contained controls in place. I do not think the unusual indentation of the remaining content will be an issue.
<Compile...> <Fix...> <Replace name="remove the Begin vsElastic and its properties up its first child control. Note that '…' is a multiline wildcard" > <OldBlock><![CDATA[ Begin vsOcx6LibCtl.vsElastic Base ... Begin VB.CommandButton cmdExit ]]></OldBlock> <NewBlock><![CDATA[ Begin VB.CommandButton cmdExit ]]></NewBlock> </Replace> <Replace name="Remove the End of the vsElastic"> <OldBlock><![CDATA[ End End Begin VB.Label Label9 ]]></OldBlock> <NewBlock><![CDATA[ End Begin VB.Label Label9 ]]></NewBlock> </Replace> ...
Removing a control may result undefined symbol results (e.g. late calls) if the remove control is referenced in logic.
In many cases, it may be more natural to use Refactor commands to migrate the container control to a simpler .NET container such as a group box. Â
These could also be implemented in a more general way using gmSL scripting to edit the code before processing.
https://greatmigrations.atlassian.net/wiki/display/GMG/Support+Statement%3A+gmSL+EditSource
See also this article that talks about removing a control that is used in logic.
https://greatmigrations.atlassian.net/wiki/display/GMG/Support+Statement%3A+Upgrading+a+COM+Component+property+to+a+WinForms+Static+property