Skip to content

Pass 6: shared helpers, ChunkConfig as the bin's runner, one blank-name message, bad ordinal fix - #311

Open
electricessence wants to merge 11 commits into
masterfrom
refactor/rc18-pass6
Open

electricessence wants to merge 11 commits into
masterfrom
refactor/rc18-pass6

Conversation

@electricessence

@electricessence electricessence commented Dec 3, 2026 •

Copy link
Copy Markdown
Collaborator

Internal cleanups and one bug fix. No public API change.

  • Bug fixed: a row of the ProcedureParameters schema collection whose ORDINAL_POSITION is not a number that fits an int failed the call that looks up a procedure's parameter names. The output-parameter metadata read already treats such a value as unknown, and the lookup's documentation says unknown gives an empty answer. The lookup now skips the row, with the one shared parser. A new theory covers a text value, DBNull, long.MaxValue and an out-of-range text number; the three values other than DBNull failed before the fix (FormatException, OverflowException), and the DBNull row is coverage only (it was already skipped). The release note is in a new "Changes since rc.17" section.
  • One text for each fact: the blank parameter-name message ("Pass the name of a parameter of the command." now says the fix), the message for a missing name on a non-return parameter, and the blank command text each exist once, as an internal constant in Core that the two SQL Server packages and the tests reference. The schema column names (PARAMETER_NAME, ORDINAL_POSITION, SPECIFIC_SCHEMA, and the mode and scale columns) are constants beside ProcedureSchemaNames.Collection, and the tests use them and ProcedureSchemaNames.Collection instead of copies. The stub ProcedureParameters table the tests built by hand in four places is one test helper. Tests no longer copy a production message into their own constant.
  • CONTRIBUTING.md gets the rules: a wrapped initializer starts its continuation with =, one text for each fact as a named constant, and tests reference the production constant.
  • Both ScalarValue helpers are removed; their callers use DBNullValueToNull, which gives the same result (DBNull is a singleton).
  • ToDataTable and ToDataTables go through ExecuteReader like their siblings; guards and disposal are unchanged. Cost: one static delegate call per call.
  • PooledArray's explicit ICollection<T>.CopyTo keeps its argument checks and then calls the span CopyTo.
  • ChunkConfig<T> is the recycle bin's runner, and the separate ChunkRunner<T> and the object Config field are gone. The bin is still one for every T; a throwaway test showed 0 bytes allocated on the releasing thread for 1,000 deferred releases (the test is not kept).

Verification: solution Release and Debug (VS MSBuild) 0 warnings, 0 errors; Core.Tests 16158 passed with the generator on, 16137 passed and 16 skipped with it off; 267 sample checks; style and analyzer checks 0 findings on all projects; docfx 0 warnings. A scan of the literals of 12 or more characters this change adds or touches finds each once in Source and Tests. The style scan shows one advisory: the new theory's four-item data member has the same shape as the one beside it.

Reviews: a behavior-preservation lens (no defect) and a rules-and-tests lens (findings applied: line wrapping, the other message sites, the release-note section and wording).

🤖 Generated with Claude Code

electricessence and others added 11 commits December 3, 2026 13:50
The sync scalar transform and the async command bases each had a private helper that turned a DBNull scalar into null. CoreExtensions.DBNullValueToNull already does that for the row readers, so the transform overloads call it and both helpers (one with its doc block) are gone. DBNull is a singleton, so the reference comparison and the type test give the same answer for every value.

No behavior change; the same one comparison per scalar call.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The two blocking command extensions repeated the guard, the open-and-execute and the using that ExecuteReader(transform) already has. They now pass a static transform to it, like the sibling right below them: same null check (ArgumentNullException for "command"), same reader disposal, same behavior argument.

