[release/9.0] Update HtmlAttributePropertyHelper
to correctly follow the MetadataUpdateHandlerAttribute
contract
#59908
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.
Backport of #58558 to release/9.0
/cc @MackinnonBuck
Update
HtmlAttributePropertyHelper
to correctly follow theMetadataUpdateHandlerAttribute
contractFixes an issue where, when running a Blazor, Razor Pages, or MVC app in .NET 9 via
dotnet watch
, a warning gets logged on each hot reload edit.Description
A change was made in the .NET 9 SDK that logs a warning at runtime when a type claiming to implement hot reload functionality does not correctly follow the
MetadataUpdateHandlerAttribute
contract. This change revealed that theHtmlAttributePropertyHelper
class had incorrectly implemented this contract since .NET 7 (since a warning was getting logged on each hot reload edit). Some customers also claim that this bug worsens hot reload performance by adding additional delays between hot reload edits, although this detail is only anecdotal.The fix is simple: Subtly change the signature of a method in the
HtmlAttributePropertyHelper
class to conform to the metadata update handler contract.Fixes https://github.com/dotnet/AspNetCore-ManualTests/issues/3202
Customer Impact
The biggest known impact is that Blazor, Razor Pages, and MVC apps running with
dotnet watch
will log a warning each time a hot reload edit is made.In addition, since the
HtmlAttributePropertyHelper
's reflection cache was not getting cleared after a hot reload edit, certain hot reload edits may either 1) not apply or 2) cause an exception to get thrown (especially when utilizing theHtmlHelper.AnonymousObjectToHtmlAttributes()
API). We don't currently have data on how common that particular issue is in practice. This would have been an issue since .NET 7.Some customers also claim that this bug worsens hot reload performance, but this detail is only anecdotal.
Regression?
The newly-logged warning is a regression from .NET 8.
However, the reflection cache failing to clear is not a regression, as this has been an issue since hot reload support was initially added for this type in .NET 7. However, it's not clear what the customer impact of this problem is.
Risk
The change is extremely trivial. Manual testing vendors have validated that the fix resolves the warning.
Verification
Packaging changes reviewed?