Skip to content

Commit 0286b64

Browse files
Style: regroup the argument lists that were one per line (#295)
Calls that wrote one argument to a line now put their arguments in logical groups, each line within 80 columns: the command, call and source on one line, then the skip, take, options, configuration and captures on the next. The same for the row-reader, stream and chunk-config calls of the mapped query. Whitespace only: the tokens of the four files are unchanged. Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
1 parent 32dd099 commit 0286b64

4 files changed

Lines changed: 46 additions & 153 deletions

File tree

‎Source/Core/MappedDbQuery.cs‎

Lines changed: 10 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,8 @@ internal MappedDbQuery(DbQuery definition, IRowSource<T> source)
6868

6969
public MappedDbQuery<T> SingleResult()
7070
=> new(
71-
Query,
72-
_source,
73-
_options | QueryOptions.SingleResult,
74-
_pool,
75-
_clearOnReturn);
71+
Query, _source, _options | QueryOptions.SingleResult,
72+
_pool, _clearOnReturn);
7673

7774
/// <summary>
7875
/// Cancels the command when a terminal stops before the last row, in every query made from this definition
@@ -82,11 +79,8 @@ public MappedDbQuery<T> SingleResult()
8279
/// <seealso cref="WithOptions(QueryOptions)"/>
8380
public MappedDbQuery<T> CancelOnEarlyStop()
8481
=> new(
85-
Query,
86-
_source,
87-
_options | QueryOptions.CancelOnEarlyStop,
88-
_pool,
89-
_clearOnReturn);
82+
Query, _source, _options | QueryOptions.CancelOnEarlyStop,
83+
_pool, _clearOnReturn);
9084

9185
/// <summary>
9286
/// Reads the rows with the asynchronous read of the provider, in every query made from this definition
@@ -96,11 +90,8 @@ public MappedDbQuery<T> CancelOnEarlyStop()
9690
/// <seealso cref="WithOptions(QueryOptions)"/>
9791
public MappedDbQuery<T> AsyncReads()
9892
=> new(
99-
Query,
100-
_source,
101-
_options | QueryOptions.AsyncReads,
102-
_pool,
103-
_clearOnReturn);
93+
Query, _source, _options | QueryOptions.AsyncReads,
94+
_pool, _clearOnReturn);
10495

10596
/// <summary>
10697
/// Asks the reader for sequential access, in every query made from this definition
@@ -110,11 +101,8 @@ public MappedDbQuery<T> AsyncReads()
110101
/// <seealso cref="WithOptions(QueryOptions)"/>
111102
public MappedDbQuery<T> SequentialAccess()
112103
=> new(
113-
Query,
114-
_source,
115-
_options | QueryOptions.SequentialAccess,
116-
_pool,
117-
_clearOnReturn);
104+
Query, _source, _options | QueryOptions.SequentialAccess,
105+
_pool, _clearOnReturn);
118106

119107
/// <summary>
120108
/// Returns a definition whose switches, in every query made from it, are
@@ -124,11 +112,8 @@ public MappedDbQuery<T> SequentialAccess()
124112
/// <returns>A definition with exactly these switches.</returns>
125113
public MappedDbQuery<T> WithOptions(QueryOptions options)
126114
=> new(
127-
Query,
128-
_source,
129-
Views.CheckedOptions(options),
130-
_pool,
131-
_clearOnReturn);
115+
Query, _source, Views.CheckedOptions(options),
116+
_pool, _clearOnReturn);
132117

133118
/// <summary>
134119
/// Takes the arrays that hold the rows from <paramref name="pool"/>, in every query made from this definition

‎Source/Core/MappedQuery.Capture.cs‎

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -52,18 +52,10 @@ public MappedQueryCore<T> WithCapture(ICaptureSource source)
5252
// first capture, and one run claims them.
5353
CaptureSet captures = CaptureSet.With(
5454
_captures as CaptureSet ?? runner.Captures,
55-
source,
56-
onQuery: true,
57-
runner.IsProcedure);
55+
source, onQuery: true, runner.IsProcedure);
5856
return new(
59-
_command,
60-
_call,
61-
_source,
62-
_skip,
63-
_take,
64-
Options,
65-
Config,
66-
captures);
57+
_command, _call, _source,
58+
_skip, _take, Options, Config, captures);
6759
}
6860

6961
/// <summary>
@@ -74,14 +66,8 @@ public MappedQueryCore<T> WithCapture(ICaptureSource source)
7466
/// <returns>The query for the stream or the buffer to read.</returns>
7567
MappedQueryCore<T> WithRun(CaptureRun run)
7668
=> new(
77-
_command,
78-
_call,
79-
_source,
80-
_skip,
81-
_take,
82-
Options,
83-
Config,
84-
run);
69+
_command, _call, _source,
70+
_skip, _take, Options, Config, run);
8571

8672
/// <summary>
8773
/// Makes the run of a stream, claimed later by its

‎Source/Core/MappedQuery.cs‎

