Skip to content

Make AnyAsync and CountAsync one line each, run the legacy-compiler tests one framework at a time, remove two protected members, one const for each repeated message - #317

Merged
electricessence merged 10 commits into
masterfrom
chore/anycount-ci-message-sweep
Dec 4, 2026
Merged

electricessence merged 10 commits into
masterfrom
chore/anycount-ci-message-sweep

Conversation

@electricessence

@electricessence electricessence commented Dec 4, 2026 •

Copy link
Copy Markdown
Collaborator

Four small pieces for rc.18; the second removes protected members and is the last decided API change before the cut.

  • AnyAsync and CountAsync of a command with no model are one expression each. They call AsObjectArrays() and its AnyAsync / CountAsync, which build the same query core. The null check on the command is the one AsObjectArrays already makes (same exception type, same parameter name command), and the comment that says why the row source is never asked for a mapper stays. Run-time cost: a MappedQuery wrapper struct is created and its terminal forwards to the core; a before-and-after benchmark showed no gap worth keeping the longer body for.
  • Removed: the protected PrepareCommand(TConnection) and ConnectionProvider of ExpressiveCommandBase. Nothing in the library, its packages, the tests, the benchmarks or the docs called or overrode either. PrepareCommand(TConnection) only forwarded to the private overload, which the one internal caller now calls directly; ConnectionProvider returned the pool (or a provider made around a bare connection) and no member read it, so the field that cached it in the options block goes with it. Both are listed as removed in PublicAPI.Unshipped.txt and in the release notes (a subclass keeps its own reference to what it passed to the base constructor). The internal DbConnectionProvider class, whose last use that was, is deleted with its two tests; the one message it carried is now a private const of the command that throws it.
  • The legacy-compiler CI job runs one target framework at a time. It ran dotnet test with no framework, which starts the net8.0, net10.0, net472 and net11.0 hosts together; twice the three that are not net11.0 failed to connect within 90 seconds and the test code never ran, and both runs passed on re-run. The step now builds once, reads the target frameworks from the project (the list cannot drift from the .csproj), and runs dotnet test --no-build -f <framework> for each in sequence with its own TRX prefix. Every target runs even if one fails, and the step fails at the end if any did. A target that wrote no TRX file, or whose TRX counts zero tests, counts as a failure (--no-build -f exits 0 and runs nothing for a target that was not built). No retry and no longer connection timeout. Cost: three more host starts per run (tens of seconds). Run locally on all four targets (46, 46, 46, 48 tests pass, exit 0), with a zero-test TRX, and with an extra unknown target (the step fails, naming it, after the four real ones ran). The step passed on GitHub's runner in this PR's CI.
  • One text for each fact, and the fix in every message. A message, a name or an analyzer id that appeared more than once as a literal in Source and Tests is now one internal const (or one method, for a message with holes) and everything that used it refers to it; tests use the same const or method instead of copying a whole production message. New homes in Core next to ParameterNameMessages and CommandTextMessages: AnalyzerIds, SuppressionJustifications, TransactionMessages, ArgumentMessages and RowMapMessages; ParameterNameMessages, CommandTextMessages, CaptureMessages, OutputBinding, ReaderAbandon, ProcedureSchemaNames and MappedDbQueryExtensions gain consts and methods. Where two texts stated one fact, one remains: an empty command says CommandTextMessages.Blank everywhere, and one CannotDerive(expression) replaces three variants. The messages that named a problem without the fix (a negative argument, a type with no public constructor, a mapping with no property name, the parameter-name collisions) now say what to do; the docsite page that quotes the constructor message is updated. Other message text is unchanged word for word. Four CreateCommand overloads on transactions no longer repeat the check that the connection overload makes (same exception type and parameter name); one order change: a transaction with no connection and a null or blank text now throws the missing-connection error first.
    Left, with the reason, in the sweep notes: the same names written in the separate generator assembly, the documented AppContext switch name that a test pins on purpose, one literal in LegacyCompiler.Tests (no InternalsVisibleTo), and test assertions on fragments of a message (splitting a production message into pieces for them is a separate decision).

Verification: solution Release build 0 warnings, 0 errors; Visual Studio's MSBuild on the whole solution 0 errors; Core.Tests Release 16229 passed, Debug 16208 passed and 16 self-skipped; 267 sample checks; style and analyzers at info 0 findings in all 14 projects; docfx 0 warnings; style scan clean; PublicAPI diff is the two *REMOVED* lines only. Master (with the Roslyn pass) is merged in and the checks were run on the merged tree.

🤖 Generated with Claude Code

electricessence and others added 10 commits December 4, 2026 08:30
AnyAsync and CountAsync on a command with no model built the query core with the object-array row source themselves and called its terminal. They now call AsObjectArrays() and its AnyAsync and CountAsync, which build the same core, so each body is one expression and the null check on the command is the one AsObjectArrays already makes (same exception type, same parameter name, "command"). The comment that says why the row source is never asked for a mapper stays, reworded to say that the work goes through AsObjectArrays().

Run-time cost: a MappedQuery wrapper struct is created and its terminal forwards to the core. A benchmark of AnyAsync and CountAsync before and after showed no gap worth keeping the longer body for. The Core tests for AnyAsync, CountAsync and the object-array views pass (72).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The legacy-compiler job ran `dotnet test` with no target framework, which builds and runs all four targets (net8.0, net10.0, net472, net11.0) at the same moment. On the runner the three test hosts that are not net11.0 twice failed to connect within 90 seconds, and the test code never ran for them; both runs passed when re-run.

