Repository navigation
Share code the Core internals wrote twice, tidy names, messages and comments - #306
Merged
Merged
Conversation
…s with named methods
No public API change and no change to generated code. The cost is none per call or per row: every change is on a declaration, chain-building or error path, or is a property read or a call that inlines.
- A capture's task is read by two methods, one that only needs the terminal to have started (AsTask) and one that also refuses an open stream (await), instead of one method taking a bool. A capture marks its stream open and closed with two methods, not a bool.
- A set of captures is extended with WithOnCommand or WithOnQuery instead of a bool; the word the messages use ("command" or "query") now comes from the set's own Noun, in one place. A capture of the return code beside a call that reads it is refused by one method on the set, which the command and the bound call both use.
- The capture of an output model builds its display text once, and the return-code capture of a captured ExecuteReturnAsync now shows the typed form of the call in its messages, like the uncaptured one.
- The eight capture overloads of a bound call share one helper that adds the capture and hands back its handle.
- A definition's call that reads outputs builds its command through the same method as a plain call, then adds the outputs, instead of repeating its ten lines. The test for a procedure whose metadata is still to be read is one property on the name set, used by the command and the definition runner.
- The declared type name of an output member is read by the same attribute reader the row map uses (Decoration), instead of a second walk over the attributes. The decimal call texts in the "no output matches" message come from the same two helpers the argument checks use, with the same wording.
- The output definitions share one place that names the definition in a refusal, one place that checks a decimal's precision and scale, and the model's refusal no longer repeats its own catch block.
- ReturnCode keeps the type check and the message in a non-generic class, and the generic one only what depends on the type.
- CaptureNames: the redundant null-forgiving operators after the white-space check are removed.
- The documentation samples read SAMPLES_BLOG_CONNECTION with string.IsNullOrWhiteSpace, so an empty value falls back to LocalDB as an unset one does.
Checks: solution Release build with 0 warnings on every target framework; Core.Tests Release 16151 passed; Generator.Tests Release 189 passed; dotnet format style and analyzers at info severity on Core, Core.Tests and the samples: 0 findings; docfx build with 0 warnings and 0 errors; style scan clean.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Members of internal types are public or private, not internal (the channel and dataflow pumps, the parameter-name caches and sets, the schema-name reader, the view builders, the row reader, and the row-map helper types). ProcedureKey becomes a primary-constructor struct, as the analyzer asks once its constructor is public. The tests and benchmarks that reach these members by reflection look for public members now. Messages that said what is wrong now also say what to do: a blank command, a command whose type does not match the connection's provider, concurrent use of a single connection, a reader of the wrong type, and a transaction with no connection (the SQL Server package test that pins the transaction text and the blank-command test follow the new text). Names and comments: - the ExpressiveCommandBase method that built the procedure key is called KeyOf, and the producer's count of rows already handed on is _handedOn, so neither shares a word with a type or with the one-shot flag of the streams; - the generator's styleB flag is buildsAfterReading, and the Slot calls name their bool arguments; - the RowReader stream flag that meant "rows still to map" is reading. Comments only: a comment about DbQuery no longer sits above ExpressiveCommandBase; the long comments there are wrapped and placed over the members they describe; the no-timeout dispose rationale is written once, in the ChunkProducer header, and the buffer and the stream point to it; comments that cited a spike or a proof now say the record is not kept in the repository, or drop the citation; the CapturedStream header is shorter and states why ToException may cast; a dangling comment in RowMap is gone; the TextNameCache note moved into its remarks; two RowReader doc blocks are indented, and the second ToArray path says why its sink is disposed by hand; the Emitter header no longer cites a missing file and is wrapped at 80 columns; the three sentences that Stream and StreamBuffered repeat in IMappedQuery are one include. Cost: none (no per-call or per-row code changed). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…g assert Group the arguments of the decimal layout calls and of the output command build, put the `=>` of the procedure key on its own line, and rename the chunk producer's count of handed-over rows to match its comment. Drop a comment in the row reader that repeated an earlier one. Restore the UTF-8 byte order mark on the two `Transaction.CreateCommand.cs` files. The message for a transaction without a connection now says it can happen after the transaction completed, not only the one way; the test that pins it and the release note are updated, and the note no longer quotes the text. The mapped query's `Stream` and `StreamBuffered` now take the three sentences on the read thread from the `stream-your-thread` include that the interface already uses, so the two cannot drift. `CaptureSet.WithOnQuery` and `WithOnCommand` assert, in Debug builds, that the set they extend was made for the same kind of caller. No change in Release. No behavior change in Release. Checks: Release and Debug builds of the solution with 0 warnings; Core tests in Release (16151 passed) and Debug (16130 passed, 16 skipped); generator tests (189 passed); `dotnet format` style and analyzers at info severity, 0 findings on Core, MSSqlClient and Core.Tests; docs build with 0 warnings. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
# Conflicts: # docsite/articles/release-notes.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Internal refactor: code the Core internals wrote twice is shared, flag parameters become named methods,
internalmembers of internal types becomepublic, messages that said what is wrong now say what to do, and comments and names follow the written rules. No public API change (thePublicAPIfiles are untouched) and no change to generated code.What changed
Shared code, flags replaced by named methods (cost: none per call or per row: every change is on a declaration, chain-building or error path, or a property read or a call that inlines)
Started: only the terminal has started;Awaited: also refuses an open stream) instead of one with a bool, and marks its stream open and closed withBeginStreamandEndStream.WithOnCommandorWithOnQueryinstead of a bool; the word the messages use ("command" or "query") comes from the set's ownNoun. A capture of the return code beside a call that reads it is refused by one method on the set.ReturnCodekeeps the type-independent part in a non-generic class.SAMPLES_BLOG_CONNECTIONwithstring.IsNullOrWhiteSpace, so an empty value falls back to LocalDB as an unset one does.Rules and names
publicorprivate, notinternal.ProcedureKeybecomes a primary-constructor struct (the analyzer asks for it once its constructor is public); the tests and benchmarks that reach these members by reflection look for public members now.KeyOf(builds the procedure key),_handedOver(the producer's count of rows handed over),buildsAfterReading(the generator's formerstyleB),reading(the row reader's "rows still to map").ChunkProducerheader; comments that cited a record that is not in the repository now say so or drop the citation; the three sentences thatStreamandStreamBufferedrepeated are one shared include (stream-your-thread).Behavior notes
ExecuteReturnAsyncshows the typed form of the call in its messages (ExecuteReturnAsync<int>()), like the uncaptured one.CaptureSet.WithOnQueryandWithOnCommandrely on the set's kind never changing, as the comment says; aDebugassertion checks it. Every caller starts from a null set.Left out: the generator's
boolparameters that choose between two emitted shapes (they predate this change; an owner decision), the benchmark's constructor lookup for the name set, and two messages the list did not name (DbQuery.csblank-command text andDbConnectionProvider.Take).Cost
None per call or per row.
Reviews
Two Haiku lenses (correctness of the consolidations; rules, names, tests and docs) read the diff. Applied: argument grouping,
=>placement,_handedOnrenamed to match the file's wording, the lost byte order marks restored, the stale release-note quote, one more shared include, and theDebugassertion. Not applied: the generator'sboolparameters and the two out-of-list messages (above).Checks: Release 16,151 and Debug 16,130 tests pass (16 skipped), 189 generator tests, 0 build warnings on every target framework, 267 sample checks,
dotnet formatstyle and analyzers clean on all 28 checks, DocFX 0 warnings, the style scan clean.🤖 Generated with Claude Code