Skip to content

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

Merged
DustinCampbell merged 1 commit into
dotnet:mainfrom
DustinCampbell:avoid-throw-in-tag-helper-discovery
Sep 3, 2024
Merged

Clarify [EventHandler] tag helper discovery logic and avoid exception#10828
DustinCampbell merged 1 commit into
dotnet:mainfrom
DustinCampbell:avoid-throw-in-tag-helper-discovery

Conversation

@DustinCampbell

@DustinCampbell DustinCampbell commented Sep 3, 2024

Copy link
Copy Markdown
Member

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

@tmat tmat left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks!

@DustinCampbell

Copy link
Copy Markdown
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