Skip to content

Source: remove the eight Map<T>(pair...) overloads; Map(new RowMap<T>(pairs)) is the one way - #151

Merged
electricessence merged 4 commits into
masterfrom
feat/a3-remove-pair-maps
Nov 16, 2026
Merged

electricessence merged 4 commits into
masterfrom
feat/a3-remove-pair-maps

Conversation

@electricessence

Copy link
Copy Markdown
Collaborator

What this changes

Removes the eight Map<T>(pair…) overloads: on each of the four receivers (IExecuteReader, IDataReader, IDbCommand and DataTable) the single-pair form and the params ReadOnlySpan<KeyValuePair<string, string?>> form. Map<T>(…, RowMap<T>? map) is the one way to pass a map; the replacement for a pair list is Map(new RowMap<T>(pairs)).

  • Why: two ways to say the same thing, one of them a footgun next to Map<T>(null) overload resolution; the removal keeps Map<T>() and Map(RowMap<T>?) as the one typed entry.
  • Public API: two *REMOVED* lines for shipped members (the single-pair and params forms of the shipped receiver) and six lines deleted from the unshipped list. No overload is added.
  • Binding. A matrix over the four receivers on C# 12, 13 and 14, before and after (committed with a test that reads the called method out of each call's IL): on C# 13 and 14 Map<T>(null) and Map<T>(default) now bind to Map(RowMap<T>?) on all four receivers, with no new ambiguity. On C# 12 they were already ambiguous before this change, because the overload-priority attribute is ignored there. A collection expression still converts to RowMap<T> through its collection builder and binds Map(RowMap<T>?); only Map<T>(pair) and Map<T>(pair, pair) stop compiling.
  • One behaviour change to know about: Map<int>([]) (an empty collection expression for a single-value type) used to read the first column through the params form; it now builds a RowMap<int> and throws InvalidOperationException ("a single value, not a row model"). Map<Person>([]) is unchanged. One parity test now asserts the throw; two tests that covered the old behaviour are deleted.
  • Tests, samples and docs that used the removed forms now use Map(new RowMap<T>(pairs)) (10 test files, the docs-site sample, mapping.md and whats-new-11.md). The internal row-source seam and Map<T>()'s final call are untouched.

Checks

  • Release build of the whole solution with 0 warnings (the benchmark project builds too); the public-API analyzer reports nothing.
  • The full Core test project passes (10,302 tests) on net10.0 and net11.0; the legacy-compiler tests pass on net472, net8.0, net10.0 and net11.0; all 125 sample checks pass.
  • The full test gate and a Visual Studio MSBuild of the solution are green; leak scan clean.

🤖 Generated with Claude Code

electricessence and others added 3 commits November 15, 2026 15:33
…tead

The single-pair and params-pair Map<T> overloads on IExecuteReader (shipped),
IDataReader, IDbCommand and DataTable (unshipped) are removed. A pair belongs
in a RowMap<T>, so the cost of building a map and compiling its reader on
every call is visible at the call, and declaring the map once is the way to
avoid it. Map(new RowMap<T>(pair, ...)) is the replacement for a one-off.
Map<T>(null) now binds Map(RowMap<T>?) on C# 13 and 14 (it was the params
overload); it was already ambiguous on C# 12. The no-argument Map<T>() and
the RowMap<T> constructors are untouched.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The LegacyCompiler binding tests now run on every target (C# 7.3, 9, 12 and
13), with null, default and [] kept to C# 13. A stale RowMapTests comment about
pairs passed to Map<T> is reworded. whats-new-11 lists the run-time change of
Map<int>([]), and a grammar fix in mapping.md.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…nt in mapping.md

The previous docs commit merged the Map<int>([]) note into item 13 and dropped
item 14. Items 13 and 14 are back as they were, the note is item 15, and
mapping.md reads "builds a new map, and compiles the row reader".

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@electricessence
electricessence marked this pull request as ready for review November 16, 2026 01:09
@electricessence
electricessence marked this pull request as draft November 16, 2026 01:35
@electricessence
electricessence marked this pull request as ready for review November 16, 2026 01:37
…70 columns

The MapCallSite and MapPairs samples are async (ToArrayAsync with a token)
and write each pair on its own line. The 10.x and 11 snippet in whats-new-11
awaits the async call on both sides, with the pairs vertical. Comments this
PR added or changed are broken at natural breaks near 70 columns.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@electricessence
electricessence merged commit 9652a82 into master Nov 16, 2026
7 checks passed
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.

1 participant