Skip to content

Replace static ImagingCache with instanced WeakReferenceCache<K, V>#10543

Open
h3xds1nz wants to merge 7 commits intodotnet:mainfrom
h3xds1nz:improv-imaging-cache
Open

Replace static ImagingCache with instanced WeakReferenceCache<K, V>#10543
h3xds1nz wants to merge 7 commits intodotnet:mainfrom
h3xds1nz:improv-imaging-cache

Conversation

@h3xds1nz
Copy link
Member

@h3xds1nz h3xds1nz commented Mar 6, 2025

Description

Replaces static ImagingCache used within BitmapDecoder and BitmapImage with a more OOP-friendly solution of WeakReferenceCache<K, V>, using strongly-typed generic version for WeakRefs and using Lock instead of locking on instance.

This behaves the same way as the previous one. And another ArrayList definition gone.

Customer Impact

Cleaner codebase for developers mostly, improved performance/allocs during cleanups.

Regression

No.

Testing

Local build.

Risk

Should be low but review carefully.

Microsoft Reviewers: Open in CodeFlow

@h3xds1nz h3xds1nz requested review from a team as code owners March 6, 2025 20:01
@dotnet-policy-service dotnet-policy-service bot added PR metadata: Label to tag PRs, to facilitate with triage Community Contribution A label for all community Contributions labels Mar 6, 2025
@codecov
Copy link

codecov bot commented Mar 6, 2025

Codecov Report

Attention: Patch coverage is 0% with 63 lines in your changes missing coverage. Please review.

Project coverage is 11.41030%. Comparing base (d94671d) to head (2cbd405).
Report is 57 commits behind head on main.

Additional details and impacted files
@@                 Coverage Diff                 @@
##                main      #10543         +/-   ##
===================================================
+ Coverage   10.99508%   11.41030%   +0.41521%     
===================================================
  Files           3215        3214          -1     
  Lines         648472      648414         -58     
  Branches       71534       71507         -27     
===================================================
+ Hits           71300       73986       +2686     
+ Misses        576170      573266       -2904     
- Partials        1002        1162        +160     
Flag Coverage Δ
Debug 11.41030% <0.00000%> (+0.51956%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@h3xds1nz
Copy link
Member Author

h3xds1nz commented Mar 8, 2025

@ThomasGoulet73 I've made a few more changes, if you get a minute, please review.

@ThomasGoulet73
Copy link
Contributor

@ThomasGoulet73 I've made a few more changes, if you get a minute, please review.

LGTM now, thanks.

@elachlan
Copy link

Your WeakReferenceCache seems similar to the solution here (though slightly different): dotnet/runtime#30759

We wanted something similar in winforms, I am not sure it ever got done. Maybe chime in on the issue to see if we can get more traction to implement in runtime?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Community Contribution A label for all community Contributions PR metadata: Label to tag PRs, to facilitate with triage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants