Skip to content

Non existing event subscriptions should raise a build error #10787

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

Open
Symbai opened this issue Apr 19, 2025 · 6 comments
Open

Non existing event subscriptions should raise a build error #10787

Symbai opened this issue Apr 19, 2025 · 6 comments
Labels
Enhancement Requested Product code improvement that does NOT require public API changes/additions

Comments

@Symbai
Copy link
Contributor

Symbai commented Apr 19, 2025

If you subscribe to any event in XAML (like KeyDown) but the method doesn't exist in your C# code, you can still successfully build your project. But if you run it and the XAML is executed your application crashes.

And because of the fact that it crashes the application (unlike a non existing binding) it should be analyzed and throw an error during the build.

@siagupta0202 siagupta0202 added the Enhancement Requested Product code improvement that does NOT require public API changes/additions label Apr 21, 2025
@lindexi
Copy link
Member

lindexi commented Apr 21, 2025

I think the main issues it perform the runtime bind the event.

@Symbai
Copy link
Contributor Author

Symbai commented Apr 21, 2025

I'm sorry but what do you mean?

@lindexi
Copy link
Member

lindexi commented Apr 21, 2025

The xaml can not check more thing in the build time.

@franchyd
Copy link

Why not? Other XAML frameworks do, and this would make future X:Bind support (compiled bindings) easier

@lindexi
Copy link
Member

lindexi commented Apr 22, 2025

@franchyd Yes, you are right. If we can bring the xaml to build time, such as SourceGenerator, that we can handle this issues. And bring the SourceGenerator to xaml is what I look to.

@miloush
Copy link
Contributor

miloush commented Apr 22, 2025

Well technically developers do not need to rely on the built-in InitializeComponents and could handle the XAML themselves. Not saying that many (or any) do, but it could be potentially breaking change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Requested Product code improvement that does NOT require public API changes/additions
Projects
None yet
Development

No branches or pull requests

5 participants