CodeConverter
CodeConverter copied to clipboard
VB -> C#: Action lambda breaks
Error thrown by compiler on erroreous code is "Delegate Action<UserPopup> does not take 0 arguments" (CS1593)
VB.Net input code
Private Sub btnFilter_Click(sender As Object, e As EventArgs) Handles btnFilter.Click
upMCIF.Height = Me.Height - Me.Panel1.Height - 20
upMCIF.Width = Me.Width - 20
upMCIF.ShowPopup(8, Me.Panel1.Height, Sub()
'upMCIF.Height = 1
'upMCIF.Width = 1
Me.SetFilters()
Me.Focus()
btnFilter.Refresh()
btnFilter.Invalidate()
btnFilter.Update()
End Sub)
upMCIF.Focus()
End Sub
Erroneous output
private void btnFilter_Click(object sender, EventArgs e)
{
upMCIF.Height = Height - Panel1.Height - 20;
upMCIF.Width = Width - 20;
upMCIF.ShowPopup(8, Panel1.Height, () =>
{
// upMCIF.Height = 1
// upMCIF.Width = 1
SetFilters();
Focus();
btnFilter.Refresh();
btnFilter.Invalidate();
btnFilter.Update();
});
upMCIF.Focus();
}
Expected output
//Unsure of what the right code should be, but this would compile.
private void btnFilter_Click(object sender, EventArgs e)
{
upMCIF.Height = Height - Panel1.Height - 20;
upMCIF.Width = Width - 20;
upMCIF.ShowPopup(8, Panel1.Height, (onclose) =>
{
// upMCIF.Height = 1
// upMCIF.Width = 1
SetFilters();
Focus();
btnFilter.Refresh();
btnFilter.Invalidate();
btnFilter.Update();
});
upMCIF.Focus();
}
Details
CC 8.41 vs2019 extension
Signature of ShowPopup is
public void ShowPopup(int x, int y, Action<UserPopup> onclose = null);
Thanks, I'm pretty sure the converter has some code to deal with this case already, will have to investigate why it's not working in this case