Skip to content

Commit d507b7a

Browse files
author
Oren (electricessence)
committed
Updated remaining packages.
1 parent 2fa239c commit d507b7a

8 files changed

Lines changed: 138 additions & 83 deletions

Dataflow/AsSourceBlock.cs

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ namespace Open.Database.Extensions
1010
/// <summary>
1111
/// Extensions for pipelining data with Dataflow blocks.
1212
/// </summary>
13+
[System.Diagnostics.CodeAnalysis.SuppressMessage("Reliability", "CA2012:Use ValueTasks correctly", Justification = "Intentionally running in the background.")]
1314
public static partial class DataflowExtensions
1415
{
1516
static BufferBlock<T> GetBufferBlock<T>(DataflowBlockOptions? options = null)
@@ -36,11 +37,11 @@ public static IReceivableSourceBlock<object[]> AsSourceBlock(this IDataReader re
3637
/// <param name="arrayPool">The array pool to acquire buffers from.</param>
3738
/// <param name="options">Optional DataflowBlockOptions for configuring the source block.</param>
3839
/// <returns>The source block containing the results.</returns>
39-
public static IReceivableSourceBlock<object[]> AsSourceBlock(this IDataReader reader,
40-
ArrayPool<object> arrayPool,
40+
public static IReceivableSourceBlock<object?[]> AsSourceBlock(this IDataReader reader,
41+
ArrayPool<object?> arrayPool,
4142
DataflowBlockOptions? options = null)
4243
{
43-
var buffer = GetBufferBlock<object[]>(options);
44+
var buffer = GetBufferBlock<object?[]>(options);
4445
ToTargetBlock(reader, buffer, true, arrayPool);
4546
return buffer;
4647
}
@@ -127,11 +128,11 @@ public static IReceivableSourceBlock<object[]> AsSourceBlock(this IDbCommand com
127128
/// <param name="arrayPool">The array pool to acquire buffers from.</param>
128129
/// <param name="options">Optional DataflowBlockOptions for configuring the source block.</param>
129130
/// <returns>The source block containing the results.</returns>
130-
public static IReceivableSourceBlock<object[]> AsSourceBlock(this IDbCommand command,
131-
ArrayPool<object> arrayPool,
131+
public static IReceivableSourceBlock<object?[]> AsSourceBlock(this IDbCommand command,
132+
ArrayPool<object?> arrayPool,
132133
DataflowBlockOptions? options = null)
133134
{
134-
var buffer = GetBufferBlock<object[]>(options);
135+
var buffer = GetBufferBlock<object?[]>(options);
135136
ToTargetBlock(command, buffer, true, arrayPool);
136137
return buffer;
137138
}
@@ -223,11 +224,11 @@ public static IReceivableSourceBlock<object[]> AsSourceBlock(this IExecuteReader
223224
/// <param name="arrayPool">The array pool to acquire buffers from.</param>
224225
/// <param name="options">Optional DataflowBlockOptions for configuring the source block.</param>
225226
/// <returns>The source block containing the results.</returns>
226-
public static IReceivableSourceBlock<object[]> AsSourceBlock(this IExecuteReader command,
227-
ArrayPool<object> arrayPool,
227+
public static IReceivableSourceBlock<object?[]> AsSourceBlock(this IExecuteReader command,
228+
ArrayPool<object?> arrayPool,
228229
DataflowBlockOptions? options = null)
229230
{
230-
var buffer = GetBufferBlock<object[]>(options);
231+
var buffer = GetBufferBlock<object?[]>(options);
231232
ToTargetBlock(command, buffer, true, arrayPool);
232233
return buffer;
233234
}
@@ -318,12 +319,12 @@ public static IReceivableSourceBlock<object[]> AsSourceBlockAsync(this IDataRead
318319
/// <param name="options">Optional DataflowBlockOptions for configuring the source block.</param>
319320
/// <param name="cancellationToken">An optional cancellation token.</param>
320321
/// <returns>The source block containing the results.</returns>
321-
public static IReceivableSourceBlock<object[]> AsSourceBlockAsync(this IDataReader reader,
322-
ArrayPool<object> arrayPool,
322+
public static IReceivableSourceBlock<object?[]> AsSourceBlockAsync(this IDataReader reader,
323+
ArrayPool<object?> arrayPool,
323324
DataflowBlockOptions? options = null,
324325
CancellationToken cancellationToken = default)
325326
{
326-
var buffer = GetBufferBlock<object[]>(options);
327+
var buffer = GetBufferBlock<object?[]>(options);
327328
_ = ToTargetBlockAsync(reader, buffer, true, arrayPool, cancellationToken);
328329
return buffer;
329330
}
@@ -416,12 +417,12 @@ public static IReceivableSourceBlock<object[]> AsSourceBlockAsync(this IDbComman
416417
/// <param name="options">Optional DataflowBlockOptions for configuring the source block.</param>
417418
/// <param name="cancellationToken">An optional cancellation token.</param>
418419
/// <returns>The source block containing the results.</returns>
419-
public static IReceivableSourceBlock<object[]> AsSourceBlockAsync(this IDbCommand command,
420-
ArrayPool<object> arrayPool,
420+
public static IReceivableSourceBlock<object?[]> AsSourceBlockAsync(this IDbCommand command,
421+
ArrayPool<object?> arrayPool,
421422
DataflowBlockOptions? options = null,
422423
CancellationToken cancellationToken = default)
423424
{
424-
var buffer = GetBufferBlock<object[]>(options);
425+
var buffer = GetBufferBlock<object?[]>(options);
425426
_ = ToTargetBlockAsync(command, buffer, true, arrayPool, cancellationToken);
426427
return buffer;
427428
}
@@ -517,11 +518,11 @@ public static IReceivableSourceBlock<object[]> AsSourceBlockAsync(this IExecuteR
517518
/// <param name="arrayPool">The array pool to acquire buffers from.</param>
518519
/// <param name="options">Optional DataflowBlockOptions for configuring the source block.</param>
519520
/// <returns>The source block containing the results.</returns>
520-
public static IReceivableSourceBlock<object[]> AsSourceBlockAsync(this IExecuteReader command,
521-
ArrayPool<object> arrayPool,
521+
public static IReceivableSourceBlock<object?[]> AsSourceBlockAsync(this IExecuteReader command,
522+
ArrayPool<object?> arrayPool,
522523
DataflowBlockOptions? options = null)
523524
{
524-
var buffer = GetBufferBlock<object[]>(options);
525+
var buffer = GetBufferBlock<object?[]>(options);
525526
_ = ToTargetBlockAsync(command, buffer, true, arrayPool);
526527
return buffer;
527528
}

Dataflow/Open.Database.Extensions.Dataflow.csproj

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,29 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4+
<RootNamespace>Open.Database.Extensions.Dataflow</RootNamespace>
45
<TargetFrameworks>netstandard2.0; netstandard2.1</TargetFrameworks>
5-
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
6+
<LangVersion>latest</LangVersion>
7+
<Nullable>enable</Nullable>
68
<Authors>electricessence</Authors>
7-
<Company />
8-
<Product />
99
<PackageLicenseExpression>MIT</PackageLicenseExpression>
10-
<PackageProjectUrl>https://github.com/electricessence/Open.Database.Extensions</PackageProjectUrl>
10+
<PackageProjectUrl>https://github.com/Open-NET-Libraries/Open.Database.Extensions</PackageProjectUrl>
1111
<Description>Useful set of utilities and abstractions for simplifying modern data-access operations with Dataflow and ensuring DI compatibility.</Description>
12-
<RepositoryUrl>https://github.com/electricessence/Open.Database.Extensions</RepositoryUrl>
12+
<RepositoryUrl>https://github.com/Open-NET-Libraries/Open.Database.Extensions</RepositoryUrl>
1313
<RepositoryType>git</RepositoryType>
14-
<Version>6.5.0</Version>
14+
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
15+
<Version>6.6.1</Version>
1516
<PackageReleaseNotes></PackageReleaseNotes>
16-
<LangVersion>latest</LangVersion>
17-
<Nullable>enable</Nullable>
18-
<RootNamespace>Open.Database.Extensions.Dataflow</RootNamespace>
17+
<PackageLicenseExpression>MIT</PackageLicenseExpression>
18+
<PublishRepositoryUrl>true</PublishRepositoryUrl>
19+
<IncludeSymbols>true</IncludeSymbols>
20+
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
21+
<PackageIcon>logo.png</PackageIcon>
1922
</PropertyGroup>
23+
24+
<ItemGroup>
25+
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />
26+
</ItemGroup>
2027

2128
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
2229
<DocumentationFile>Documentation.xml</DocumentationFile>
@@ -25,13 +32,20 @@
2532
<ItemGroup>
2633
<Compile Remove="DataReader.ToTargetBlock.cs" />
2734
</ItemGroup>
35+
36+
<ItemGroup>
37+
<None Include="..\logo.png">
38+
<Pack>True</Pack>
39+
<PackagePath></PackagePath>
40+
</None>
41+
</ItemGroup>
2842

2943
<ItemGroup>
30-
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="3.0.0">
44+
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="3.3.0-beta2.final">
3145
<PrivateAssets>all</PrivateAssets>
3246
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
3347
</PackageReference>
34-
<PackageReference Include="Open.Database.Extensions.Core" Version="6.5.0" />
48+
<PackageReference Include="Open.Database.Extensions.Core" Version="6.6.1" />
3549
<PackageReference Include="System.Threading.Tasks.Dataflow" Version="4.11.1" />
3650
</ItemGroup>
3751

Dataflow/ToTargetBlock.cs

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ public static long ToTargetBlock(this IDataReader reader,
5757
/// <param name="arrayPool">The array pool to acquire buffers from.</param>
5858
/// <returns>The number of records processed.</returns>
5959
public static long ToTargetBlock(this IDataReader reader,
60-
ITargetBlock<object[]> target,
60+
ITargetBlock<object?[]> target,
6161
bool complete,
62-
ArrayPool<object> arrayPool)
62+
ArrayPool<object?> arrayPool)
6363
{
6464
if (reader is null) throw new ArgumentNullException(nameof(reader));
6565
if (target is null) throw new ArgumentNullException(nameof(target));
@@ -202,9 +202,9 @@ public static long ToTargetBlock(this IDbCommand command,
202202
/// <param name="arrayPool">The array pool to acquire buffers from.</param>
203203
/// <returns>The number of records processed.</returns>
204204
public static long ToTargetBlock(this IDbCommand command,
205-
ITargetBlock<object[]> target,
205+
ITargetBlock<object?[]> target,
206206
bool complete,
207-
ArrayPool<object> arrayPool)
207+
ArrayPool<object?> arrayPool)
208208
{
209209
if (command is null) throw new ArgumentNullException(nameof(command));
210210
if (target is null) throw new ArgumentNullException(nameof(target));
@@ -410,9 +410,9 @@ public static long ToTargetBlock(this IExecuteReader command,
410410
/// <param name="arrayPool">The array pool to acquire buffers from.</param>
411411
/// <returns>The number of records processed.</returns>
412412
public static long ToTargetBlock(this IExecuteReader command,
413-
ITargetBlock<object[]> target,
413+
ITargetBlock<object?[]> target,
414414
bool complete,
415-
ArrayPool<object> arrayPool)
415+
ArrayPool<object?> arrayPool)
416416
{
417417
if (command is null) throw new ArgumentNullException(nameof(command));
418418
if (target is null) throw new ArgumentNullException(nameof(target));
@@ -624,9 +624,9 @@ await r.ReadAsync(cancellationToken).ConfigureAwait(false)
624624
/// <param name="cancellationToken">An optional cancellation token.</param>
625625
/// <returns>The number of records processed.</returns>
626626
public static async ValueTask<long> ToTargetBlockAsync(this IDataReader reader,
627-
ITargetBlock<object[]> target,
627+
ITargetBlock<object?[]> target,
628628
bool complete,
629-
ArrayPool<object> arrayPool,
629+
ArrayPool<object?> arrayPool,
630630
CancellationToken cancellationToken = default)
631631
{
632632
if (reader is null) throw new ArgumentNullException(nameof(reader));
@@ -776,7 +776,7 @@ public static async ValueTask<long> ToTargetBlockAsync(this IDbCommand command,
776776
try
777777
{
778778
return await command.ExecuteReaderAsync(reader =>
779-
ToTargetBlockAsync(reader, target, false, cancellationToken), cancellationToken: cancellationToken);
779+
ToTargetBlockAsync(reader, target, false, cancellationToken), cancellationToken: cancellationToken).ConfigureAwait(false);
780780
}
781781
catch (Exception ex)
782782
{
@@ -806,9 +806,9 @@ public static async ValueTask<long> ToTargetBlockAsync(this IDbCommand command,
806806
/// <param name="cancellationToken">An optional cancellation token.</param>
807807
/// <returns>The number of records processed.</returns>
808808
public static async ValueTask<long> ToTargetBlockAsync(this IDbCommand command,
809-
ITargetBlock<object[]> target,
809+
ITargetBlock<object?[]> target,
810810
bool complete,
811-
ArrayPool<object> arrayPool,
811+
ArrayPool<object?> arrayPool,
812812
CancellationToken cancellationToken = default)
813813
{
814814
if (command is null) throw new ArgumentNullException(nameof(command));
@@ -822,7 +822,7 @@ public static async ValueTask<long> ToTargetBlockAsync(this IDbCommand command,
822822
try
823823
{
824824
return await command.ExecuteReaderAsync(reader =>
825-
ToTargetBlockAsync(reader, target, false, arrayPool), cancellationToken: cancellationToken);
825+
ToTargetBlockAsync(reader, target, false, arrayPool), cancellationToken: cancellationToken).ConfigureAwait(false);
826826
}
827827
catch (Exception ex)
828828
{
@@ -868,7 +868,7 @@ public static async ValueTask<long> ToTargetBlockAsync<T>(this IDbCommand comman
868868
try
869869
{
870870
return await command.ExecuteReaderAsync(reader =>
871-
ToTargetBlockAsync(reader, target, false, transform), cancellationToken: cancellationToken);
871+
ToTargetBlockAsync(reader, target, false, transform), cancellationToken: cancellationToken).ConfigureAwait(false);
872872
}
873873
catch (Exception ex)
874874
{
@@ -913,11 +913,11 @@ public static async ValueTask<long> ToTargetBlockAsync<T>(this IDbCommand comman
913913
try
914914
{
915915
var dbc = command as DbCommand;
916-
var state = dbc == null ? command.Connection.EnsureOpen() : await dbc.Connection.EnsureOpenAsync(cancellationToken);
916+
var state = dbc == null ? command.Connection.EnsureOpen() : await dbc.Connection.EnsureOpenAsync(cancellationToken).ConfigureAwait(false);
917917
var behavior = CommandBehavior.SingleResult;
918918
if (state == ConnectionState.Closed) behavior |= CommandBehavior.CloseConnection;
919919
using var reader = dbc == null ? command.ExecuteReader(behavior) : await dbc.ExecuteReaderAsync(behavior, cancellationToken).ConfigureAwait(false);
920-
return await ToTargetBlockAsync(reader, target, false, cancellationToken);
920+
return await ToTargetBlockAsync(reader, target, false, cancellationToken).ConfigureAwait(false);
921921
}
922922
catch (Exception ex)
923923
{
@@ -964,11 +964,11 @@ public static async ValueTask<long> ToTargetBlockAsync<T>(this IDbCommand comman
964964
try
965965
{
966966
var dbc = command as DbCommand;
967-
var state = dbc == null ? command.Connection.EnsureOpen() : await dbc.Connection.EnsureOpenAsync(cancellationToken);
967+
var state = dbc == null ? command.Connection.EnsureOpen() : await dbc.Connection.EnsureOpenAsync(cancellationToken).ConfigureAwait(false);
968968
var behavior = CommandBehavior.SingleResult;
969969
if (state == ConnectionState.Closed) behavior |= CommandBehavior.CloseConnection;
970970
using var reader = dbc == null ? command.ExecuteReader(behavior) : await dbc.ExecuteReaderAsync(behavior, cancellationToken).ConfigureAwait(false);
971-
return await ToTargetBlockAsync(reader, target, false, fieldMappingOverrides, cancellationToken);
971+
return await ToTargetBlockAsync(reader, target, false, fieldMappingOverrides, cancellationToken).ConfigureAwait(false);
972972
}
973973
catch (Exception ex)
974974
{
@@ -1007,7 +1007,7 @@ public static async ValueTask<long> ToTargetBlockAsync(this IExecuteReader comma
10071007
try
10081008
{
10091009
return await command.ExecuteReaderAsync(reader =>
1010-
ToTargetBlockAsync(reader, target, false, command.CancellationToken));
1010+
ToTargetBlockAsync(reader, target, false, command.CancellationToken)).ConfigureAwait(false);
10111011
}
10121012
catch (Exception ex)
10131013
{
@@ -1036,9 +1036,9 @@ public static async ValueTask<long> ToTargetBlockAsync(this IExecuteReader comma
10361036
/// <param name="arrayPool">The array pool to acquire buffers from.</param>
10371037
/// <returns>The number of records processed.</returns>
10381038
public static async ValueTask<long> ToTargetBlockAsync(this IExecuteReader command,
1039-
ITargetBlock<object[]> target,
1039+
ITargetBlock<object?[]> target,
10401040
bool complete,
1041-
ArrayPool<object> arrayPool)
1041+
ArrayPool<object?> arrayPool)
10421042
{
10431043
if (command is null) throw new ArgumentNullException(nameof(command));
10441044
if (target is null) throw new ArgumentNullException(nameof(target));
@@ -1049,7 +1049,7 @@ public static async ValueTask<long> ToTargetBlockAsync(this IExecuteReader comma
10491049
try
10501050
{
10511051
return await command.ExecuteReaderAsync(reader =>
1052-
ToTargetBlockAsync(reader, target, false, arrayPool, command.CancellationToken));
1052+
ToTargetBlockAsync(reader, target, false, arrayPool, command.CancellationToken)).ConfigureAwait(false);
10531053
}
10541054
catch (Exception ex)
10551055
{
@@ -1091,7 +1091,7 @@ public static async ValueTask<long> ToTargetBlockAsync<T>(this IExecuteReader co
10911091
try
10921092
{
10931093
return await command.ExecuteReaderAsync(reader =>
1094-
ToTargetBlockAsync(reader, target, false, transform, command.CancellationToken));
1094+
ToTargetBlockAsync(reader, target, false, transform, command.CancellationToken)).ConfigureAwait(false);
10951095
}
10961096
catch (Exception ex)
10971097
{
@@ -1133,7 +1133,7 @@ public static async ValueTask<long> ToTargetBlockAsync<T>(this IExecuteReader co
11331133
try
11341134
{
11351135
return await command.ExecuteReaderAsync(reader =>
1136-
ToTargetBlockAsync(reader, target, false, command.CancellationToken));
1136+
ToTargetBlockAsync(reader, target, false, command.CancellationToken)).ConfigureAwait(false);
11371137
}
11381138
catch (Exception ex)
11391139
{
@@ -1176,7 +1176,7 @@ public static async ValueTask<long> ToTargetBlockAsync<T>(this IExecuteReader co
11761176
try
11771177
{
11781178
return await command.ExecuteReaderAsync(reader =>
1179-
ToTargetBlockAsync(reader, target, false, fieldMappingOverrides, command.CancellationToken));
1179+
ToTargetBlockAsync(reader, target, false, fieldMappingOverrides, command.CancellationToken)).ConfigureAwait(false);
11801180
}
11811181
catch (Exception ex)
11821182
{

Dataflow/Transformer.cs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,11 @@ public Transformer(IEnumerable<(string Field, string? Column)>? fieldMappingOver
3636
/// <param name="complete">Will call complete when no more results are avaiable.</param>
3737
/// <param name="options">The options to apply to the transform block.</param>
3838
/// <returns>The ChannelReader of the target.</returns>
39-
internal long PipeResultsTo(IDataReader reader, ITargetBlock<T> target, bool complete, ExecutionDataflowBlockOptions? options = null)
39+
internal long PipeResultsTo(
40+
IDataReader reader,
41+
ITargetBlock<T> target,
42+
bool complete,
43+
ExecutionDataflowBlockOptions? options = null)
4044
{
4145
if (reader is null) throw new ArgumentNullException(nameof(reader));
4246
if (target is null) throw new ArgumentNullException(nameof(target));
@@ -50,7 +54,7 @@ internal long PipeResultsTo(IDataReader reader, ITargetBlock<T> target, bool com
5054
var transform = processor.Transform;
5155
var columnCount = columns.Length;
5256

53-
var transformBlock = new TransformBlock<object[], T>(
57+
var transformBlock = new TransformBlock<object?[], T>(
5458
a =>
5559
{
5660
try
@@ -95,7 +99,12 @@ internal long PipeResultsTo(IDataReader reader, ITargetBlock<T> target, bool com
9599
/// <param name="cancellationToken">The cancellation token.</param>
96100
/// <param name="options">The options to apply to the transform block.</param>
97101
/// <returns>The ChannelReader of the target.</returns>
98-
internal async ValueTask<long> PipeResultsToAsync(IDataReader reader, ITargetBlock<T> target, bool complete, CancellationToken cancellationToken, ExecutionDataflowBlockOptions? options = null)
102+
internal async ValueTask<long> PipeResultsToAsync(
103+
IDataReader reader,
104+
ITargetBlock<T> target,
105+
bool complete,
106+
CancellationToken cancellationToken,
107+
ExecutionDataflowBlockOptions? options = null)
99108
{
100109
if (reader is null) throw new ArgumentNullException(nameof(reader));
101110
if (target is null) throw new ArgumentNullException(nameof(target));
@@ -109,7 +118,7 @@ internal async ValueTask<long> PipeResultsToAsync(IDataReader reader, ITargetBlo
109118
var transform = processor.Transform;
110119
var columnCount = columns.Length;
111120

112-
var transformBlock = new TransformBlock<object[], T>(
121+
var transformBlock = new TransformBlock<object?[], T>(
113122
a =>
114123
{
115124
try
@@ -142,7 +151,7 @@ internal async ValueTask<long> PipeResultsToAsync(IDataReader reader, ITargetBlo
142151
TaskScheduler.Current);
143152
}
144153

145-
return await reader.ToTargetBlockAsync(transformBlock, true, LocalPool, cancellationToken);
154+
return await reader.ToTargetBlockAsync(transformBlock, true, LocalPool, cancellationToken).ConfigureAwait(false);
146155
}
147156

148157
}

0 commit comments

Comments
 (0)