Skip to content

Review fixes for the generator and shared-internals refactors, and dead code removed - #305

Merged
electricessence merged 7 commits into
masterfrom
refactor/review-fixes
Dec 3, 2026
Merged

electricessence merged 7 commits into
masterfrom
refactor/review-fixes

Conversation

@electricessence

@electricessence electricessence commented Dec 2, 2026 •

Copy link
Copy Markdown
Collaborator

Follow-up to the generator refactor (#303) and the shared-internals refactor (#304), which merged before their review fixes, plus a round of dead-code and duplicated-text removal. Internal only: no public API change, and the generated text changes in one place, named below.

Review fixes for #303 and #304

  • Generator: IsNullableValue and Underlying put => on the next line, and the IsPartial call chain is one line. The generated text for the Bind change in Generator: share repeated code, no change to the generated text #303 was proved byte-identical for both emit sites: baseline from the generator before Generator: share repeated code, no change to the generated text #303, diff -r empty over the generated files of the generator tests (counters on and off) and the generated benchmarks; the five models that exercise the first site and the two that exercise the second are listed in the proof.
  • Shared internals: ExpressiveDbCommand keeps its formatting, added code lines are wrapped to the column limit, and four comments that repeated the same file's text are cut.
  • Behavior note for Share code that two places wrote twice, in the Core internals and the two pumps #304: in ProcedureSchemaNames.Names the check for rows from more than one schema now runs before the row loop. A malformed ORDINAL_POSITION on a row that comes before a row of another schema now returns no names instead of throwing FormatException; the result for a well-formed table is identical.

Dead code and duplicated text removed

  • The generator no longer emits the Ordinals field of a layout or the l.Ordinals = o; line that stored into it: nothing read it. This is the one change to generated text: 70 lines in the generated test file (the field once, the store 17 times), and no test compares the generated text.
  • ArrayMapper documentation names its real callers (the capture and output reads) and drops "for generated code"; one duplicated comment in RowMap.cs is folded.
  • The Token = stores in the stored-definition output run, which nothing read, are gone; the repeated guards in IterateWhileAsyncInternal are gone (both callers guard first).
  • The sentence "DbQuery.Using throws ArgumentNullException for a null source" is once per type, not sixteen times; the two SingleResult documentation blocks are one shared include.
  • Two private EnsureOpen wrappers are inlined, an unused using static is removed, and a member of an internal type that said internal says public.

Left out on purpose: removing the non-generic connection-factory adapter. Making AsPool return the generic adapter would change which commands share procedure names (commands built from one factory function would share them), and that is a behavior change, not a refactor. It is the owner's call.

Cost

Nothing per call or per row. The only change on a run path is the generated layout setup, which no longer stores the ordinals (once per layout).

Reviews

Two lenses of Haiku reviewers (correctness of what was removed; repository rules and documentation) read the diff. Applied: the adapter change was reverted (the finding above), the first call of three chains stays on its receiver's line, the schema comparison's arguments are grouped, and the comment above the Using overloads says it covers every overload of the type. Not applied: three removed comments whose text repeated the same file.

Checks: Release 16,151 and Debug 16,130 tests pass (16 skipped), 0 build warnings on every target framework, 267 sample checks, VS MSBuild 0 errors, dotnet format style and analyzers clean on all 28 checks, DocFX 0 warnings, the style scan clean.

🤖 Generated with Claude Code

electricessence and others added 7 commits December 2, 2026 14:44
… cut repeated comments

Follow-up to the shared-code change, after the merge of master:

- Views.CommandCore is back to its two-branch form: the command inside a
  SingleResultDbCommand is never null (the one place that makes it checks the
  argument), so a fallback for null was dead code.
- ExpressiveDbCommand's `: base(` line keeps its original indentation; only the
  argument changed.
- Lines that this change added are wrapped at about 80 columns (the text-name
  helper, the procedure lookup command, the schema table reads, the
  NoMatch call).
- Comments that repeated what the next line says are removed (the bounds helper
  of ChunkSizes, the integer reader and the schema check of the procedure
  metadata, the chunk release in the stream).

No behavior change, no public API change, no cost per call or per row.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
A six-line helper is not worth a shared Core internal that two packages call.
The channel pump and the block pump each have their private CloseAsync again,
with the body they had before the helper was shared; the shared class is gone.
No other change.

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

Layout fixes in the generator's own code, no change to its behavior or to the
text it emits. The two Nullable helpers in ModelReader put their expression
body's arrow on the next line, and the partial check in ModelReader keeps its
single call chain on one line.

The generated file of the generator tests (counters on and off) and of the
generated benchmarks is byte-identical to the one the generator made before
the previous change, so that change's two partial-model Bind sites are covered
too: five models exercise one, two trusted models the other.

Checks: whole solution Release build without warnings; generator tests in
Release; dotnet format style and analyzers on the generator.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Internal removals and consolidation. No behavior change and no cost per call
or per row: everything removed was never read, or is the same code written twice.

- The source generator no longer emits the layout's `Ordinals` field and the
  `l.Ordinals = o;` store: nothing reads it. This changes the generated text,
  and only that: a before and after comparison of the generated files differs by
  exactly those lines (the field and its comment once, the store once per layout).
  No test compares the generated text.
- The command-path cancellation token store on an output run is dropped from the
  two query-definition paths that never read it (the command path sets and reads
  its own).
- The private `EnsureOpen` and `EnsureOpenAsync` command helpers, each with one
  caller, are inlined at that caller.
- `IterateWhileAsyncInternal` no longer repeats the null checks that both of its
  callers already make.
- The non-generic `ConnectionFactoryToPoolAdapter` is deleted. `AsPool` on a
  factory or a function now returns the generic adapter over `IDbConnection`,
  and the name-cache owner switch loses its second arm. A null factory still
  names `factory` in the exception.
- `ArrayMapper` and its region are documented with their real callers (the
  output and capture reads), not "generated code" and the Channel and Dataflow
  pipelines.
- A comment that said the same thing twice on the per-model-type statics of
  `RowMap<T>` is folded into one.
- The sentence about `DbQuery.Using` throwing for a null source is written once
  per type in the scalar and non-query definitions instead of on every overload.
- The two `SingleResult` doc blocks share their common paragraphs through one
  include in `Mapped.docs.xml`.
- An unused `using static` in the MSSqlClient synchronous transaction extensions
  is removed.
- `DirectStream.HasTimer`, an `internal` member of an internal type, is `public`.

Checks: solution Release build with no warnings on every target framework; Core
and Generator tests in Release; `dotnet format` style and analyzers at info
severity on the touched projects and their tests; the docs build.

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

The non-generic connection-factory adapter stays. Making AsPool return the
generic adapter would change what the procedure-name cache shares between
commands built from one factory function (it would share across them, where
today each command has its own), which is a behavior change and not a
refactor.

Also: the first call of three chains stays on its receiver's line, the
schema comparison's arguments are grouped, and the comment above the Using
overloads says it covers every overload of the type.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The shared helper in Core stays: both pumps call AsyncEnumerators.CloseAsync,
as before the earlier commit of this branch, which removed it.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@electricessence
electricessence merged commit 4c7ee14 into master Dec 3, 2026
9 checks passed
@electricessence
electricessence deleted the refactor/review-fixes branch December 3, 2026 01:17
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