Lines changed: 26 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -296,14 +296,8 @@ CommandBehavior Behavior
296296
/// <returns>A copy of the query with <paramref name="options"/>.</returns>
297297
public MappedQueryCore<T> WithOptions(QueryOptions options)
298298
=> Checked(new(
299-
_command,
300-
_call,
301-
_source,
302-
_skip,
303-
_take,
304-
options,
305-
Config,
306-
_captures));
299+
_command, _call, _source,
300+
_skip, _take, options, Config, _captures));
307301

308302
/// <summary>
309303
/// Returns the query with one more switch set, and the others as they were.
@@ -334,11 +328,8 @@ public MappedQueryCore<T> WithPool(ArrayPool<T> pool, bool clearOnReturn)
334328

335329
// The pool is the caller's; the sizes and the bin stay what the query had.
336330
return WithConfig(new ChunkConfig<T>(
337-
pool,
338-
clearOnReturn,
339-
Config.Sizes,
340-
Config.Bin,
341-
Config.DeferFromClearedBytes));
331+
pool, clearOnReturn,
332+
Config.Sizes, Config.Bin, Config.DeferFromClearedBytes));
342333
}
343334

344335
/// <summary>
@@ -349,14 +340,8 @@ public MappedQueryCore<T> WithPool(ArrayPool<T> pool, bool clearOnReturn)
349340
/// <returns>A copy of the query that uses <paramref name="config"/>.</returns>
350341
public MappedQueryCore<T> WithConfig(ChunkConfig<T> config)
351342
=> Checked(new(
352-
_command,
353-
_call,
354-
_source,
355-
_skip,
356-
_take,
357-
Options,
358-
config,
359-
_captures));
343+
_command, _call, _source,
344+
_skip, _take, Options, config, _captures));
360345

361346
/// <summary>Returns the same query over another call.</summary>
362347
/// <exception cref="InvalidOperationException">The query carries a capture,
@@ -370,14 +355,8 @@ public MappedQueryCore<T> WithCall(DbQueryCall call)
370355
public MappedQueryCore<T> WithSkip(int count)
371356
=> count >= 0
372357
? Checked(new(
373-
_command,
374-
_call,
375-
_source,
376-
_skip + count,
377-
_take,
378-
Options,
379-
Config,
380-
_captures))
358+
_command, _call, _source,
359+
_skip + count, _take, Options, Config, _captures))
381360
: throw new ArgumentOutOfRangeException(nameof(count), count, "Cannot be negative.");
382361

383362
/// <summary>
@@ -391,14 +370,8 @@ public MappedQueryCore<T> WithSkip(int count)
391370
public MappedQueryCore<T> WithTake(int count)
392371
=> count >= 0
393372
? Checked(new(
394-
_command,
395-
_call,
396-
_source,
397-
_skip,
398-
count,
399-
Options,
400-
Config,
401-
_captures))
373+
_command, _call, _source,
374+
_skip, count, Options, Config, _captures))
402375
: throw new ArgumentOutOfRangeException(nameof(count), count, "Cannot be negative.");
403376

404377
/// <summary>
@@ -527,11 +500,7 @@ TResult ExecuteReader<TState, TResult>(TState state, Func<IDataReader, TState, T
527500
ValueTask<TResult> ExecuteReaderAsync<TState, TResult>(TState state, Func<IDataReader, TState, ValueTask<TResult>> transform, CommandBehavior behavior, CancellationToken token)
528501
=> Captured() is { } captures
529502
? ((ICaptureRunner)_command!).ExecuteReaderAsync(
530-
captures,
531-
state,
532-
transform,
533-
behavior,
534-
token)
503+
captures, state, transform, behavior, token)
535504
: _call.IsBound
536505
? _call.RunAsync(state, transform, behavior, token)
537506
: Command.ExecuteReaderAsync(state, transform, behavior, token);
@@ -582,12 +551,8 @@ public void Read(Action<IEnumerable<T>> handler)
582551
static (reader, s) =>
583552
{
584553
s.handler(RowReader.Stream(
585-
s._source,
586-
reader,
587-
s._skip,
588-
s._take,
589-
!s.SingleResult,
590-
s.abandon));
554+
s._source, reader, s._skip, s._take,
555+
!s.SingleResult, s.abandon));
591556
return false;
592557
},
593558
Behavior,
@@ -628,14 +593,8 @@ static async (reader, s) =>
628593
{
629594
await s.handler(
630595
StreamAsync(
631-
s._source,
632-
reader,
633-
s._skip,
634-
s._take,
635-
s.SingleResult,
636-
s.AsyncReads,
637-
s.abandon,
638-
s.token),
596+
s._source, reader, s._skip, s._take,
597+
s.SingleResult, s.AsyncReads, s.abandon, s.token),
639598
s.token).ConfigureAwait(false);
640599
return false;
641600
},
@@ -850,24 +809,14 @@ static async (reader, s) =>
850809
if (reader is DbDataReader db)
851810
{
852811
(bool found, T? item) = await RowReader.TryFirstAsync(
853-
s._source,
854-
db,
855-
s._skip,
856-
s._take,
857-
s.AsyncReads,
858-
s.token,
859-
s.abandon).ConfigureAwait(false);
812+
s._source, db, s._skip, s._take,
813+
s.AsyncReads, s.token, s.abandon).ConfigureAwait(false);
860814
return found ? item : default;
861815
}
862816

