Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No overload for ... matches delegate 'MouseEventHandler' #474

Closed
pmantos opened this issue Jan 3, 2020 · 3 comments · Fixed by #537
Closed

No overload for ... matches delegate 'MouseEventHandler' #474

pmantos opened this issue Jan 3, 2020 · 3 comments · Fixed by #537
Assignees
Labels
VB -> C# Specific to VB -> C# conversion

Comments

@pmantos
Copy link

pmantos commented Jan 3, 2020

Erroneous output

    private void ChangeMinLevel()
    {
        try
        {
            Waterfall1.Levels.Axis.Min = tb_MinLevel.Value;
        }
        catch (Exception ex)
        {
            PostErrors_ThreadSafe(ex.ToString(), "ChangeMinLevel", "", true);
        }
    }

Expected output

    private void ChangeMaxLevel(object sender, MouseEventArgs e)
    {
        try
        {
            Waterfall1.Levels.Axis.Max = tb_MaxLevel.Value;
        }
        catch (Exception ex)
        {
            PostErrors_ThreadSafe(ex.ToString(), "ChangeMaxLevel", "", true);
        }
    }
@pmantos pmantos added the VB -> C# Specific to VB -> C# conversion label Jan 3, 2020
@GrahamTheCoder
Copy link
Member

Thanks for the report, could you post the input code please? I tried the following but it seemed to work fine:

Private Sub ChangeMaxLevel(ByVal sender As Object, ByVal e As MouseEventArgs)
    Try
        Waterfall1.Levels.Axis.Max = tb_MaxLevel.Value
    Catch ex As Exception
        PostErrors_ThreadSafe(ex.ToString, "ChangeMaxLevel", "", True)
    End Try
End Sub

I notice you posted two different methods in your report, did one work and the other not work? If so, seeing both might speed up diagnosis of the issue. Thanks!

@GrahamTheCoder GrahamTheCoder added the needs-repro Needs either the input that caused the error, or more information to allow reproducing the error label Jan 3, 2020
@GrahamTheCoder GrahamTheCoder removed the needs-repro Needs either the input that caused the error, or more information to allow reproducing the error label Mar 3, 2020
@GrahamTheCoder
Copy link
Member

GrahamTheCoder commented Mar 3, 2020

Found a repro

Partial Public Class Form1
    Private Sub Form1_MouseClick() Handles Me.MouseClick
    End Sub

    Public Sub Init()
        AddHandler Me.MouseClick, AddressOf Form1_MouseClick
    End Sub

    Public Sub Other()
        Form1_MouseClick()
    End Sub
End Class

Notes:

  • The only compilable forms in VB are to specify all parameters, or none. You can't specify just some.
  • The correct output in these cases is to add the event handler as a lambda which throws away the args (checked in DotPeek)
  • Removing a handler like this generates a warning and has no compile time effect since the lambda is a different instance. Converting to use its own lambda, then prefixing with a #warning directive would be slightly better in terms of allowing the user to see and deal with the issue in their own time

@Saibamen
Copy link
Contributor

Saibamen commented Mar 8, 2020

Please retest. Should be fixed by #537

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
VB -> C# Specific to VB -> C# conversion
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants