Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix nullability [PR]. #161

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ public EmptyLocalizationCatalog(CultureInfo cultureInfo)

public virtual string GetString(string text) => text;

public virtual string GetString(string text, params object[] args) => string.Format(FormatProvider, text, args);
public virtual string GetString(string text, params object?[] args) => string.Format(FormatProvider, text, args);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ public interface ILocalizationCatalog
/// <param name="text">The text to be translated.</param>
/// <param name="args">The format arguments.</param>
/// <returns>The translated text.</returns>
string GetString(string text, params object[] args);
string GetString(string text, params object?[] args);
}
}
6 changes: 3 additions & 3 deletions src/FubarDev.FtpServer/FtpConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public sealed class FtpConnection
private readonly FtpConnectionKeepAlive _keepAlive;
#pragma warning restore 612

private readonly IAuthorizationInformationFeature _authorizationInformationFeature;
private readonly IAuthorizationInformationFeature? _authorizationInformationFeature;

private bool _connectionClosing;

Expand Down Expand Up @@ -383,8 +383,8 @@ await _serviceControl.WaitAsync(CancellationToken.None)
return;
}

var currentUser = _authorizationInformationFeature.FtpUser;
var membershipProvider = _authorizationInformationFeature.MembershipProvider;
var currentUser = _authorizationInformationFeature?.FtpUser;
var membershipProvider = _authorizationInformationFeature?.MembershipProvider;
if (currentUser != null
&& membershipProvider is IMembershipProviderAsync membershipProviderAsync)
{
Expand Down
2 changes: 1 addition & 1 deletion src/FubarDev.FtpServer/FtpServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ private async Task AddClientAsync(TcpClient client)
// Remember connection
if (!_connections.TryAdd(connection, new FtpConnectionInfo(scope)))
{
_log.LogCritical("A new scope was created, but the connection couldn't be added to the list");
_log?.LogCritical("A new scope was created, but the connection couldn't be added to the list");
client.Dispose();
scope.Dispose();
return;
Expand Down
2 changes: 1 addition & 1 deletion src/FubarDev.FtpServer/ServiceCollectionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public static IServiceCollection AddFtpServer(
services.AddScoped<IFeatureInfoProvider, DefaultFeatureInfoProvider>();

services.AddScoped<TcpSocketClientAccessor>();
services.AddScoped(sp => sp.GetRequiredService<TcpSocketClientAccessor>().TcpSocketClient);
services.AddScoped(sp => sp.GetRequiredService<TcpSocketClientAccessor>().TcpSocketClient ?? throw new NullReferenceException("TCP socket client null"));

services.AddScoped<IFtpConnection, FtpConnection>();
services.AddScoped<IFtpLoginStateMachine, FtpLoginStateMachine>();
Expand Down