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.
Cache Brushes #36405
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
Uh oh!
There was an error while loading. Please reload this page.
Cache Brushes #36405
Changes from 17 commits
9f8df77e6a017e62f7add4cde161ff4b3491622d0c96f7a9077b3c481c9c308d98ec21201e243cbb9bfded00d5717519be0d562df317b1a9e351aa442877ed3c80b8a019810006aacbfFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
There are no files selected for viewing
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.
[major] Threading/static state — This makes every public
Color/SolidPainttoBrushconversion mutate one process-wide cache, but the cache implementation usesDictionary/LinkedListand explicitly documentsLRUBrushCacheas not thread-safe. The previous conversion was stateless. Concurrent conversions can corrupt the cache or throw; make the static cache synchronized/thread-safe or keep the conversion allocation-local.Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
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.
[major] Public behavior change — The implicit
Colorconversion used to return a fresh mutableSolidColorBrush; it now returns a cachedImmutableBrush. Code such asvar b = (SolidColorBrush)(Brush)Colors.Red; b.Color = Colors.Blue;used to update that independent brush, but now silently no-ops and shares the instance globally. Avoid changing the mutability contract of this public conversion, or explicitly account for the breaking behavior with API review/tests.Uh oh!
There was an error while loading. Please reload this page.
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.
[critical] Build / netstandard compatibility —
Controls.Core.csprojstill targetsnetstandard2.0/netstandard2.1, but this new unconditional code uses APIs that are not available in the netstandard reference assemblies (CollectionsMarshal.GetValueRefOrAddDefaulthere, plusThrowIfNegativeOrZero/ThrowIfNullin the new cache types). Existing code such asBindableObject.GetOrCreateContextguardsCollectionsMarshalwith#if !NETSTANDARD; this needs the same fallback or netstandard-safe dictionary code.Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.