-
Notifications
You must be signed in to change notification settings - Fork 10.3k
[release/7.0] Hot reload: Acknowledge Blazor component parameter removal #43418
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
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
javiercn
reviewed
Aug 31, 2022
javiercn
reviewed
Aug 31, 2022
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great so far, I have a minor question, but that's it.
javiercn
approved these changes
Sep 1, 2022
The overall approach here looks good to me 👍 |
SteveSandersonMS
approved these changes
Sep 2, 2022
@Pilchie Would you be able to take a look at this? It's ready to be merged. |
Approved for .NET 7 RC2. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
area-blazor
Includes: Blazor, Razor Components
feature-hot-reload
This issue is related to the Hot Reload feaature
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.
[release/7.0] Hot reload: Acknowledge Blazor component parameter removal
If a parameter value was removed from a component during a hot reload edit, the component would retain the previously-supplied value. This PR fixes the issue by reinstantiating a component when a hot reload edit removes one of its parameters.
Description
One approach to solving this bug could be to directly
default
-out all parameter properties before applying the new set of parameter values. The main problem with that is any custom construction logic initializing properties to their default values will be skipped. This can be fine in some cases, but even some of our E2E test pages would throw exceptions or break in other ways when any hot reload change was applied using this approach.Thus, with the changes in this PR, a component will get completely disposed and reinstantiated when a component parameter removal is detected during hot reload. This allows the component's construction logic to correctly reset parameter property values.
Fixes #31272
Customer Impact
Certain types of code edits require the customer to either rebuild their project or refresh the webpage in order for the changes to be applied. Expanding the range of edits that a customer can make to their code without requiring manual refreshing/rebuilding makes Hot Reload a larger productivity booster. Supporting the live removal of Blazor component parameters is a step in that direction.
Regression?
Risk
This PR adds a single additional code path to the rendering logic, and it only applies for hot reload scenarios. New automated tests have been added for the logic determining when that new code path should be taken (i.e., detecting when component parameters have been removed).
Verification
Packaging changes reviewed?