863817
return RowReader.TryFirst(
864-
s._source,
865-
reader,
866-
s._skip,
867-
s._take,
868-
out T? i,
869-
s.abandon,
870-
s.token)
818+
s._source, reader, s._skip, s._take,
819+
out T? i, s.abandon, s.token)
871820
? i
872821
: default;
873822
},
@@ -888,24 +837,14 @@ static async (reader, s) =>
888837
if (reader is DbDataReader db)
889838
{
890839
(bool found, T? item) = await RowReader.TrySingleAsync(
891-
s._source,
892-
db,
893-
s._skip,
894-
s._take,
895-
s.AsyncReads,
896-
s.token,
897-
s.abandon).ConfigureAwait(false);
840+
s._source, db, s._skip, s._take,
841+
s.AsyncReads, s.token, s.abandon).ConfigureAwait(false);
898842
return found ? item : default;
899843
}
900844

901845
return RowReader.TrySingle(
902-
s._source,
903-
reader,
904-
s._skip,
905-
s._take,
906-
out T? i,
907-
s.abandon,
908-
s.token)
846+
s._source, reader, s._skip, s._take,
847+
out T? i, s.abandon, s.token)
909848
? i
910849
: default;
911850
},
@@ -1192,8 +1131,7 @@ public IAsyncEnumerable<T> ToPooledStream(
11921131
IAsyncEnumerable<T> rows = Flatten(
11931132
new ChunkStream<T>(
11941133
run is null ? this : WithRun(run),
1195-
Config,
1196-
cancellationToken),
1134+
Config, cancellationToken),
11971135
CancellationToken.None);
11981136

11991137
// Captured: the claim is at the flattened stream's GetAsyncEnumerator.
@@ -1259,10 +1197,7 @@ IAsyncEnumerable<T> StreamCore(
12591197
return bufferSize == 0
12601198
? new DirectStream<T>(this, stallTimeout, cancellationToken)
12611199
: new StallStream<T>(
1262-
this,
1263-
stallTimeout,
1264-
bufferSize,
1265-
cancellationToken);
1200+
this, stallTimeout, bufferSize, cancellationToken);
12661201
}
12671202

12681203
CaptureRun run = StreamRun(captures, cancellationToken);
@@ -1271,10 +1206,7 @@ IAsyncEnumerable<T> StreamCore(
12711206
bufferSize == 0
12721207
? new DirectStream<T>(claimed, stallTimeout, cancellationToken)
12731208
: new StallStream<T>(
1274-
claimed,
1275-
stallTimeout,
1276-
bufferSize,
1277-
cancellationToken),
1209+
claimed, stallTimeout, bufferSize, cancellationToken),
12781210
run);
12791211
}
12801212

‎Source/Core/MappedViews.cs‎

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -345,9 +345,7 @@ DbQueryCall call
345345
DbQueryUsing bound
346346
=> NewCore(null, bound.ToCall(), source, Single(singleResult)),
347347
_ => NewCore(
348-
command,
349-
default,
350-
source,
348+
command, default, source,
351349
Single(singleResult)
352350
| (AsyncReads(command)
353351
? QueryOptions.AsyncReads
@@ -367,33 +365,25 @@ internal static MappedQueryCore<T> ReaderCore<T>(
367365
IDataReader reader,
368366
IRowSource<T> source)
369367
=> NewCore(
370-
new ReaderExecutor(reader),
371-
default,
372-
source,
368+
new ReaderExecutor(reader), default, source,
373369
QueryOptions.SingleResult);
374370

375371
internal static MappedQueryCore<T> CommandCore<T>(
376372
IDbCommand command,
377373
IRowSource<T> source)
378374
=> command is SingleResultDbCommand single
379375
? NewCore(
380-
new CommandExecutor(single.Command),
381-
default,
382-
source,
376+
new CommandExecutor(single.Command), default, source,
383377
QueryOptions.SingleResult)
384378
: NewCore(
385-
new CommandExecutor(command),
386-
default,
387-
source,
379+
new CommandExecutor(command), default, source,
388380
QueryOptions.None);
389381

390382
internal static MappedQueryCore<T> TableCore<T>(
391383
DataTable table,
392384
IRowSource<T> source)
393385
=> NewCore(
394-
new TableExecutor(table),
395-
default,
396-
source,
386+
new TableExecutor(table), default, source,
397387
QueryOptions.SingleResult);
398388

399389
/// <summary>

0 commit comments

Comments
 (0)