CodeConverter
CodeConverter copied to clipboard
C# -> VB: Method cannot have both a ParamArray and Optional parameters.
Input code
public SyntaxTokenList ConvertModifiers(SyntaxNode node, IEnumerable<SyntaxToken> modifiers,
TokenContext context = TokenContext.Global, bool isVariableOrConst = false, params CSSyntaxKind[] extraCsModifierKinds)
{
}
Erroneous output
Public Function ConvertModifiers(ByVal node As SyntaxNode, ByVal modifiers As IEnumerable(Of SyntaxToken), ByVal Optional context As TokenContext = TokenContext.[Global], ByVal Optional isVariableOrConst As Boolean = False, ParamArray extraCsModifierKinds As CSSyntaxKind()) As SyntaxTokenList
End Function
Details
In VB a method cannot have both a ParamArray and Optional parameters.
- Error Message: "Method cannot have both a ParamArray and Optional parameters."
- Version in use: Current compiled repo
I didn't know about this rule. The solution is probably to convert to an array at the call site. Then the method can take an optional array that defaults to nothing, then replaces nothing with an empty array on the first line