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

Improve error about non generic RoutedEvent bindings fails #17887

Open
SKProCH opened this issue Jan 4, 2025 · 0 comments
Open

Improve error about non generic RoutedEvent bindings fails #17887

SKProCH opened this issue Jan 4, 2025 · 0 comments

Comments

@SKProCH
Copy link
Contributor

SKProCH commented Jan 4, 2025

Describe the bug

Usually we register the routed events like this:

public static readonly RoutedEvent<DialogClosingEventArgs> DialogClosingEvent =
    RoutedEvent.Register<DialogHost, DialogClosingEventArgs>(nameof(DialogClosing), RoutingStrategies.Bubble);

public event EventHandler<DialogClosingEventArgs> DialogClosing {
    add => AddHandler(DialogClosingEvent, value);
    remove => RemoveHandler(DialogClosingEvent, value);
}

but in some old code field type can be without generic, e.g.

public static readonly RoutedEvent DialogClosingEvent =
    RoutedEvent.Register<DialogHost, DialogClosingEventArgs>(nameof(DialogClosing), RoutingStrategies.Bubble);
...

In this case if we try to add event handler method in xaml markup:

<dialogHostAvalonia:DialogHost
    DialogClosing="FruitBowl_OnDialogClosing"

in Avalonia 11.2.0 and upper, we get this compilation error:

Error AVLN3000 Avalonia: Unable to find suitable setter or adder for property DialogClosing of type DialogHost.Avalonia:DialogHostAvalonia.DialogHost for argument System.Runtime:System.String, available setter parameter lists are:
System.EventHandler`1<Avalonia.Interactivity.RoutedEventArgs> Line 11, position 5.

To Reproduce

Create non generic routed event, create xaml event subscription to method, try to compile.

Can be reproduced by cloning and building this commit

Expected behavior

Error message should be more precise

Avalonia version

11.2.x

OS

No response

Additional context

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants