Skip to content

Commit

Permalink
Fixed warnings around nullable reference types
Browse files Browse the repository at this point in the history
  • Loading branch information
fubar-coder committed Oct 28, 2019
1 parent 323284e commit e104f30
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 7 deletions.
2 changes: 2 additions & 0 deletions FubarDev.FtpServer.ruleset
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
<RuleSet Name="Regeln für FubarDev.FtpServer" Description="Codeanalyseregeln für FubarDev.FtpServer.csproj." ToolsVersion="14.0">
<Rules AnalyzerId="StyleCop.Analyzers" RuleNamespace="StyleCop.Analyzers">
<Rule Id="SA0001" Action="None" />
<!-- StyleCop.Analyzers cannot handle C# 8.0 yet -->
<Rule Id="SA1009" Action="None" />
<Rule Id="SA1101" Action="None" />
<Rule Id="SA1200" Action="None" />
<Rule Id="SA1309" Action="None" />
Expand Down
2 changes: 1 addition & 1 deletion src/FubarDev.FtpServer/FtpConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ await _serverCommandExecutor.ExecuteAsync(response, cancellationToken)
catch (Exception ex)
{
var exception = ex;
while (exception is AggregateException aggregateException)
while (exception is AggregateException aggregateException && aggregateException.InnerException != null)
{
exception = aggregateException.InnerException;
}
Expand Down
6 changes: 3 additions & 3 deletions src/FubarDev.FtpServer/FtpServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ await AddClientAsync(client)
catch (Exception ex)
{
var exception = ex;
while (exception is AggregateException aggregateException)
while (exception is AggregateException aggregateException && aggregateException.InnerException != null)
{
exception = aggregateException.InnerException;
}
Expand Down Expand Up @@ -292,9 +292,9 @@ await connection.StartAsync()
}
}

private void ConnectionOnClosed(object sender, EventArgs eventArgs)
private void ConnectionOnClosed(object? sender, EventArgs eventArgs)
{
var connection = (IFtpConnection)sender;
var connection = (IFtpConnection)(sender ?? throw new InvalidOperationException("Missing sender information."));
if (!_connections.TryRemove(connection, out var info))
{
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public Task ExecuteAsync(IServerCommand serverCommand, CancellationToken cancell
_serverCommandHandlerDelegates.Add(serverCommandType, cmdDelegate);
}

return (Task)cmdDelegate.DynamicInvoke(serverCommand, cancellationToken);
return (Task)cmdDelegate.DynamicInvoke(serverCommand, cancellationToken)!;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ public Task ExecuteAsync(IServerCommand serverCommand, CancellationToken cancell
var executeAsyncMethod = handlerType.GetRuntimeMethod("ExecuteAsync", new[] { serverCommandType, typeof(CancellationToken) });
var handler = _ftpConnectionAccessor.FtpConnection.ConnectionServices.GetRequiredService(handlerType);

commandHandlerInfo = new CommandHandlerInfo(handler, executeAsyncMethod);
commandHandlerInfo = new CommandHandlerInfo(handler, executeAsyncMethod!);
_serverCommandHandlerInfo.Add(serverCommandType, commandHandlerInfo);
}

return (Task)commandHandlerInfo.ExecuteMethodInfo.Invoke(
commandHandlerInfo.CommandHandler,
new object[] { serverCommand, cancellationToken });
new object[] { serverCommand, cancellationToken })!;
}

private class CommandHandlerInfo
Expand Down

0 comments on commit e104f30

Please sign in to comment.