Skip to content

Small fixes: async disposal in UsingAsync, blank return-parameter names, argument names, one enumeration message - #315

Merged
electricessence merged 4 commits into
masterfrom
fix/rc18-small-fixes
Dec 4, 2026
Merged

electricessence merged 4 commits into
masterfrom
fix/rc18-small-fixes

Conversation

@electricessence

@electricessence electricessence commented Dec 4, 2026 •

Copy link
Copy Markdown
Collaborator

Small fixes, each with a test that failed before the change.

  • UsingAsync on a connection factory or a function disposes asynchronously. It disposes the connection the way a connection scope does: DisposeAsync when the connection implements IAsyncDisposable (every DbConnection), Dispose otherwise. It called Dispose before, so a provider's asynchronous disposal was never used. All six overloads that dispose a connection they created are covered (IDbConnectionFactory, IDbConnectionFactory<T>, and the Func<T> forms). Cost: one type check per call.
  • A blank name for AddReturnParameter is no name. The overload with a DbType, and the SQL Server one with a SqlDbType, treat an empty or white-space name as no name, as the overload without a type and a null name already did. They threw ArgumentException before.
  • Argument name. AsGeneric on a null IDbConnectionPool throws ArgumentNullException named connectionPool (it named an internal parameter, source). The private wrapper it makes no longer checks its argument itself: AsGeneric, its only caller, does, and the wrapper asserts it in debug builds.
  • One message for a second enumeration. The text is one constant, StallStream.EnumeratedTwiceMessage, used by the row stream and by the chunk stream (which had its own, shorter text). The tests refer to the constant.
  • Rename, no behavior change. The private RowMap method ColumnIndex is OrdinalsByName, so it no longer shares a name with the internal ColumnIndex type.
  • A test no longer depends on test order. A theory of ProcedureSchemaNamesTests used dbo.names1, which the test helper that names procedures also hands out first; since qualified names are remembered for every connection of one kind (Share the parameter names of a schema-qualified procedure by server and database #314), it failed in CI when the helper's test ran first. The theory uses names the helper never gives out. Tests only.

The release notes list the three changes a caller can see. No public API change (the PublicAPI files are untouched). The System.Data.SqlClient package is left as it is.

Tests: 17 new or changed tests; 7 failed on the unfixed code (UsingAsync 1, AddReturnParameter 4 across Core and the SQL Server package, AsGeneric 1, the chunk stream message 1) and none fail now. One existing test that pinned the old parameter name source for the pool now pins connectionPool.

Verification: solution Release and Debug (VS MSBuild) 0 warnings, 0 errors; Core.Tests 16229 passed with the generator on, 16208 passed and 16 skipped with it off; 267 sample checks; style and analyzer checks 0 findings on all projects; docfx 0 warnings; style scan clean. Each literal of 12 or more characters this change adds appears once in Source and Tests, apart from the ParamName strings tests pin (connectionPool, connectionFactory) and one repeated XML doc sentence.

🤖 Generated with Claude Code

electricessence and others added 4 commits December 4, 2026 05:52
…es, argument names, one enumeration message

UsingAsync on a connection factory or a function now disposes the connection the way a connection scope does: DisposeAsync when the connection implements IAsyncDisposable (every DbConnection), Dispose otherwise. It called Dispose before, so a provider's asynchronous disposal was never used. The cost is one type check per call.

AddReturnParameter with a DbType, and the SQL Server one with a SqlDbType, now treat an empty or white-space name as no name, as the overload without a type and a null name already did. They threw ArgumentException for a blank name before.

AsGeneric on a null IDbConnectionPool now throws ArgumentNullException named connectionPool (it named an internal parameter, source). ToChannel(query, channel) with both arguments null now names the first parameter, source, as the ChannelWriter overload does; it named channel.

The message for a second enumeration of a stream is one constant, StallStream.EnumeratedTwiceMessage, used by the row stream and by the chunk stream; the chunk stream had its own text. The tests refer to the constant.

The private RowMap method ColumnIndex is renamed OrdinalsByName, so it no longer shares a name with the internal ColumnIndex type. No behavior change.

Each behavior change has a test that failed before the change. The release notes list the four changes a caller can see.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…callee, and the pool wrapper's to AsGeneric

ToChannel(query, channel) checked the query itself before the call that takes the channel's writer, which checks it again. The first overload now checks only what it uses before the callee does (the channel), with a comment that the query is guarded by the ChannelWriter overload. With both arguments null the exception names the channel again; the test pins that, and the release note for the name is dropped.

The private wrapper that AsGeneric makes around a non-generic pool no longer throws for a null pool: AsGeneric, its only caller, checks the argument and names it, and the wrapper asserts it in debug builds.

No public API change.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
# Conflicts:
#	docsite/articles/release-notes.md
The theory that checks how a procedure name is split into the restrictions of the schema read used the name dbo.names1. The test helper that gives each test a fresh procedure name hands out dbo.names1 too, as its first name. A qualified name is now remembered for every connection of one kind, so when a test that uses the helper ran first, the theory's call found the names already remembered, read no schema and recorded no restrictions, and the assertion failed. Whether it failed depended on the order the tests ran in, and it did in CI.

The theory now uses names the helper never hands out.

Tests only: no run-time change.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@electricessence
electricessence merged commit 5a68779 into master Dec 4, 2026
9 checks passed
@electricessence
electricessence deleted the fix/rc18-small-fixes branch December 4, 2026 15:12
electricessence added a commit that referenced this pull request Dec 4, 2026
…en one is fixed (#316)

The remembered parameter names of a schema-qualified procedure are kept for the whole process, by server, database, kind of connection and procedure text (#314). Most test fakes reported the same fixed server name (`fake`, `gate`, `output` and so on), so a test could find names another test had left for the same procedure text, and pass or fail by the order the tests ran in. The theory in `ProcedureSchemaNamesTests` that failed in CI on #315 was one such case (#315 renamed its procedure names; this change removes the class of problem).

- **Every fake connection reports its own server name.** Each now takes it from `NameServer.Unique`, which already existed. A fake that stands for one server across several connections of one test (the tracked connections of a tally, the connections of a token rig, the connections of a database rig) takes the name once for the tally or rig instead of once per connection, so what a test counts across those connections keeps its meaning. A fake that reports no server at all (the gated connection of the ConfigureAwait test) stays as it is: a connection that names no server is never shared.
- **A guard fails when it comes back.** `SharedTierIsolationTests` reads the test project's own source files and fails when a type reports a string literal as its server name (except that one allowed fake, with its reason), or when a test file uses a procedure name of the form `ParameterNameHarness.NewProcedure` hands out (`dbo.names` followed by a number). The failure message says what is wrong and the fix. Seen failing: a fixed `fake` put back in one file and a `dbo.names3` in another made the two checks fail; both were restored before the commit.
- **No other channel into the shared table.** `Shared.ByProcedure.Count` is asserted only in the shared-tier collection, which runs alone, and the table is cleared only there.

Tests only: no run-time change, no public API change.

**Verification:** solution Release build 0 warnings, 0 errors; Core.Tests all passed in three runs with the test classes and collections shuffled (seeds 101, 202 and 303), and in the normal gate; 267 sample checks; style and analyzer checks 0 findings; docfx 0 warnings; style scan clean; each literal of 12 or more characters this change adds appears once.

🤖 Generated with [Claude Code](https://claude.com/claude-code)
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