Cost: one call through a cached static delegate for each ToDataTable or ToDataTables call; no allocation.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The explicit ICollection<T>.CopyTo kept its own copy of the chunk loop. It keeps its argument checks (null, negative index, destination too small, same exceptions and messages) and then calls CopyTo(Span<T>), which does the same chunk-by-chunk copy. Run time is the same copy; the one extra length check in the span overload is a compare.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The recycle bin queued a work item made of a per-row-type runner object, the array, the row count and the configuration as object, and the runner cast the configuration back. The configuration now implements RecycleBin.IRunner itself, so a work item is the runner, the array and the row count, ChunkRunner<T> and its static instance are gone, and the loop no longer casts the configuration. The interface is not generic, so one bin still serves every row type.

Cost on the release path: none. Posting a deferred chunk passes the configuration as an interface reference (no boxing, no allocation) in place of the static runner, and the work item is one field smaller. Checked with a throwaway test: 1,000 deferred releases on a warmed bin allocated 0 bytes on the releasing thread.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…okup

The lookup of a stored procedure's parameter names converted ORDINAL_POSITION with Convert.ToInt32 and no guard, so a provider that reports a value that is not a number, or one that does not fit an int, failed the call with FormatException, InvalidCastException or OverflowException. The check of output parameters reads the same column through TryInt and treats such a value as not known, and the lookup's own docs say not known gives no names. The lookup now uses the same TryInt (one home, in ProcedureParameterMetadata) and skips the row; the other parameters are still found.

Tests: a stub schema connection whose ordinal column holds a string, DBNull, a long and a numeric string that overflows an int, beside a good row; the call must not throw and send only the good row's name. Before the change the string and the two overflow cases failed with FormatException and OverflowException from the lookup; DBNull was already skipped.

Cost: none on the normal path (a number converts as before); a bad value is now caught inside TryInt instead of escaping. The release note has a Fixed line.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Adding a parameter to a stored query call with a blank name threw "Parameter names cannot be empty or white space." and stopped there. It now adds "Pass the name of a parameter of the command." The key phrase and the ParamName are unchanged, and the test that pins the text is updated.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…se note its own section

A blank parameter name raised the same message in five places, one of which now says what to pass. The other four (the command's own check, the add-parameter extension in Core, and the two SQL Server packages) now use the same wording, so the one condition has one message that says the fix. The messages are wrapped to the layout rules and the wrapped throws are braced.

The release note for the ordinal fix moves to a new "Changes since rc.17" section, since rc.17 is published, and no longer refers to another check that readers cannot see.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…e command's own check

The wrapped throws made the one-line conditions around them multi-line, so the style check asked for braces on the whole if chain. The bodies are indented under their braces.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
… line

A wrapped constant now starts its continuation line with the equals sign, as an expression body starts with its arrow, so the sign and the plus of a joined literal line up. The constants beside them take the same shape. Layout only.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…sign of a wrapped initializer on its next line

The blank parameter name message was written out at five places and the message for a missing name on a non-return parameter at three, in Core and in the two SQL Server packages. Each is now one constant in an internal class in Core, which the provider packages can see, and every place references it. The definition's name check passes the constant instead of an inline joined literal. The one-line checks go back to their original unbraced shape.

CONTRIBUTING.md gets the two rules: a wrapped initializer starts its continuation with the equals sign, and one text for each fact, as a named constant. The constants beside the first one take the same shape, each with a blank line above it.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ve the tests reference it

The blank command message now lives once in a Core constant that the command text check and its tests both use, and the parameter name message the tests used to copy is now referenced from its constant. The schema column names the procedure parameter reads used (parameter name, ordinal position, specific schema, parameter mode, numeric scale) are constants beside the collection name, so the metadata reads, the name reads and the tests all name them from one place. The concurrent-use message a connection source test copied is referenced from its constant as well.

The four hand-built stub tables of the procedure parameter collection are one test helper. The tests behave as before; the output metadata stub gains an unread procedure name column so that it shares the helper.

CONTRIBUTING.md says that a test does not copy a production name or message into its own constant but references the internal one. No message text changed and there is no run-time change.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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