Avoid null ref in TagHelperMatchingConvention when attribute name is null #38271
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
As part of .NET 6, we made some tweaks to the razor parser to avoid string allocations. This change
results in a null-ref for bound properties without public setters. The parser change affects building
apps going back all the way to .NET 2.1, so we'd like to fix this.
Fixes #38194
Description / Customer Impact
Attempting to build an app that references certain kinds of tag helpers[1] in cshtml files results in a null reference exception in the Razor parser. With the 6.0 SDK installed, this causes the build to fail in < 6.0 apps and for the source generator to not add files in 6.0.
[1] - TagHelpers with IDictionary properties that do not have setters.
Regression
[x] Yes
[ ] No
Regression introduced in .NET 6 preview6
Testing
[x] Automated (added additional unit tests for this)
[x] Manual testing (patched the SDK and verified the fix)
Risk
The change is primarily limited to build, not part of the shared fx. The null-ref happens with somewhat uncommon inputs so we have confidence this change addresses it.