DynamicResource support for app resource changes#6354
Open
miloush wants to merge 2 commits intodotnet:mainfrom
Open
DynamicResource support for app resource changes#6354miloush wants to merge 2 commits intodotnet:mainfrom
miloush wants to merge 2 commits intodotnet:mainfrom
Conversation
anjaligupta-dev
previously approved these changes
Jun 1, 2022
Contributor
|
Doesn't the event subscription create a strong reference between application and expression, thus holding all expressions in memory for the lifetime of the application? Before the change the expression could be garbage collected as soon as the mentor could be. I guess this change will cause a massive memory leak. |
Contributor
|
Ah, i was blind... |
Contributor
Author
|
How do we feel about this one, do we want this issue to be addressed and is this a reasonable way to do so? (It appears this is waiting on me for being a draft.) |
d8666d4 to
2ad9b0f
Compare
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.
Fixes #6302
Description
Changes in application resources are not picked up by
DynamicResourceextension if the target object is not in the visual tree (i.e. has no mentor). It already has code to access App/System resources in the absence of mentor which suggests this was meant to be a supported scenario.This PR introduces internal
ResourcesChangedinstance event on theApplicationobject and subscribes theResourceReferenceExpressionto the changes when the target element does not have a mentor.Customer Impact
DynamicResourceextension onDependencyObjects such asDataGridColumns or other user types will not track the changes to the application resources. However, the extension reads them correct the first time, making this issue difficult to diagnose.Regression
No.
Testing
Built an updated PresentationFramework.dll and tested with the repro project in #6302 on 6.0.2 x86 app.
Built again and tested on 9.0.0 Preview 6 with changing system colors.
Risk
No changes to public API. No changes to behavior when the resource does not come from App/System resources, or when the target object has a mentor. At runtime, each instance of
ResourceReferenceExpressionwill create a strong reference to the Application instance, but only in the affected case.