|
1 | | -using System; |
2 | | -using System.Buffers; |
3 | | -using System.Collections.Generic; |
4 | | -using System.Data; |
5 | | -using System.Data.Common; |
6 | | -using System.Diagnostics.Contracts; |
7 | | -using System.Threading; |
8 | | -using System.Threading.Channels; |
9 | | - |
10 | | -namespace Open.Database.Extensions; |
| 1 | +namespace Open.Database.Extensions; |
11 | 2 |
|
12 | 3 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Reliability", "CA2012:Use ValueTasks correctly", Justification = "Intentionally running in the background.")] |
13 | 4 | [System.Diagnostics.CodeAnalysis.SuppressMessage("Roslynator", "RCS1047:Non-asynchronous method name should not end with 'Async'.", Justification = "<Pending>")] |
@@ -42,16 +33,16 @@ public static ChannelReader<object[]> AsChannel(this IDataReader reader, |
42 | 33 | /// <param name="arrayPool">The array pool to acquire buffers from.</param> |
43 | 34 | /// <param name="cancellationToken">An optional cancellation token.</param> |
44 | 35 | /// <returns>The channel reader containing the results.</returns> |
45 | | - public static ChannelReader<object?[]> AsChannel(this IDataReader reader, |
| 36 | + public static ChannelReader<object[]> AsChannel(this IDataReader reader, |
46 | 37 | bool singleReader, |
47 | | - ArrayPool<object?> arrayPool, |
| 38 | + ArrayPool<object> arrayPool, |
48 | 39 | CancellationToken cancellationToken = default) |
49 | 40 | { |
50 | 41 | if (reader is null) throw new ArgumentNullException(nameof(reader)); |
51 | 42 | if (arrayPool is null) throw new ArgumentNullException(nameof(arrayPool)); |
52 | 43 | Contract.EndContractBlock(); |
53 | 44 |
|
54 | | - var channel = CreateChannel<object?[]>(-1, singleReader); |
| 45 | + var channel = CreateChannel<object[]>(-1, singleReader); |
55 | 46 | _ = ToChannel(reader, channel.Writer, true, arrayPool, cancellationToken); |
56 | 47 | return channel.Reader; |
57 | 48 | } |
@@ -153,16 +144,16 @@ public static ChannelReader<object[]> AsChannel(this IDbCommand command, |
153 | 144 | /// <param name="arrayPool">The array pool to acquire buffers from.</param> |
154 | 145 | /// <param name="cancellationToken">An optional cancellation token.</param> |
155 | 146 | /// <returns>The channel reader containing the results.</returns> |
156 | | - public static ChannelReader<object?[]> AsChannel(this IDbCommand command, |
| 147 | + public static ChannelReader<object[]> AsChannel(this IDbCommand command, |
157 | 148 | bool singleReader, |
158 | | - ArrayPool<object?> arrayPool, |
| 149 | + ArrayPool<object> arrayPool, |
159 | 150 | CancellationToken cancellationToken = default) |
160 | 151 | { |
161 | 152 | if (command is null) throw new ArgumentNullException(nameof(command)); |
162 | 153 | if (arrayPool is null) throw new ArgumentNullException(nameof(arrayPool)); |
163 | 154 | Contract.EndContractBlock(); |
164 | 155 |
|
165 | | - var channel = CreateChannel<object?[]>(-1, singleReader); |
| 156 | + var channel = CreateChannel<object[]>(-1, singleReader); |
166 | 157 | _ = ToChannel(command, channel.Writer, true, arrayPool, cancellationToken); |
167 | 158 | return channel.Reader; |
168 | 159 | } |
@@ -261,15 +252,15 @@ public static ChannelReader<object[]> AsChannel(this IExecuteReader command, |
261 | 252 | /// <param name="singleReader">True will cause the resultant reader to optimize for the assumption that no concurrent read operations will occur.</param> |
262 | 253 | /// <param name="arrayPool">The array pool to acquire buffers from.</param> |
263 | 254 | /// <returns>The channel reader containing the results.</returns> |
264 | | - public static ChannelReader<object?[]> AsChannel(this IExecuteReader command, |
| 255 | + public static ChannelReader<object[]> AsChannel(this IExecuteReader command, |
265 | 256 | bool singleReader, |
266 | | - ArrayPool<object?> arrayPool) |
| 257 | + ArrayPool<object> arrayPool) |
267 | 258 | { |
268 | 259 | if (command is null) throw new ArgumentNullException(nameof(command)); |
269 | 260 | if (arrayPool is null) throw new ArgumentNullException(nameof(arrayPool)); |
270 | 261 | Contract.EndContractBlock(); |
271 | 262 |
|
272 | | - var channel = CreateChannel<object?[]>(-1, singleReader); |
| 263 | + var channel = CreateChannel<object[]>(-1, singleReader); |
273 | 264 | _ = ToChannel(command, channel.Writer, true, arrayPool); |
274 | 265 | return channel.Reader; |
275 | 266 | } |
@@ -336,7 +327,8 @@ public static ChannelReader<T> AsChannel<T>(this IExecuteReader command, |
336 | 327 | return channel.Reader; |
337 | 328 | } |
338 | 329 |
|
339 | | -#if NETSTANDARD2_1 |
| 330 | +#if NETSTANDARD2_0 |
| 331 | +#else |
340 | 332 | /// <summary> |
341 | 333 | /// Asynchronously iterates an DbDataReader and writes each record as an array to an unbound channel. |
342 | 334 | /// Iterates an DbDataReader through the transform function and writes each record to an unbound channel. |
@@ -367,16 +359,16 @@ public static ChannelReader<object[]> AsChannelAsync(this DbDataReader reader, |
367 | 359 | /// <param name="arrayPool">The array pool to acquire buffers from.</param> |
368 | 360 | /// <param name="cancellationToken">An optional cancellation token.</param> |
369 | 361 | /// <returns>The channel reader containing the results.</returns> |
370 | | - public static ChannelReader<object?[]> AsChannelAsync(this DbDataReader reader, |
| 362 | + public static ChannelReader<object[]> AsChannelAsync(this DbDataReader reader, |
371 | 363 | bool singleReader, |
372 | | - ArrayPool<object?> arrayPool, |
| 364 | + ArrayPool<object> arrayPool, |
373 | 365 | CancellationToken cancellationToken = default) |
374 | 366 | { |
375 | 367 | if (reader is null) throw new ArgumentNullException(nameof(reader)); |
376 | 368 | if (arrayPool is null) throw new ArgumentNullException(nameof(arrayPool)); |
377 | 369 | Contract.EndContractBlock(); |
378 | 370 |
|
379 | | - var channel = CreateChannel<object?[]>(-1, singleReader); |
| 371 | + var channel = CreateChannel<object[]>(-1, singleReader); |
380 | 372 | _ = ToChannelAsync(reader, channel.Writer, true, arrayPool, cancellationToken); |
381 | 373 | return channel.Reader; |
382 | 374 | } |
@@ -478,16 +470,16 @@ public static ChannelReader<object[]> AsChannelAsync(this DbCommand command, |
478 | 470 | /// <param name="arrayPool">The array pool to acquire buffers from.</param> |
479 | 471 | /// <param name="cancellationToken">An optional cancellation token.</param> |
480 | 472 | /// <returns>The channel reader containing the results.</returns> |
481 | | - public static ChannelReader<object?[]> AsChannelAsync(this DbCommand command, |
| 473 | + public static ChannelReader<object[]> AsChannelAsync(this DbCommand command, |
482 | 474 | bool singleReader, |
483 | | - ArrayPool<object?> arrayPool, |
| 475 | + ArrayPool<object> arrayPool, |
484 | 476 | CancellationToken cancellationToken = default) |
485 | 477 | { |
486 | 478 | if (command is null) throw new ArgumentNullException(nameof(command)); |
487 | 479 | if (arrayPool is null) throw new ArgumentNullException(nameof(arrayPool)); |
488 | 480 | Contract.EndContractBlock(); |
489 | 481 |
|
490 | | - var channel = CreateChannel<object?[]>(-1, singleReader); |
| 482 | + var channel = CreateChannel<object[]>(-1, singleReader); |
491 | 483 | _ = ToChannelAsync(command, channel.Writer, true, arrayPool, cancellationToken); |
492 | 484 | return channel.Reader; |
493 | 485 | } |
@@ -586,14 +578,14 @@ public static ChannelReader<object[]> AsChannelAsync(this IExecuteReaderAsync co |
586 | 578 | /// <param name="singleReader">True will cause the resultant reader to optimize for the assumption that no concurrent read operations will occur.</param> |
587 | 579 | /// <param name="arrayPool">The array pool to acquire buffers from.</param> |
588 | 580 | /// <returns>The channel reader containing the results.</returns> |
589 | | - public static ChannelReader<object?[]> AsChannelAsync(this IExecuteReaderAsync command, |
| 581 | + public static ChannelReader<object[]> AsChannelAsync(this IExecuteReaderAsync command, |
590 | 582 | bool singleReader, |
591 | | - ArrayPool<object?> arrayPool) |
| 583 | + ArrayPool<object> arrayPool) |
592 | 584 | { |
593 | 585 | if (command is null) throw new ArgumentNullException(nameof(command)); |
594 | 586 | Contract.EndContractBlock(); |
595 | 587 |
|
596 | | - var channel = CreateChannel<object?[]>(-1, singleReader); |
| 588 | + var channel = CreateChannel<object[]>(-1, singleReader); |
597 | 589 | _ = ToChannelAsync(command, channel.Writer, true, arrayPool); |
598 | 590 | return channel.Reader; |
599 | 591 | } |
|
0 commit comments