diff --git a/src/FubarDev.FtpServer.Abstractions/Localization/EmptyLocalizationCatalog.cs b/src/FubarDev.FtpServer.Abstractions/Localization/EmptyLocalizationCatalog.cs
index 52293513..1a7b26dc 100644
--- a/src/FubarDev.FtpServer.Abstractions/Localization/EmptyLocalizationCatalog.cs
+++ b/src/FubarDev.FtpServer.Abstractions/Localization/EmptyLocalizationCatalog.cs
@@ -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);
}
}
diff --git a/src/FubarDev.FtpServer.Abstractions/Localization/ILocalizationCatalog.cs b/src/FubarDev.FtpServer.Abstractions/Localization/ILocalizationCatalog.cs
index 668fd41f..4cf2a1b6 100644
--- a/src/FubarDev.FtpServer.Abstractions/Localization/ILocalizationCatalog.cs
+++ b/src/FubarDev.FtpServer.Abstractions/Localization/ILocalizationCatalog.cs
@@ -15,6 +15,6 @@ public interface ILocalizationCatalog
/// The text to be translated.
/// The format arguments.
/// The translated text.
- string GetString(string text, params object[] args);
+ string GetString(string text, params object?[] args);
}
}
diff --git a/src/FubarDev.FtpServer/FtpConnection.cs b/src/FubarDev.FtpServer/FtpConnection.cs
index d86f6ac4..4f7a0fbb 100644
--- a/src/FubarDev.FtpServer/FtpConnection.cs
+++ b/src/FubarDev.FtpServer/FtpConnection.cs
@@ -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;
@@ -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)
{
diff --git a/src/FubarDev.FtpServer/FtpServer.cs b/src/FubarDev.FtpServer/FtpServer.cs
index 8f654653..13d7a2bf 100644
--- a/src/FubarDev.FtpServer/FtpServer.cs
+++ b/src/FubarDev.FtpServer/FtpServer.cs
@@ -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;
diff --git a/src/FubarDev.FtpServer/ServiceCollectionExtensions.cs b/src/FubarDev.FtpServer/ServiceCollectionExtensions.cs
index 320cc587..f4477992 100644
--- a/src/FubarDev.FtpServer/ServiceCollectionExtensions.cs
+++ b/src/FubarDev.FtpServer/ServiceCollectionExtensions.cs
@@ -78,7 +78,7 @@ public static IServiceCollection AddFtpServer(
services.AddScoped();
services.AddScoped();
- services.AddScoped(sp => sp.GetRequiredService().TcpSocketClient);
+ services.AddScoped(sp => sp.GetRequiredService().TcpSocketClient ?? throw new NullReferenceException("TCP socket client null"));
services.AddScoped();
services.AddScoped();