Skip to content

Commit

Permalink
Fix possibly null references
Browse files Browse the repository at this point in the history
  • Loading branch information
tinohager committed Nov 7, 2024
1 parent ecfc69b commit 6ec9a5a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/Nager.TcpClient.UnitTest/SendAfterConnectedEventTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public void SendAfterConnect_Successful()
x => x.Log(
LogLevel.Debug,
It.IsAny<EventId>(),
It.Is<It.IsAnyType>((o, t) => o.ToString().Contains("SendAsync")),
It.Is<It.IsAnyType>((o, t) => (o.ToString() ?? string.Empty).Contains("SendAsync")),
It.IsAny<Exception>(),
It.IsAny<Func<It.IsAnyType, Exception?, string>>()),
Times.Once);
Expand All @@ -52,7 +52,7 @@ public async Task SendAfterConnectAsync_Successful()
x => x.Log(
LogLevel.Debug,
It.IsAny<EventId>(),
It.Is<It.IsAnyType>((o, t) => o.ToString().Contains("SendAsync")),
It.Is<It.IsAnyType>((o, t) => (o.ToString() ?? string.Empty).Contains("SendAsync")),
It.IsAny<Exception>(),
It.IsAny<Func<It.IsAnyType, Exception?, string>>()),
Times.Once);
Expand Down
2 changes: 1 addition & 1 deletion src/Nager.TcpClient/Nager.TcpClient.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

<TargetFrameworks>netstandard2.0;netstandard2.1;net6;net8</TargetFrameworks>

<Version>1.3.0</Version>
<Version>1.3.1</Version>
</PropertyGroup>

<ItemGroup>
Expand Down
7 changes: 6 additions & 1 deletion src/Nager.TcpClient/TcpClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -580,8 +580,13 @@ await Task
this._logger.LogInformation($"{nameof(DataReceiverAsync)} - Stopped");
}

private bool IsKnownException(Exception exception)
private bool IsKnownException(Exception? exception)
{
if (exception == null)
{
return false;
}

if (exception is AggregateException aggregateException)
{
if (aggregateException.InnerException is IOException ioException)
Expand Down

0 comments on commit 6ec9a5a

Please sign in to comment.