Closed TymurGubayev closed 9 months ago
Sub S(Optional a As Integer = 0, Optional ByRef b As Integer = 0) End Sub
public void S(int a = 0, [Optional, DefaultParameterValue(0)] ref int b) //CS1737: Optional parameters must appear after all required parameters { }
Using the OptionalAttribute instead on preceding parameters fixes the issue.
OptionalAttribute
public void S([Optional, DefaultParameterValue(0)] int a, [Optional, DefaultParameterValue(0)] ref int b) { }
Ah, yes, makes sense. There are some cases where an attribute can't be used such as a vb date I think but should generally work Edit: just spotted https://github.com/icsharpcode/CodeConverter/issues/1056
VB.Net input code
Erroneous output
Expected output
Using the
OptionalAttribute
instead on preceding parameters fixes the issue.Details