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

Clarify [EventHandler] tag helper discovery logic and avoid exception #10828

Conversation

DustinCampbell
Copy link
Member

@DustinCampbell DustinCampbell commented Sep 3, 2024

This fixes an issue that @tmat pointed out to me over email. In a recent change (#10720), I added a call to Assumed.Unreachable() when [EventHandler] tag helper discovery encounters an attribute with invalid constructor attributes. However, throwing an exception during tag helper discovery is usually the wrong approach. Normally, if Roslyn symbols aren't in the proper shape during tag helper discovery, Razor will simply not produce a tag helper. (We do support diagnostics for tag helpers, but those are usually reserved for warnings and errors that are related to a tag helper's data that would make it unusable, such as a name containing whitespace.)

It turns out that the "unreachable" condition wasn't actually all that unreachable and @tmat was hitting it while working on hot reload tests. So, I've changed the code to make the success conditions clearer, i.e., the attribute data must match one of the two constructor calls. And, I changed the logic to simply skip [EventHandler] attributes that don't meet the success conditions.

@DustinCampbell DustinCampbell requested a review from a team as a code owner September 3, 2024 18:05
Copy link
Member

@tmat tmat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@DustinCampbell
Copy link
Member Author

Thanks everyone!

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

Successfully merging this pull request may close these issues.

7 participants