Skip to content

Commit b6045ae

Browse files
Cut the hover text of the shipped packages to what a member does and its traps, link the articles for the rest, and fix the statements that were false (#322)
The XML docs ship in the packages, so a hover that is wrong or that carries a whole article is worse than a short one. This is docs only; no code changes. False statements fixed: - The async ExecuteReader overloads no longer say behavior defaults to CommandBehavior.Default (they have no default), in Core and in the SQL Server package. - ToPooledBufferStream no longer says the connection is freed before the consumer sees a row; it is released when the read ends. - The buffered terminals no longer say the rows are buffered before the call returns. - ToChannel and ToTargetBlock no longer say the channel or block is left as it was for complete: true, and name the returned ValueTask<long>. - stallTimeout on the holding-connection overloads names StreamBuffered with a buffer of one row, not Stream. - The ten synchronous terminals on the reader and table views now have summaries, so their hover is no longer empty. Shortened to a summary, the traps and an article link: the Map, CancelOnEarlyStop, SingleResult, UsePool, pooled-memory, PooledBuffer, RowMap, NullPolicy, MappedDbQuery, ConnectionScope, reader-helper, transaction, output-parameter and name-matching remarks. The Stream, StreamBuffered and ToPooledStream comparison table is removed from the hovers; it stays in the Terminals article. Dead shared doc nodes are removed. Docsite: a Connection scopes section in the foundation article, the held-connection explanation under reader and command helpers, the per-call switch rule for a mapped definition, and the Terminals link and ValueTask<long> wording in the channels article. The factory and pool docs say the factory or pool must return a connection (null is not supported). SetTimeout says when the procedure-name lookup is bounded by it. Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
1 parent 59146a3 commit b6045ae

42 files changed

Lines changed: 443 additions & 1022 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎Source/Channel/ToChannel.Produce.cs‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public static partial class ChannelDbExtensions
2121
/// The channel is always completed:
2222
/// without an error after the last row, or with the exception that
2323
/// ended the read, a cancel included.
24+
/// <see href="https://open-net-libraries.github.io/Open.Database.Extensions/articles/channels-and-dataflow.html#channels">Channels</see>.
2425
/// </para>
2526
/// </remarks>
2627
/// <typeparam name="T">The type of each row.</typeparam>
@@ -140,8 +141,8 @@ public static Channel<T> ToChannel<T>(
140141
/// </summary>
141142
/// <remarks>
142143
/// The bound limits the channel, not memory:
143-
/// the query is still read at full speed, and the rows the channel has
144-
/// no room for wait in an internal queue.
144+
/// the query is still read at full speed, and the rows that do not fit
145+
/// wait in memory.
145146
/// </remarks>
146147
/// <inheritdoc cref="ToChannelReader{T}(IMappedQuery{T}, CancellationToken)" path="/typeparam"/>
147148
/// <param name="source">The mapped query to read.</param>

‎Source/Channel/ToChannel.Streaming.cs‎

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,18 @@ public static partial class ChannelDbExtensions
1010
/// </summary>
1111
/// <remarks>
1212
/// Holds the reader and the connection open for each row: while the channel is full,
13-
/// the next row is not pulled and the connection stays open until
13+
/// the read waits and the connection stays open until
1414
/// <paramref name="stallTimeout"/> expires (never, with <see cref="Timeout.InfiniteTimeSpan"/>).
1515
/// Use <see cref="ToChannel{T}(IMappedQuery{T}, Channel{T}, CancellationToken)"/>,
1616
/// which frees the connection first, unless the rows must be pulled one at a time;
17-
/// otherwise it behaves as that member.
18-
/// See <see cref="IMappedQuery{T}.StreamBuffered(TimeSpan, int, CancellationToken)"/> (with a buffer of one row) for the stall rules.
17+
/// otherwise it behaves the same, apart from the stall timeout.
18+
/// See <see href="https://open-net-libraries.github.io/Open.Database.Extensions/articles/mapping.html#terminals">Terminals</see> for the stall rules.
1919
/// </remarks>
2020
/// <typeparam name="T">The type of each row.</typeparam>
2121
/// <param name="source">The mapped query to read.</param>
2222
/// <param name="channel">The channel to write to.</param>
2323
/// <param name="stallTimeout">
24-
/// The longest the channel may make no room while the reader is held. Required; passed to <c>Stream</c>.
24+
/// The longest the channel may make no room while the reader is held. Required; passed to <see cref="IMappedQuery{T}.StreamBuffered(TimeSpan, int, CancellationToken)"/> with a buffer of one row.
2525
/// The wait for room before the command runs is not timed.
2626
/// </param>
2727
/// <include file="../Core/Mapped.docs.xml" path="docs/members[@name='token-pass']/*" />
@@ -42,7 +42,11 @@ public static ValueTask<long> ToChannelHoldingConnection<T>(
4242
false,
4343
cancellationToken);
4444

45-
/// <inheritdoc cref="ToChannelHoldingConnection{T}(IMappedQuery{T}, Channel{T}, TimeSpan, CancellationToken)" path="/summary"/>
45+
/// <summary>
46+
/// Reads the query one row at a time and writes each row to a channel
47+
/// you own, completing the channel when the pass ends if
48+
/// <paramref name="complete"/> is <see langword="true"/>.
49+
/// </summary>
4650
/// <inheritdoc cref="ToChannelHoldingConnection{T}(IMappedQuery{T}, Channel{T}, TimeSpan, CancellationToken)" path="/remarks"/>
4751
/// <inheritdoc cref="ToChannelHoldingConnection{T}(IMappedQuery{T}, Channel{T}, TimeSpan, CancellationToken)" path="/typeparam"/>
4852
/// <inheritdoc cref="ToChannelHoldingConnection{T}(IMappedQuery{T}, Channel{T}, TimeSpan, CancellationToken)" path="/returns"/>
@@ -53,7 +57,7 @@ public static ValueTask<long> ToChannelHoldingConnection<T>(
5357
/// </param>
5458
/// <param name="source">The mapped query to read.</param>
5559
/// <param name="channel">The channel to write to.</param>
56-
/// <param name="stallTimeout">The longest the channel may make no room while the reader is held. Required; passed to <c>Stream</c>.
60+
/// <param name="stallTimeout">The longest the channel may make no room while the reader is held. Required; passed to <see cref="IMappedQuery{T}.StreamBuffered(TimeSpan, int, CancellationToken)"/> with a buffer of one row.
5761
/// The wait for room before the command runs is not timed.</param>
5862
/// <include file="../Core/Mapped.docs.xml" path="docs/members[@name='token-pass']/*" />
5963
public static ValueTask<long> ToChannelHoldingConnection<T>(
@@ -85,7 +89,7 @@ public static ValueTask<long> ToChannelHoldingConnection<T>(
8589
/// <inheritdoc cref="ToChannelHoldingConnection{T}(IMappedQuery{T}, Channel{T}, TimeSpan, CancellationToken)" path="/exception"/>
8690
/// <param name="writer">The writer to write to.</param>
8791
/// <param name="source">The mapped query to read.</param>
88-
/// <param name="stallTimeout">The longest the writer may make no room while the reader is held. Required; passed to <c>Stream</c>.
92+
/// <param name="stallTimeout">The longest the writer may make no room while the reader is held. Required; passed to <see cref="IMappedQuery{T}.StreamBuffered(TimeSpan, int, CancellationToken)"/> with a buffer of one row.
8993
/// The wait for room before the command runs is not timed.</param>
9094
/// <include file="../Core/Mapped.docs.xml" path="docs/members[@name='token-pass']/*" />
9195
public static ValueTask<long> ToChannelHoldingConnection<T>(
@@ -107,7 +111,7 @@ public static ValueTask<long> ToChannelHoldingConnection<T>(
107111
/// <inheritdoc cref="ToChannelHoldingConnection{T}(IMappedQuery{T}, Channel{T}, TimeSpan, bool, CancellationToken)" path="/exception"/>
108112
/// <param name="writer">The writer to write to.</param>
109113
/// <param name="source">The mapped query to read.</param>
110-
/// <param name="stallTimeout">The longest the writer may make no room while the reader is held. Required; passed to <c>Stream</c>.
114+
/// <param name="stallTimeout">The longest the writer may make no room while the reader is held. Required; passed to <see cref="IMappedQuery{T}.StreamBuffered(TimeSpan, int, CancellationToken)"/> with a buffer of one row.
111115
/// The wait for room before the command runs is not timed.</param>
112116
/// <param name="complete">
113117
/// <see langword="true"/> to complete the writer when the pass ends,

‎Source/Channel/ToChannel.Target.cs‎

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,23 @@ public static partial class ChannelDbExtensions
1010
/// </summary>
1111
/// <remarks>
1212
/// <para>
13-
/// The task is the done signal: it completes with the number of rows
14-
/// handed to the channel after the last result set was read through.
15-
/// A failure or a cancel comes back through the task, and the channel
13+
/// The returned <c>ValueTask&lt;long&gt;</c> completes with the number of
14+
/// rows written after the last result set was read through.
15+
/// A failure or a cancel is thrown by the await, and the channel
1616
/// is left as it was.
1717
/// </para>
1818
/// <para>
1919
/// The channel stays open, so several passes can share one.
2020
/// Pass <c>complete: true</c> to complete it when the pass ends.
2121
/// </para>
2222
/// <para>
23-
/// The query is read at full speed and the connection is closed when the
24-
/// read ends. When the channel is full, the write waits for room,
25-
/// before the command runs and then between rows, while the rows wait in
26-
/// an internal queue: the connection is free, but your channel does not
27-
/// limit memory.
28-
/// When the channel is closed, the pass stops without an exception and
29-
/// returns the rows written so far.
30-
/// A channel completed with an error throws that error.
23+
/// The connection is closed when the read ends.
24+
/// A full channel makes the write wait, before the command runs and then
25+
/// between rows; the rows wait in memory meanwhile, so the channel does
26+
/// not limit memory.
27+
/// A closed channel ends the pass without an exception and returns the
28+
/// rows written so far; a channel completed with an error throws that error.
29+
/// <see href="https://open-net-libraries.github.io/Open.Database.Extensions/articles/channels-and-dataflow.html#a-channel-you-own">A channel you own</see>.
3130
/// </para>
3231
/// </remarks>
3332
/// <typeparam name="T">The type of each row.</typeparam>
@@ -47,8 +46,17 @@ public static ValueTask<long> ToChannel<T>(
4746
false,
4847
cancellationToken);
4948

50-
/// <inheritdoc cref="ToChannel{T}(IMappedQuery{T}, Channel{T}, CancellationToken)" path="/summary"/>
51-
/// <inheritdoc cref="ToChannel{T}(IMappedQuery{T}, Channel{T}, CancellationToken)" path="/remarks"/>
49+
/// <summary>
50+
/// Reads the query and writes each row to a channel you own,
51+
/// completing the channel when the pass ends if <paramref name="complete"/> is
52+
/// <see langword="true"/>.
53+
/// </summary>
54+
/// <remarks>
55+
/// With <c>complete: false</c> it is
56+
/// <see cref="ToChannel{T}(IMappedQuery{T}, Channel{T}, CancellationToken)"/>.
57+
/// With <c>complete: true</c> the channel is completed when the pass ends,
58+
/// or completed with the exception that ended it, a cancel included.
59+
/// </remarks>
5260
/// <inheritdoc cref="ToChannel{T}(IMappedQuery{T}, Channel{T}, CancellationToken)" path="/typeparam"/>
5361
/// <inheritdoc cref="ToChannel{T}(IMappedQuery{T}, Channel{T}, CancellationToken)" path="/returns"/>
5462
/// <inheritdoc cref="ToChannel{T}(IMappedQuery{T}, Channel{T}, CancellationToken)" path="/exception"/>

‎Source/Core/Commands.docs.xml‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
<param name="connectionPool">
7171
The pool to take connections from.
7272
Each execution takes one and gives it back when finished.
73+
The pool must return a connection; <see langword="null"/> is not supported.
7374
</param>
7475
<exception cref="ArgumentNullException">
7576
<paramref name="connectionPool"/> or <paramref name="command"/> is
@@ -82,6 +83,7 @@
8283
The factory that creates the connections.
8384
Each execution creates a connection, opens it if needed, and disposes it
8485
when finished.
86+
The factory must return a connection; <see langword="null"/> is not supported.
8587
</param>
8688
<exception cref="ArgumentNullException">
8789
<paramref name="connFactory"/> or <paramref name="command"/> is
@@ -94,6 +96,7 @@
9496
The function that creates the connections.
9597
Each execution invokes it, opens the connection if needed, and disposes
9698
it when finished.
99+
The function must return a connection; <see langword="null"/> is not supported.
97100
</param>
98101
<exception cref="ArgumentNullException">
99102
<paramref name="connFactory"/> or <paramref name="command"/> is

‎Source/Core/ConnectionScope.cs‎

Lines changed: 9 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -27,69 +27,15 @@ enum ScopeEnd : byte
2727
/// to do with it when the scope is disposed.
2828
/// </summary>
2929
/// <remarks>
30-
/// <para>
31-
/// One type for every source of a connection: the scope carries how it ends. What
32-
/// disposing does depends on what made it:
33-
/// </para>
34-
/// <list type="table">
35-
/// <listheader>
36-
/// <term>Made by</term>
37-
/// <description>The connection came from; disposing the scope</description>
38-
/// </listheader>
39-
/// <item>
40-
/// <term><see cref="ConnectionExtensions.EnsureOpenScope{TConnection}(TConnection)"/> /
41-
/// <see cref="ConnectionExtensions.EnsureOpenScopeAsync{TConnection}(TConnection, CancellationToken)"/></term>
42-
/// <description>You already hold it; closes it if the scope opened it, and leaves it open if it was already open.
43-
/// Never disposes it.</description>
44-
/// </item>
45-
/// <item>
46-
/// <term><see cref="ConnectionExtensions.EnsureOpenScope(IDbConnectionFactory)"/> /
47-
/// <see cref="ConnectionExtensions.EnsureOpenScopeAsync(IDbConnectionFactory, CancellationToken)"/> (on a factory)</term>
48-
/// <description>The factory created it, so it is yours; disposes it: <c>Dispose</c>, as
49-
/// <c>factory.Open(...)</c> does, and <c>DisposeAsync</c> from <see cref="DisposeAsync"/> when the connection has one.</description>
50-
/// </item>
51-
/// <item>
52-
/// <term><see cref="ConnectionExtensions.EnsureOpenScope(IDbConnectionPool)"/> /
53-
/// <see cref="ConnectionExtensions.EnsureOpenScopeAsync(IDbConnectionPool, CancellationToken)"/> (on a pool)</term>
54-
/// <description>The pool leased it; gives it back with <see cref="IDbConnectionPool.Give(IDbConnection)"/>, as
55-
/// <c>pool.Open(...)</c> does. What giving back means (close it, keep it, dispose it) is the pool's.</description>
56-
/// </item>
30+
/// What disposing the scope does depends on where the connection came from:
31+
/// <list type="bullet">
32+
/// <item><description>From <c>EnsureOpenScope</c> on a connection: closes it if the scope opened it; never disposes it.</description></item>
33+
/// <item><description>From <c>EnsureOpenScope</c> on a factory: disposes it (<c>DisposeAsync</c> when it has one).</description></item>
34+
/// <item><description>From <c>EnsureOpenScope</c> on a pool: gives it back with <see cref="IDbConnectionPool.Give(IDbConnection)"/>; what that means is the pool's.</description></item>
5735
/// </list>
58-
/// <para>
59-
/// When you already hold the connection the scope is usually only there to be disposed:
60-
/// </para>
61-
/// <code language="csharp">
62-
/// await using var _ = await connection.EnsureOpenScopeAsync(cancellationToken);
63-
/// // ... use the connection you already hold.
64-
/// </code>
65-
/// <para>
66-
/// When the connection came from a factory or a pool the scope is how you get it:
67-
/// </para>
68-
/// <code language="csharp">
69-
/// await using var scope = await factory.EnsureOpenScopeAsync(cancellationToken);
70-
/// var connection = scope.Connection;
71-
/// </code>
72-
/// <para>
73-
/// The scope keeps the type of the connection (a <c>SqlConnection</c> stays a
74-
/// <c>SqlConnection</c>), and deconstructs into the connection and the state it was found in:
75-
/// <c>var (sql, was) = scope;</c>.
76-
/// </para>
77-
/// <para>
78-
/// A connection that was broken is closed and opened again, so a scope that closes it closes it
79-
/// again afterwards; the broken state is not restored.
80-
/// </para>
81-
/// <para>
82-
/// Dispose the value you were given exactly once, and do not copy it: a second dispose of a copy
83-
/// disposes a factory's connection again, gives a pool's connection back again, or closes a connection
84-
/// that someone opened in between. Deconstruct a scope you hold, never the call itself:
85-
/// <c>var (c, s) = connection.EnsureOpenScope();</c> drops the scope, and the connection it opened
86-
/// stays open.
87-
/// </para>
88-
/// <para>
89-
/// A <see langword="default"/> scope holds nothing: disposing it does nothing, and
90-
/// reading <see cref="Connection"/> (or deconstructing it) throws
91-
/// <see cref="InvalidOperationException"/>.
92-
/// </para>
36+
/// Dispose the value exactly once; a copy disposes again.
37+
/// Deconstruct a scope you hold, never the call itself, which drops the scope and leaves a connection it opened open.
38+
/// <see href="https://open-net-libraries.github.io/Open.Database.Extensions/articles/foundation.html#connection-scopes">Connection scopes</see>.
9339
/// </remarks>
9440
/// <typeparam name="TConnection">The type of the connection, as the caller holds it.</typeparam>
9541
public readonly struct ConnectionScope<TConnection> : IDisposable, IAsyncDisposable
@@ -169,7 +115,7 @@ public void Deconstruct(out TConnection connection, out ConnectionState priorSta
169115
/// <summary>
170116
/// Lets go of the connection the way its source calls for: closes it if the scope opened it
171117
/// (a connection the caller held), disposes it (a factory's), or gives it back to the pool
172-
/// (a pool's). See the table in the remarks of the type.
118+
/// (a pool's). See the remarks of the type.
173119
/// </summary>
174120
public void Dispose()
175121
{
@@ -264,11 +210,6 @@ public CommandBehavior ReaderBehavior(CommandBehavior behavior = CommandBehavior
264210
/// Configures how <see langword="await"/> <see langword="using"/> awaits the disposal of this scope.
265211
/// </summary>
266212
/// <remarks>
267-
/// Library code takes the scope first, then hands it to <see langword="await"/> <see langword="using"/> on its own line:
268-
/// <code language="csharp">
269-
/// var scope = await connection.EnsureOpenScopeAsync(cancellationToken).ConfigureAwait(false);
270-
/// await using var disposal = scope.ConfigureAwait(false);
271-
/// </code>
272213
/// The library never returns to a caller's context; whether to is the caller's choice at their own call site,
273214
/// as with <see cref="Task.ConfigureAwait(bool)"/>.
274215
/// </remarks>

‎Source/Core/Core/NullPolicy.cs‎

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public enum NullAction
1616
/// <remarks>
1717
/// The same as no policy. On a member it overrides the type's policy, so one hot member can opt out.
1818
/// A NULL into a nullable member is <see langword="null"/>;
19-
/// into a non-nullable one it surfaces as the provider's own exception inside a <see cref="ValueMappingException"/> that names the model type and, when the row is known, the row (the member and the column are not known).
19+
/// into a non-nullable one it throws <see cref="ValueMappingException"/> naming the model type and the row, not the member or the column.
2020
/// To find which member and column, use <see cref="Throw"/>.
2121
/// </remarks>
2222
/// <seealso cref="Throw"/>
@@ -50,21 +50,11 @@ public enum NullAction
5050
/// Declares what a NULL does to a member when a row is mapped: on the model type for every member, or on one member.
5151
/// </summary>
5252
/// <remarks>
53-
/// <para>
5453
/// A policy always applies, nullable members included.
55-
/// On the type it covers every member, and a member's own policy overrides it (<see cref="NullAction.None"/> included).
56-
/// A <see cref="NullValueAttribute"/> on a member overrides any policy, the member's own included.
57-
/// A positional record's parameter takes the policy on the parameter or on its property.
58-
/// A pair or a converter of a <see cref="RowMap{T}"/> that names the member is explicit and overrides the member's own declarations in that map (the type's policy still covers it);
59-
/// a converter whose column type is a <see cref="Nullable{T}"/> receives the NULL itself, and no policy applies.
60-
/// A converter whose column type is a reference type (<see cref="string"/>) is not called for a NULL; the member then follows the NULL rules and the type's policy.
61-
/// A policy on a base type covers a derived model's members. The nearest declaration wins: the derived type's own policy, then its base type's;
62-
/// a member's own policy beats both, and a <see cref="NullValueAttribute"/> beats all.
63-
/// The declarations are read once per type, when its slots are built.
64-
/// </para>
65-
/// <para>
66-
/// Every check costs one NULL test per covered member per row. A member with no policy is not checked (<see cref="NullAction.None"/>).
67-
/// </para>
54+
/// On the type it covers every member, and a policy on a base type covers a derived model's members.
55+
/// A member's own policy overrides the type's, and a <see cref="NullValueAttribute"/> on a member overrides any policy.
56+
/// A member with no policy is not checked (<see cref="NullAction.None"/>).
57+
/// See <see href="https://open-net-libraries.github.io/Open.Database.Extensions/articles/mapping.html#null-policy">Null policy</see>.
6858
/// </remarks>
6959
/// <example>
7060
/// <code>

0 commit comments

Comments
 (0)