[release/8.0-preview5] Fix IJSObjectReference disposal #48522
Merged
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 #48287 to release/8.0-preview5
/cc @MackinnonBuck @LostBeard
Fix IJSObjectReference disposal
Fixes a bug where disposing an
IJSObjectReference
instance from .NET results in an exception getting thrown.Description
IJSObjectReference
s are useful for passing references to JavaScript objects between JS and .NET. After obtaining aIJSObjectReference
via JS interop, it can be disposed from .NET via theIJSObjectReference.DisposeAsync()
method. Due to some recent changes in Blazor's JavaScript implementation, disposing a JS object reference now throws the following exception:This PR fixes the issue by updating
IJSObjectReference
disposal according to the recent changes in Blazor's JS implementation.Fixes #48280
Customer Impact
IJSObjectReference
is commonly used by many Blazor apps and component libraries. While app developers could temporarily work around the issue by not disposing anyIJSObjectReference
instances, the change could make some component libraries unusable without a workaround.Regression?
Regressed from .NET 8 Preview 4
Risk
The change is just updating a string value that got out of sync with other changes. Most of the diff is caused by the additional tests added to catch this case in the future.
Verification
Packaging changes reviewed?