Nullify ServerFactory

This commit is contained in:
Jordan Dominion
2023-11-23 18:45:51 -05:00
parent c6d17a1fa5
commit f8b0d62c60
3 changed files with 5 additions and 8 deletions
+1 -3
View File
@@ -3,8 +3,6 @@ using System.Threading.Tasks;
using Tgstation.Server.Host.IO;
#nullable disable
namespace Tgstation.Server.Host
{
/// <summary>
@@ -24,6 +22,6 @@ namespace Tgstation.Server.Host
/// <param name="updatePath">The directory in which to install server updates.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the operation.</param>
/// <returns>A <see cref="ValueTask{TResult}"/> resulting in a new <see cref="IServer"/> if it should be run, <see langword="null"/> otherwise.</returns>
ValueTask<IServer> CreateServer(string[] args, string updatePath, CancellationToken cancellationToken);
ValueTask<IServer?> CreateServer(string[] args, string? updatePath, CancellationToken cancellationToken);
}
}
+1 -1
View File
@@ -83,7 +83,7 @@ namespace Tgstation.Server.Host
{
using var shutdownNotifier = new ProgramShutdownTokenSource();
var cancellationToken = shutdownNotifier.Token;
IServer server;
IServer? server;
try
{
server = await ServerFactory.CreateServer(
+3 -4
View File
@@ -17,8 +17,6 @@ using Tgstation.Server.Host.IO;
using Tgstation.Server.Host.Setup;
using Tgstation.Server.Host.System;
#nullable disable
namespace Tgstation.Server.Host
{
/// <summary>
@@ -53,7 +51,7 @@ namespace Tgstation.Server.Host
/// <inheritdoc />
// TODO: Decomplexify
#pragma warning disable CA1506
public async ValueTask<IServer> CreateServer(string[] args, string updatePath, CancellationToken cancellationToken)
public async ValueTask<IServer?> CreateServer(string[] args, string? updatePath, CancellationToken cancellationToken)
{
ArgumentNullException.ThrowIfNull(args);
@@ -98,7 +96,8 @@ namespace Tgstation.Server.Host
#if !NET8_0
#error Validate this monstrosity works on current .NET
#endif
IConfigurationSource cmdLineConfig, baseYmlConfig, environmentYmlConfig;
IConfigurationSource? cmdLineConfig;
IConfigurationSource baseYmlConfig, environmentYmlConfig;
if (args.Length == 0)
{
cmdLineConfig = null;