-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Improving DynamicResource performance (second try) #10532
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
Conversation
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.
PR Overview
This PR aims to improve the performance of dynamic resource resolution by refactoring the deferred resource reference handling and optimizing related lookup methods. Key changes include:
- Replacing the DeferredResourceReferenceList with a Dictionary-based weak reference map (_weakDeferredResourceReferencesMap) for deferred resource references.
- Introducing a new private Contains method that returns additional flags to better control deferred resource lookup.
- Refactoring resource reference classes in SystemResources.cs and Baml2006KeyRecord.cs for clarity and performance.
Reviewed Changes
File | Description |
---|---|
ResourceDictionary.cs | Updated deferred reference management with a weak reference map; added new Contains overload and revised methods to use the new infrastructure. |
Baml2006KeyRecord.cs | Minor syntax change to standardize type usage. |
StyleHelper.cs | Altered the logic order in the deferred resource check to prioritize Freezable types. |
SystemResources.cs | Refactored DeferredResourceReference and related classes to use separate _key and _value fields and updated removal logic accordingly. |
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/ResourceDictionary.cs:713
- [nitpick] The private Contains method shares its name with the public Contains method, which may lead to confusion. Consider renaming it to better reflect its specialized behavior.
private void Contains(object key, bool mustReturnDeferredResourceReference, out bool contains, out bool containsBamlObjectFactory)
src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/ResourceDictionary.cs
Outdated
Show resolved
Hide resolved
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #10532 +/- ##
===================================================
+ Coverage 12.66562% 13.05569% +0.39006%
===================================================
Files 3316 3316
Lines 665321 665434 +113
Branches 74667 74674 +7
===================================================
+ Hits 84267 86877 +2610
+ Misses 578844 576217 -2627
- Partials 2210 2340 +130
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/ResourceDictionary.cs
Show resolved
Hide resolved
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.
@batzen apologies for the delay in getting started with this. At this state the changes LGTM and we will include this in the next
test run.
src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/ResourceDictionary.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/ResourceDictionary.cs
Outdated
Show resolved
Hide resolved
@batzen The test pass of this is done with, can you please resolve the conflicts? We can take this PR in post that. |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
e675765
to
c08649b
Compare
Rebased and resolved conflicts. |
...oft.DotNet.Wpf/src/PresentationFramework/System/Windows/Markup/Baml2006/Baml2006KeyRecord.cs
Outdated
Show resolved
Hide resolved
Not sure why the build is failing. |
src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/ResourceDictionary.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/ResourceDictionary.cs
Show resolved
Hide resolved
* Fixes the layout and resource usage for PasswordBox (#10768) * Fixed PasswordBox style * Fixes minor issues in the new PasswordBox style * [Fluent] Fixes mulitple issues is TextBox and TextBoxBase styles (#10756) * Fixes issues is TextBox and TextBoxBase styles * Minimizing extra non functional changes * Matching parity with Aero2 for TextBox style * [Fluent] Fixes multiple issues in DatePicker style (#10688) * Fixes multiple issues in DatePicker style * Reintroduced commented .NET 9 DatePicker resources * Improving DynamicResource performance (second try) (#10532) * Using alternative storage for dynamic resources * Fixing removal * Removing not required check Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Improving Contains * Addressing PR feedback * Adjusting code to false positive IDE warning... * Addressing PR feedback --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Ignore DR Optimization preferences --------- Co-authored-by: Dipesh Kumar <85861525+dipeshmsft@users.noreply.github.com> Co-authored-by: Bastian Schmidt <batzen@gmx.org> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Second try to improve performance of DynamicResource.
This approach should not cause issues like #10491.
Original issue is still #4468.
Original PR was #5610 with follow up PR #9393 with opt out switch introduced in #9501 and final opt-in switch added in #10516.
Feedback on the approach is very appreciated.
Microsoft Reviewers: Open in CodeFlow