The step now builds the project once, reads its target frameworks from the project (so the list cannot drift from the .csproj), and runs `dotnet test --no-build -f <framework>` for each one in sequence, with its own TRX file prefix so no file overwrites another. Every target runs even if one fails, each failure is reported, and the step fails at the end if any target failed. `dotnet test --no-build -f` exits 0 and runs nothing for a target that was not built, so a target that wrote no TRX file counts as a failure too. There is no retry and no longer connection timeout: a host that cannot connect still fails the step.

Cost: three more test host starts per run (tens of seconds), no contention between them. The loop was run locally on all four targets (46, 46, 46 and 48 tests pass, exit 0) and with an extra unknown target (the step fails, naming it, after the four real ones ran).

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

Nothing in the library, its packages, the tests, the benchmarks or the documentation called or overrode either member. PrepareCommand(TConnection) only forwarded to the private PrepareCommand(TConnection, OutputRun?), which stays and which the one internal caller now calls directly. ConnectionProvider returned the pool, or a provider made around a bare connection, and no member read it; the field that cached that provider in the rarely-set options block is removed with it.

The two shipped members are listed as removed in PublicAPI.Unshipped.txt, and the release notes say what was removed and that a subclass keeps its own reference to what it passed to the base constructor. Run-time cost: none; a command that is built the same way is built the same way.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…de and its tests repeat

A message, a name or an analyzer id that appeared more than once as a literal in Source and Tests is now one internal const (or one method, for a message with holes), and everything that used the text refers to it. Tests no longer copy a production message or name: they use the same const. No message text changed word for word; joined literals were only re-wrapped.

New homes in Core, next to ParameterNameMessages and CommandTextMessages: AnalyzerIds and SuppressionJustifications (the SuppressMessage ids and the two reasons that repeat), TransactionMessages, ArgumentMessages, MappedDbQueryMessages and RowMapMessages (the checks on a type that a row map builds, which UnmappableTypeTests had copied whole). ParameterNameMessages gains the not-known, name-one-explicitly, not-supplied and tier texts; CommandTextMessages, CaptureMessages and OutputBinding gain one const each; ProcedureSchemaNames holds the SQL Server parameter-names query that the two SQL Server packages both wrote out. Four private consts that tests copied (ReaderAbandon.Option and the two attribute names in Shape) are public on their internal types.

Repeats that stay are listed with the reason in the sweep notes: the same names written in the separate generator assembly, the documented AppContext switch name that a test pins on purpose, and test-owned text.

Run-time cost: none on a hot path; the messages are built on the same failure paths as before, through a method instead of inline.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
RowMapMessages.Bag is now DictionaryOrDynamic, after the check it describes. The message holders end with a newline and have a blank line above their first const, as the constants in the other holders do (also CaptureMessages, OutputBinding, ReaderAbandon and Shape); long lines and summaries in the code the sweep added are wrapped to about 80 columns. AnyAsync and CountAsync put the second call of the chain on its own line. The AddParam-after-Map message returns to MappedDbQueryExtensions as an internal const (its naming rule gives it the underscore prefix), and the file that held it alone is removed. DerivedNameCostTests now uses ParameterNameMessages for the three texts it copied. No message text changed word for word, and the public API is unchanged.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
… the fix in every message

Messages may change here, by the owner's rules. A message that says what is wrong
now also says what to do, and a text is written once.

- The empty-command text of CreateCommand (Core, SqlClient, and
  Transaction.CreateCommand) is CommandTextMessages.Blank; EmptyOrWhiteSpace is gone.
- One "cannot derive a parameter name" text, ParameterNameMessages.CannotDerive, with
  the fix and filter.AuthorId as the example, used by DbQueryCall, ExpressiveCommandBase
  and ParameterNames.
- The DataReaderExtensions justification reads SuppressionJustifications.OverloadForEasierConsumption.
- ArgumentMessages.NotNegative, RowMapMessages.NoConstructor and RowMapMessages.NoPropertyName
  now say what to do; docsite/articles/mapping.md shows the new constructor text.
- New homes for texts the tests copied: the collision and ambiguity of parameter names
  (ParameterNameMessages), the empty column name (RowMapMessages.EmptyColumn), the capture
  sync-call fact (CaptureMessages.OnlyAsyncTerminals), the delivered-output fix
  (OutputRun.ReadToTheEnd), and the sources named by the CancelOnEarlyStop refusal
  (ReaderAbandon). The tests reference them.
- Four sentences that Capture.cs wrote twice are consts of CaptureMessages.

The public API is unchanged.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ble guard, no DbConnectionProvider

- ParameterNameMessages.Collision builds the whole collision text, joining spaces
  included; DbQueryBinding and ExpressiveCommandBase call it, and so do the pinned tests.
- The CreateCommand overloads on a transaction (Core, MSSqlClient, SqlClient) no longer
  check commandText: the connection overload they call checks it the same way.
- DbConnectionProvider is deleted: its last use went with ConnectionProvider. Its message
  is a private const of ExpressiveCommandBase, its only user. Two tests that existed
  only for the class are deleted.
- The brace indent of RowMap.Declare is fixed.
- The legacy-compiler CI step fails a target framework whose TRX file counts no tests.

The public API is unchanged.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Calls to ParameterNameMessages.Ambiguous and ParameterNameMessages.Collision had one
argument per line; the arguments that belong together now share a line. No text changes.

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

No text changes.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@electricessence
electricessence merged commit 7bddacf into master Dec 4, 2026
9 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