Add 'EnableComWrappersReleaseObjects' feature switch#2343
Closed
Sergio0694 wants to merge 3 commits intomasterfrom
Closed
Add 'EnableComWrappersReleaseObjects' feature switch#2343Sergio0694 wants to merge 3 commits intomasterfrom
Sergio0694 wants to merge 3 commits intomasterfrom
Conversation
Add a new 'EnableComWrappersReleaseObjects' feature switch (enabled by default) to FeatureSwitches.cs with its backing field and property name constant, and add the corresponding ILLink substitution entries for trimming support. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add 'CsWinRTEnableComWrappersReleaseObjects' MSBuild property (default: true) and the corresponding 'CSWINRT_ENABLE_COMWRAPPERS_RELEASE_OBJECTS' runtime host configuration option for IL trimming support. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…Objects Skip releasing objects when the feature switch is disabled, allowing long-lived apps with multiple windows to retain access to previously instantiated XAML objects that would otherwise be marked as disposed. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR adds a new
EnableComWrappersReleaseObjectsfeature switch (enabled by default) that controls whetherDefaultComWrappers.ReleaseObjectsdisposes objects or not.Motivation
In some specific scenarios where a long-lived app uses multiple windows, previously instantiated XAML objects can be marked as disposed when the runtime calls
ReleaseObjects. This feature switch allows disabling that behavior so those objects remain accessible.Changes
FeatureSwitches.cs: addedEnableComWrappersReleaseObjectsproperty with its constant name (CSWINRT_ENABLE_COMWRAPPERS_RELEASE_OBJECTS) and backing field, following the existing pattern.ILLink.Substitutions.xml: added substitution entries for the new switch to support IL trimming.Microsoft.Windows.CsWinRT.targets: addedCsWinRTEnableComWrappersReleaseObjectsMSBuild property (default:true) and the correspondingRuntimeHostConfigurationOptionfor trimming.ComWrappersSupport.net5.cs: added an early return guard inDefaultComWrappers.ReleaseObjectswhen the switch is disabled.