Question
How to selectively suppress OptionalArguments=on for a specific method?
The code has an optional implicity-byref parameter and I want to suppress the OptionalArguments migration for this method. The methods is called in the VBP where it is declared and from other VBPs in the system.
Public Function SearchForWindow(PartTitle$, Optional SwitchTo, Optional WholeTitleFoundOUT) As Long <-- WholeTitleFoundOUT must remain ByRef Some calls passed all parameters: hWndLoc& = SearchForWindow(OrigCaption, False, NameString) Some calls omit the optional parameters: hWnd = SearchForWindow(ReaderServerWindowName(iServerNo)) hWnd = SearchForWindow(ReaderServerWindowName(iReaderServerNoIN)) hWnd = SearchForWindow(ReaderServerWindowNameFromReader(iReaderIndexIN)) hWnd = SearchForWindow(SReaderServerWindowNamePrefix())
Answer
You may use compile/refactor/fixtype:
<refactor> <FixType identifier="APPCommon.SearchForWindow.WholeTitleFoundOUT" status="ByRef" type="String" /> </refactor> NOTE: type="String" is added because FixType will suppress the automatic type inference to string so you need to do it here. While you are at it, you may want to add a fixtype for SwitchTo: <FixType identifier="APPCommon.SearchForWindow.SwitchTo" type="Boolean" />
Bonus
Question: How to report cases where an implicit byref explicit optional was migrated to byval optional?
Answer: Search the definition report for byval.*optional.*changed