Repository navigation
Report a null key in OrderedMap.AddRange as "pairs" [patch] - #156
Open
matt-edmondson wants to merge 1 commit into
Open
matt-edmondson wants to merge 1 commit into
matt-edmondson wants to merge 1 commit into
Conversation
AddRange checked each key with Ensure.NotNull((object?)pair.Key), so the ArgumentNullException carried the cast text as its ParamName. It now goes through a NullKey helper named for the method's parameter, as the other map entry points have since #146. Fixes #155 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017vfJW3WKKpY45VJvchCp92
|
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 #155
What changed
OrderedMap.AddRangechecked each key withEnsure.NotNull((object?)pair.Key), so itsArgumentNullException.ParamNamewas the cast text(object?)pair.Key. It now calls a newNullKey.ThrowIfNullInPairshelper, which reportspairs, the method's own parameter. This matches howOrderedMap(IDictionary)reportsdictionary.Ensure.NotNull((object?)…)casts, as the triage asked.AddRangewas the only one left.Tests
NullKeyParamNameTests.OrderedMap_AddRangeWithNullKey_ReportsPairsAndLeavesMapUnchanged. It checks a batch that is just the null key and a batch where the null key comes after a valid pair. In both cases the ParamName should bepairsand the map should be unchanged.Expected strings to be equal). With the fix it passes.Generated by Claude Code