Skip to content

Commit b8bf4ed

Browse files
Cleanup and fix null checks.
1 parent f4d737b commit b8bf4ed

File tree

3 files changed

+15
-11
lines changed

3 files changed

+15
-11
lines changed

Open.ChannelExtensions/Extensions.Pipe.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
using static System.Net.Mime.MediaTypeNames;
2-
3-
namespace Open.ChannelExtensions;
1+
namespace Open.ChannelExtensions;
42

53
[SuppressMessage("Roslynator", "RCS1047:Non-asynchronous method name should not end with 'Async'.", Justification = "In order to differentiate between non async versions.")]
64
public static partial class Extensions

Open.ChannelExtensions/Extensions._.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,13 +117,16 @@ public static ChannelReader<TSource> PropagateCompletion<TSource, TTarget>(
117117
[ExcludeFromCodeCoverage]
118118
public static ChannelReader<TSource> PropagateCompletion<TSource, TTargetIn, TTargetOut>(
119119
this ChannelReader<TSource> source, Channel<TTargetIn, TTargetOut> target, CancellationToken cancellationToken = default)
120-
=> PropagateCompletion(source, target.Writer, cancellationToken);
120+
=> target is null
121+
? throw new ArgumentNullException(nameof(target))
122+
: source.PropagateCompletion(target.Writer, cancellationToken);
121123

122124
/// <inheritdoc cref="PropagateCompletion{TSource, TTarget}(ChannelReader{TSource}, ChannelWriter{TTarget}, CancellationToken)"/>
123125
[ExcludeFromCodeCoverage]
124126
public static Channel<TSourceIn, TSourceOut> PropagateCompletion<TSourceIn, TSourceOut, TTarget>(
125127
this Channel<TSourceIn, TSourceOut> source, ChannelWriter<TTarget> target, CancellationToken cancellationToken = default)
126128
{
129+
if (source is null) throw new ArgumentNullException(nameof(source));
127130
_ = source.Reader.PropagateCompletion(target, cancellationToken);
128131
return source;
129132
}
@@ -132,7 +135,9 @@ public static Channel<TSourceIn, TSourceOut> PropagateCompletion<TSourceIn, TSou
132135
[ExcludeFromCodeCoverage]
133136
public static Channel<TSourceIn, TSourceOut> PropagateCompletion<TSourceIn, TSourceOut, TTargetIn, TTargetOut>(
134137
this Channel<TSourceIn, TSourceOut> source, Channel<TTargetIn, TTargetOut> target, CancellationToken cancellationToken = default)
135-
=> PropagateCompletion(source, target.Writer, cancellationToken);
138+
=> target is null
139+
? throw new ArgumentNullException(nameof(target))
140+
: source.PropagateCompletion(target.Writer, cancellationToken);
136141

137142
/// <summary>
138143
/// Uses <see cref="ChannelWriter{T}.WaitToWriteAsync(CancellationToken)"/> to peek and see if the channel can still be written to.

Open.ChannelExtensions/Open.ChannelExtensions.csproj

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,18 @@
2222
<RepositoryType>git</RepositoryType>
2323
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
2424
<GenerateDocumentationFile>true</GenerateDocumentationFile>
25-
<Version>8.4.2</Version>
25+
<Version>8.4.3</Version>
2626
<PackageReleaseNotes>Added .Merge, .PipeAsync, and .PropagateCompletion extensions.</PackageReleaseNotes>
2727
<PackageLicenseExpression>MIT</PackageLicenseExpression>
2828
<PublishRepositoryUrl>true</PublishRepositoryUrl>
2929
<IncludeSymbols>true</IncludeSymbols>
3030
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
3131
<PackageIcon>logo.png</PackageIcon>
3232
<PackageReadmeFile>README.md</PackageReadmeFile>
33-
<!-- Don't enforce colleciton expressions as they don't work in .NET 6. -->
33+
<!-- Don't enforce collection expressions as they don't work in .NET 6. -->
3434
<NoWarn>IDE0301;IDE0303;IDE0304</NoWarn>
3535
</PropertyGroup>
3636

37-
<PropertyGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
38-
<NoWarn>$(NoWarn);nullable</NoWarn>
39-
</PropertyGroup>
40-
4137
<ItemGroup>
4238
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.*" PrivateAssets="All" />
4339
</ItemGroup>
@@ -58,4 +54,9 @@
5854
<PackageReference Include="System.Collections.Immutable" Version="8.*" />
5955
</ItemGroup>
6056

57+
<!-- Disable the nullable warnings when compiling for .NET Standard 2.0 -->
58+
<PropertyGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
59+
<NoWarn>$(NoWarn);nullable</NoWarn>
60+
</PropertyGroup>
61+
6162
</Project>

0 commit comments

Comments
 (0)