Skip to content

fix: make Join(items, separator, nullItemHandling) reject a null separator [patch] - #145

Merged
matt-edmondson merged 1 commit into
mainfrom
fix/join-null-separator
Sep 29, 2026
Merged

matt-edmondson merged 1 commit into
mainfrom
fix/join-null-separator

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Join(items, null, <any NullItemHandling>) now throws ArgumentNullException with ParamName == "separator", as its XML docs say. Before this, the null separator went straight into string.Join, which treats it as "", so new[] { "a", "b" }.Join(null!, NullItemHandling.Remove) returned "ab".

The guard is the same one the two-argument overload already has. It runs before the NullItemHandling.Throw scan, so a null separator is reported even when the items also contain a null.

Tests

  • New data-driven test JoinWithNullItemHandlingThrowsArgumentNullExceptionWhenSeparatorIsNull covers Remove, Include, and Throw, and checks ParamName.
  • With the fix reverted, all three rows fail. With it, the full suite passes (162 tests), and dotnet build is clean on every target framework.

Fixes #144

🤖 Generated with Claude Code

https://claude.ai/code/session_01VwgZGoivWyqL4pWDsenTPm


Generated by Claude Code

…rator [patch]

The three-argument overload documented ArgumentNullException for a null
separator but passed it straight to string.Join, which treats null as "".
It now carries the same guard as the two-argument overload.

Fixes #144

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VwgZGoivWyqL4pWDsenTPm
@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.

Join(items, null, NullItemHandling) returns the items concatenated instead of throwing the documented ArgumentNullException

2 participants