镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

Report a null key in OrderedMap.AddRange as "pairs" [patch] - #156

Open
matt-edmondson wants to merge 1 commit into
mainfrom
fix/155-addrange-null-key-paramname
Open

matt-edmondson wants to merge 1 commit into
mainfrom
fix/155-addrange-null-key-paramname

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Fixes #155

What changed

  • OrderedMap.AddRange checked each key with Ensure.NotNull((object?)pair.Key), so its ArgumentNullException.ParamName was the cast text (object?)pair.Key. It now calls a new NullKey.ThrowIfNullInPairs helper, which reports pairs, the method's own parameter. This matches how OrderedMap(IDictionary) reports dictionary.
  • I also checked for other Ensure.NotNull((object?)…) casts, as the triage asked. AddRange was the only one left.

Tests

  • Added 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 be pairs and the map should be unchanged.
  • With the fix reverted, the new test fails (Expected strings to be equal). With the fix it passes.
  • The full suite passes: 580 tests on net10.0.

Generated by Claude Code

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
@sonarqubecloud

Copy link
Copy Markdown

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OrderedMap.AddRange reports a null key with ParamName "(object?)pair.Key": #146's symptom is back in the method #150 added

2 participants