Improve DirtyFlagMap dirty flag correctness and mark Get() obsolete#2986
Merged
Conversation
…1417) - Add [MaybeNullWhen(false)] to TryGetValue out param (NET8_0_OR_GREATER) - Only set dirty flag when indexer setter value actually changes - Fix Put() to set dirty after operation, not before (bug: dirty was set even when subsequent operation threw) - Only set dirty in Put() when value differs from current - Mark Get(TKey) as [Obsolete] and replace all internal callers with indexer - Add PutAll dirty-flag tests Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
|
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.



Summary
Non-breaking improvements to
DirtyFlagMap<TKey,TValue>from #1417:[MaybeNullWhen(false)]toTryGetValueout param (onNET8_0_OR_GREATERonly, older TFMs lack the attribute on the interface)EqualityComparer<TValue>.Default)Put()sets dirty after the operation (was a bug — dirty was set even when the subsequent operation threw on null key), and only when value differsPutAllbenefits automatically from items 6+15, no code change neededGet(TKey)marked[Obsolete], all 6 internal callers replaced with indexer accessWhat's NOT in this PR (breaking changes for main/4.x)
Items 1, 2, 4 (removal), 5, 7, 8, 10, 11, 12, 13, 14 (return type change) — these are all breaking API/behavior changes tracked separately.
Test plan
PutAlldirty-flag testsnet10.0Closes the non-breaking subset of #1417.
🤖 Generated with Claude Code