From bc701d288ad27f0fd6b79dddfa6c67c2ed6ab425 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 23 Nov 2023 17:10:06 -0500 Subject: [PATCH 001/425] Enable NRT with global opt-out We will phase this in gradually --- src/Tgstation.Server.Host/Components/Chat/ChannelMapping.cs | 4 +++- .../Components/Chat/ChannelRepresentation.cs | 2 ++ src/Tgstation.Server.Host/Components/Chat/ChatManager.cs | 2 ++ .../Components/Chat/ChatManagerFactory.cs | 2 ++ .../Components/Chat/ChatTrackingContext.cs | 2 ++ src/Tgstation.Server.Host/Components/Chat/ChatUser.cs | 2 ++ .../Components/Chat/Commands/CommandFactory.cs | 2 ++ .../Components/Chat/Commands/CustomCommand.cs | 2 ++ .../Components/Chat/Commands/EngineCommand.cs | 2 ++ .../Components/Chat/Commands/ICommand.cs | 2 ++ .../Components/Chat/Commands/ICommandFactory.cs | 2 ++ .../Components/Chat/Commands/KekCommand.cs | 2 ++ .../Components/Chat/Commands/PullRequestsCommand.cs | 2 ++ .../Components/Chat/Commands/RevisionCommand.cs | 2 ++ .../Components/Chat/Commands/VersionCommand.cs | 2 ++ src/Tgstation.Server.Host/Components/Chat/IChannelSink.cs | 2 ++ src/Tgstation.Server.Host/Components/Chat/IChatManager.cs | 2 ++ .../Components/Chat/IChatManagerFactory.cs | 2 ++ .../Components/Chat/IChatTrackingContext.cs | 2 ++ .../Components/Chat/ICustomCommandHandler.cs | 2 ++ .../Components/Chat/Providers/DiscordForwardingResponder.cs | 2 ++ .../Components/Chat/Providers/DiscordMessage.cs | 2 ++ .../Components/Chat/Providers/DiscordProvider.cs | 2 ++ .../Components/Chat/Providers/IDiscordResponders.cs | 2 ++ .../Components/Chat/Providers/IProvider.cs | 2 ++ .../Components/Chat/Providers/IProviderFactory.cs | 2 ++ .../Components/Chat/Providers/IrcProvider.cs | 2 ++ .../Components/Chat/Providers/Message.cs | 4 +++- .../Components/Chat/Providers/Provider.cs | 2 ++ .../Components/Chat/Providers/ProviderFactory.cs | 2 ++ src/Tgstation.Server.Host/Components/Deployment/DmbFactory.cs | 2 ++ .../Components/Deployment/DmbProvider.cs | 2 ++ .../Components/Deployment/DmbProviderBase.cs | 2 ++ src/Tgstation.Server.Host/Components/Deployment/DreamMaker.cs | 2 ++ .../Components/Deployment/HardLinkDmbProvider.cs | 2 ++ .../Components/Deployment/ICompileJobSink.cs | 2 ++ .../Components/Deployment/IDmbFactory.cs | 2 ++ .../Components/Deployment/IDmbProvider.cs | 2 ++ .../Components/Deployment/IDreamMaker.cs | 2 ++ .../Components/Deployment/ILatestCompileJobProvider.cs | 2 ++ .../Deployment/Remote/BaseRemoteDeploymentManager.cs | 2 ++ .../Deployment/Remote/GitHubRemoteDeploymentManager.cs | 2 ++ .../Deployment/Remote/GitLabRemoteDeploymentManager.cs | 2 ++ .../Components/Deployment/Remote/IRemoteDeploymentManager.cs | 2 ++ .../Deployment/Remote/IRemoteDeploymentManagerFactory.cs | 2 ++ .../Deployment/Remote/NoOpRemoteDeploymentManager.cs | 2 ++ .../Deployment/Remote/RemoteDeploymentManagerFactory.cs | 2 ++ .../Components/Deployment/SwappableDmbProvider.cs | 2 ++ .../Components/Deployment/SymlinkDmbProvider.cs | 2 ++ .../Components/Deployment/TemporaryDmbProvider.cs | 2 ++ .../Components/Engine/ByondInstallation.cs | 2 ++ .../Components/Engine/ByondInstallerBase.cs | 2 ++ .../Components/Engine/DelegatingEngineInstaller.cs | 2 ++ .../Components/Engine/EngineExecutableLock.cs | 2 ++ .../Components/Engine/EngineInstallationBase.cs | 2 ++ .../Components/Engine/EngineInstallerBase.cs | 2 ++ src/Tgstation.Server.Host/Components/Engine/EngineManager.cs | 2 ++ .../Components/Engine/IEngineExecutableLock.cs | 2 ++ .../Components/Engine/IEngineInstallation.cs | 2 ++ .../Components/Engine/IEngineInstallationData.cs | 2 ++ .../Components/Engine/IEngineInstaller.cs | 2 ++ src/Tgstation.Server.Host/Components/Engine/IEngineManager.cs | 2 ++ .../Components/Engine/OpenDreamInstallation.cs | 2 ++ .../Components/Engine/OpenDreamInstaller.cs | 2 ++ .../Components/Engine/PosixByondInstaller.cs | 2 ++ .../Components/Engine/RepositoryEngineInstallationData.cs | 2 ++ .../Components/Engine/WindowsByondInstaller.cs | 2 ++ .../Components/Engine/WindowsOpenDreamInstaller.cs | 2 ++ .../Components/Engine/ZipStreamEngineInstallationData.cs | 2 ++ src/Tgstation.Server.Host/Components/Events/EventConsumer.cs | 2 ++ .../Components/Events/EventScriptAttribute.cs | 2 ++ src/Tgstation.Server.Host/Components/Events/IEventConsumer.cs | 2 ++ .../Components/Events/NoopEventConsumer.cs | 2 ++ src/Tgstation.Server.Host/Components/IComponentService.cs | 2 ++ src/Tgstation.Server.Host/Components/IInstance.cs | 2 ++ src/Tgstation.Server.Host/Components/IInstanceCore.cs | 2 ++ src/Tgstation.Server.Host/Components/IInstanceFactory.cs | 2 ++ src/Tgstation.Server.Host/Components/IInstanceManager.cs | 2 ++ src/Tgstation.Server.Host/Components/IInstanceOperations.cs | 2 ++ src/Tgstation.Server.Host/Components/IInstanceReference.cs | 2 ++ src/Tgstation.Server.Host/Components/IRenameNotifyee.cs | 2 ++ src/Tgstation.Server.Host/Components/Instance.cs | 2 ++ src/Tgstation.Server.Host/Components/InstanceFactory.cs | 2 ++ src/Tgstation.Server.Host/Components/InstanceManager.cs | 2 ++ src/Tgstation.Server.Host/Components/InstanceWrapper.cs | 2 ++ .../Components/Interop/Bridge/BridgeParameters.cs | 2 ++ .../Components/Interop/Bridge/BridgeRegistration.cs | 2 ++ .../Components/Interop/Bridge/BridgeResponse.cs | 2 ++ .../Components/Interop/Bridge/IBridgeDispatcher.cs | 2 ++ .../Components/Interop/Bridge/IBridgeRegistration.cs | 2 ++ .../Components/Interop/Bridge/RuntimeInformation.cs | 2 ++ .../Components/Interop/Bridge/TestMergeInformation.cs | 2 ++ src/Tgstation.Server.Host/Components/Interop/ChatEmbed.cs | 2 ++ .../Components/Interop/ChatEmbedAuthor.cs | 4 +++- .../Components/Interop/ChatEmbedField.cs | 4 +++- .../Components/Interop/ChatEmbedFooter.cs | 4 +++- .../Components/Interop/ChatEmbedMedia.cs | 4 +++- .../Components/Interop/ChatEmbedProvider.cs | 4 +++- src/Tgstation.Server.Host/Components/Interop/ChatMessage.cs | 2 ++ src/Tgstation.Server.Host/Components/Interop/ChatUpdate.cs | 2 ++ src/Tgstation.Server.Host/Components/Interop/ChunkData.cs | 4 +++- src/Tgstation.Server.Host/Components/Interop/Chunker.cs | 2 ++ .../Components/Interop/DMApiConstants.cs | 2 ++ .../Components/Interop/DMApiParameters.cs | 2 ++ src/Tgstation.Server.Host/Components/Interop/DMApiResponse.cs | 4 +++- .../Components/Interop/IMissingPayloadsCommunication.cs | 2 ++ .../Components/Interop/MessageContent.cs | 4 +++- .../Components/Interop/Topic/ChatCommand.cs | 2 ++ .../Components/Interop/Topic/ChunkedTopicParameters.cs | 2 ++ .../Components/Interop/Topic/EventNotification.cs | 2 ++ .../Components/Interop/Topic/TopicCommandType.cs | 2 ++ .../Components/Interop/Topic/TopicParameters.cs | 2 ++ .../Components/Interop/Topic/TopicResponse.cs | 2 ++ .../Components/Repository/DefaultGitRemoteFeatures.cs | 2 ++ .../Components/Repository/GitHubRemoteFeatures.cs | 2 ++ .../Components/Repository/GitLabRemoteFeatures.cs | 2 ++ .../Components/Repository/GitRemoteFeaturesBase.cs | 2 ++ .../Components/Repository/GitRemoteFeaturesFactory.cs | 2 ++ .../Components/Repository/ICredentialsProvider.cs | 2 ++ .../Components/Repository/IGitRemoteAdditionalInformation.cs | 2 ++ .../Components/Repository/IGitRemoteFeaturesFactory.cs | 2 ++ .../Components/Repository/ILibGit2Commands.cs | 2 ++ .../Components/Repository/ILibGit2RepositoryFactory.cs | 2 ++ .../Components/Repository/IRepository.cs | 2 ++ .../Components/Repository/IRepositoryManager.cs | 2 ++ .../Components/Repository/IRepositoryManagerFactory.cs | 2 ++ .../Components/Repository/LibGit2Commands.cs | 2 ++ .../Components/Repository/LibGit2RepositoryFactory.cs | 2 ++ src/Tgstation.Server.Host/Components/Repository/Repository.cs | 2 ++ .../Components/Repository/RepositoryManager.cs | 2 ++ .../Components/Repository/RepositoryUpdateService.cs | 2 ++ .../Components/Repository/RepostoryManagerFactory.cs | 2 ++ .../Components/Repository/TestMergeResult.cs | 2 ++ .../Components/Session/CombinedTopicResponse.cs | 2 ++ .../Components/Session/ISessionController.cs | 2 ++ .../Components/Session/ISessionControllerFactory.cs | 2 ++ .../Components/Session/ISessionPersistor.cs | 2 ++ .../Components/Session/ITopicClientFactory.cs | 2 ++ src/Tgstation.Server.Host/Components/Session/LaunchResult.cs | 2 ++ .../Components/Session/ReattachInformation.cs | 2 ++ .../Components/Session/SessionController.cs | 2 ++ .../Components/Session/SessionControllerFactory.cs | 2 ++ .../Components/Session/SessionPersistor.cs | 2 ++ .../Components/Session/TopicClientFactory.cs | 2 ++ .../Components/StaticFiles/Configuration.cs | 2 ++ .../Components/StaticFiles/IConfiguration.cs | 2 ++ .../Components/Watchdog/AdvancedWatchdog.cs | 2 ++ .../Components/Watchdog/BasicWatchdog.cs | 2 ++ src/Tgstation.Server.Host/Components/Watchdog/IWatchdog.cs | 2 ++ .../Components/Watchdog/IWatchdogFactory.cs | 2 ++ .../Components/Watchdog/PosixWatchdog.cs | 2 ++ .../Components/Watchdog/PosixWatchdogFactory.cs | 2 ++ src/Tgstation.Server.Host/Components/Watchdog/WatchdogBase.cs | 2 ++ .../Components/Watchdog/WatchdogFactory.cs | 2 ++ .../Components/Watchdog/WindowsWatchdog.cs | 2 ++ .../Components/Watchdog/WindowsWatchdogFactory.cs | 2 ++ .../Configuration/ControlPanelConfiguration.cs | 2 ++ .../Configuration/DatabaseConfiguration.cs | 2 ++ .../Configuration/ElasticsearchConfiguration.cs | 2 ++ .../Configuration/FileLoggingConfiguration.cs | 2 ++ .../Configuration/GeneralConfiguration.cs | 2 ++ .../Configuration/InternalConfiguration.cs | 4 +++- src/Tgstation.Server.Host/Configuration/OAuthConfiguration.cs | 2 ++ .../Configuration/OAuthConfigurationBase.cs | 2 ++ .../Configuration/SecurityConfiguration.cs | 2 ++ src/Tgstation.Server.Host/Configuration/SwarmConfiguration.cs | 2 ++ .../Configuration/UpdatesConfiguration.cs | 2 ++ .../Controllers/AdministrationController.cs | 2 ++ src/Tgstation.Server.Host/Controllers/ApiController.cs | 2 ++ src/Tgstation.Server.Host/Controllers/ApiControllerBase.cs | 2 ++ src/Tgstation.Server.Host/Controllers/ApiRootController.cs | 2 ++ src/Tgstation.Server.Host/Controllers/BridgeController.cs | 2 ++ src/Tgstation.Server.Host/Controllers/ChatController.cs | 2 ++ .../Controllers/ComponentInterfacingController.cs | 2 ++ .../Controllers/ConfigurationController.cs | 2 ++ .../Controllers/ControlPanelController.cs | 2 ++ .../Controllers/DreamDaemonController.cs | 2 ++ src/Tgstation.Server.Host/Controllers/DreamMakerController.cs | 2 ++ src/Tgstation.Server.Host/Controllers/EngineController.cs | 2 ++ src/Tgstation.Server.Host/Controllers/InstanceController.cs | 2 ++ .../Controllers/InstancePermissionSetController.cs | 2 ++ .../Controllers/InstanceRequiredController.cs | 2 ++ src/Tgstation.Server.Host/Controllers/JobController.cs | 2 ++ src/Tgstation.Server.Host/Controllers/RepositoryController.cs | 2 ++ .../Controllers/Results/LimitedStreamResult.cs | 2 ++ .../Controllers/Results/LimitedStreamResultExecutor.cs | 2 ++ .../Controllers/Results/PaginatableResult.cs | 2 ++ src/Tgstation.Server.Host/Controllers/RootController.cs | 2 ++ src/Tgstation.Server.Host/Controllers/SwarmController.cs | 2 ++ src/Tgstation.Server.Host/Controllers/TransferController.cs | 2 ++ src/Tgstation.Server.Host/Controllers/UserController.cs | 2 ++ src/Tgstation.Server.Host/Controllers/UserGroupController.cs | 2 ++ src/Tgstation.Server.Host/Core/Application.cs | 2 ++ src/Tgstation.Server.Host/Core/CommandPipeManager.cs | 2 ++ src/Tgstation.Server.Host/Core/IRestartHandler.cs | 2 ++ src/Tgstation.Server.Host/Core/IRestartRegistration.cs | 2 ++ src/Tgstation.Server.Host/Core/IServerControl.cs | 2 ++ src/Tgstation.Server.Host/Core/IServerUpdateExecutor.cs | 2 ++ src/Tgstation.Server.Host/Core/IServerUpdateInitiator.cs | 2 ++ src/Tgstation.Server.Host/Core/IServerUpdater.cs | 2 ++ src/Tgstation.Server.Host/Core/RestartRegistration.cs | 2 ++ src/Tgstation.Server.Host/Core/ServerPortProivder.cs | 2 ++ src/Tgstation.Server.Host/Core/ServerUpdateInitiator.cs | 2 ++ src/Tgstation.Server.Host/Core/ServerUpdateOperation.cs | 2 ++ src/Tgstation.Server.Host/Core/ServerUpdater.cs | 2 ++ src/Tgstation.Server.Host/Database/DatabaseCollection.cs | 2 ++ .../Database/DatabaseConnectionFactory.cs | 2 ++ src/Tgstation.Server.Host/Database/DatabaseContext.cs | 2 ++ src/Tgstation.Server.Host/Database/DatabaseContextFactory.cs | 2 ++ src/Tgstation.Server.Host/Database/DatabaseSeeder.cs | 2 ++ .../Database/Design/DesignTimeDbContextFactoryHelpers.cs | 2 ++ .../Database/Design/MySqlDesignTimeDbContextFactory.cs | 2 ++ .../Database/Design/PostgresSqlDesignTimeDbContextFactory.cs | 2 ++ .../Database/Design/SqlServerDesignTimeDbContextFactory.cs | 2 ++ .../Database/Design/SqliteDesignTimeDbContextFactory.cs | 2 ++ src/Tgstation.Server.Host/Database/IDatabaseCollection.cs | 2 ++ .../Database/IDatabaseConnectionFactory.cs | 2 ++ src/Tgstation.Server.Host/Database/IDatabaseContext.cs | 2 ++ src/Tgstation.Server.Host/Database/IDatabaseContextFactory.cs | 2 ++ src/Tgstation.Server.Host/Database/IDatabaseSeeder.cs | 2 ++ src/Tgstation.Server.Host/Database/MySqlDatabaseContext.cs | 2 ++ .../Database/PostgresSqlDatabaseContext.cs | 2 ++ .../Database/SqlServerDatabaseContext.cs | 2 ++ src/Tgstation.Server.Host/Database/SqliteDatabaseContext.cs | 2 ++ .../Extensions/ApplicationBuilderExtensions.cs | 2 ++ src/Tgstation.Server.Host/Extensions/ChatChannelExtensions.cs | 2 ++ .../Extensions/ControllerBaseExtensions.cs | 2 ++ .../Extensions/Converters/BoolConverter.cs | 2 ++ .../Extensions/Converters/VersionConverter.cs | 2 ++ .../Extensions/DatabaseCollectionExtensions.cs | 2 ++ .../Extensions/DateTimeOffsetExtensions.cs | 2 ++ .../Extensions/FileTransferStreamHandlerExtensions.cs | 2 ++ .../Extensions/GeneralConfigurationExtensions.cs | 2 ++ src/Tgstation.Server.Host/Extensions/HostBuilderExtensions.cs | 2 ++ .../Extensions/ModelBuilderExtensions.cs | 2 ++ src/Tgstation.Server.Host/Extensions/ResultExtensions.cs | 2 ++ .../Extensions/ServiceCollectionExtensions.cs | 2 ++ src/Tgstation.Server.Host/Extensions/SocketExtensions.cs | 2 ++ src/Tgstation.Server.Host/Extensions/TaskExtensions.cs | 2 ++ .../Extensions/WebHostBuilderExtensions.cs | 2 ++ src/Tgstation.Server.Host/IO/BufferedFileStreamProvider.cs | 2 ++ src/Tgstation.Server.Host/IO/Console.cs | 2 ++ src/Tgstation.Server.Host/IO/DefaultIOManager.cs | 2 ++ src/Tgstation.Server.Host/IO/FileDownloader.cs | 2 ++ src/Tgstation.Server.Host/IO/IConsole.cs | 2 ++ src/Tgstation.Server.Host/IO/IFileDownloader.cs | 2 ++ src/Tgstation.Server.Host/IO/IFileStreamProvider.cs | 2 ++ src/Tgstation.Server.Host/IO/IFilesystemLinkFactory.cs | 2 ++ src/Tgstation.Server.Host/IO/IIOManager.cs | 2 ++ src/Tgstation.Server.Host/IO/ISeekableFileStreamProvider.cs | 2 ++ src/Tgstation.Server.Host/IO/ISynchronousIOManager.cs | 2 ++ src/Tgstation.Server.Host/IO/PosixFilesystemLinkFactory.cs | 2 ++ src/Tgstation.Server.Host/IO/PosixPostWriteHandler.cs | 2 ++ src/Tgstation.Server.Host/IO/RequestFileStreamProvider.cs | 2 ++ src/Tgstation.Server.Host/IO/ResolvingIOManager.cs | 2 ++ src/Tgstation.Server.Host/IO/SynchronousIOManager.cs | 2 ++ src/Tgstation.Server.Host/IO/WindowsFilesystemLinkFactory.cs | 2 ++ src/Tgstation.Server.Host/IO/WindowsPostWriteHandler.cs | 2 ++ src/Tgstation.Server.Host/IServer.cs | 2 ++ src/Tgstation.Server.Host/IServerFactory.cs | 2 ++ src/Tgstation.Server.Host/Jobs/IJobManager.cs | 2 ++ src/Tgstation.Server.Host/Jobs/IJobService.cs | 2 ++ src/Tgstation.Server.Host/Jobs/JobEntrypoint.cs | 2 ++ src/Tgstation.Server.Host/Jobs/JobException.cs | 2 ++ src/Tgstation.Server.Host/Jobs/JobHandler.cs | 2 ++ src/Tgstation.Server.Host/Jobs/JobProgressReporter.cs | 2 ++ src/Tgstation.Server.Host/Jobs/JobService.cs | 2 ++ src/Tgstation.Server.Host/Jobs/JobsHub.cs | 2 ++ src/Tgstation.Server.Host/Jobs/JobsHubGroupMapper.cs | 2 ++ src/Tgstation.Server.Host/Models/ChatBot.cs | 2 ++ src/Tgstation.Server.Host/Models/ChatChannel.cs | 2 ++ src/Tgstation.Server.Host/Models/CompileJob.cs | 2 ++ src/Tgstation.Server.Host/Models/DreamDaemonSettings.cs | 2 ++ src/Tgstation.Server.Host/Models/DreamMakerSettings.cs | 2 ++ src/Tgstation.Server.Host/Models/Instance.cs | 2 ++ src/Tgstation.Server.Host/Models/InstancePermissionSet.cs | 2 ++ src/Tgstation.Server.Host/Models/Job.cs | 2 ++ src/Tgstation.Server.Host/Models/OAuthConnection.cs | 4 +++- src/Tgstation.Server.Host/Models/PermissionSet.cs | 2 ++ src/Tgstation.Server.Host/Models/ReattachInformation.cs | 2 ++ src/Tgstation.Server.Host/Models/ReattachInformationBase.cs | 2 ++ src/Tgstation.Server.Host/Models/RepositorySettings.cs | 2 ++ src/Tgstation.Server.Host/Models/RevInfoTestMerge.cs | 2 ++ src/Tgstation.Server.Host/Models/RevisionInformation.cs | 2 ++ src/Tgstation.Server.Host/Models/TestMerge.cs | 2 ++ src/Tgstation.Server.Host/Models/User.cs | 2 ++ src/Tgstation.Server.Host/Models/UserGroup.cs | 2 ++ src/Tgstation.Server.Host/Program.cs | 2 ++ .../Properties/MasterVersionsAttribute.cs | 2 ++ src/Tgstation.Server.Host/Security/AuthenticationContext.cs | 2 ++ .../Security/AuthenticationContextAuthorizationFilter.cs | 2 ++ .../Security/AuthenticationContextClaimsTransformation.cs | 2 ++ .../Security/AuthenticationContextFactory.cs | 2 ++ .../Security/AuthorizationContextHubFilter.cs | 2 ++ src/Tgstation.Server.Host/Security/CryptographySuite.cs | 2 ++ src/Tgstation.Server.Host/Security/IAuthenticationContext.cs | 2 ++ .../Security/IAuthenticationContextFactory.cs | 2 ++ src/Tgstation.Server.Host/Security/ICryptographySuite.cs | 2 ++ src/Tgstation.Server.Host/Security/IIdentityCache.cs | 2 ++ .../Security/IPermissionsUpdateNotifyee.cs | 2 ++ src/Tgstation.Server.Host/Security/ISystemIdentity.cs | 2 ++ src/Tgstation.Server.Host/Security/ISystemIdentityFactory.cs | 2 ++ src/Tgstation.Server.Host/Security/ITokenFactory.cs | 2 ++ src/Tgstation.Server.Host/Security/IdentityCache.cs | 2 ++ src/Tgstation.Server.Host/Security/IdentityCacheObject.cs | 2 ++ .../Security/OAuth/DiscordOAuthValidator.cs | 2 ++ .../Security/OAuth/GenericOAuthValidator.cs | 2 ++ .../Security/OAuth/GitHubOAuthValidator.cs | 2 ++ src/Tgstation.Server.Host/Security/OAuth/IOAuthProviders.cs | 2 ++ src/Tgstation.Server.Host/Security/OAuth/IOAuthValidator.cs | 2 ++ .../Security/OAuth/InvisionCommunityOAuthValidator.cs | 2 ++ .../Security/OAuth/KeycloakOAuthValidator.cs | 2 ++ src/Tgstation.Server.Host/Security/OAuth/OAuthProviders.cs | 2 ++ src/Tgstation.Server.Host/Security/OAuth/OAuthTokenRequest.cs | 2 ++ .../Security/OAuth/TGForumsOAuthValidator.cs | 2 ++ src/Tgstation.Server.Host/Security/PosixSystemIdentity.cs | 2 ++ .../Security/PosixSystemIdentityFactory.cs | 2 ++ src/Tgstation.Server.Host/Security/TgsAuthorizeAttribute.cs | 2 ++ src/Tgstation.Server.Host/Security/TokenFactory.cs | 2 ++ src/Tgstation.Server.Host/Security/WindowsSystemIdentity.cs | 2 ++ .../Security/WindowsSystemIdentityFactory.cs | 2 ++ src/Tgstation.Server.Host/Server.cs | 2 ++ src/Tgstation.Server.Host/ServerFactory.cs | 2 ++ src/Tgstation.Server.Host/Setup/IPostSetupServices.cs | 2 ++ .../Setup/IPostSetupServices{TLoggerType}.cs | 2 ++ src/Tgstation.Server.Host/Setup/PostSetupServices.cs | 2 ++ src/Tgstation.Server.Host/Setup/SetupApplication.cs | 2 ++ src/Tgstation.Server.Host/Setup/SetupWizard.cs | 2 ++ src/Tgstation.Server.Host/Swarm/ISwarmOperations.cs | 2 ++ src/Tgstation.Server.Host/Swarm/ISwarmService.cs | 2 ++ src/Tgstation.Server.Host/Swarm/ISwarmServiceController.cs | 2 ++ src/Tgstation.Server.Host/Swarm/ISwarmUpdateAborter.cs | 2 ++ src/Tgstation.Server.Host/Swarm/SwarmConstants.cs | 2 ++ src/Tgstation.Server.Host/Swarm/SwarmRegistrationRequest.cs | 2 ++ src/Tgstation.Server.Host/Swarm/SwarmServersUpdateRequest.cs | 2 ++ src/Tgstation.Server.Host/Swarm/SwarmService.cs | 2 ++ src/Tgstation.Server.Host/Swarm/SwarmUpdateOperation.cs | 2 ++ src/Tgstation.Server.Host/Swarm/SwarmUpdateRequest.cs | 2 ++ .../System/AssemblyInformationProvider.cs | 2 ++ .../System/IAssemblyInformationProvider.cs | 2 ++ src/Tgstation.Server.Host/System/IPlatformIdentifier.cs | 2 ++ src/Tgstation.Server.Host/System/IProcess.cs | 2 ++ src/Tgstation.Server.Host/System/IProcessBase.cs | 2 ++ src/Tgstation.Server.Host/System/IProcessExecutor.cs | 4 +++- src/Tgstation.Server.Host/System/IProcessFeatures.cs | 2 ++ src/Tgstation.Server.Host/System/NativeMethods.cs | 2 ++ src/Tgstation.Server.Host/System/PlatformIdentifier.cs | 2 ++ src/Tgstation.Server.Host/System/PosixProcessFeatures.cs | 2 ++ src/Tgstation.Server.Host/System/PosixSignalHandler.cs | 2 ++ src/Tgstation.Server.Host/System/Process.cs | 2 ++ src/Tgstation.Server.Host/System/ProcessExecutor.cs | 2 ++ .../System/ProgramShutdownTokenSource.cs | 2 ++ src/Tgstation.Server.Host/System/SystemDManager.cs | 2 ++ src/Tgstation.Server.Host/System/WindowsFirewallHelper.cs | 2 ++ .../System/WindowsNetworkPromptReaper.cs | 2 ++ src/Tgstation.Server.Host/System/WindowsProcessFeatures.cs | 2 ++ src/Tgstation.Server.Host/Tgstation.Server.Host.csproj | 1 + src/Tgstation.Server.Host/Transfer/FileDownloadProvider.cs | 2 ++ src/Tgstation.Server.Host/Transfer/FileTransferService.cs | 2 ++ src/Tgstation.Server.Host/Transfer/FileUploadProvider.cs | 2 ++ .../Transfer/IFileTransferStreamHandler.cs | 2 ++ .../Transfer/IFileTransferTicketProvider.cs | 2 ++ src/Tgstation.Server.Host/Transfer/IFileUploadTicket.cs | 2 ++ src/Tgstation.Server.Host/Utils/AbstractHttpClientFactory.cs | 2 ++ src/Tgstation.Server.Host/Utils/ApiHeadersProvider.cs | 2 ++ src/Tgstation.Server.Host/Utils/AsyncDelayer.cs | 2 ++ src/Tgstation.Server.Host/Utils/FifoSemaphore.cs | 2 ++ src/Tgstation.Server.Host/Utils/GitHub/GitHubClientFactory.cs | 2 ++ src/Tgstation.Server.Host/Utils/GitHub/GitHubService.cs | 2 ++ .../Utils/GitHub/GitHubServiceFactory.cs | 2 ++ .../Utils/GitHub/IAuthenticatedGitHubService.cs | 2 ++ .../Utils/GitHub/IGitHubClientFactory.cs | 2 ++ src/Tgstation.Server.Host/Utils/GitHub/IGitHubService.cs | 2 ++ src/Tgstation.Server.Host/Utils/IApiHeadersProvider.cs | 2 ++ src/Tgstation.Server.Host/Utils/IAsyncDelayer.cs | 2 ++ src/Tgstation.Server.Host/Utils/IPortAllocator.cs | 2 ++ .../Utils/OpenApiEnumVarNamesExtension.cs | 2 ++ src/Tgstation.Server.Host/Utils/PortAllocator.cs | 2 ++ src/Tgstation.Server.Host/Utils/ReferenceCounter.cs | 2 ++ src/Tgstation.Server.Host/Utils/ReferenceCountingContainer.cs | 2 ++ src/Tgstation.Server.Host/Utils/SemaphoreSlimContext.cs | 2 ++ .../Utils/SignalR/ComprehensiveHubContext.cs | 2 ++ .../Utils/SignalR/ConnectionMappingHub.cs | 2 ++ .../Utils/SignalR/IConnectionMappedHubContext.cs | 2 ++ .../Utils/SignalR/IHubConnectionMapper.cs | 2 ++ src/Tgstation.Server.Host/Utils/SwaggerConfiguration.cs | 2 ++ 386 files changed, 784 insertions(+), 13 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Chat/ChannelMapping.cs b/src/Tgstation.Server.Host/Components/Chat/ChannelMapping.cs index d7430d7c69..8773e402a9 100644 --- a/src/Tgstation.Server.Host/Components/Chat/ChannelMapping.cs +++ b/src/Tgstation.Server.Host/Components/Chat/ChannelMapping.cs @@ -1,4 +1,6 @@ -namespace Tgstation.Server.Host.Components.Chat +#nullable disable + +namespace Tgstation.Server.Host.Components.Chat { /// /// Represents a mapping of a . diff --git a/src/Tgstation.Server.Host/Components/Chat/ChannelRepresentation.cs b/src/Tgstation.Server.Host/Components/Chat/ChannelRepresentation.cs index a24f416ec1..aed43e0817 100644 --- a/src/Tgstation.Server.Host/Components/Chat/ChannelRepresentation.cs +++ b/src/Tgstation.Server.Host/Components/Chat/ChannelRepresentation.cs @@ -3,6 +3,8 @@ using System.Globalization; using Newtonsoft.Json; +#nullable disable + namespace Tgstation.Server.Host.Components.Chat { /// diff --git a/src/Tgstation.Server.Host/Components/Chat/ChatManager.cs b/src/Tgstation.Server.Host/Components/Chat/ChatManager.cs index 7e3daa6646..409c6555c2 100644 --- a/src/Tgstation.Server.Host/Components/Chat/ChatManager.cs +++ b/src/Tgstation.Server.Host/Components/Chat/ChatManager.cs @@ -21,6 +21,8 @@ using Tgstation.Server.Host.Components.Interop; using Tgstation.Server.Host.Core; using Tgstation.Server.Host.Utils; +#nullable disable + namespace Tgstation.Server.Host.Components.Chat { /// diff --git a/src/Tgstation.Server.Host/Components/Chat/ChatManagerFactory.cs b/src/Tgstation.Server.Host/Components/Chat/ChatManagerFactory.cs index 12427da6be..7e9c09eb42 100644 --- a/src/Tgstation.Server.Host/Components/Chat/ChatManagerFactory.cs +++ b/src/Tgstation.Server.Host/Components/Chat/ChatManagerFactory.cs @@ -8,6 +8,8 @@ using Tgstation.Server.Host.Components.Chat.Commands; using Tgstation.Server.Host.Components.Chat.Providers; using Tgstation.Server.Host.Core; +#nullable disable + namespace Tgstation.Server.Host.Components.Chat { /// diff --git a/src/Tgstation.Server.Host/Components/Chat/ChatTrackingContext.cs b/src/Tgstation.Server.Host/Components/Chat/ChatTrackingContext.cs index 369ccdeeeb..bf6ab315ed 100644 --- a/src/Tgstation.Server.Host/Components/Chat/ChatTrackingContext.cs +++ b/src/Tgstation.Server.Host/Components/Chat/ChatTrackingContext.cs @@ -8,6 +8,8 @@ using Microsoft.Extensions.Logging; using Tgstation.Server.Host.Components.Chat.Commands; +#nullable disable + namespace Tgstation.Server.Host.Components.Chat { /// diff --git a/src/Tgstation.Server.Host/Components/Chat/ChatUser.cs b/src/Tgstation.Server.Host/Components/Chat/ChatUser.cs index 6de07109ea..9660bc6c83 100644 --- a/src/Tgstation.Server.Host/Components/Chat/ChatUser.cs +++ b/src/Tgstation.Server.Host/Components/Chat/ChatUser.cs @@ -3,6 +3,8 @@ using System.Globalization; using Newtonsoft.Json; +#nullable disable + namespace Tgstation.Server.Host.Components.Chat { /// diff --git a/src/Tgstation.Server.Host/Components/Chat/Commands/CommandFactory.cs b/src/Tgstation.Server.Host/Components/Chat/Commands/CommandFactory.cs index d4fda66603..28eecb2628 100644 --- a/src/Tgstation.Server.Host/Components/Chat/Commands/CommandFactory.cs +++ b/src/Tgstation.Server.Host/Components/Chat/Commands/CommandFactory.cs @@ -8,6 +8,8 @@ using Tgstation.Server.Host.Components.Watchdog; using Tgstation.Server.Host.Database; using Tgstation.Server.Host.System; +#nullable disable + namespace Tgstation.Server.Host.Components.Chat.Commands { /// diff --git a/src/Tgstation.Server.Host/Components/Chat/Commands/CustomCommand.cs b/src/Tgstation.Server.Host/Components/Chat/Commands/CustomCommand.cs index 617b1dba48..b11d22d5ef 100644 --- a/src/Tgstation.Server.Host/Components/Chat/Commands/CustomCommand.cs +++ b/src/Tgstation.Server.Host/Components/Chat/Commands/CustomCommand.cs @@ -4,6 +4,8 @@ using System.Threading.Tasks; using Tgstation.Server.Host.Components.Interop; +#nullable disable + namespace Tgstation.Server.Host.Components.Chat.Commands { /// diff --git a/src/Tgstation.Server.Host/Components/Chat/Commands/EngineCommand.cs b/src/Tgstation.Server.Host/Components/Chat/Commands/EngineCommand.cs index 9e92f3f02f..75a6e79e54 100644 --- a/src/Tgstation.Server.Host/Components/Chat/Commands/EngineCommand.cs +++ b/src/Tgstation.Server.Host/Components/Chat/Commands/EngineCommand.cs @@ -8,6 +8,8 @@ using Tgstation.Server.Host.Components.Engine; using Tgstation.Server.Host.Components.Interop; using Tgstation.Server.Host.Components.Watchdog; +#nullable disable + namespace Tgstation.Server.Host.Components.Chat.Commands { /// diff --git a/src/Tgstation.Server.Host/Components/Chat/Commands/ICommand.cs b/src/Tgstation.Server.Host/Components/Chat/Commands/ICommand.cs index 766f29b6c0..c5d4e3ef3e 100644 --- a/src/Tgstation.Server.Host/Components/Chat/Commands/ICommand.cs +++ b/src/Tgstation.Server.Host/Components/Chat/Commands/ICommand.cs @@ -3,6 +3,8 @@ using System.Threading.Tasks; using Tgstation.Server.Host.Components.Interop; +#nullable disable + namespace Tgstation.Server.Host.Components.Chat.Commands { /// diff --git a/src/Tgstation.Server.Host/Components/Chat/Commands/ICommandFactory.cs b/src/Tgstation.Server.Host/Components/Chat/Commands/ICommandFactory.cs index c3ffa50d74..1cc91c7ada 100644 --- a/src/Tgstation.Server.Host/Components/Chat/Commands/ICommandFactory.cs +++ b/src/Tgstation.Server.Host/Components/Chat/Commands/ICommandFactory.cs @@ -1,5 +1,7 @@ using System.Collections.Generic; +#nullable disable + namespace Tgstation.Server.Host.Components.Chat.Commands { /// diff --git a/src/Tgstation.Server.Host/Components/Chat/Commands/KekCommand.cs b/src/Tgstation.Server.Host/Components/Chat/Commands/KekCommand.cs index a41278ae0a..f5ef18e1d9 100644 --- a/src/Tgstation.Server.Host/Components/Chat/Commands/KekCommand.cs +++ b/src/Tgstation.Server.Host/Components/Chat/Commands/KekCommand.cs @@ -3,6 +3,8 @@ using System.Threading.Tasks; using Tgstation.Server.Host.Components.Interop; +#nullable disable + namespace Tgstation.Server.Host.Components.Chat.Commands { /// diff --git a/src/Tgstation.Server.Host/Components/Chat/Commands/PullRequestsCommand.cs b/src/Tgstation.Server.Host/Components/Chat/Commands/PullRequestsCommand.cs index 39a99bcac4..990b5bdc11 100644 --- a/src/Tgstation.Server.Host/Components/Chat/Commands/PullRequestsCommand.cs +++ b/src/Tgstation.Server.Host/Components/Chat/Commands/PullRequestsCommand.cs @@ -13,6 +13,8 @@ using Tgstation.Server.Host.Components.Repository; using Tgstation.Server.Host.Components.Watchdog; using Tgstation.Server.Host.Database; +#nullable disable + namespace Tgstation.Server.Host.Components.Chat.Commands { /// diff --git a/src/Tgstation.Server.Host/Components/Chat/Commands/RevisionCommand.cs b/src/Tgstation.Server.Host/Components/Chat/Commands/RevisionCommand.cs index aceff96435..60c12f9fc3 100644 --- a/src/Tgstation.Server.Host/Components/Chat/Commands/RevisionCommand.cs +++ b/src/Tgstation.Server.Host/Components/Chat/Commands/RevisionCommand.cs @@ -9,6 +9,8 @@ using Tgstation.Server.Host.Components.Interop; using Tgstation.Server.Host.Components.Repository; using Tgstation.Server.Host.Components.Watchdog; +#nullable disable + namespace Tgstation.Server.Host.Components.Chat.Commands { /// diff --git a/src/Tgstation.Server.Host/Components/Chat/Commands/VersionCommand.cs b/src/Tgstation.Server.Host/Components/Chat/Commands/VersionCommand.cs index 60e7f9e9a1..5857f6fea7 100644 --- a/src/Tgstation.Server.Host/Components/Chat/Commands/VersionCommand.cs +++ b/src/Tgstation.Server.Host/Components/Chat/Commands/VersionCommand.cs @@ -5,6 +5,8 @@ using System.Threading.Tasks; using Tgstation.Server.Host.Components.Interop; using Tgstation.Server.Host.System; +#nullable disable + namespace Tgstation.Server.Host.Components.Chat.Commands { /// diff --git a/src/Tgstation.Server.Host/Components/Chat/IChannelSink.cs b/src/Tgstation.Server.Host/Components/Chat/IChannelSink.cs index e9e366902e..78dbee1d73 100644 --- a/src/Tgstation.Server.Host/Components/Chat/IChannelSink.cs +++ b/src/Tgstation.Server.Host/Components/Chat/IChannelSink.cs @@ -2,6 +2,8 @@ using System.Threading; using System.Threading.Tasks; +#nullable disable + namespace Tgstation.Server.Host.Components.Chat { /// diff --git a/src/Tgstation.Server.Host/Components/Chat/IChatManager.cs b/src/Tgstation.Server.Host/Components/Chat/IChatManager.cs index ae4aefb8fb..435c867d3e 100644 --- a/src/Tgstation.Server.Host/Components/Chat/IChatManager.cs +++ b/src/Tgstation.Server.Host/Components/Chat/IChatManager.cs @@ -6,6 +6,8 @@ using System.Threading.Tasks; using Tgstation.Server.Api.Models.Internal; using Tgstation.Server.Host.Components.Interop; +#nullable disable + namespace Tgstation.Server.Host.Components.Chat { /// diff --git a/src/Tgstation.Server.Host/Components/Chat/IChatManagerFactory.cs b/src/Tgstation.Server.Host/Components/Chat/IChatManagerFactory.cs index bff29dc9c4..4af42411be 100644 --- a/src/Tgstation.Server.Host/Components/Chat/IChatManagerFactory.cs +++ b/src/Tgstation.Server.Host/Components/Chat/IChatManagerFactory.cs @@ -2,6 +2,8 @@ using Tgstation.Server.Host.Components.Chat.Commands; +#nullable disable + namespace Tgstation.Server.Host.Components.Chat { /// diff --git a/src/Tgstation.Server.Host/Components/Chat/IChatTrackingContext.cs b/src/Tgstation.Server.Host/Components/Chat/IChatTrackingContext.cs index 37e1da9584..284c0f5564 100644 --- a/src/Tgstation.Server.Host/Components/Chat/IChatTrackingContext.cs +++ b/src/Tgstation.Server.Host/Components/Chat/IChatTrackingContext.cs @@ -3,6 +3,8 @@ using System.Collections.Generic; using Tgstation.Server.Host.Components.Chat.Commands; +#nullable disable + namespace Tgstation.Server.Host.Components.Chat { /// diff --git a/src/Tgstation.Server.Host/Components/Chat/ICustomCommandHandler.cs b/src/Tgstation.Server.Host/Components/Chat/ICustomCommandHandler.cs index bf406bb421..988f3faa2f 100644 --- a/src/Tgstation.Server.Host/Components/Chat/ICustomCommandHandler.cs +++ b/src/Tgstation.Server.Host/Components/Chat/ICustomCommandHandler.cs @@ -3,6 +3,8 @@ using System.Threading.Tasks; using Tgstation.Server.Host.Components.Interop; +#nullable disable + namespace Tgstation.Server.Host.Components.Chat { /// diff --git a/src/Tgstation.Server.Host/Components/Chat/Providers/DiscordForwardingResponder.cs b/src/Tgstation.Server.Host/Components/Chat/Providers/DiscordForwardingResponder.cs index 85444cb499..878ac1bc4c 100644 --- a/src/Tgstation.Server.Host/Components/Chat/Providers/DiscordForwardingResponder.cs +++ b/src/Tgstation.Server.Host/Components/Chat/Providers/DiscordForwardingResponder.cs @@ -6,6 +6,8 @@ using Remora.Discord.API.Abstractions.Gateway.Events; using Remora.Discord.Gateway.Responders; using Remora.Results; +#nullable disable + namespace Tgstation.Server.Host.Components.Chat.Providers { /// diff --git a/src/Tgstation.Server.Host/Components/Chat/Providers/DiscordMessage.cs b/src/Tgstation.Server.Host/Components/Chat/Providers/DiscordMessage.cs index b0b3fbb56e..4d55e31d85 100644 --- a/src/Tgstation.Server.Host/Components/Chat/Providers/DiscordMessage.cs +++ b/src/Tgstation.Server.Host/Components/Chat/Providers/DiscordMessage.cs @@ -1,6 +1,8 @@ using Remora.Discord.API.Abstractions.Objects; using Remora.Rest.Core; +#nullable disable + namespace Tgstation.Server.Host.Components.Chat.Providers { /// diff --git a/src/Tgstation.Server.Host/Components/Chat/Providers/DiscordProvider.cs b/src/Tgstation.Server.Host/Components/Chat/Providers/DiscordProvider.cs index bda2228065..3ee853f36c 100644 --- a/src/Tgstation.Server.Host/Components/Chat/Providers/DiscordProvider.cs +++ b/src/Tgstation.Server.Host/Components/Chat/Providers/DiscordProvider.cs @@ -33,6 +33,8 @@ using Tgstation.Server.Host.Models; using Tgstation.Server.Host.System; using Tgstation.Server.Host.Utils; +#nullable disable + namespace Tgstation.Server.Host.Components.Chat.Providers { /// diff --git a/src/Tgstation.Server.Host/Components/Chat/Providers/IDiscordResponders.cs b/src/Tgstation.Server.Host/Components/Chat/Providers/IDiscordResponders.cs index d0c320fa9e..3ca8ec9d42 100644 --- a/src/Tgstation.Server.Host/Components/Chat/Providers/IDiscordResponders.cs +++ b/src/Tgstation.Server.Host/Components/Chat/Providers/IDiscordResponders.cs @@ -1,6 +1,8 @@ using Remora.Discord.API.Abstractions.Gateway.Events; using Remora.Discord.Gateway.Responders; +#nullable disable + namespace Tgstation.Server.Host.Components.Chat.Providers { /// diff --git a/src/Tgstation.Server.Host/Components/Chat/Providers/IProvider.cs b/src/Tgstation.Server.Host/Components/Chat/Providers/IProvider.cs index 22028aefc7..0fc6beeb29 100644 --- a/src/Tgstation.Server.Host/Components/Chat/Providers/IProvider.cs +++ b/src/Tgstation.Server.Host/Components/Chat/Providers/IProvider.cs @@ -7,6 +7,8 @@ using Tgstation.Server.Api.Models.Internal; using Tgstation.Server.Host.Components.Interop; using Tgstation.Server.Host.Models; +#nullable disable + namespace Tgstation.Server.Host.Components.Chat.Providers { /// diff --git a/src/Tgstation.Server.Host/Components/Chat/Providers/IProviderFactory.cs b/src/Tgstation.Server.Host/Components/Chat/Providers/IProviderFactory.cs index d79e0bb7d5..fea864ea71 100644 --- a/src/Tgstation.Server.Host/Components/Chat/Providers/IProviderFactory.cs +++ b/src/Tgstation.Server.Host/Components/Chat/Providers/IProviderFactory.cs @@ -1,5 +1,7 @@ using Tgstation.Server.Host.Models; +#nullable disable + namespace Tgstation.Server.Host.Components.Chat.Providers { /// diff --git a/src/Tgstation.Server.Host/Components/Chat/Providers/IrcProvider.cs b/src/Tgstation.Server.Host/Components/Chat/Providers/IrcProvider.cs index e4fe37a93e..b870536fb7 100644 --- a/src/Tgstation.Server.Host/Components/Chat/Providers/IrcProvider.cs +++ b/src/Tgstation.Server.Host/Components/Chat/Providers/IrcProvider.cs @@ -19,6 +19,8 @@ using Tgstation.Server.Host.Jobs; using Tgstation.Server.Host.System; using Tgstation.Server.Host.Utils; +#nullable disable + namespace Tgstation.Server.Host.Components.Chat.Providers { /// diff --git a/src/Tgstation.Server.Host/Components/Chat/Providers/Message.cs b/src/Tgstation.Server.Host/Components/Chat/Providers/Message.cs index 9510113f62..f410514b80 100644 --- a/src/Tgstation.Server.Host/Components/Chat/Providers/Message.cs +++ b/src/Tgstation.Server.Host/Components/Chat/Providers/Message.cs @@ -1,4 +1,6 @@ -namespace Tgstation.Server.Host.Components.Chat.Providers +#nullable disable + +namespace Tgstation.Server.Host.Components.Chat.Providers { /// /// Represents a message received by a . diff --git a/src/Tgstation.Server.Host/Components/Chat/Providers/Provider.cs b/src/Tgstation.Server.Host/Components/Chat/Providers/Provider.cs index 7da3b29930..1a036d7ffd 100644 --- a/src/Tgstation.Server.Host/Components/Chat/Providers/Provider.cs +++ b/src/Tgstation.Server.Host/Components/Chat/Providers/Provider.cs @@ -11,6 +11,8 @@ using Tgstation.Server.Host.Jobs; using Tgstation.Server.Host.Models; using Tgstation.Server.Host.Utils; +#nullable disable + namespace Tgstation.Server.Host.Components.Chat.Providers { /// diff --git a/src/Tgstation.Server.Host/Components/Chat/Providers/ProviderFactory.cs b/src/Tgstation.Server.Host/Components/Chat/Providers/ProviderFactory.cs index ed3608b92d..9519abcc1c 100644 --- a/src/Tgstation.Server.Host/Components/Chat/Providers/ProviderFactory.cs +++ b/src/Tgstation.Server.Host/Components/Chat/Providers/ProviderFactory.cs @@ -10,6 +10,8 @@ using Tgstation.Server.Host.Jobs; using Tgstation.Server.Host.System; using Tgstation.Server.Host.Utils; +#nullable disable + namespace Tgstation.Server.Host.Components.Chat.Providers { /// diff --git a/src/Tgstation.Server.Host/Components/Deployment/DmbFactory.cs b/src/Tgstation.Server.Host/Components/Deployment/DmbFactory.cs index de36092c6b..3e969409b4 100644 --- a/src/Tgstation.Server.Host/Components/Deployment/DmbFactory.cs +++ b/src/Tgstation.Server.Host/Components/Deployment/DmbFactory.cs @@ -16,6 +16,8 @@ using Tgstation.Server.Host.Database; using Tgstation.Server.Host.IO; using Tgstation.Server.Host.Models; +#nullable disable + namespace Tgstation.Server.Host.Components.Deployment { /// diff --git a/src/Tgstation.Server.Host/Components/Deployment/DmbProvider.cs b/src/Tgstation.Server.Host/Components/Deployment/DmbProvider.cs index 37c44d9fab..359fc615e2 100644 --- a/src/Tgstation.Server.Host/Components/Deployment/DmbProvider.cs +++ b/src/Tgstation.Server.Host/Components/Deployment/DmbProvider.cs @@ -5,6 +5,8 @@ using Tgstation.Server.Api.Models; using Tgstation.Server.Api.Models.Internal; using Tgstation.Server.Host.IO; +#nullable disable + namespace Tgstation.Server.Host.Components.Deployment { /// diff --git a/src/Tgstation.Server.Host/Components/Deployment/DmbProviderBase.cs b/src/Tgstation.Server.Host/Components/Deployment/DmbProviderBase.cs index 5f1248463d..cdc57215ac 100644 --- a/src/Tgstation.Server.Host/Components/Deployment/DmbProviderBase.cs +++ b/src/Tgstation.Server.Host/Components/Deployment/DmbProviderBase.cs @@ -5,6 +5,8 @@ using Tgstation.Server.Api.Models; using Tgstation.Server.Api.Models.Internal; using Tgstation.Server.Host.Models; +#nullable disable + namespace Tgstation.Server.Host.Components.Deployment { /// diff --git a/src/Tgstation.Server.Host/Components/Deployment/DreamMaker.cs b/src/Tgstation.Server.Host/Components/Deployment/DreamMaker.cs index 3a8a256fd1..5d99463637 100644 --- a/src/Tgstation.Server.Host/Components/Deployment/DreamMaker.cs +++ b/src/Tgstation.Server.Host/Components/Deployment/DreamMaker.cs @@ -25,6 +25,8 @@ using Tgstation.Server.Host.Models; using Tgstation.Server.Host.System; using Tgstation.Server.Host.Utils; +#nullable disable + namespace Tgstation.Server.Host.Components.Deployment { /// diff --git a/src/Tgstation.Server.Host/Components/Deployment/HardLinkDmbProvider.cs b/src/Tgstation.Server.Host/Components/Deployment/HardLinkDmbProvider.cs index 568786e340..99fd9c4bc2 100644 --- a/src/Tgstation.Server.Host/Components/Deployment/HardLinkDmbProvider.cs +++ b/src/Tgstation.Server.Host/Components/Deployment/HardLinkDmbProvider.cs @@ -15,6 +15,8 @@ using Tgstation.Server.Host.Extensions; using Tgstation.Server.Host.IO; using Tgstation.Server.Host.Utils; +#nullable disable + namespace Tgstation.Server.Host.Components.Deployment { /// diff --git a/src/Tgstation.Server.Host/Components/Deployment/ICompileJobSink.cs b/src/Tgstation.Server.Host/Components/Deployment/ICompileJobSink.cs index 49d4eae165..90a0f1596c 100644 --- a/src/Tgstation.Server.Host/Components/Deployment/ICompileJobSink.cs +++ b/src/Tgstation.Server.Host/Components/Deployment/ICompileJobSink.cs @@ -4,6 +4,8 @@ using System.Threading.Tasks; using Tgstation.Server.Host.Models; +#nullable disable + namespace Tgstation.Server.Host.Components.Deployment { /// diff --git a/src/Tgstation.Server.Host/Components/Deployment/IDmbFactory.cs b/src/Tgstation.Server.Host/Components/Deployment/IDmbFactory.cs index 6ff04b0a00..a6c3173677 100644 --- a/src/Tgstation.Server.Host/Components/Deployment/IDmbFactory.cs +++ b/src/Tgstation.Server.Host/Components/Deployment/IDmbFactory.cs @@ -4,6 +4,8 @@ using System.Threading.Tasks; using Tgstation.Server.Host.Models; +#nullable disable + namespace Tgstation.Server.Host.Components.Deployment { /// diff --git a/src/Tgstation.Server.Host/Components/Deployment/IDmbProvider.cs b/src/Tgstation.Server.Host/Components/Deployment/IDmbProvider.cs index 820796c318..20ef72dd33 100644 --- a/src/Tgstation.Server.Host/Components/Deployment/IDmbProvider.cs +++ b/src/Tgstation.Server.Host/Components/Deployment/IDmbProvider.cs @@ -2,6 +2,8 @@ using Tgstation.Server.Api.Models; +#nullable disable + namespace Tgstation.Server.Host.Components.Deployment { /// diff --git a/src/Tgstation.Server.Host/Components/Deployment/IDreamMaker.cs b/src/Tgstation.Server.Host/Components/Deployment/IDreamMaker.cs index 3244308016..b9e8f4e88a 100644 --- a/src/Tgstation.Server.Host/Components/Deployment/IDreamMaker.cs +++ b/src/Tgstation.Server.Host/Components/Deployment/IDreamMaker.cs @@ -5,6 +5,8 @@ using Tgstation.Server.Host.Database; using Tgstation.Server.Host.Jobs; using Tgstation.Server.Host.Models; +#nullable disable + namespace Tgstation.Server.Host.Components.Deployment { /// diff --git a/src/Tgstation.Server.Host/Components/Deployment/ILatestCompileJobProvider.cs b/src/Tgstation.Server.Host/Components/Deployment/ILatestCompileJobProvider.cs index 38a90c8dc6..d60ac9ad31 100644 --- a/src/Tgstation.Server.Host/Components/Deployment/ILatestCompileJobProvider.cs +++ b/src/Tgstation.Server.Host/Components/Deployment/ILatestCompileJobProvider.cs @@ -1,5 +1,7 @@ using Tgstation.Server.Host.Models; +#nullable disable + namespace Tgstation.Server.Host.Components.Deployment { /// diff --git a/src/Tgstation.Server.Host/Components/Deployment/Remote/BaseRemoteDeploymentManager.cs b/src/Tgstation.Server.Host/Components/Deployment/Remote/BaseRemoteDeploymentManager.cs index db48c659ba..b06a3f8662 100644 --- a/src/Tgstation.Server.Host/Components/Deployment/Remote/BaseRemoteDeploymentManager.cs +++ b/src/Tgstation.Server.Host/Components/Deployment/Remote/BaseRemoteDeploymentManager.cs @@ -11,6 +11,8 @@ using Tgstation.Server.Common.Extensions; using Tgstation.Server.Host.Components.Repository; using Tgstation.Server.Host.Models; +#nullable disable + namespace Tgstation.Server.Host.Components.Deployment.Remote { /// diff --git a/src/Tgstation.Server.Host/Components/Deployment/Remote/GitHubRemoteDeploymentManager.cs b/src/Tgstation.Server.Host/Components/Deployment/Remote/GitHubRemoteDeploymentManager.cs index 751bb33646..493daab039 100644 --- a/src/Tgstation.Server.Host/Components/Deployment/Remote/GitHubRemoteDeploymentManager.cs +++ b/src/Tgstation.Server.Host/Components/Deployment/Remote/GitHubRemoteDeploymentManager.cs @@ -17,6 +17,8 @@ using Tgstation.Server.Host.Database; using Tgstation.Server.Host.Models; using Tgstation.Server.Host.Utils.GitHub; +#nullable disable + namespace Tgstation.Server.Host.Components.Deployment.Remote { /// diff --git a/src/Tgstation.Server.Host/Components/Deployment/Remote/GitLabRemoteDeploymentManager.cs b/src/Tgstation.Server.Host/Components/Deployment/Remote/GitLabRemoteDeploymentManager.cs index 2686764cca..0190d0c993 100644 --- a/src/Tgstation.Server.Host/Components/Deployment/Remote/GitLabRemoteDeploymentManager.cs +++ b/src/Tgstation.Server.Host/Components/Deployment/Remote/GitLabRemoteDeploymentManager.cs @@ -14,6 +14,8 @@ using Microsoft.Extensions.Logging; using Tgstation.Server.Host.Components.Repository; using Tgstation.Server.Host.Models; +#nullable disable + namespace Tgstation.Server.Host.Components.Deployment.Remote { /// diff --git a/src/Tgstation.Server.Host/Components/Deployment/Remote/IRemoteDeploymentManager.cs b/src/Tgstation.Server.Host/Components/Deployment/Remote/IRemoteDeploymentManager.cs index 42b154ac7e..de92f3d31b 100644 --- a/src/Tgstation.Server.Host/Components/Deployment/Remote/IRemoteDeploymentManager.cs +++ b/src/Tgstation.Server.Host/Components/Deployment/Remote/IRemoteDeploymentManager.cs @@ -6,6 +6,8 @@ using System.Threading.Tasks; using Tgstation.Server.Host.Components.Repository; using Tgstation.Server.Host.Models; +#nullable disable + namespace Tgstation.Server.Host.Components.Deployment.Remote { /// diff --git a/src/Tgstation.Server.Host/Components/Deployment/Remote/IRemoteDeploymentManagerFactory.cs b/src/Tgstation.Server.Host/Components/Deployment/Remote/IRemoteDeploymentManagerFactory.cs index b3dce1f69c..129d5aa35a 100644 --- a/src/Tgstation.Server.Host/Components/Deployment/Remote/IRemoteDeploymentManagerFactory.cs +++ b/src/Tgstation.Server.Host/Components/Deployment/Remote/IRemoteDeploymentManagerFactory.cs @@ -2,6 +2,8 @@ using Tgstation.Server.Api.Models; +#nullable disable + namespace Tgstation.Server.Host.Components.Deployment.Remote { /// diff --git a/src/Tgstation.Server.Host/Components/Deployment/Remote/NoOpRemoteDeploymentManager.cs b/src/Tgstation.Server.Host/Components/Deployment/Remote/NoOpRemoteDeploymentManager.cs index 6751f18184..250b43bddf 100644 --- a/src/Tgstation.Server.Host/Components/Deployment/Remote/NoOpRemoteDeploymentManager.cs +++ b/src/Tgstation.Server.Host/Components/Deployment/Remote/NoOpRemoteDeploymentManager.cs @@ -10,6 +10,8 @@ using Tgstation.Server.Api.Models.Internal; using Tgstation.Server.Host.Components.Repository; using Tgstation.Server.Host.Models; +#nullable disable + namespace Tgstation.Server.Host.Components.Deployment.Remote { /// diff --git a/src/Tgstation.Server.Host/Components/Deployment/Remote/RemoteDeploymentManagerFactory.cs b/src/Tgstation.Server.Host/Components/Deployment/Remote/RemoteDeploymentManagerFactory.cs index 0fdce864cf..d525d3dffe 100644 --- a/src/Tgstation.Server.Host/Components/Deployment/Remote/RemoteDeploymentManagerFactory.cs +++ b/src/Tgstation.Server.Host/Components/Deployment/Remote/RemoteDeploymentManagerFactory.cs @@ -9,6 +9,8 @@ using Tgstation.Server.Host.Components.Repository; using Tgstation.Server.Host.Database; using Tgstation.Server.Host.Utils.GitHub; +#nullable disable + namespace Tgstation.Server.Host.Components.Deployment.Remote { /// diff --git a/src/Tgstation.Server.Host/Components/Deployment/SwappableDmbProvider.cs b/src/Tgstation.Server.Host/Components/Deployment/SwappableDmbProvider.cs index 75c5a1b6bb..954fa920be 100644 --- a/src/Tgstation.Server.Host/Components/Deployment/SwappableDmbProvider.cs +++ b/src/Tgstation.Server.Host/Components/Deployment/SwappableDmbProvider.cs @@ -5,6 +5,8 @@ using System.Threading.Tasks; using Tgstation.Server.Api.Models; using Tgstation.Server.Host.IO; +#nullable disable + namespace Tgstation.Server.Host.Components.Deployment { /// diff --git a/src/Tgstation.Server.Host/Components/Deployment/SymlinkDmbProvider.cs b/src/Tgstation.Server.Host/Components/Deployment/SymlinkDmbProvider.cs index edb570bcb8..a920641d0d 100644 --- a/src/Tgstation.Server.Host/Components/Deployment/SymlinkDmbProvider.cs +++ b/src/Tgstation.Server.Host/Components/Deployment/SymlinkDmbProvider.cs @@ -3,6 +3,8 @@ using System.Threading.Tasks; using Tgstation.Server.Host.IO; +#nullable disable + namespace Tgstation.Server.Host.Components.Deployment { /// diff --git a/src/Tgstation.Server.Host/Components/Deployment/TemporaryDmbProvider.cs b/src/Tgstation.Server.Host/Components/Deployment/TemporaryDmbProvider.cs index 4d528d7ba1..38c5067c55 100644 --- a/src/Tgstation.Server.Host/Components/Deployment/TemporaryDmbProvider.cs +++ b/src/Tgstation.Server.Host/Components/Deployment/TemporaryDmbProvider.cs @@ -3,6 +3,8 @@ using System.Threading.Tasks; using Tgstation.Server.Api.Models; +#nullable disable + namespace Tgstation.Server.Host.Components.Deployment { /// diff --git a/src/Tgstation.Server.Host/Components/Engine/ByondInstallation.cs b/src/Tgstation.Server.Host/Components/Engine/ByondInstallation.cs index ba730a7c7f..b1cc0a9d5d 100644 --- a/src/Tgstation.Server.Host/Components/Engine/ByondInstallation.cs +++ b/src/Tgstation.Server.Host/Components/Engine/ByondInstallation.cs @@ -7,6 +7,8 @@ using Tgstation.Server.Api.Models; using Tgstation.Server.Api.Models.Internal; using Tgstation.Server.Host.Components.Deployment; +#nullable disable + namespace Tgstation.Server.Host.Components.Engine { /// diff --git a/src/Tgstation.Server.Host/Components/Engine/ByondInstallerBase.cs b/src/Tgstation.Server.Host/Components/Engine/ByondInstallerBase.cs index cf20d498a9..96a7df1aa9 100644 --- a/src/Tgstation.Server.Host/Components/Engine/ByondInstallerBase.cs +++ b/src/Tgstation.Server.Host/Components/Engine/ByondInstallerBase.cs @@ -11,6 +11,8 @@ using Tgstation.Server.Host.IO; using Tgstation.Server.Host.Jobs; using Tgstation.Server.Host.Utils; +#nullable disable + namespace Tgstation.Server.Host.Components.Engine { /// diff --git a/src/Tgstation.Server.Host/Components/Engine/DelegatingEngineInstaller.cs b/src/Tgstation.Server.Host/Components/Engine/DelegatingEngineInstaller.cs index 75393af5b7..c9e859f37d 100644 --- a/src/Tgstation.Server.Host/Components/Engine/DelegatingEngineInstaller.cs +++ b/src/Tgstation.Server.Host/Components/Engine/DelegatingEngineInstaller.cs @@ -7,6 +7,8 @@ using System.Threading.Tasks; using Tgstation.Server.Api.Models; using Tgstation.Server.Host.Jobs; +#nullable disable + namespace Tgstation.Server.Host.Components.Engine { /// diff --git a/src/Tgstation.Server.Host/Components/Engine/EngineExecutableLock.cs b/src/Tgstation.Server.Host/Components/Engine/EngineExecutableLock.cs index 70614f13e1..02d9bfe493 100644 --- a/src/Tgstation.Server.Host/Components/Engine/EngineExecutableLock.cs +++ b/src/Tgstation.Server.Host/Components/Engine/EngineExecutableLock.cs @@ -6,6 +6,8 @@ using Tgstation.Server.Api.Models.Internal; using Tgstation.Server.Host.Components.Deployment; using Tgstation.Server.Host.Utils; +#nullable disable + namespace Tgstation.Server.Host.Components.Engine { /// diff --git a/src/Tgstation.Server.Host/Components/Engine/EngineInstallationBase.cs b/src/Tgstation.Server.Host/Components/Engine/EngineInstallationBase.cs index fb607d3601..2133bdade4 100644 --- a/src/Tgstation.Server.Host/Components/Engine/EngineInstallationBase.cs +++ b/src/Tgstation.Server.Host/Components/Engine/EngineInstallationBase.cs @@ -8,6 +8,8 @@ using Tgstation.Server.Api.Models; using Tgstation.Server.Api.Models.Internal; using Tgstation.Server.Host.Components.Deployment; +#nullable disable + namespace Tgstation.Server.Host.Components.Engine { /// diff --git a/src/Tgstation.Server.Host/Components/Engine/EngineInstallerBase.cs b/src/Tgstation.Server.Host/Components/Engine/EngineInstallerBase.cs index e281c3f48f..6e2d5ad3cc 100644 --- a/src/Tgstation.Server.Host/Components/Engine/EngineInstallerBase.cs +++ b/src/Tgstation.Server.Host/Components/Engine/EngineInstallerBase.cs @@ -8,6 +8,8 @@ using Tgstation.Server.Api.Models; using Tgstation.Server.Host.IO; using Tgstation.Server.Host.Jobs; +#nullable disable + namespace Tgstation.Server.Host.Components.Engine { /// diff --git a/src/Tgstation.Server.Host/Components/Engine/EngineManager.cs b/src/Tgstation.Server.Host/Components/Engine/EngineManager.cs index 1205120411..ab76763167 100644 --- a/src/Tgstation.Server.Host/Components/Engine/EngineManager.cs +++ b/src/Tgstation.Server.Host/Components/Engine/EngineManager.cs @@ -16,6 +16,8 @@ using Tgstation.Server.Host.IO; using Tgstation.Server.Host.Jobs; using Tgstation.Server.Host.Utils; +#nullable disable + namespace Tgstation.Server.Host.Components.Engine { /// diff --git a/src/Tgstation.Server.Host/Components/Engine/IEngineExecutableLock.cs b/src/Tgstation.Server.Host/Components/Engine/IEngineExecutableLock.cs index 66031902fb..5d7bb087f9 100644 --- a/src/Tgstation.Server.Host/Components/Engine/IEngineExecutableLock.cs +++ b/src/Tgstation.Server.Host/Components/Engine/IEngineExecutableLock.cs @@ -1,5 +1,7 @@ using System; +#nullable disable + namespace Tgstation.Server.Host.Components.Engine { /// diff --git a/src/Tgstation.Server.Host/Components/Engine/IEngineInstallation.cs b/src/Tgstation.Server.Host/Components/Engine/IEngineInstallation.cs index f9aecca33b..861d6ebe90 100644 --- a/src/Tgstation.Server.Host/Components/Engine/IEngineInstallation.cs +++ b/src/Tgstation.Server.Host/Components/Engine/IEngineInstallation.cs @@ -5,6 +5,8 @@ using Tgstation.Server.Api.Models; using Tgstation.Server.Api.Models.Internal; using Tgstation.Server.Host.Components.Deployment; +#nullable disable + namespace Tgstation.Server.Host.Components.Engine { /// diff --git a/src/Tgstation.Server.Host/Components/Engine/IEngineInstallationData.cs b/src/Tgstation.Server.Host/Components/Engine/IEngineInstallationData.cs index b3d8458973..6385be5a9e 100644 --- a/src/Tgstation.Server.Host/Components/Engine/IEngineInstallationData.cs +++ b/src/Tgstation.Server.Host/Components/Engine/IEngineInstallationData.cs @@ -2,6 +2,8 @@ using System.Threading; using System.Threading.Tasks; +#nullable disable + namespace Tgstation.Server.Host.Components.Engine { /// diff --git a/src/Tgstation.Server.Host/Components/Engine/IEngineInstaller.cs b/src/Tgstation.Server.Host/Components/Engine/IEngineInstaller.cs index 2360202584..427ebfe55f 100644 --- a/src/Tgstation.Server.Host/Components/Engine/IEngineInstaller.cs +++ b/src/Tgstation.Server.Host/Components/Engine/IEngineInstaller.cs @@ -4,6 +4,8 @@ using System.Threading.Tasks; using Tgstation.Server.Api.Models; using Tgstation.Server.Host.Jobs; +#nullable disable + namespace Tgstation.Server.Host.Components.Engine { /// diff --git a/src/Tgstation.Server.Host/Components/Engine/IEngineManager.cs b/src/Tgstation.Server.Host/Components/Engine/IEngineManager.cs index bc272b1038..d53d77c53a 100644 --- a/src/Tgstation.Server.Host/Components/Engine/IEngineManager.cs +++ b/src/Tgstation.Server.Host/Components/Engine/IEngineManager.cs @@ -7,6 +7,8 @@ using System.Threading.Tasks; using Tgstation.Server.Api.Models; using Tgstation.Server.Host.Jobs; +#nullable disable + namespace Tgstation.Server.Host.Components.Engine { /// diff --git a/src/Tgstation.Server.Host/Components/Engine/OpenDreamInstallation.cs b/src/Tgstation.Server.Host/Components/Engine/OpenDreamInstallation.cs index 254861e69a..db3e7a7392 100644 --- a/src/Tgstation.Server.Host/Components/Engine/OpenDreamInstallation.cs +++ b/src/Tgstation.Server.Host/Components/Engine/OpenDreamInstallation.cs @@ -7,6 +7,8 @@ using Tgstation.Server.Api.Models.Internal; using Tgstation.Server.Host.Components.Deployment; using Tgstation.Server.Host.IO; +#nullable disable + namespace Tgstation.Server.Host.Components.Engine { /// diff --git a/src/Tgstation.Server.Host/Components/Engine/OpenDreamInstaller.cs b/src/Tgstation.Server.Host/Components/Engine/OpenDreamInstaller.cs index bbd09ed1c1..feb26e8be5 100644 --- a/src/Tgstation.Server.Host/Components/Engine/OpenDreamInstaller.cs +++ b/src/Tgstation.Server.Host/Components/Engine/OpenDreamInstaller.cs @@ -15,6 +15,8 @@ using Tgstation.Server.Host.IO; using Tgstation.Server.Host.Jobs; using Tgstation.Server.Host.System; +#nullable disable + namespace Tgstation.Server.Host.Components.Engine { /// diff --git a/src/Tgstation.Server.Host/Components/Engine/PosixByondInstaller.cs b/src/Tgstation.Server.Host/Components/Engine/PosixByondInstaller.cs index cddace53c8..ed58f07d41 100644 --- a/src/Tgstation.Server.Host/Components/Engine/PosixByondInstaller.cs +++ b/src/Tgstation.Server.Host/Components/Engine/PosixByondInstaller.cs @@ -10,6 +10,8 @@ using Tgstation.Server.Api.Models; using Tgstation.Server.Common.Extensions; using Tgstation.Server.Host.IO; +#nullable disable + namespace Tgstation.Server.Host.Components.Engine { /// diff --git a/src/Tgstation.Server.Host/Components/Engine/RepositoryEngineInstallationData.cs b/src/Tgstation.Server.Host/Components/Engine/RepositoryEngineInstallationData.cs index 88fbb77911..2c96b6f311 100644 --- a/src/Tgstation.Server.Host/Components/Engine/RepositoryEngineInstallationData.cs +++ b/src/Tgstation.Server.Host/Components/Engine/RepositoryEngineInstallationData.cs @@ -5,6 +5,8 @@ using System.Threading.Tasks; using Tgstation.Server.Host.Components.Repository; using Tgstation.Server.Host.IO; +#nullable disable + namespace Tgstation.Server.Host.Components.Engine { /// diff --git a/src/Tgstation.Server.Host/Components/Engine/WindowsByondInstaller.cs b/src/Tgstation.Server.Host/Components/Engine/WindowsByondInstaller.cs index 0ebf63ff9f..d119a5350f 100644 --- a/src/Tgstation.Server.Host/Components/Engine/WindowsByondInstaller.cs +++ b/src/Tgstation.Server.Host/Components/Engine/WindowsByondInstaller.cs @@ -15,6 +15,8 @@ using Tgstation.Server.Host.Jobs; using Tgstation.Server.Host.System; using Tgstation.Server.Host.Utils; +#nullable disable + namespace Tgstation.Server.Host.Components.Engine { /// diff --git a/src/Tgstation.Server.Host/Components/Engine/WindowsOpenDreamInstaller.cs b/src/Tgstation.Server.Host/Components/Engine/WindowsOpenDreamInstaller.cs index 4f42884c7f..e821f675af 100644 --- a/src/Tgstation.Server.Host/Components/Engine/WindowsOpenDreamInstaller.cs +++ b/src/Tgstation.Server.Host/Components/Engine/WindowsOpenDreamInstaller.cs @@ -13,6 +13,8 @@ using Tgstation.Server.Host.IO; using Tgstation.Server.Host.Jobs; using Tgstation.Server.Host.System; +#nullable disable + namespace Tgstation.Server.Host.Components.Engine { /// diff --git a/src/Tgstation.Server.Host/Components/Engine/ZipStreamEngineInstallationData.cs b/src/Tgstation.Server.Host/Components/Engine/ZipStreamEngineInstallationData.cs index 292b725981..71c26b92ef 100644 --- a/src/Tgstation.Server.Host/Components/Engine/ZipStreamEngineInstallationData.cs +++ b/src/Tgstation.Server.Host/Components/Engine/ZipStreamEngineInstallationData.cs @@ -5,6 +5,8 @@ using System.Threading.Tasks; using Tgstation.Server.Host.IO; +#nullable disable + namespace Tgstation.Server.Host.Components.Engine { /// diff --git a/src/Tgstation.Server.Host/Components/Events/EventConsumer.cs b/src/Tgstation.Server.Host/Components/Events/EventConsumer.cs index 81a0d34585..ae805853fb 100644 --- a/src/Tgstation.Server.Host/Components/Events/EventConsumer.cs +++ b/src/Tgstation.Server.Host/Components/Events/EventConsumer.cs @@ -6,6 +6,8 @@ using System.Threading.Tasks; using Tgstation.Server.Host.Components.StaticFiles; using Tgstation.Server.Host.Components.Watchdog; +#nullable disable + namespace Tgstation.Server.Host.Components.Events { /// diff --git a/src/Tgstation.Server.Host/Components/Events/EventScriptAttribute.cs b/src/Tgstation.Server.Host/Components/Events/EventScriptAttribute.cs index ba93d34cf9..fafcd82562 100644 --- a/src/Tgstation.Server.Host/Components/Events/EventScriptAttribute.cs +++ b/src/Tgstation.Server.Host/Components/Events/EventScriptAttribute.cs @@ -1,6 +1,8 @@ using System; using System.Collections.Generic; +#nullable disable + namespace Tgstation.Server.Host.Components.Events { /// diff --git a/src/Tgstation.Server.Host/Components/Events/IEventConsumer.cs b/src/Tgstation.Server.Host/Components/Events/IEventConsumer.cs index 7fddbb8950..4c2a7be5bd 100644 --- a/src/Tgstation.Server.Host/Components/Events/IEventConsumer.cs +++ b/src/Tgstation.Server.Host/Components/Events/IEventConsumer.cs @@ -2,6 +2,8 @@ using System.Threading; using System.Threading.Tasks; +#nullable disable + namespace Tgstation.Server.Host.Components.Events { /// diff --git a/src/Tgstation.Server.Host/Components/Events/NoopEventConsumer.cs b/src/Tgstation.Server.Host/Components/Events/NoopEventConsumer.cs index a8b07e4d7e..531018f7b5 100644 --- a/src/Tgstation.Server.Host/Components/Events/NoopEventConsumer.cs +++ b/src/Tgstation.Server.Host/Components/Events/NoopEventConsumer.cs @@ -2,6 +2,8 @@ using System.Threading; using System.Threading.Tasks; +#nullable disable + namespace Tgstation.Server.Host.Components.Events { /// diff --git a/src/Tgstation.Server.Host/Components/IComponentService.cs b/src/Tgstation.Server.Host/Components/IComponentService.cs index b094e0a092..6ef039f654 100644 --- a/src/Tgstation.Server.Host/Components/IComponentService.cs +++ b/src/Tgstation.Server.Host/Components/IComponentService.cs @@ -1,5 +1,7 @@ using Microsoft.Extensions.Hosting; +#nullable disable + namespace Tgstation.Server.Host.Components { /// diff --git a/src/Tgstation.Server.Host/Components/IInstance.cs b/src/Tgstation.Server.Host/Components/IInstance.cs index 9d8c34988e..b7b7505053 100644 --- a/src/Tgstation.Server.Host/Components/IInstance.cs +++ b/src/Tgstation.Server.Host/Components/IInstance.cs @@ -1,5 +1,7 @@ using System; +#nullable disable + namespace Tgstation.Server.Host.Components { /// diff --git a/src/Tgstation.Server.Host/Components/IInstanceCore.cs b/src/Tgstation.Server.Host/Components/IInstanceCore.cs index 78bce9e3f3..1fd3a29d45 100644 --- a/src/Tgstation.Server.Host/Components/IInstanceCore.cs +++ b/src/Tgstation.Server.Host/Components/IInstanceCore.cs @@ -7,6 +7,8 @@ using Tgstation.Server.Host.Components.Repository; using Tgstation.Server.Host.Components.StaticFiles; using Tgstation.Server.Host.Components.Watchdog; +#nullable disable + namespace Tgstation.Server.Host.Components { /// diff --git a/src/Tgstation.Server.Host/Components/IInstanceFactory.cs b/src/Tgstation.Server.Host/Components/IInstanceFactory.cs index 6258614b5f..5728f7f632 100644 --- a/src/Tgstation.Server.Host/Components/IInstanceFactory.cs +++ b/src/Tgstation.Server.Host/Components/IInstanceFactory.cs @@ -3,6 +3,8 @@ using Tgstation.Server.Host.Components.Interop.Bridge; using Tgstation.Server.Host.IO; +#nullable disable + namespace Tgstation.Server.Host.Components { /// diff --git a/src/Tgstation.Server.Host/Components/IInstanceManager.cs b/src/Tgstation.Server.Host/Components/IInstanceManager.cs index 3174686efe..c9439c2bdb 100644 --- a/src/Tgstation.Server.Host/Components/IInstanceManager.cs +++ b/src/Tgstation.Server.Host/Components/IInstanceManager.cs @@ -2,6 +2,8 @@ using Tgstation.Server.Host.Components.Interop.Bridge; +#nullable disable + namespace Tgstation.Server.Host.Components { /// diff --git a/src/Tgstation.Server.Host/Components/IInstanceOperations.cs b/src/Tgstation.Server.Host/Components/IInstanceOperations.cs index 3212d9d6dc..8d81a1d69c 100644 --- a/src/Tgstation.Server.Host/Components/IInstanceOperations.cs +++ b/src/Tgstation.Server.Host/Components/IInstanceOperations.cs @@ -3,6 +3,8 @@ using System.Threading.Tasks; using Tgstation.Server.Host.Models; +#nullable disable + namespace Tgstation.Server.Host.Components { /// diff --git a/src/Tgstation.Server.Host/Components/IInstanceReference.cs b/src/Tgstation.Server.Host/Components/IInstanceReference.cs index 55f9379e80..14a63a7649 100644 --- a/src/Tgstation.Server.Host/Components/IInstanceReference.cs +++ b/src/Tgstation.Server.Host/Components/IInstanceReference.cs @@ -1,5 +1,7 @@ using System; +#nullable disable + namespace Tgstation.Server.Host.Components { /// diff --git a/src/Tgstation.Server.Host/Components/IRenameNotifyee.cs b/src/Tgstation.Server.Host/Components/IRenameNotifyee.cs index be22158bd9..5394921314 100644 --- a/src/Tgstation.Server.Host/Components/IRenameNotifyee.cs +++ b/src/Tgstation.Server.Host/Components/IRenameNotifyee.cs @@ -1,6 +1,8 @@ using System.Threading; using System.Threading.Tasks; +#nullable disable + namespace Tgstation.Server.Host.Components { /// diff --git a/src/Tgstation.Server.Host/Components/Instance.cs b/src/Tgstation.Server.Host/Components/Instance.cs index 7176e8f050..10b0e89cd7 100644 --- a/src/Tgstation.Server.Host/Components/Instance.cs +++ b/src/Tgstation.Server.Host/Components/Instance.cs @@ -21,6 +21,8 @@ using Tgstation.Server.Host.Jobs; using Tgstation.Server.Host.Models; using Tgstation.Server.Host.Utils; +#nullable disable + namespace Tgstation.Server.Host.Components { /// diff --git a/src/Tgstation.Server.Host/Components/InstanceFactory.cs b/src/Tgstation.Server.Host/Components/InstanceFactory.cs index a2e9dc6ff5..a9f5878c41 100644 --- a/src/Tgstation.Server.Host/Components/InstanceFactory.cs +++ b/src/Tgstation.Server.Host/Components/InstanceFactory.cs @@ -25,6 +25,8 @@ using Tgstation.Server.Host.System; using Tgstation.Server.Host.Transfer; using Tgstation.Server.Host.Utils; +#nullable disable + namespace Tgstation.Server.Host.Components { /// diff --git a/src/Tgstation.Server.Host/Components/InstanceManager.cs b/src/Tgstation.Server.Host/Components/InstanceManager.cs index 0959e9ca01..bf2b5dbba0 100644 --- a/src/Tgstation.Server.Host/Components/InstanceManager.cs +++ b/src/Tgstation.Server.Host/Components/InstanceManager.cs @@ -26,6 +26,8 @@ using Tgstation.Server.Host.Swarm; using Tgstation.Server.Host.System; using Tgstation.Server.Host.Utils; +#nullable disable + namespace Tgstation.Server.Host.Components { /// diff --git a/src/Tgstation.Server.Host/Components/InstanceWrapper.cs b/src/Tgstation.Server.Host/Components/InstanceWrapper.cs index 5c525d9869..21861d1706 100644 --- a/src/Tgstation.Server.Host/Components/InstanceWrapper.cs +++ b/src/Tgstation.Server.Host/Components/InstanceWrapper.cs @@ -10,6 +10,8 @@ using Tgstation.Server.Host.Components.Watchdog; using Tgstation.Server.Host.Models; using Tgstation.Server.Host.Utils; +#nullable disable + namespace Tgstation.Server.Host.Components { /// diff --git a/src/Tgstation.Server.Host/Components/Interop/Bridge/BridgeParameters.cs b/src/Tgstation.Server.Host/Components/Interop/Bridge/BridgeParameters.cs index c1c9213063..a1475ed1f9 100644 --- a/src/Tgstation.Server.Host/Components/Interop/Bridge/BridgeParameters.cs +++ b/src/Tgstation.Server.Host/Components/Interop/Bridge/BridgeParameters.cs @@ -4,6 +4,8 @@ using System.Collections.Generic; using Tgstation.Server.Api.Models; using Tgstation.Server.Host.Components.Chat.Commands; +#nullable disable + namespace Tgstation.Server.Host.Components.Interop.Bridge { /// diff --git a/src/Tgstation.Server.Host/Components/Interop/Bridge/BridgeRegistration.cs b/src/Tgstation.Server.Host/Components/Interop/Bridge/BridgeRegistration.cs index ade7d5adfe..e209a63aa6 100644 --- a/src/Tgstation.Server.Host/Components/Interop/Bridge/BridgeRegistration.cs +++ b/src/Tgstation.Server.Host/Components/Interop/Bridge/BridgeRegistration.cs @@ -1,5 +1,7 @@ using System; +#nullable disable + namespace Tgstation.Server.Host.Components.Interop.Bridge { /// diff --git a/src/Tgstation.Server.Host/Components/Interop/Bridge/BridgeResponse.cs b/src/Tgstation.Server.Host/Components/Interop/Bridge/BridgeResponse.cs index f7f358d612..27113567b2 100644 --- a/src/Tgstation.Server.Host/Components/Interop/Bridge/BridgeResponse.cs +++ b/src/Tgstation.Server.Host/Components/Interop/Bridge/BridgeResponse.cs @@ -1,5 +1,7 @@ using System.Collections.Generic; +#nullable disable + namespace Tgstation.Server.Host.Components.Interop.Bridge { /// diff --git a/src/Tgstation.Server.Host/Components/Interop/Bridge/IBridgeDispatcher.cs b/src/Tgstation.Server.Host/Components/Interop/Bridge/IBridgeDispatcher.cs index 82de2d6631..166daa4a21 100644 --- a/src/Tgstation.Server.Host/Components/Interop/Bridge/IBridgeDispatcher.cs +++ b/src/Tgstation.Server.Host/Components/Interop/Bridge/IBridgeDispatcher.cs @@ -1,6 +1,8 @@ using System.Threading; using System.Threading.Tasks; +#nullable disable + namespace Tgstation.Server.Host.Components.Interop.Bridge { /// diff --git a/src/Tgstation.Server.Host/Components/Interop/Bridge/IBridgeRegistration.cs b/src/Tgstation.Server.Host/Components/Interop/Bridge/IBridgeRegistration.cs index 189846f081..50f17cf912 100644 --- a/src/Tgstation.Server.Host/Components/Interop/Bridge/IBridgeRegistration.cs +++ b/src/Tgstation.Server.Host/Components/Interop/Bridge/IBridgeRegistration.cs @@ -1,5 +1,7 @@ using System; +#nullable disable + namespace Tgstation.Server.Host.Components.Interop.Bridge { /// diff --git a/src/Tgstation.Server.Host/Components/Interop/Bridge/RuntimeInformation.cs b/src/Tgstation.Server.Host/Components/Interop/Bridge/RuntimeInformation.cs index b7d05b67d7..a24a17a614 100644 --- a/src/Tgstation.Server.Host/Components/Interop/Bridge/RuntimeInformation.cs +++ b/src/Tgstation.Server.Host/Components/Interop/Bridge/RuntimeInformation.cs @@ -9,6 +9,8 @@ using Tgstation.Server.Host.Components.Chat; using Tgstation.Server.Host.Components.Deployment; using Tgstation.Server.Host.System; +#nullable disable + namespace Tgstation.Server.Host.Components.Interop.Bridge { /// diff --git a/src/Tgstation.Server.Host/Components/Interop/Bridge/TestMergeInformation.cs b/src/Tgstation.Server.Host/Components/Interop/Bridge/TestMergeInformation.cs index 1270af68cf..3543f052bb 100644 --- a/src/Tgstation.Server.Host/Components/Interop/Bridge/TestMergeInformation.cs +++ b/src/Tgstation.Server.Host/Components/Interop/Bridge/TestMergeInformation.cs @@ -3,6 +3,8 @@ using System.Globalization; using Tgstation.Server.Api.Models.Internal; +#nullable disable + namespace Tgstation.Server.Host.Components.Interop.Bridge { /// diff --git a/src/Tgstation.Server.Host/Components/Interop/ChatEmbed.cs b/src/Tgstation.Server.Host/Components/Interop/ChatEmbed.cs index da3518ec2a..e76c2bcbd8 100644 --- a/src/Tgstation.Server.Host/Components/Interop/ChatEmbed.cs +++ b/src/Tgstation.Server.Host/Components/Interop/ChatEmbed.cs @@ -1,5 +1,7 @@ using System.Collections.Generic; +#nullable disable + namespace Tgstation.Server.Host.Components.Interop { /// diff --git a/src/Tgstation.Server.Host/Components/Interop/ChatEmbedAuthor.cs b/src/Tgstation.Server.Host/Components/Interop/ChatEmbedAuthor.cs index b79d38be5b..97b5d26fd4 100644 --- a/src/Tgstation.Server.Host/Components/Interop/ChatEmbedAuthor.cs +++ b/src/Tgstation.Server.Host/Components/Interop/ChatEmbedAuthor.cs @@ -1,4 +1,6 @@ -namespace Tgstation.Server.Host.Components.Interop +#nullable disable + +namespace Tgstation.Server.Host.Components.Interop { /// /// Represents information about a author. diff --git a/src/Tgstation.Server.Host/Components/Interop/ChatEmbedField.cs b/src/Tgstation.Server.Host/Components/Interop/ChatEmbedField.cs index 9d3ca0b864..f584557992 100644 --- a/src/Tgstation.Server.Host/Components/Interop/ChatEmbedField.cs +++ b/src/Tgstation.Server.Host/Components/Interop/ChatEmbedField.cs @@ -1,4 +1,6 @@ -namespace Tgstation.Server.Host.Components.Interop +#nullable disable + +namespace Tgstation.Server.Host.Components.Interop { /// /// Represents a field in a . diff --git a/src/Tgstation.Server.Host/Components/Interop/ChatEmbedFooter.cs b/src/Tgstation.Server.Host/Components/Interop/ChatEmbedFooter.cs index 0df7a2c5d9..2105603d92 100644 --- a/src/Tgstation.Server.Host/Components/Interop/ChatEmbedFooter.cs +++ b/src/Tgstation.Server.Host/Components/Interop/ChatEmbedFooter.cs @@ -1,4 +1,6 @@ -namespace Tgstation.Server.Host.Components.Interop +#nullable disable + +namespace Tgstation.Server.Host.Components.Interop { /// /// Represents a footer in a . diff --git a/src/Tgstation.Server.Host/Components/Interop/ChatEmbedMedia.cs b/src/Tgstation.Server.Host/Components/Interop/ChatEmbedMedia.cs index 1cad4c4349..ebab7bfa80 100644 --- a/src/Tgstation.Server.Host/Components/Interop/ChatEmbedMedia.cs +++ b/src/Tgstation.Server.Host/Components/Interop/ChatEmbedMedia.cs @@ -1,4 +1,6 @@ -namespace Tgstation.Server.Host.Components.Interop +#nullable disable + +namespace Tgstation.Server.Host.Components.Interop { /// /// Represents information about a thumbnail in a . diff --git a/src/Tgstation.Server.Host/Components/Interop/ChatEmbedProvider.cs b/src/Tgstation.Server.Host/Components/Interop/ChatEmbedProvider.cs index 386a269a7d..c7a29b039e 100644 --- a/src/Tgstation.Server.Host/Components/Interop/ChatEmbedProvider.cs +++ b/src/Tgstation.Server.Host/Components/Interop/ChatEmbedProvider.cs @@ -1,4 +1,6 @@ -namespace Tgstation.Server.Host.Components.Interop +#nullable disable + +namespace Tgstation.Server.Host.Components.Interop { /// /// Represents information about a provider. diff --git a/src/Tgstation.Server.Host/Components/Interop/ChatMessage.cs b/src/Tgstation.Server.Host/Components/Interop/ChatMessage.cs index 3d8900e427..2178cc1a1d 100644 --- a/src/Tgstation.Server.Host/Components/Interop/ChatMessage.cs +++ b/src/Tgstation.Server.Host/Components/Interop/ChatMessage.cs @@ -1,5 +1,7 @@ using System.Collections.Generic; +#nullable disable + namespace Tgstation.Server.Host.Components.Interop { /// diff --git a/src/Tgstation.Server.Host/Components/Interop/ChatUpdate.cs b/src/Tgstation.Server.Host/Components/Interop/ChatUpdate.cs index 12e9b408ab..af902de7b6 100644 --- a/src/Tgstation.Server.Host/Components/Interop/ChatUpdate.cs +++ b/src/Tgstation.Server.Host/Components/Interop/ChatUpdate.cs @@ -4,6 +4,8 @@ using System.Linq; using Tgstation.Server.Host.Components.Chat; +#nullable disable + namespace Tgstation.Server.Host.Components.Interop { /// diff --git a/src/Tgstation.Server.Host/Components/Interop/ChunkData.cs b/src/Tgstation.Server.Host/Components/Interop/ChunkData.cs index ee6122d764..8c442413c5 100644 --- a/src/Tgstation.Server.Host/Components/Interop/ChunkData.cs +++ b/src/Tgstation.Server.Host/Components/Interop/ChunkData.cs @@ -1,4 +1,6 @@ -namespace Tgstation.Server.Host.Components.Interop +#nullable disable + +namespace Tgstation.Server.Host.Components.Interop { /// /// A packet of a split serialized set of data. diff --git a/src/Tgstation.Server.Host/Components/Interop/Chunker.cs b/src/Tgstation.Server.Host/Components/Interop/Chunker.cs index d6a0c7c024..ae8341b942 100644 --- a/src/Tgstation.Server.Host/Components/Interop/Chunker.cs +++ b/src/Tgstation.Server.Host/Components/Interop/Chunker.cs @@ -7,6 +7,8 @@ using Microsoft.Extensions.Logging; using Newtonsoft.Json; +#nullable disable + namespace Tgstation.Server.Host.Components.Interop { /// diff --git a/src/Tgstation.Server.Host/Components/Interop/DMApiConstants.cs b/src/Tgstation.Server.Host/Components/Interop/DMApiConstants.cs index 2a59892180..def2cb27e7 100644 --- a/src/Tgstation.Server.Host/Components/Interop/DMApiConstants.cs +++ b/src/Tgstation.Server.Host/Components/Interop/DMApiConstants.cs @@ -6,6 +6,8 @@ using Newtonsoft.Json.Serialization; using Tgstation.Server.Host.Extensions.Converters; using Tgstation.Server.Host.Properties; +#nullable disable + namespace Tgstation.Server.Host.Components.Interop { /// diff --git a/src/Tgstation.Server.Host/Components/Interop/DMApiParameters.cs b/src/Tgstation.Server.Host/Components/Interop/DMApiParameters.cs index a6faad3292..55954dd38d 100644 --- a/src/Tgstation.Server.Host/Components/Interop/DMApiParameters.cs +++ b/src/Tgstation.Server.Host/Components/Interop/DMApiParameters.cs @@ -1,5 +1,7 @@ using System.ComponentModel.DataAnnotations; +#nullable disable + namespace Tgstation.Server.Host.Components.Interop { /// diff --git a/src/Tgstation.Server.Host/Components/Interop/DMApiResponse.cs b/src/Tgstation.Server.Host/Components/Interop/DMApiResponse.cs index bb1adf4925..1196d8aa6f 100644 --- a/src/Tgstation.Server.Host/Components/Interop/DMApiResponse.cs +++ b/src/Tgstation.Server.Host/Components/Interop/DMApiResponse.cs @@ -1,4 +1,6 @@ -namespace Tgstation.Server.Host.Components.Interop +#nullable disable + +namespace Tgstation.Server.Host.Components.Interop { /// /// Common base for interop responses. diff --git a/src/Tgstation.Server.Host/Components/Interop/IMissingPayloadsCommunication.cs b/src/Tgstation.Server.Host/Components/Interop/IMissingPayloadsCommunication.cs index 392cd7eecb..77c3ebff3f 100644 --- a/src/Tgstation.Server.Host/Components/Interop/IMissingPayloadsCommunication.cs +++ b/src/Tgstation.Server.Host/Components/Interop/IMissingPayloadsCommunication.cs @@ -1,5 +1,7 @@ using System.Collections.Generic; +#nullable disable + namespace Tgstation.Server.Host.Components.Interop { /// diff --git a/src/Tgstation.Server.Host/Components/Interop/MessageContent.cs b/src/Tgstation.Server.Host/Components/Interop/MessageContent.cs index 6d484a411b..73e2980906 100644 --- a/src/Tgstation.Server.Host/Components/Interop/MessageContent.cs +++ b/src/Tgstation.Server.Host/Components/Interop/MessageContent.cs @@ -1,4 +1,6 @@ -namespace Tgstation.Server.Host.Components.Interop +#nullable disable + +namespace Tgstation.Server.Host.Components.Interop { /// /// Represents a message to send to a chat provider. diff --git a/src/Tgstation.Server.Host/Components/Interop/Topic/ChatCommand.cs b/src/Tgstation.Server.Host/Components/Interop/Topic/ChatCommand.cs index 5f50d6bba8..34aeed50e7 100644 --- a/src/Tgstation.Server.Host/Components/Interop/Topic/ChatCommand.cs +++ b/src/Tgstation.Server.Host/Components/Interop/Topic/ChatCommand.cs @@ -2,6 +2,8 @@ using Tgstation.Server.Host.Components.Chat; +#nullable disable + namespace Tgstation.Server.Host.Components.Interop.Topic { /// diff --git a/src/Tgstation.Server.Host/Components/Interop/Topic/ChunkedTopicParameters.cs b/src/Tgstation.Server.Host/Components/Interop/Topic/ChunkedTopicParameters.cs index 79353a66bb..99bf573d9b 100644 --- a/src/Tgstation.Server.Host/Components/Interop/Topic/ChunkedTopicParameters.cs +++ b/src/Tgstation.Server.Host/Components/Interop/Topic/ChunkedTopicParameters.cs @@ -1,5 +1,7 @@ using System.Collections.Generic; +#nullable disable + namespace Tgstation.Server.Host.Components.Interop.Topic { /// diff --git a/src/Tgstation.Server.Host/Components/Interop/Topic/EventNotification.cs b/src/Tgstation.Server.Host/Components/Interop/Topic/EventNotification.cs index 54a8d496a5..6977a27554 100644 --- a/src/Tgstation.Server.Host/Components/Interop/Topic/EventNotification.cs +++ b/src/Tgstation.Server.Host/Components/Interop/Topic/EventNotification.cs @@ -4,6 +4,8 @@ using System.Linq; using Tgstation.Server.Host.Components.Events; +#nullable disable + namespace Tgstation.Server.Host.Components.Interop.Topic { /// diff --git a/src/Tgstation.Server.Host/Components/Interop/Topic/TopicCommandType.cs b/src/Tgstation.Server.Host/Components/Interop/Topic/TopicCommandType.cs index 286c605d07..08d8917a66 100644 --- a/src/Tgstation.Server.Host/Components/Interop/Topic/TopicCommandType.cs +++ b/src/Tgstation.Server.Host/Components/Interop/Topic/TopicCommandType.cs @@ -1,5 +1,7 @@ using System; +#nullable disable + namespace Tgstation.Server.Host.Components.Interop.Topic { /// diff --git a/src/Tgstation.Server.Host/Components/Interop/Topic/TopicParameters.cs b/src/Tgstation.Server.Host/Components/Interop/Topic/TopicParameters.cs index 65c060b412..8674e0679d 100644 --- a/src/Tgstation.Server.Host/Components/Interop/Topic/TopicParameters.cs +++ b/src/Tgstation.Server.Host/Components/Interop/Topic/TopicParameters.cs @@ -4,6 +4,8 @@ using Newtonsoft.Json; using Tgstation.Server.Host.Components.Session; +#nullable disable + namespace Tgstation.Server.Host.Components.Interop.Topic { /// diff --git a/src/Tgstation.Server.Host/Components/Interop/Topic/TopicResponse.cs b/src/Tgstation.Server.Host/Components/Interop/Topic/TopicResponse.cs index f108aba543..3b936b514e 100644 --- a/src/Tgstation.Server.Host/Components/Interop/Topic/TopicResponse.cs +++ b/src/Tgstation.Server.Host/Components/Interop/Topic/TopicResponse.cs @@ -2,6 +2,8 @@ using Tgstation.Server.Host.Components.Chat.Commands; +#nullable disable + namespace Tgstation.Server.Host.Components.Interop.Topic { /// diff --git a/src/Tgstation.Server.Host/Components/Repository/DefaultGitRemoteFeatures.cs b/src/Tgstation.Server.Host/Components/Repository/DefaultGitRemoteFeatures.cs index ead4007720..c5909b7b84 100644 --- a/src/Tgstation.Server.Host/Components/Repository/DefaultGitRemoteFeatures.cs +++ b/src/Tgstation.Server.Host/Components/Repository/DefaultGitRemoteFeatures.cs @@ -4,6 +4,8 @@ using System.Threading.Tasks; using Tgstation.Server.Api.Models; +#nullable disable + namespace Tgstation.Server.Host.Components.Repository { /// diff --git a/src/Tgstation.Server.Host/Components/Repository/GitHubRemoteFeatures.cs b/src/Tgstation.Server.Host/Components/Repository/GitHubRemoteFeatures.cs index 6e5d5c4ec0..2aa9cb3312 100644 --- a/src/Tgstation.Server.Host/Components/Repository/GitHubRemoteFeatures.cs +++ b/src/Tgstation.Server.Host/Components/Repository/GitHubRemoteFeatures.cs @@ -9,6 +9,8 @@ using Tgstation.Server.Api.Models; using Tgstation.Server.Api.Models.Internal; using Tgstation.Server.Host.Utils.GitHub; +#nullable disable + namespace Tgstation.Server.Host.Components.Repository { /// diff --git a/src/Tgstation.Server.Host/Components/Repository/GitLabRemoteFeatures.cs b/src/Tgstation.Server.Host/Components/Repository/GitLabRemoteFeatures.cs index def1adbaaf..1f34ceeacb 100644 --- a/src/Tgstation.Server.Host/Components/Repository/GitLabRemoteFeatures.cs +++ b/src/Tgstation.Server.Host/Components/Repository/GitLabRemoteFeatures.cs @@ -8,6 +8,8 @@ using Microsoft.Extensions.Logging; using Tgstation.Server.Api.Models; using Tgstation.Server.Api.Models.Internal; +#nullable disable + namespace Tgstation.Server.Host.Components.Repository { /// diff --git a/src/Tgstation.Server.Host/Components/Repository/GitRemoteFeaturesBase.cs b/src/Tgstation.Server.Host/Components/Repository/GitRemoteFeaturesBase.cs index 1b1c5337af..b0adfdb298 100644 --- a/src/Tgstation.Server.Host/Components/Repository/GitRemoteFeaturesBase.cs +++ b/src/Tgstation.Server.Host/Components/Repository/GitRemoteFeaturesBase.cs @@ -8,6 +8,8 @@ using Microsoft.Extensions.Logging; using Tgstation.Server.Api.Models; using Tgstation.Server.Api.Models.Internal; +#nullable disable + namespace Tgstation.Server.Host.Components.Repository { /// diff --git a/src/Tgstation.Server.Host/Components/Repository/GitRemoteFeaturesFactory.cs b/src/Tgstation.Server.Host/Components/Repository/GitRemoteFeaturesFactory.cs index ab5dcb45ec..2c7c222071 100644 --- a/src/Tgstation.Server.Host/Components/Repository/GitRemoteFeaturesFactory.cs +++ b/src/Tgstation.Server.Host/Components/Repository/GitRemoteFeaturesFactory.cs @@ -5,6 +5,8 @@ using Microsoft.Extensions.Logging; using Tgstation.Server.Api.Models; using Tgstation.Server.Host.Utils.GitHub; +#nullable disable + namespace Tgstation.Server.Host.Components.Repository { /// diff --git a/src/Tgstation.Server.Host/Components/Repository/ICredentialsProvider.cs b/src/Tgstation.Server.Host/Components/Repository/ICredentialsProvider.cs index cef08354c6..d120754a5e 100644 --- a/src/Tgstation.Server.Host/Components/Repository/ICredentialsProvider.cs +++ b/src/Tgstation.Server.Host/Components/Repository/ICredentialsProvider.cs @@ -3,6 +3,8 @@ using LibGit2Sharp.Handlers; using Tgstation.Server.Host.Jobs; +#nullable disable + namespace Tgstation.Server.Host.Components.Repository { /// diff --git a/src/Tgstation.Server.Host/Components/Repository/IGitRemoteAdditionalInformation.cs b/src/Tgstation.Server.Host/Components/Repository/IGitRemoteAdditionalInformation.cs index ffead020f9..a933a85ad1 100644 --- a/src/Tgstation.Server.Host/Components/Repository/IGitRemoteAdditionalInformation.cs +++ b/src/Tgstation.Server.Host/Components/Repository/IGitRemoteAdditionalInformation.cs @@ -4,6 +4,8 @@ using System.Threading.Tasks; using Tgstation.Server.Api.Models; using Tgstation.Server.Api.Models.Internal; +#nullable disable + namespace Tgstation.Server.Host.Components.Repository { /// diff --git a/src/Tgstation.Server.Host/Components/Repository/IGitRemoteFeaturesFactory.cs b/src/Tgstation.Server.Host/Components/Repository/IGitRemoteFeaturesFactory.cs index 42a55e6285..dd4ee7de3a 100644 --- a/src/Tgstation.Server.Host/Components/Repository/IGitRemoteFeaturesFactory.cs +++ b/src/Tgstation.Server.Host/Components/Repository/IGitRemoteFeaturesFactory.cs @@ -2,6 +2,8 @@ using Tgstation.Server.Api.Models; +#nullable disable + namespace Tgstation.Server.Host.Components.Repository { /// diff --git a/src/Tgstation.Server.Host/Components/Repository/ILibGit2Commands.cs b/src/Tgstation.Server.Host/Components/Repository/ILibGit2Commands.cs index 6c0ab0da49..e4fc821ec4 100644 --- a/src/Tgstation.Server.Host/Components/Repository/ILibGit2Commands.cs +++ b/src/Tgstation.Server.Host/Components/Repository/ILibGit2Commands.cs @@ -2,6 +2,8 @@ using LibGit2Sharp; +#nullable disable + namespace Tgstation.Server.Host.Components.Repository { /// diff --git a/src/Tgstation.Server.Host/Components/Repository/ILibGit2RepositoryFactory.cs b/src/Tgstation.Server.Host/Components/Repository/ILibGit2RepositoryFactory.cs index 34b8c56669..b69df2783f 100644 --- a/src/Tgstation.Server.Host/Components/Repository/ILibGit2RepositoryFactory.cs +++ b/src/Tgstation.Server.Host/Components/Repository/ILibGit2RepositoryFactory.cs @@ -4,6 +4,8 @@ using System.Threading.Tasks; using LibGit2Sharp; +#nullable disable + namespace Tgstation.Server.Host.Components.Repository { /// diff --git a/src/Tgstation.Server.Host/Components/Repository/IRepository.cs b/src/Tgstation.Server.Host/Components/Repository/IRepository.cs index 0482eaaa90..ed858ab492 100644 --- a/src/Tgstation.Server.Host/Components/Repository/IRepository.cs +++ b/src/Tgstation.Server.Host/Components/Repository/IRepository.cs @@ -5,6 +5,8 @@ using System.Threading.Tasks; using Tgstation.Server.Api.Models; using Tgstation.Server.Host.Jobs; +#nullable disable + namespace Tgstation.Server.Host.Components.Repository { /// diff --git a/src/Tgstation.Server.Host/Components/Repository/IRepositoryManager.cs b/src/Tgstation.Server.Host/Components/Repository/IRepositoryManager.cs index d602730e15..090e3cad82 100644 --- a/src/Tgstation.Server.Host/Components/Repository/IRepositoryManager.cs +++ b/src/Tgstation.Server.Host/Components/Repository/IRepositoryManager.cs @@ -4,6 +4,8 @@ using System.Threading.Tasks; using Tgstation.Server.Host.Jobs; +#nullable disable + namespace Tgstation.Server.Host.Components.Repository { /// diff --git a/src/Tgstation.Server.Host/Components/Repository/IRepositoryManagerFactory.cs b/src/Tgstation.Server.Host/Components/Repository/IRepositoryManagerFactory.cs index 0e8c54c70e..049ad396de 100644 --- a/src/Tgstation.Server.Host/Components/Repository/IRepositoryManagerFactory.cs +++ b/src/Tgstation.Server.Host/Components/Repository/IRepositoryManagerFactory.cs @@ -1,6 +1,8 @@ using Tgstation.Server.Host.Components.Events; using Tgstation.Server.Host.IO; +#nullable disable + namespace Tgstation.Server.Host.Components.Repository { /// diff --git a/src/Tgstation.Server.Host/Components/Repository/LibGit2Commands.cs b/src/Tgstation.Server.Host/Components/Repository/LibGit2Commands.cs index ec5c37a880..b70dc7b156 100644 --- a/src/Tgstation.Server.Host/Components/Repository/LibGit2Commands.cs +++ b/src/Tgstation.Server.Host/Components/Repository/LibGit2Commands.cs @@ -3,6 +3,8 @@ using System.Collections.Generic; using LibGit2Sharp; +#nullable disable + namespace Tgstation.Server.Host.Components.Repository { /// diff --git a/src/Tgstation.Server.Host/Components/Repository/LibGit2RepositoryFactory.cs b/src/Tgstation.Server.Host/Components/Repository/LibGit2RepositoryFactory.cs index 83011a61b1..e47d1a553f 100644 --- a/src/Tgstation.Server.Host/Components/Repository/LibGit2RepositoryFactory.cs +++ b/src/Tgstation.Server.Host/Components/Repository/LibGit2RepositoryFactory.cs @@ -10,6 +10,8 @@ using Tgstation.Server.Api.Models; using Tgstation.Server.Host.IO; using Tgstation.Server.Host.Jobs; +#nullable disable + namespace Tgstation.Server.Host.Components.Repository { /// diff --git a/src/Tgstation.Server.Host/Components/Repository/Repository.cs b/src/Tgstation.Server.Host/Components/Repository/Repository.cs index a3b81d2bad..7c8328344a 100644 --- a/src/Tgstation.Server.Host/Components/Repository/Repository.cs +++ b/src/Tgstation.Server.Host/Components/Repository/Repository.cs @@ -18,6 +18,8 @@ using Tgstation.Server.Host.Extensions; using Tgstation.Server.Host.IO; using Tgstation.Server.Host.Jobs; +#nullable disable + namespace Tgstation.Server.Host.Components.Repository { /// diff --git a/src/Tgstation.Server.Host/Components/Repository/RepositoryManager.cs b/src/Tgstation.Server.Host/Components/Repository/RepositoryManager.cs index 2940e0d134..2bbe2be2d6 100644 --- a/src/Tgstation.Server.Host/Components/Repository/RepositoryManager.cs +++ b/src/Tgstation.Server.Host/Components/Repository/RepositoryManager.cs @@ -13,6 +13,8 @@ using Tgstation.Server.Host.IO; using Tgstation.Server.Host.Jobs; using Tgstation.Server.Host.Utils; +#nullable disable + namespace Tgstation.Server.Host.Components.Repository { /// diff --git a/src/Tgstation.Server.Host/Components/Repository/RepositoryUpdateService.cs b/src/Tgstation.Server.Host/Components/Repository/RepositoryUpdateService.cs index 418dc9462d..8b00701f69 100644 --- a/src/Tgstation.Server.Host/Components/Repository/RepositoryUpdateService.cs +++ b/src/Tgstation.Server.Host/Components/Repository/RepositoryUpdateService.cs @@ -15,6 +15,8 @@ using Tgstation.Server.Host.Database; using Tgstation.Server.Host.Jobs; using Tgstation.Server.Host.Models; +#nullable disable + namespace Tgstation.Server.Host.Components.Repository { /// diff --git a/src/Tgstation.Server.Host/Components/Repository/RepostoryManagerFactory.cs b/src/Tgstation.Server.Host/Components/Repository/RepostoryManagerFactory.cs index cba66ff69a..140b79f03c 100644 --- a/src/Tgstation.Server.Host/Components/Repository/RepostoryManagerFactory.cs +++ b/src/Tgstation.Server.Host/Components/Repository/RepostoryManagerFactory.cs @@ -9,6 +9,8 @@ using Tgstation.Server.Host.Components.Events; using Tgstation.Server.Host.Configuration; using Tgstation.Server.Host.IO; +#nullable disable + namespace Tgstation.Server.Host.Components.Repository { /// diff --git a/src/Tgstation.Server.Host/Components/Repository/TestMergeResult.cs b/src/Tgstation.Server.Host/Components/Repository/TestMergeResult.cs index 387a6baad1..c722590e30 100644 --- a/src/Tgstation.Server.Host/Components/Repository/TestMergeResult.cs +++ b/src/Tgstation.Server.Host/Components/Repository/TestMergeResult.cs @@ -2,6 +2,8 @@ using LibGit2Sharp; +#nullable disable + namespace Tgstation.Server.Host.Components.Repository { /// diff --git a/src/Tgstation.Server.Host/Components/Session/CombinedTopicResponse.cs b/src/Tgstation.Server.Host/Components/Session/CombinedTopicResponse.cs index 417934f04a..2b7a09b174 100644 --- a/src/Tgstation.Server.Host/Components/Session/CombinedTopicResponse.cs +++ b/src/Tgstation.Server.Host/Components/Session/CombinedTopicResponse.cs @@ -2,6 +2,8 @@ using Tgstation.Server.Host.Components.Interop.Topic; +#nullable disable + namespace Tgstation.Server.Host.Components.Session { /// diff --git a/src/Tgstation.Server.Host/Components/Session/ISessionController.cs b/src/Tgstation.Server.Host/Components/Session/ISessionController.cs index 2769aafa60..d42190c78f 100644 --- a/src/Tgstation.Server.Host/Components/Session/ISessionController.cs +++ b/src/Tgstation.Server.Host/Components/Session/ISessionController.cs @@ -7,6 +7,8 @@ using Tgstation.Server.Host.Components.Deployment; using Tgstation.Server.Host.Components.Interop.Topic; using Tgstation.Server.Host.System; +#nullable disable + namespace Tgstation.Server.Host.Components.Session { /// diff --git a/src/Tgstation.Server.Host/Components/Session/ISessionControllerFactory.cs b/src/Tgstation.Server.Host/Components/Session/ISessionControllerFactory.cs index 26cc5e4a63..34f58c8cc0 100644 --- a/src/Tgstation.Server.Host/Components/Session/ISessionControllerFactory.cs +++ b/src/Tgstation.Server.Host/Components/Session/ISessionControllerFactory.cs @@ -5,6 +5,8 @@ using Tgstation.Server.Api.Models.Internal; using Tgstation.Server.Host.Components.Deployment; using Tgstation.Server.Host.Components.Engine; +#nullable disable + namespace Tgstation.Server.Host.Components.Session { /// diff --git a/src/Tgstation.Server.Host/Components/Session/ISessionPersistor.cs b/src/Tgstation.Server.Host/Components/Session/ISessionPersistor.cs index 5b1f1d7200..597208530e 100644 --- a/src/Tgstation.Server.Host/Components/Session/ISessionPersistor.cs +++ b/src/Tgstation.Server.Host/Components/Session/ISessionPersistor.cs @@ -1,6 +1,8 @@ using System.Threading; using System.Threading.Tasks; +#nullable disable + namespace Tgstation.Server.Host.Components.Session { /// diff --git a/src/Tgstation.Server.Host/Components/Session/ITopicClientFactory.cs b/src/Tgstation.Server.Host/Components/Session/ITopicClientFactory.cs index c4be5235a1..7f60ace9d0 100644 --- a/src/Tgstation.Server.Host/Components/Session/ITopicClientFactory.cs +++ b/src/Tgstation.Server.Host/Components/Session/ITopicClientFactory.cs @@ -2,6 +2,8 @@ using Byond.TopicSender; +#nullable disable + namespace Tgstation.Server.Host.Components.Session { /// diff --git a/src/Tgstation.Server.Host/Components/Session/LaunchResult.cs b/src/Tgstation.Server.Host/Components/Session/LaunchResult.cs index fd5785fd41..de536ce83e 100644 --- a/src/Tgstation.Server.Host/Components/Session/LaunchResult.cs +++ b/src/Tgstation.Server.Host/Components/Session/LaunchResult.cs @@ -1,6 +1,8 @@ using System; using System.Globalization; +#nullable disable + namespace Tgstation.Server.Host.Components.Session { /// diff --git a/src/Tgstation.Server.Host/Components/Session/ReattachInformation.cs b/src/Tgstation.Server.Host/Components/Session/ReattachInformation.cs index 6c429d2d0a..3ddeff51d7 100644 --- a/src/Tgstation.Server.Host/Components/Session/ReattachInformation.cs +++ b/src/Tgstation.Server.Host/Components/Session/ReattachInformation.cs @@ -5,6 +5,8 @@ using Tgstation.Server.Host.Components.Interop.Bridge; using Tgstation.Server.Host.Models; using Tgstation.Server.Host.System; +#nullable disable + namespace Tgstation.Server.Host.Components.Session { /// diff --git a/src/Tgstation.Server.Host/Components/Session/SessionController.cs b/src/Tgstation.Server.Host/Components/Session/SessionController.cs index d3feab14a6..0b191289cb 100644 --- a/src/Tgstation.Server.Host/Components/Session/SessionController.cs +++ b/src/Tgstation.Server.Host/Components/Session/SessionController.cs @@ -25,6 +25,8 @@ using Tgstation.Server.Host.Components.Interop.Topic; using Tgstation.Server.Host.System; using Tgstation.Server.Host.Utils; +#nullable disable + namespace Tgstation.Server.Host.Components.Session { /// diff --git a/src/Tgstation.Server.Host/Components/Session/SessionControllerFactory.cs b/src/Tgstation.Server.Host/Components/Session/SessionControllerFactory.cs index a54f9f8874..79abda99a8 100644 --- a/src/Tgstation.Server.Host/Components/Session/SessionControllerFactory.cs +++ b/src/Tgstation.Server.Host/Components/Session/SessionControllerFactory.cs @@ -26,6 +26,8 @@ using Tgstation.Server.Host.Security; using Tgstation.Server.Host.System; using Tgstation.Server.Host.Utils; +#nullable disable + namespace Tgstation.Server.Host.Components.Session { /// diff --git a/src/Tgstation.Server.Host/Components/Session/SessionPersistor.cs b/src/Tgstation.Server.Host/Components/Session/SessionPersistor.cs index e932fa6ec7..7eebd9a2af 100644 --- a/src/Tgstation.Server.Host/Components/Session/SessionPersistor.cs +++ b/src/Tgstation.Server.Host/Components/Session/SessionPersistor.cs @@ -12,6 +12,8 @@ using Tgstation.Server.Host.System; using Z.EntityFramework.Plus; +#nullable disable + namespace Tgstation.Server.Host.Components.Session { /// diff --git a/src/Tgstation.Server.Host/Components/Session/TopicClientFactory.cs b/src/Tgstation.Server.Host/Components/Session/TopicClientFactory.cs index 40605e5de8..e319b53ec5 100644 --- a/src/Tgstation.Server.Host/Components/Session/TopicClientFactory.cs +++ b/src/Tgstation.Server.Host/Components/Session/TopicClientFactory.cs @@ -3,6 +3,8 @@ using Byond.TopicSender; using Microsoft.Extensions.Logging; +#nullable disable + namespace Tgstation.Server.Host.Components.Session { /// diff --git a/src/Tgstation.Server.Host/Components/StaticFiles/Configuration.cs b/src/Tgstation.Server.Host/Components/StaticFiles/Configuration.cs index f42b4cc7e2..5208567047 100644 --- a/src/Tgstation.Server.Host/Components/StaticFiles/Configuration.cs +++ b/src/Tgstation.Server.Host/Components/StaticFiles/Configuration.cs @@ -23,6 +23,8 @@ using Tgstation.Server.Host.System; using Tgstation.Server.Host.Transfer; using Tgstation.Server.Host.Utils; +#nullable disable + namespace Tgstation.Server.Host.Components.StaticFiles { /// diff --git a/src/Tgstation.Server.Host/Components/StaticFiles/IConfiguration.cs b/src/Tgstation.Server.Host/Components/StaticFiles/IConfiguration.cs index 59546a044e..63b940d646 100644 --- a/src/Tgstation.Server.Host/Components/StaticFiles/IConfiguration.cs +++ b/src/Tgstation.Server.Host/Components/StaticFiles/IConfiguration.cs @@ -8,6 +8,8 @@ using Tgstation.Server.Api.Models.Response; using Tgstation.Server.Host.Components.Events; using Tgstation.Server.Host.Security; +#nullable disable + namespace Tgstation.Server.Host.Components.StaticFiles { /// diff --git a/src/Tgstation.Server.Host/Components/Watchdog/AdvancedWatchdog.cs b/src/Tgstation.Server.Host/Components/Watchdog/AdvancedWatchdog.cs index 33140b9e57..ed3c507317 100644 --- a/src/Tgstation.Server.Host/Components/Watchdog/AdvancedWatchdog.cs +++ b/src/Tgstation.Server.Host/Components/Watchdog/AdvancedWatchdog.cs @@ -18,6 +18,8 @@ using Tgstation.Server.Host.IO; using Tgstation.Server.Host.Jobs; using Tgstation.Server.Host.Utils; +#nullable disable + namespace Tgstation.Server.Host.Components.Watchdog { /// diff --git a/src/Tgstation.Server.Host/Components/Watchdog/BasicWatchdog.cs b/src/Tgstation.Server.Host/Components/Watchdog/BasicWatchdog.cs index 5beaab473c..d9f37a6f55 100644 --- a/src/Tgstation.Server.Host/Components/Watchdog/BasicWatchdog.cs +++ b/src/Tgstation.Server.Host/Components/Watchdog/BasicWatchdog.cs @@ -17,6 +17,8 @@ using Tgstation.Server.Host.IO; using Tgstation.Server.Host.Jobs; using Tgstation.Server.Host.Utils; +#nullable disable + namespace Tgstation.Server.Host.Components.Watchdog { /// diff --git a/src/Tgstation.Server.Host/Components/Watchdog/IWatchdog.cs b/src/Tgstation.Server.Host/Components/Watchdog/IWatchdog.cs index a54cde8e83..cd88606600 100644 --- a/src/Tgstation.Server.Host/Components/Watchdog/IWatchdog.cs +++ b/src/Tgstation.Server.Host/Components/Watchdog/IWatchdog.cs @@ -7,6 +7,8 @@ using Tgstation.Server.Api.Models.Internal; using Tgstation.Server.Host.Components.Events; using Tgstation.Server.Host.Components.Session; +#nullable disable + namespace Tgstation.Server.Host.Components.Watchdog { /// diff --git a/src/Tgstation.Server.Host/Components/Watchdog/IWatchdogFactory.cs b/src/Tgstation.Server.Host/Components/Watchdog/IWatchdogFactory.cs index 308cd3db54..eff60cf711 100644 --- a/src/Tgstation.Server.Host/Components/Watchdog/IWatchdogFactory.cs +++ b/src/Tgstation.Server.Host/Components/Watchdog/IWatchdogFactory.cs @@ -6,6 +6,8 @@ using Tgstation.Server.Host.Components.Events; using Tgstation.Server.Host.Components.Session; using Tgstation.Server.Host.IO; +#nullable disable + namespace Tgstation.Server.Host.Components.Watchdog { /// diff --git a/src/Tgstation.Server.Host/Components/Watchdog/PosixWatchdog.cs b/src/Tgstation.Server.Host/Components/Watchdog/PosixWatchdog.cs index 27874178af..7b142d6b54 100644 --- a/src/Tgstation.Server.Host/Components/Watchdog/PosixWatchdog.cs +++ b/src/Tgstation.Server.Host/Components/Watchdog/PosixWatchdog.cs @@ -17,6 +17,8 @@ using Tgstation.Server.Host.IO; using Tgstation.Server.Host.Jobs; using Tgstation.Server.Host.Utils; +#nullable disable + namespace Tgstation.Server.Host.Components.Watchdog { /// diff --git a/src/Tgstation.Server.Host/Components/Watchdog/PosixWatchdogFactory.cs b/src/Tgstation.Server.Host/Components/Watchdog/PosixWatchdogFactory.cs index 1d0d140bc0..491f0ff362 100644 --- a/src/Tgstation.Server.Host/Components/Watchdog/PosixWatchdogFactory.cs +++ b/src/Tgstation.Server.Host/Components/Watchdog/PosixWatchdogFactory.cs @@ -16,6 +16,8 @@ using Tgstation.Server.Host.IO; using Tgstation.Server.Host.Jobs; using Tgstation.Server.Host.Utils; +#nullable disable + namespace Tgstation.Server.Host.Components.Watchdog { /// diff --git a/src/Tgstation.Server.Host/Components/Watchdog/WatchdogBase.cs b/src/Tgstation.Server.Host/Components/Watchdog/WatchdogBase.cs index 33b5ca0720..e9bca68ee9 100644 --- a/src/Tgstation.Server.Host/Components/Watchdog/WatchdogBase.cs +++ b/src/Tgstation.Server.Host/Components/Watchdog/WatchdogBase.cs @@ -27,6 +27,8 @@ using Tgstation.Server.Host.IO; using Tgstation.Server.Host.Jobs; using Tgstation.Server.Host.Utils; +#nullable disable + namespace Tgstation.Server.Host.Components.Watchdog { /// diff --git a/src/Tgstation.Server.Host/Components/Watchdog/WatchdogFactory.cs b/src/Tgstation.Server.Host/Components/Watchdog/WatchdogFactory.cs index e9a37ecb2b..868155d3dc 100644 --- a/src/Tgstation.Server.Host/Components/Watchdog/WatchdogFactory.cs +++ b/src/Tgstation.Server.Host/Components/Watchdog/WatchdogFactory.cs @@ -15,6 +15,8 @@ using Tgstation.Server.Host.IO; using Tgstation.Server.Host.Jobs; using Tgstation.Server.Host.Utils; +#nullable disable + namespace Tgstation.Server.Host.Components.Watchdog { /// diff --git a/src/Tgstation.Server.Host/Components/Watchdog/WindowsWatchdog.cs b/src/Tgstation.Server.Host/Components/Watchdog/WindowsWatchdog.cs index cd8f0b4525..98a8d0da46 100644 --- a/src/Tgstation.Server.Host/Components/Watchdog/WindowsWatchdog.cs +++ b/src/Tgstation.Server.Host/Components/Watchdog/WindowsWatchdog.cs @@ -15,6 +15,8 @@ using Tgstation.Server.Host.IO; using Tgstation.Server.Host.Jobs; using Tgstation.Server.Host.Utils; +#nullable disable + namespace Tgstation.Server.Host.Components.Watchdog { /// diff --git a/src/Tgstation.Server.Host/Components/Watchdog/WindowsWatchdogFactory.cs b/src/Tgstation.Server.Host/Components/Watchdog/WindowsWatchdogFactory.cs index 89ed6b145d..cd78148c37 100644 --- a/src/Tgstation.Server.Host/Components/Watchdog/WindowsWatchdogFactory.cs +++ b/src/Tgstation.Server.Host/Components/Watchdog/WindowsWatchdogFactory.cs @@ -15,6 +15,8 @@ using Tgstation.Server.Host.IO; using Tgstation.Server.Host.Jobs; using Tgstation.Server.Host.Utils; +#nullable disable + namespace Tgstation.Server.Host.Components.Watchdog { /// diff --git a/src/Tgstation.Server.Host/Configuration/ControlPanelConfiguration.cs b/src/Tgstation.Server.Host/Configuration/ControlPanelConfiguration.cs index 19dfa9cace..437a420495 100644 --- a/src/Tgstation.Server.Host/Configuration/ControlPanelConfiguration.cs +++ b/src/Tgstation.Server.Host/Configuration/ControlPanelConfiguration.cs @@ -1,5 +1,7 @@ using System.Collections.Generic; +#nullable disable + namespace Tgstation.Server.Host.Configuration { /// diff --git a/src/Tgstation.Server.Host/Configuration/DatabaseConfiguration.cs b/src/Tgstation.Server.Host/Configuration/DatabaseConfiguration.cs index d5adce7577..51e78a2494 100644 --- a/src/Tgstation.Server.Host/Configuration/DatabaseConfiguration.cs +++ b/src/Tgstation.Server.Host/Configuration/DatabaseConfiguration.cs @@ -1,6 +1,8 @@ using Newtonsoft.Json; using Newtonsoft.Json.Converters; +#nullable disable + namespace Tgstation.Server.Host.Configuration { /// diff --git a/src/Tgstation.Server.Host/Configuration/ElasticsearchConfiguration.cs b/src/Tgstation.Server.Host/Configuration/ElasticsearchConfiguration.cs index 8c45f2e9f5..424d746a67 100644 --- a/src/Tgstation.Server.Host/Configuration/ElasticsearchConfiguration.cs +++ b/src/Tgstation.Server.Host/Configuration/ElasticsearchConfiguration.cs @@ -1,5 +1,7 @@ using System; +#nullable disable + namespace Tgstation.Server.Host.Configuration { /// diff --git a/src/Tgstation.Server.Host/Configuration/FileLoggingConfiguration.cs b/src/Tgstation.Server.Host/Configuration/FileLoggingConfiguration.cs index aa798cfed3..6d73d95ad9 100644 --- a/src/Tgstation.Server.Host/Configuration/FileLoggingConfiguration.cs +++ b/src/Tgstation.Server.Host/Configuration/FileLoggingConfiguration.cs @@ -7,6 +7,8 @@ using Newtonsoft.Json.Converters; using Tgstation.Server.Host.IO; using Tgstation.Server.Host.System; +#nullable disable + namespace Tgstation.Server.Host.Configuration { /// diff --git a/src/Tgstation.Server.Host/Configuration/GeneralConfiguration.cs b/src/Tgstation.Server.Host/Configuration/GeneralConfiguration.cs index f33ef79b11..a21f796dc7 100644 --- a/src/Tgstation.Server.Host/Configuration/GeneralConfiguration.cs +++ b/src/Tgstation.Server.Host/Configuration/GeneralConfiguration.cs @@ -11,6 +11,8 @@ using Tgstation.Server.Host.Setup; using YamlDotNet.Serialization; +#nullable disable + namespace Tgstation.Server.Host.Configuration { /// diff --git a/src/Tgstation.Server.Host/Configuration/InternalConfiguration.cs b/src/Tgstation.Server.Host/Configuration/InternalConfiguration.cs index 6bf30bafdc..315cdad35c 100644 --- a/src/Tgstation.Server.Host/Configuration/InternalConfiguration.cs +++ b/src/Tgstation.Server.Host/Configuration/InternalConfiguration.cs @@ -1,4 +1,6 @@ -namespace Tgstation.Server.Host.Configuration +#nullable disable + +namespace Tgstation.Server.Host.Configuration { /// /// Unstable configuration options used internally by TGS. diff --git a/src/Tgstation.Server.Host/Configuration/OAuthConfiguration.cs b/src/Tgstation.Server.Host/Configuration/OAuthConfiguration.cs index 1818a15d8b..ae1005b00e 100644 --- a/src/Tgstation.Server.Host/Configuration/OAuthConfiguration.cs +++ b/src/Tgstation.Server.Host/Configuration/OAuthConfiguration.cs @@ -1,5 +1,7 @@ using System; +#nullable disable + namespace Tgstation.Server.Host.Configuration { /// diff --git a/src/Tgstation.Server.Host/Configuration/OAuthConfigurationBase.cs b/src/Tgstation.Server.Host/Configuration/OAuthConfigurationBase.cs index d2d7668072..ab77c0fcbc 100644 --- a/src/Tgstation.Server.Host/Configuration/OAuthConfigurationBase.cs +++ b/src/Tgstation.Server.Host/Configuration/OAuthConfigurationBase.cs @@ -1,5 +1,7 @@ using System; +#nullable disable + namespace Tgstation.Server.Host.Configuration { /// diff --git a/src/Tgstation.Server.Host/Configuration/SecurityConfiguration.cs b/src/Tgstation.Server.Host/Configuration/SecurityConfiguration.cs index a6073538cd..f6df85278c 100644 --- a/src/Tgstation.Server.Host/Configuration/SecurityConfiguration.cs +++ b/src/Tgstation.Server.Host/Configuration/SecurityConfiguration.cs @@ -5,6 +5,8 @@ using Swashbuckle.AspNetCore.SwaggerGen; using Tgstation.Server.Api.Models; +#nullable disable + namespace Tgstation.Server.Host.Configuration { /// diff --git a/src/Tgstation.Server.Host/Configuration/SwarmConfiguration.cs b/src/Tgstation.Server.Host/Configuration/SwarmConfiguration.cs index 38c709ec39..417203bd1b 100644 --- a/src/Tgstation.Server.Host/Configuration/SwarmConfiguration.cs +++ b/src/Tgstation.Server.Host/Configuration/SwarmConfiguration.cs @@ -3,6 +3,8 @@ using Tgstation.Server.Api.Models.Internal; using YamlDotNet.Serialization; +#nullable disable + namespace Tgstation.Server.Host.Configuration { /// diff --git a/src/Tgstation.Server.Host/Configuration/UpdatesConfiguration.cs b/src/Tgstation.Server.Host/Configuration/UpdatesConfiguration.cs index 1e340c84ca..a8a4b6c932 100644 --- a/src/Tgstation.Server.Host/Configuration/UpdatesConfiguration.cs +++ b/src/Tgstation.Server.Host/Configuration/UpdatesConfiguration.cs @@ -1,5 +1,7 @@ using Tgstation.Server.Common; +#nullable disable + namespace Tgstation.Server.Host.Configuration { /// diff --git a/src/Tgstation.Server.Host/Controllers/AdministrationController.cs b/src/Tgstation.Server.Host/Controllers/AdministrationController.cs index c1da69a69d..f90a842a5c 100644 --- a/src/Tgstation.Server.Host/Controllers/AdministrationController.cs +++ b/src/Tgstation.Server.Host/Controllers/AdministrationController.cs @@ -29,6 +29,8 @@ using Tgstation.Server.Host.Transfer; using Tgstation.Server.Host.Utils; using Tgstation.Server.Host.Utils.GitHub; +#nullable disable + namespace Tgstation.Server.Host.Controllers { /// diff --git a/src/Tgstation.Server.Host/Controllers/ApiController.cs b/src/Tgstation.Server.Host/Controllers/ApiController.cs index ffa4e84960..561bde364b 100644 --- a/src/Tgstation.Server.Host/Controllers/ApiController.cs +++ b/src/Tgstation.Server.Host/Controllers/ApiController.cs @@ -28,6 +28,8 @@ using Tgstation.Server.Host.Models; using Tgstation.Server.Host.Security; using Tgstation.Server.Host.Utils; +#nullable disable + namespace Tgstation.Server.Host.Controllers { /// diff --git a/src/Tgstation.Server.Host/Controllers/ApiControllerBase.cs b/src/Tgstation.Server.Host/Controllers/ApiControllerBase.cs index 9a8b119808..8e313397f1 100644 --- a/src/Tgstation.Server.Host/Controllers/ApiControllerBase.cs +++ b/src/Tgstation.Server.Host/Controllers/ApiControllerBase.cs @@ -8,6 +8,8 @@ using Microsoft.AspNetCore.Mvc.Filters; using Microsoft.Extensions.Primitives; using Microsoft.Net.Http.Headers; +#nullable disable + namespace Tgstation.Server.Host.Controllers { /// diff --git a/src/Tgstation.Server.Host/Controllers/ApiRootController.cs b/src/Tgstation.Server.Host/Controllers/ApiRootController.cs index fbfc1d4465..5480c689d2 100644 --- a/src/Tgstation.Server.Host/Controllers/ApiRootController.cs +++ b/src/Tgstation.Server.Host/Controllers/ApiRootController.cs @@ -27,6 +27,8 @@ using Tgstation.Server.Host.Swarm; using Tgstation.Server.Host.System; using Tgstation.Server.Host.Utils; +#nullable disable + namespace Tgstation.Server.Host.Controllers { /// diff --git a/src/Tgstation.Server.Host/Controllers/BridgeController.cs b/src/Tgstation.Server.Host/Controllers/BridgeController.cs index a1acb954a9..96c44f5085 100644 --- a/src/Tgstation.Server.Host/Controllers/BridgeController.cs +++ b/src/Tgstation.Server.Host/Controllers/BridgeController.cs @@ -18,6 +18,8 @@ using Tgstation.Server.Host.Components.Interop; using Tgstation.Server.Host.Components.Interop.Bridge; using Tgstation.Server.Host.Utils; +#nullable disable + namespace Tgstation.Server.Host.Controllers { /// diff --git a/src/Tgstation.Server.Host/Controllers/ChatController.cs b/src/Tgstation.Server.Host/Controllers/ChatController.cs index 967971eb24..551d03d943 100644 --- a/src/Tgstation.Server.Host/Controllers/ChatController.cs +++ b/src/Tgstation.Server.Host/Controllers/ChatController.cs @@ -27,6 +27,8 @@ using Tgstation.Server.Host.Security; using Tgstation.Server.Host.Utils; using Z.EntityFramework.Plus; +#nullable disable + namespace Tgstation.Server.Host.Controllers { /// diff --git a/src/Tgstation.Server.Host/Controllers/ComponentInterfacingController.cs b/src/Tgstation.Server.Host/Controllers/ComponentInterfacingController.cs index eef1af8b18..c830a45d17 100644 --- a/src/Tgstation.Server.Host/Controllers/ComponentInterfacingController.cs +++ b/src/Tgstation.Server.Host/Controllers/ComponentInterfacingController.cs @@ -13,6 +13,8 @@ using Tgstation.Server.Host.Database; using Tgstation.Server.Host.Security; using Tgstation.Server.Host.Utils; +#nullable disable + namespace Tgstation.Server.Host.Controllers { /// diff --git a/src/Tgstation.Server.Host/Controllers/ConfigurationController.cs b/src/Tgstation.Server.Host/Controllers/ConfigurationController.cs index 37b7e89ed1..2b95796ef7 100644 --- a/src/Tgstation.Server.Host/Controllers/ConfigurationController.cs +++ b/src/Tgstation.Server.Host/Controllers/ConfigurationController.cs @@ -19,6 +19,8 @@ using Tgstation.Server.Host.Models; using Tgstation.Server.Host.Security; using Tgstation.Server.Host.Utils; +#nullable disable + namespace Tgstation.Server.Host.Controllers { /// diff --git a/src/Tgstation.Server.Host/Controllers/ControlPanelController.cs b/src/Tgstation.Server.Host/Controllers/ControlPanelController.cs index 08d8f74dad..1d2d1274b8 100644 --- a/src/Tgstation.Server.Host/Controllers/ControlPanelController.cs +++ b/src/Tgstation.Server.Host/Controllers/ControlPanelController.cs @@ -16,6 +16,8 @@ using Microsoft.Net.Http.Headers; using Tgstation.Server.Api; using Tgstation.Server.Host.Configuration; +#nullable disable + namespace Tgstation.Server.Host.Controllers { /// diff --git a/src/Tgstation.Server.Host/Controllers/DreamDaemonController.cs b/src/Tgstation.Server.Host/Controllers/DreamDaemonController.cs index 5a3ff51f0e..2ccd942edb 100644 --- a/src/Tgstation.Server.Host/Controllers/DreamDaemonController.cs +++ b/src/Tgstation.Server.Host/Controllers/DreamDaemonController.cs @@ -25,6 +25,8 @@ using Tgstation.Server.Host.Utils; #pragma warning disable API1001 // Action method returns a success result without a corresponding ProducesResponseType. Somehow this happens ONLY IN THIS CONTROLLER??? +#nullable disable + namespace Tgstation.Server.Host.Controllers { /// diff --git a/src/Tgstation.Server.Host/Controllers/DreamMakerController.cs b/src/Tgstation.Server.Host/Controllers/DreamMakerController.cs index 714713763f..9401f646d9 100644 --- a/src/Tgstation.Server.Host/Controllers/DreamMakerController.cs +++ b/src/Tgstation.Server.Host/Controllers/DreamMakerController.cs @@ -21,6 +21,8 @@ using Tgstation.Server.Host.Models; using Tgstation.Server.Host.Security; using Tgstation.Server.Host.Utils; +#nullable disable + namespace Tgstation.Server.Host.Controllers { /// diff --git a/src/Tgstation.Server.Host/Controllers/EngineController.cs b/src/Tgstation.Server.Host/Controllers/EngineController.cs index 75c7ef289b..a65ac97455 100644 --- a/src/Tgstation.Server.Host/Controllers/EngineController.cs +++ b/src/Tgstation.Server.Host/Controllers/EngineController.cs @@ -23,6 +23,8 @@ using Tgstation.Server.Host.Security; using Tgstation.Server.Host.Transfer; using Tgstation.Server.Host.Utils; +#nullable disable + namespace Tgstation.Server.Host.Controllers { /// diff --git a/src/Tgstation.Server.Host/Controllers/InstanceController.cs b/src/Tgstation.Server.Host/Controllers/InstanceController.cs index d63396daf9..471a0fd006 100644 --- a/src/Tgstation.Server.Host/Controllers/InstanceController.cs +++ b/src/Tgstation.Server.Host/Controllers/InstanceController.cs @@ -29,6 +29,8 @@ using Tgstation.Server.Host.Security; using Tgstation.Server.Host.System; using Tgstation.Server.Host.Utils; +#nullable disable + namespace Tgstation.Server.Host.Controllers { /// diff --git a/src/Tgstation.Server.Host/Controllers/InstancePermissionSetController.cs b/src/Tgstation.Server.Host/Controllers/InstancePermissionSetController.cs index 13defd8048..d5d4a0fb79 100644 --- a/src/Tgstation.Server.Host/Controllers/InstancePermissionSetController.cs +++ b/src/Tgstation.Server.Host/Controllers/InstancePermissionSetController.cs @@ -22,6 +22,8 @@ using Tgstation.Server.Host.Utils; using Z.EntityFramework.Plus; +#nullable disable + namespace Tgstation.Server.Host.Controllers { /// diff --git a/src/Tgstation.Server.Host/Controllers/InstanceRequiredController.cs b/src/Tgstation.Server.Host/Controllers/InstanceRequiredController.cs index cdf3f0e139..6ee1fe4963 100644 --- a/src/Tgstation.Server.Host/Controllers/InstanceRequiredController.cs +++ b/src/Tgstation.Server.Host/Controllers/InstanceRequiredController.cs @@ -5,6 +5,8 @@ using Tgstation.Server.Host.Database; using Tgstation.Server.Host.Security; using Tgstation.Server.Host.Utils; +#nullable disable + namespace Tgstation.Server.Host.Controllers { /// diff --git a/src/Tgstation.Server.Host/Controllers/JobController.cs b/src/Tgstation.Server.Host/Controllers/JobController.cs index 521a560a0b..6019223426 100644 --- a/src/Tgstation.Server.Host/Controllers/JobController.cs +++ b/src/Tgstation.Server.Host/Controllers/JobController.cs @@ -19,6 +19,8 @@ using Tgstation.Server.Host.Models; using Tgstation.Server.Host.Security; using Tgstation.Server.Host.Utils; +#nullable disable + namespace Tgstation.Server.Host.Controllers { /// diff --git a/src/Tgstation.Server.Host/Controllers/RepositoryController.cs b/src/Tgstation.Server.Host/Controllers/RepositoryController.cs index 6bc447a044..dbf80a4171 100644 --- a/src/Tgstation.Server.Host/Controllers/RepositoryController.cs +++ b/src/Tgstation.Server.Host/Controllers/RepositoryController.cs @@ -24,6 +24,8 @@ using Tgstation.Server.Host.Models; using Tgstation.Server.Host.Security; using Tgstation.Server.Host.Utils; +#nullable disable + namespace Tgstation.Server.Host.Controllers { /// diff --git a/src/Tgstation.Server.Host/Controllers/Results/LimitedStreamResult.cs b/src/Tgstation.Server.Host/Controllers/Results/LimitedStreamResult.cs index 998f5779c5..10b0e08909 100644 --- a/src/Tgstation.Server.Host/Controllers/Results/LimitedStreamResult.cs +++ b/src/Tgstation.Server.Host/Controllers/Results/LimitedStreamResult.cs @@ -10,6 +10,8 @@ using Microsoft.Extensions.DependencyInjection; using Tgstation.Server.Host.IO; +#nullable disable + namespace Tgstation.Server.Host.Controllers.Results { /// diff --git a/src/Tgstation.Server.Host/Controllers/Results/LimitedStreamResultExecutor.cs b/src/Tgstation.Server.Host/Controllers/Results/LimitedStreamResultExecutor.cs index 3178db355b..2a7bc72279 100644 --- a/src/Tgstation.Server.Host/Controllers/Results/LimitedStreamResultExecutor.cs +++ b/src/Tgstation.Server.Host/Controllers/Results/LimitedStreamResultExecutor.cs @@ -7,6 +7,8 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Infrastructure; using Microsoft.Extensions.Logging; +#nullable disable + namespace Tgstation.Server.Host.Controllers.Results { /// diff --git a/src/Tgstation.Server.Host/Controllers/Results/PaginatableResult.cs b/src/Tgstation.Server.Host/Controllers/Results/PaginatableResult.cs index b936d0f3e6..7be3c27aa1 100644 --- a/src/Tgstation.Server.Host/Controllers/Results/PaginatableResult.cs +++ b/src/Tgstation.Server.Host/Controllers/Results/PaginatableResult.cs @@ -3,6 +3,8 @@ using System.Linq; using Microsoft.AspNetCore.Mvc; +#nullable disable + namespace Tgstation.Server.Host.Controllers.Results { /// diff --git a/src/Tgstation.Server.Host/Controllers/RootController.cs b/src/Tgstation.Server.Host/Controllers/RootController.cs index 850785d612..c063984cc1 100644 --- a/src/Tgstation.Server.Host/Controllers/RootController.cs +++ b/src/Tgstation.Server.Host/Controllers/RootController.cs @@ -9,6 +9,8 @@ using Tgstation.Server.Host.Configuration; using Tgstation.Server.Host.System; using Tgstation.Server.Host.Utils; +#nullable disable + namespace Tgstation.Server.Host.Controllers { /// diff --git a/src/Tgstation.Server.Host/Controllers/SwarmController.cs b/src/Tgstation.Server.Host/Controllers/SwarmController.cs index 2512eda8dd..c56cfaa5c8 100644 --- a/src/Tgstation.Server.Host/Controllers/SwarmController.cs +++ b/src/Tgstation.Server.Host/Controllers/SwarmController.cs @@ -19,6 +19,8 @@ using Tgstation.Server.Host.System; using Tgstation.Server.Host.Transfer; using Tgstation.Server.Host.Utils; +#nullable disable + namespace Tgstation.Server.Host.Controllers { /// diff --git a/src/Tgstation.Server.Host/Controllers/TransferController.cs b/src/Tgstation.Server.Host/Controllers/TransferController.cs index 8a0a2ebcd3..07feea08a0 100644 --- a/src/Tgstation.Server.Host/Controllers/TransferController.cs +++ b/src/Tgstation.Server.Host/Controllers/TransferController.cs @@ -16,6 +16,8 @@ using Tgstation.Server.Host.Security; using Tgstation.Server.Host.Transfer; using Tgstation.Server.Host.Utils; +#nullable disable + namespace Tgstation.Server.Host.Controllers { /// diff --git a/src/Tgstation.Server.Host/Controllers/UserController.cs b/src/Tgstation.Server.Host/Controllers/UserController.cs index 08c61e05fe..8eed28d3f5 100644 --- a/src/Tgstation.Server.Host/Controllers/UserController.cs +++ b/src/Tgstation.Server.Host/Controllers/UserController.cs @@ -22,6 +22,8 @@ using Tgstation.Server.Host.Models; using Tgstation.Server.Host.Security; using Tgstation.Server.Host.Utils; +#nullable disable + namespace Tgstation.Server.Host.Controllers { /// diff --git a/src/Tgstation.Server.Host/Controllers/UserGroupController.cs b/src/Tgstation.Server.Host/Controllers/UserGroupController.cs index 3f2c5ea3a2..d50bc8e9c5 100644 --- a/src/Tgstation.Server.Host/Controllers/UserGroupController.cs +++ b/src/Tgstation.Server.Host/Controllers/UserGroupController.cs @@ -23,6 +23,8 @@ using Tgstation.Server.Host.Utils; using Z.EntityFramework.Plus; +#nullable disable + namespace Tgstation.Server.Host.Controllers { /// diff --git a/src/Tgstation.Server.Host/Core/Application.cs b/src/Tgstation.Server.Host/Core/Application.cs index 3ce52f39be..404655f379 100644 --- a/src/Tgstation.Server.Host/Core/Application.cs +++ b/src/Tgstation.Server.Host/Core/Application.cs @@ -63,6 +63,8 @@ using Tgstation.Server.Host.System; using Tgstation.Server.Host.Transfer; using Tgstation.Server.Host.Utils; +#nullable disable + namespace Tgstation.Server.Host.Core { /// diff --git a/src/Tgstation.Server.Host/Core/CommandPipeManager.cs b/src/Tgstation.Server.Host/Core/CommandPipeManager.cs index cd06a7a073..798b7db57c 100644 --- a/src/Tgstation.Server.Host/Core/CommandPipeManager.cs +++ b/src/Tgstation.Server.Host/Core/CommandPipeManager.cs @@ -13,6 +13,8 @@ using Tgstation.Server.Host.Common; using Tgstation.Server.Host.Components; using Tgstation.Server.Host.Configuration; +#nullable disable + namespace Tgstation.Server.Host.Core { /// diff --git a/src/Tgstation.Server.Host/Core/IRestartHandler.cs b/src/Tgstation.Server.Host/Core/IRestartHandler.cs index e1c8a771ef..4db9ad18c3 100644 --- a/src/Tgstation.Server.Host/Core/IRestartHandler.cs +++ b/src/Tgstation.Server.Host/Core/IRestartHandler.cs @@ -2,6 +2,8 @@ using System.Threading; using System.Threading.Tasks; +#nullable disable + namespace Tgstation.Server.Host.Core { /// diff --git a/src/Tgstation.Server.Host/Core/IRestartRegistration.cs b/src/Tgstation.Server.Host/Core/IRestartRegistration.cs index 586d73f004..ee2ddc7ddf 100644 --- a/src/Tgstation.Server.Host/Core/IRestartRegistration.cs +++ b/src/Tgstation.Server.Host/Core/IRestartRegistration.cs @@ -1,5 +1,7 @@ using System; +#nullable disable + namespace Tgstation.Server.Host.Core { /// diff --git a/src/Tgstation.Server.Host/Core/IServerControl.cs b/src/Tgstation.Server.Host/Core/IServerControl.cs index d864080db6..8eca773ecb 100644 --- a/src/Tgstation.Server.Host/Core/IServerControl.cs +++ b/src/Tgstation.Server.Host/Core/IServerControl.cs @@ -1,6 +1,8 @@ using System; using System.Threading.Tasks; +#nullable disable + namespace Tgstation.Server.Host.Core { /// diff --git a/src/Tgstation.Server.Host/Core/IServerUpdateExecutor.cs b/src/Tgstation.Server.Host/Core/IServerUpdateExecutor.cs index c2bf6f2090..9a1ea2d011 100644 --- a/src/Tgstation.Server.Host/Core/IServerUpdateExecutor.cs +++ b/src/Tgstation.Server.Host/Core/IServerUpdateExecutor.cs @@ -1,6 +1,8 @@ using System.Threading; using System.Threading.Tasks; +#nullable disable + namespace Tgstation.Server.Host.Core { /// diff --git a/src/Tgstation.Server.Host/Core/IServerUpdateInitiator.cs b/src/Tgstation.Server.Host/Core/IServerUpdateInitiator.cs index 8b290bdcd2..f9af6f34de 100644 --- a/src/Tgstation.Server.Host/Core/IServerUpdateInitiator.cs +++ b/src/Tgstation.Server.Host/Core/IServerUpdateInitiator.cs @@ -4,6 +4,8 @@ using System.Threading.Tasks; using Tgstation.Server.Host.IO; +#nullable disable + namespace Tgstation.Server.Host.Core { /// diff --git a/src/Tgstation.Server.Host/Core/IServerUpdater.cs b/src/Tgstation.Server.Host/Core/IServerUpdater.cs index 6485ed4713..de0e38b67d 100644 --- a/src/Tgstation.Server.Host/Core/IServerUpdater.cs +++ b/src/Tgstation.Server.Host/Core/IServerUpdater.cs @@ -5,6 +5,8 @@ using System.Threading.Tasks; using Tgstation.Server.Host.IO; using Tgstation.Server.Host.Swarm; +#nullable disable + namespace Tgstation.Server.Host.Core { /// diff --git a/src/Tgstation.Server.Host/Core/RestartRegistration.cs b/src/Tgstation.Server.Host/Core/RestartRegistration.cs index 025c274e07..d685fe590b 100644 --- a/src/Tgstation.Server.Host/Core/RestartRegistration.cs +++ b/src/Tgstation.Server.Host/Core/RestartRegistration.cs @@ -1,5 +1,7 @@ using System; +#nullable disable + namespace Tgstation.Server.Host.Core { /// diff --git a/src/Tgstation.Server.Host/Core/ServerPortProivder.cs b/src/Tgstation.Server.Host/Core/ServerPortProivder.cs index e4c4927c53..0b97105c43 100644 --- a/src/Tgstation.Server.Host/Core/ServerPortProivder.cs +++ b/src/Tgstation.Server.Host/Core/ServerPortProivder.cs @@ -7,6 +7,8 @@ using Microsoft.Extensions.Options; using Tgstation.Server.Host.Configuration; +#nullable disable + namespace Tgstation.Server.Host.Core { /// diff --git a/src/Tgstation.Server.Host/Core/ServerUpdateInitiator.cs b/src/Tgstation.Server.Host/Core/ServerUpdateInitiator.cs index f7fad73122..0819b4ddd5 100644 --- a/src/Tgstation.Server.Host/Core/ServerUpdateInitiator.cs +++ b/src/Tgstation.Server.Host/Core/ServerUpdateInitiator.cs @@ -5,6 +5,8 @@ using System.Threading.Tasks; using Tgstation.Server.Host.IO; using Tgstation.Server.Host.Swarm; +#nullable disable + namespace Tgstation.Server.Host.Core { /// diff --git a/src/Tgstation.Server.Host/Core/ServerUpdateOperation.cs b/src/Tgstation.Server.Host/Core/ServerUpdateOperation.cs index f14d85ec75..1e673f8239 100644 --- a/src/Tgstation.Server.Host/Core/ServerUpdateOperation.cs +++ b/src/Tgstation.Server.Host/Core/ServerUpdateOperation.cs @@ -3,6 +3,8 @@ using Tgstation.Server.Host.IO; using Tgstation.Server.Host.Swarm; +#nullable disable + namespace Tgstation.Server.Host.Core { /// diff --git a/src/Tgstation.Server.Host/Core/ServerUpdater.cs b/src/Tgstation.Server.Host/Core/ServerUpdater.cs index aacf44fd19..be3b9f033c 100644 --- a/src/Tgstation.Server.Host/Core/ServerUpdater.cs +++ b/src/Tgstation.Server.Host/Core/ServerUpdater.cs @@ -11,6 +11,8 @@ using Tgstation.Server.Host.IO; using Tgstation.Server.Host.Swarm; using Tgstation.Server.Host.Utils.GitHub; +#nullable disable + namespace Tgstation.Server.Host.Core { /// diff --git a/src/Tgstation.Server.Host/Database/DatabaseCollection.cs b/src/Tgstation.Server.Host/Database/DatabaseCollection.cs index b2dafa719d..831772335b 100644 --- a/src/Tgstation.Server.Host/Database/DatabaseCollection.cs +++ b/src/Tgstation.Server.Host/Database/DatabaseCollection.cs @@ -7,6 +7,8 @@ using System.Threading; using Microsoft.EntityFrameworkCore; +#nullable disable + namespace Tgstation.Server.Host.Database { /// diff --git a/src/Tgstation.Server.Host/Database/DatabaseConnectionFactory.cs b/src/Tgstation.Server.Host/Database/DatabaseConnectionFactory.cs index b118f346db..7cc0e2e5ed 100644 --- a/src/Tgstation.Server.Host/Database/DatabaseConnectionFactory.cs +++ b/src/Tgstation.Server.Host/Database/DatabaseConnectionFactory.cs @@ -10,6 +10,8 @@ using Npgsql; using Tgstation.Server.Host.Configuration; +#nullable disable + namespace Tgstation.Server.Host.Database { /// diff --git a/src/Tgstation.Server.Host/Database/DatabaseContext.cs b/src/Tgstation.Server.Host/Database/DatabaseContext.cs index cca6313b53..6b1ce65d23 100644 --- a/src/Tgstation.Server.Host/Database/DatabaseContext.cs +++ b/src/Tgstation.Server.Host/Database/DatabaseContext.cs @@ -15,6 +15,8 @@ using Tgstation.Server.Host.Configuration; using Tgstation.Server.Host.Database.Migrations; using Tgstation.Server.Host.Models; +#nullable disable + namespace Tgstation.Server.Host.Database { /// diff --git a/src/Tgstation.Server.Host/Database/DatabaseContextFactory.cs b/src/Tgstation.Server.Host/Database/DatabaseContextFactory.cs index b04e32858b..854bc6ea65 100644 --- a/src/Tgstation.Server.Host/Database/DatabaseContextFactory.cs +++ b/src/Tgstation.Server.Host/Database/DatabaseContextFactory.cs @@ -3,6 +3,8 @@ using System.Threading.Tasks; using Microsoft.Extensions.DependencyInjection; +#nullable disable + namespace Tgstation.Server.Host.Database { /// diff --git a/src/Tgstation.Server.Host/Database/DatabaseSeeder.cs b/src/Tgstation.Server.Host/Database/DatabaseSeeder.cs index 19efc59b47..51bf71bc6d 100644 --- a/src/Tgstation.Server.Host/Database/DatabaseSeeder.cs +++ b/src/Tgstation.Server.Host/Database/DatabaseSeeder.cs @@ -16,6 +16,8 @@ using Tgstation.Server.Host.System; using Z.EntityFramework.Plus; +#nullable disable + namespace Tgstation.Server.Host.Database { /// diff --git a/src/Tgstation.Server.Host/Database/Design/DesignTimeDbContextFactoryHelpers.cs b/src/Tgstation.Server.Host/Database/Design/DesignTimeDbContextFactoryHelpers.cs index 54d79bddc3..b8527648bb 100644 --- a/src/Tgstation.Server.Host/Database/Design/DesignTimeDbContextFactoryHelpers.cs +++ b/src/Tgstation.Server.Host/Database/Design/DesignTimeDbContextFactoryHelpers.cs @@ -3,6 +3,8 @@ using Microsoft.Extensions.Options; using Tgstation.Server.Host.Configuration; +#nullable disable + namespace Tgstation.Server.Host.Database.Design { /// diff --git a/src/Tgstation.Server.Host/Database/Design/MySqlDesignTimeDbContextFactory.cs b/src/Tgstation.Server.Host/Database/Design/MySqlDesignTimeDbContextFactory.cs index f67028efff..86efd5568f 100644 --- a/src/Tgstation.Server.Host/Database/Design/MySqlDesignTimeDbContextFactory.cs +++ b/src/Tgstation.Server.Host/Database/Design/MySqlDesignTimeDbContextFactory.cs @@ -2,6 +2,8 @@ using Tgstation.Server.Host.Configuration; +#nullable disable + namespace Tgstation.Server.Host.Database.Design { /// diff --git a/src/Tgstation.Server.Host/Database/Design/PostgresSqlDesignTimeDbContextFactory.cs b/src/Tgstation.Server.Host/Database/Design/PostgresSqlDesignTimeDbContextFactory.cs index 965eade13e..11151e5e58 100644 --- a/src/Tgstation.Server.Host/Database/Design/PostgresSqlDesignTimeDbContextFactory.cs +++ b/src/Tgstation.Server.Host/Database/Design/PostgresSqlDesignTimeDbContextFactory.cs @@ -3,6 +3,8 @@ using Tgstation.Server.Common; using Tgstation.Server.Host.Configuration; +#nullable disable + namespace Tgstation.Server.Host.Database.Design { /// diff --git a/src/Tgstation.Server.Host/Database/Design/SqlServerDesignTimeDbContextFactory.cs b/src/Tgstation.Server.Host/Database/Design/SqlServerDesignTimeDbContextFactory.cs index 9b5623725e..ac0704df2a 100644 --- a/src/Tgstation.Server.Host/Database/Design/SqlServerDesignTimeDbContextFactory.cs +++ b/src/Tgstation.Server.Host/Database/Design/SqlServerDesignTimeDbContextFactory.cs @@ -2,6 +2,8 @@ using Tgstation.Server.Host.Configuration; +#nullable disable + namespace Tgstation.Server.Host.Database.Design { /// diff --git a/src/Tgstation.Server.Host/Database/Design/SqliteDesignTimeDbContextFactory.cs b/src/Tgstation.Server.Host/Database/Design/SqliteDesignTimeDbContextFactory.cs index 924d8934f9..f4c36cb31f 100644 --- a/src/Tgstation.Server.Host/Database/Design/SqliteDesignTimeDbContextFactory.cs +++ b/src/Tgstation.Server.Host/Database/Design/SqliteDesignTimeDbContextFactory.cs @@ -2,6 +2,8 @@ using Tgstation.Server.Host.Configuration; +#nullable disable + namespace Tgstation.Server.Host.Database.Design { /// diff --git a/src/Tgstation.Server.Host/Database/IDatabaseCollection.cs b/src/Tgstation.Server.Host/Database/IDatabaseCollection.cs index a9e1fe0e03..08df6330f9 100644 --- a/src/Tgstation.Server.Host/Database/IDatabaseCollection.cs +++ b/src/Tgstation.Server.Host/Database/IDatabaseCollection.cs @@ -1,6 +1,8 @@ using System.Collections.Generic; using System.Linq; +#nullable disable + namespace Tgstation.Server.Host.Database { /// diff --git a/src/Tgstation.Server.Host/Database/IDatabaseConnectionFactory.cs b/src/Tgstation.Server.Host/Database/IDatabaseConnectionFactory.cs index abea5f1702..7ce5ba0f5f 100644 --- a/src/Tgstation.Server.Host/Database/IDatabaseConnectionFactory.cs +++ b/src/Tgstation.Server.Host/Database/IDatabaseConnectionFactory.cs @@ -2,6 +2,8 @@ using Tgstation.Server.Host.Configuration; +#nullable disable + namespace Tgstation.Server.Host.Database { /// diff --git a/src/Tgstation.Server.Host/Database/IDatabaseContext.cs b/src/Tgstation.Server.Host/Database/IDatabaseContext.cs index 00b90298c6..dc276cf371 100644 --- a/src/Tgstation.Server.Host/Database/IDatabaseContext.cs +++ b/src/Tgstation.Server.Host/Database/IDatabaseContext.cs @@ -8,6 +8,8 @@ using Microsoft.Extensions.Logging; using Tgstation.Server.Host.Configuration; using Tgstation.Server.Host.Models; +#nullable disable + namespace Tgstation.Server.Host.Database { /// diff --git a/src/Tgstation.Server.Host/Database/IDatabaseContextFactory.cs b/src/Tgstation.Server.Host/Database/IDatabaseContextFactory.cs index 4004c873c0..a51906ff40 100644 --- a/src/Tgstation.Server.Host/Database/IDatabaseContextFactory.cs +++ b/src/Tgstation.Server.Host/Database/IDatabaseContextFactory.cs @@ -1,6 +1,8 @@ using System; using System.Threading.Tasks; +#nullable disable + namespace Tgstation.Server.Host.Database { /// diff --git a/src/Tgstation.Server.Host/Database/IDatabaseSeeder.cs b/src/Tgstation.Server.Host/Database/IDatabaseSeeder.cs index e888b0093a..76c0761fb9 100644 --- a/src/Tgstation.Server.Host/Database/IDatabaseSeeder.cs +++ b/src/Tgstation.Server.Host/Database/IDatabaseSeeder.cs @@ -2,6 +2,8 @@ using System.Threading; using System.Threading.Tasks; +#nullable disable + namespace Tgstation.Server.Host.Database { /// diff --git a/src/Tgstation.Server.Host/Database/MySqlDatabaseContext.cs b/src/Tgstation.Server.Host/Database/MySqlDatabaseContext.cs index 4bdcf9a066..68112d5fb2 100644 --- a/src/Tgstation.Server.Host/Database/MySqlDatabaseContext.cs +++ b/src/Tgstation.Server.Host/Database/MySqlDatabaseContext.cs @@ -8,6 +8,8 @@ using Tgstation.Server.Host.Configuration; using Tgstation.Server.Host.Extensions; using Tgstation.Server.Host.Models; +#nullable disable + namespace Tgstation.Server.Host.Database { /// diff --git a/src/Tgstation.Server.Host/Database/PostgresSqlDatabaseContext.cs b/src/Tgstation.Server.Host/Database/PostgresSqlDatabaseContext.cs index d9157ab41a..952f515347 100644 --- a/src/Tgstation.Server.Host/Database/PostgresSqlDatabaseContext.cs +++ b/src/Tgstation.Server.Host/Database/PostgresSqlDatabaseContext.cs @@ -4,6 +4,8 @@ using Microsoft.EntityFrameworkCore; using Tgstation.Server.Host.Configuration; +#nullable disable + namespace Tgstation.Server.Host.Database { /// diff --git a/src/Tgstation.Server.Host/Database/SqlServerDatabaseContext.cs b/src/Tgstation.Server.Host/Database/SqlServerDatabaseContext.cs index 3997e0a46b..10e1f6d16f 100644 --- a/src/Tgstation.Server.Host/Database/SqlServerDatabaseContext.cs +++ b/src/Tgstation.Server.Host/Database/SqlServerDatabaseContext.cs @@ -4,6 +4,8 @@ using Microsoft.EntityFrameworkCore; using Tgstation.Server.Host.Configuration; +#nullable disable + namespace Tgstation.Server.Host.Database { /// diff --git a/src/Tgstation.Server.Host/Database/SqliteDatabaseContext.cs b/src/Tgstation.Server.Host/Database/SqliteDatabaseContext.cs index 98a58190d9..1a35d2e769 100644 --- a/src/Tgstation.Server.Host/Database/SqliteDatabaseContext.cs +++ b/src/Tgstation.Server.Host/Database/SqliteDatabaseContext.cs @@ -6,6 +6,8 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion; using Tgstation.Server.Host.Configuration; +#nullable disable + namespace Tgstation.Server.Host.Database { /// diff --git a/src/Tgstation.Server.Host/Extensions/ApplicationBuilderExtensions.cs b/src/Tgstation.Server.Host/Extensions/ApplicationBuilderExtensions.cs index 637484f5bd..1e69a743f0 100644 --- a/src/Tgstation.Server.Host/Extensions/ApplicationBuilderExtensions.cs +++ b/src/Tgstation.Server.Host/Extensions/ApplicationBuilderExtensions.cs @@ -17,6 +17,8 @@ using Tgstation.Server.Host.Configuration; using Tgstation.Server.Host.System; using Tgstation.Server.Host.Utils; +#nullable disable + namespace Tgstation.Server.Host.Extensions { /// diff --git a/src/Tgstation.Server.Host/Extensions/ChatChannelExtensions.cs b/src/Tgstation.Server.Host/Extensions/ChatChannelExtensions.cs index edfb7bb426..e4bb8948e3 100644 --- a/src/Tgstation.Server.Host/Extensions/ChatChannelExtensions.cs +++ b/src/Tgstation.Server.Host/Extensions/ChatChannelExtensions.cs @@ -4,6 +4,8 @@ using System.Linq; using Tgstation.Server.Host.Models; +#nullable disable + namespace Tgstation.Server.Host.Extensions { /// diff --git a/src/Tgstation.Server.Host/Extensions/ControllerBaseExtensions.cs b/src/Tgstation.Server.Host/Extensions/ControllerBaseExtensions.cs index 9ab3b1cc87..73f87308c7 100644 --- a/src/Tgstation.Server.Host/Extensions/ControllerBaseExtensions.cs +++ b/src/Tgstation.Server.Host/Extensions/ControllerBaseExtensions.cs @@ -6,6 +6,8 @@ using Microsoft.AspNetCore.Mvc; using Tgstation.Server.Api.Models; using Tgstation.Server.Api.Models.Response; +#nullable disable + namespace Tgstation.Server.Host.Extensions { /// diff --git a/src/Tgstation.Server.Host/Extensions/Converters/BoolConverter.cs b/src/Tgstation.Server.Host/Extensions/Converters/BoolConverter.cs index ece3052282..502980a212 100644 --- a/src/Tgstation.Server.Host/Extensions/Converters/BoolConverter.cs +++ b/src/Tgstation.Server.Host/Extensions/Converters/BoolConverter.cs @@ -2,6 +2,8 @@ using Newtonsoft.Json; +#nullable disable + namespace Tgstation.Server.Host.Extensions.Converters { /// diff --git a/src/Tgstation.Server.Host/Extensions/Converters/VersionConverter.cs b/src/Tgstation.Server.Host/Extensions/Converters/VersionConverter.cs index 0373dc5e20..e1bf992cab 100644 --- a/src/Tgstation.Server.Host/Extensions/Converters/VersionConverter.cs +++ b/src/Tgstation.Server.Host/Extensions/Converters/VersionConverter.cs @@ -8,6 +8,8 @@ using YamlDotNet.Core; using YamlDotNet.Core.Events; using YamlDotNet.Serialization; +#nullable disable + namespace Tgstation.Server.Host.Extensions.Converters { /// diff --git a/src/Tgstation.Server.Host/Extensions/DatabaseCollectionExtensions.cs b/src/Tgstation.Server.Host/Extensions/DatabaseCollectionExtensions.cs index ea50a7af17..40f005609c 100644 --- a/src/Tgstation.Server.Host/Extensions/DatabaseCollectionExtensions.cs +++ b/src/Tgstation.Server.Host/Extensions/DatabaseCollectionExtensions.cs @@ -9,6 +9,8 @@ using Microsoft.EntityFrameworkCore; using Tgstation.Server.Host.Database; using Tgstation.Server.Host.Models; +#nullable disable + namespace Tgstation.Server.Host.Extensions { /// diff --git a/src/Tgstation.Server.Host/Extensions/DateTimeOffsetExtensions.cs b/src/Tgstation.Server.Host/Extensions/DateTimeOffsetExtensions.cs index 44b0669314..1d3a864cf9 100644 --- a/src/Tgstation.Server.Host/Extensions/DateTimeOffsetExtensions.cs +++ b/src/Tgstation.Server.Host/Extensions/DateTimeOffsetExtensions.cs @@ -1,6 +1,8 @@ using System; using System.Globalization; +#nullable disable + namespace Tgstation.Server.Host.Extensions { /// diff --git a/src/Tgstation.Server.Host/Extensions/FileTransferStreamHandlerExtensions.cs b/src/Tgstation.Server.Host/Extensions/FileTransferStreamHandlerExtensions.cs index a7e84abac1..632bd0bd72 100644 --- a/src/Tgstation.Server.Host/Extensions/FileTransferStreamHandlerExtensions.cs +++ b/src/Tgstation.Server.Host/Extensions/FileTransferStreamHandlerExtensions.cs @@ -14,6 +14,8 @@ using Tgstation.Server.Api.Models.Response; using Tgstation.Server.Host.Controllers.Results; using Tgstation.Server.Host.Transfer; +#nullable disable + namespace Tgstation.Server.Host.Extensions { /// diff --git a/src/Tgstation.Server.Host/Extensions/GeneralConfigurationExtensions.cs b/src/Tgstation.Server.Host/Extensions/GeneralConfigurationExtensions.cs index 0a2a5fc8d8..5214ed0085 100644 --- a/src/Tgstation.Server.Host/Extensions/GeneralConfigurationExtensions.cs +++ b/src/Tgstation.Server.Host/Extensions/GeneralConfigurationExtensions.cs @@ -2,6 +2,8 @@ using Tgstation.Server.Host.Configuration; +#nullable disable + namespace Tgstation.Server.Host.Extensions { /// diff --git a/src/Tgstation.Server.Host/Extensions/HostBuilderExtensions.cs b/src/Tgstation.Server.Host/Extensions/HostBuilderExtensions.cs index 6bfc4cb528..160293e744 100644 --- a/src/Tgstation.Server.Host/Extensions/HostBuilderExtensions.cs +++ b/src/Tgstation.Server.Host/Extensions/HostBuilderExtensions.cs @@ -6,6 +6,8 @@ using Tgstation.Server.Host.IO; using Tgstation.Server.Host.Setup; using Tgstation.Server.Host.System; +#nullable disable + namespace Tgstation.Server.Host.Extensions { /// diff --git a/src/Tgstation.Server.Host/Extensions/ModelBuilderExtensions.cs b/src/Tgstation.Server.Host/Extensions/ModelBuilderExtensions.cs index f503f2c717..8ecf17c600 100644 --- a/src/Tgstation.Server.Host/Extensions/ModelBuilderExtensions.cs +++ b/src/Tgstation.Server.Host/Extensions/ModelBuilderExtensions.cs @@ -7,6 +7,8 @@ using Microsoft.EntityFrameworkCore; using Tgstation.Server.Api.Models; +#nullable disable + namespace Tgstation.Server.Host.Extensions { /// diff --git a/src/Tgstation.Server.Host/Extensions/ResultExtensions.cs b/src/Tgstation.Server.Host/Extensions/ResultExtensions.cs index 5d4370734f..4f7d3bc4a4 100644 --- a/src/Tgstation.Server.Host/Extensions/ResultExtensions.cs +++ b/src/Tgstation.Server.Host/Extensions/ResultExtensions.cs @@ -7,6 +7,8 @@ using Remora.Discord.API.Objects; using Remora.Rest.Results; using Remora.Results; +#nullable disable + namespace Tgstation.Server.Host.Extensions { /// diff --git a/src/Tgstation.Server.Host/Extensions/ServiceCollectionExtensions.cs b/src/Tgstation.Server.Host/Extensions/ServiceCollectionExtensions.cs index c90433f1ff..f32d2a675d 100644 --- a/src/Tgstation.Server.Host/Extensions/ServiceCollectionExtensions.cs +++ b/src/Tgstation.Server.Host/Extensions/ServiceCollectionExtensions.cs @@ -18,6 +18,8 @@ using Tgstation.Server.Host.Utils; using Tgstation.Server.Host.Utils.GitHub; using Tgstation.Server.Host.Utils.SignalR; +#nullable disable + namespace Tgstation.Server.Host.Extensions { /// diff --git a/src/Tgstation.Server.Host/Extensions/SocketExtensions.cs b/src/Tgstation.Server.Host/Extensions/SocketExtensions.cs index 6c1a695025..1c74a95a50 100644 --- a/src/Tgstation.Server.Host/Extensions/SocketExtensions.cs +++ b/src/Tgstation.Server.Host/Extensions/SocketExtensions.cs @@ -4,6 +4,8 @@ using System.Net.Sockets; using Tgstation.Server.Host.System; +#nullable disable + namespace Tgstation.Server.Host.Extensions { /// diff --git a/src/Tgstation.Server.Host/Extensions/TaskExtensions.cs b/src/Tgstation.Server.Host/Extensions/TaskExtensions.cs index 55b6701dbb..b2e5eaaf9e 100644 --- a/src/Tgstation.Server.Host/Extensions/TaskExtensions.cs +++ b/src/Tgstation.Server.Host/Extensions/TaskExtensions.cs @@ -1,5 +1,7 @@ using System.Threading.Tasks; +#nullable disable + namespace Tgstation.Server.Host.Extensions { /// diff --git a/src/Tgstation.Server.Host/Extensions/WebHostBuilderExtensions.cs b/src/Tgstation.Server.Host/Extensions/WebHostBuilderExtensions.cs index e6815cd7a0..c2f430e172 100644 --- a/src/Tgstation.Server.Host/Extensions/WebHostBuilderExtensions.cs +++ b/src/Tgstation.Server.Host/Extensions/WebHostBuilderExtensions.cs @@ -13,6 +13,8 @@ using Tgstation.Server.Host.Security; using Tgstation.Server.Host.Setup; using Tgstation.Server.Host.System; +#nullable disable + namespace Tgstation.Server.Host.Extensions { /// diff --git a/src/Tgstation.Server.Host/IO/BufferedFileStreamProvider.cs b/src/Tgstation.Server.Host/IO/BufferedFileStreamProvider.cs index c324869860..e4a8fcd139 100644 --- a/src/Tgstation.Server.Host/IO/BufferedFileStreamProvider.cs +++ b/src/Tgstation.Server.Host/IO/BufferedFileStreamProvider.cs @@ -5,6 +5,8 @@ using System.Threading.Tasks; using Tgstation.Server.Host.Utils; +#nullable disable + namespace Tgstation.Server.Host.IO { /// diff --git a/src/Tgstation.Server.Host/IO/Console.cs b/src/Tgstation.Server.Host/IO/Console.cs index fdf06eea52..ae6efa4ed7 100644 --- a/src/Tgstation.Server.Host/IO/Console.cs +++ b/src/Tgstation.Server.Host/IO/Console.cs @@ -5,6 +5,8 @@ using System.Threading.Tasks; using Tgstation.Server.Host.System; +#nullable disable + namespace Tgstation.Server.Host.IO { /// diff --git a/src/Tgstation.Server.Host/IO/DefaultIOManager.cs b/src/Tgstation.Server.Host/IO/DefaultIOManager.cs index 4841980dd3..321271faf9 100644 --- a/src/Tgstation.Server.Host/IO/DefaultIOManager.cs +++ b/src/Tgstation.Server.Host/IO/DefaultIOManager.cs @@ -8,6 +8,8 @@ using System.Threading.Tasks; using Tgstation.Server.Host.Utils; +#nullable disable + namespace Tgstation.Server.Host.IO { /// diff --git a/src/Tgstation.Server.Host/IO/FileDownloader.cs b/src/Tgstation.Server.Host/IO/FileDownloader.cs index 1aa554e647..1b133e9647 100644 --- a/src/Tgstation.Server.Host/IO/FileDownloader.cs +++ b/src/Tgstation.Server.Host/IO/FileDownloader.cs @@ -7,6 +7,8 @@ using Microsoft.Extensions.Logging; using Tgstation.Server.Api; using Tgstation.Server.Common.Http; +#nullable disable + namespace Tgstation.Server.Host.IO { /// diff --git a/src/Tgstation.Server.Host/IO/IConsole.cs b/src/Tgstation.Server.Host/IO/IConsole.cs index 605f3e421d..cc71295c55 100644 --- a/src/Tgstation.Server.Host/IO/IConsole.cs +++ b/src/Tgstation.Server.Host/IO/IConsole.cs @@ -1,6 +1,8 @@ using System.Threading; using System.Threading.Tasks; +#nullable disable + namespace Tgstation.Server.Host.IO { /// diff --git a/src/Tgstation.Server.Host/IO/IFileDownloader.cs b/src/Tgstation.Server.Host/IO/IFileDownloader.cs index 5a2c989170..6cc9baad86 100644 --- a/src/Tgstation.Server.Host/IO/IFileDownloader.cs +++ b/src/Tgstation.Server.Host/IO/IFileDownloader.cs @@ -1,5 +1,7 @@ using System; +#nullable disable + namespace Tgstation.Server.Host.IO { /// diff --git a/src/Tgstation.Server.Host/IO/IFileStreamProvider.cs b/src/Tgstation.Server.Host/IO/IFileStreamProvider.cs index e27f779314..47a2caca10 100644 --- a/src/Tgstation.Server.Host/IO/IFileStreamProvider.cs +++ b/src/Tgstation.Server.Host/IO/IFileStreamProvider.cs @@ -3,6 +3,8 @@ using System.IO; using System.Threading; using System.Threading.Tasks; +#nullable disable + namespace Tgstation.Server.Host.IO { /// diff --git a/src/Tgstation.Server.Host/IO/IFilesystemLinkFactory.cs b/src/Tgstation.Server.Host/IO/IFilesystemLinkFactory.cs index 3cf0622801..36ea58a9df 100644 --- a/src/Tgstation.Server.Host/IO/IFilesystemLinkFactory.cs +++ b/src/Tgstation.Server.Host/IO/IFilesystemLinkFactory.cs @@ -1,6 +1,8 @@ using System.Threading; using System.Threading.Tasks; +#nullable disable + namespace Tgstation.Server.Host.IO { /// diff --git a/src/Tgstation.Server.Host/IO/IIOManager.cs b/src/Tgstation.Server.Host/IO/IIOManager.cs index 0b249b23a2..b66bd6f0fa 100644 --- a/src/Tgstation.Server.Host/IO/IIOManager.cs +++ b/src/Tgstation.Server.Host/IO/IIOManager.cs @@ -4,6 +4,8 @@ using System.IO; using System.Threading; using System.Threading.Tasks; +#nullable disable + namespace Tgstation.Server.Host.IO { /// diff --git a/src/Tgstation.Server.Host/IO/ISeekableFileStreamProvider.cs b/src/Tgstation.Server.Host/IO/ISeekableFileStreamProvider.cs index 7a6b76eb0d..f34e28745d 100644 --- a/src/Tgstation.Server.Host/IO/ISeekableFileStreamProvider.cs +++ b/src/Tgstation.Server.Host/IO/ISeekableFileStreamProvider.cs @@ -2,6 +2,8 @@ using System.Threading; using System.Threading.Tasks; +#nullable disable + namespace Tgstation.Server.Host.IO { /// diff --git a/src/Tgstation.Server.Host/IO/ISynchronousIOManager.cs b/src/Tgstation.Server.Host/IO/ISynchronousIOManager.cs index 36f90140aa..df87b894c6 100644 --- a/src/Tgstation.Server.Host/IO/ISynchronousIOManager.cs +++ b/src/Tgstation.Server.Host/IO/ISynchronousIOManager.cs @@ -2,6 +2,8 @@ using System.IO; using System.Threading; +#nullable disable + namespace Tgstation.Server.Host.IO { /// diff --git a/src/Tgstation.Server.Host/IO/PosixFilesystemLinkFactory.cs b/src/Tgstation.Server.Host/IO/PosixFilesystemLinkFactory.cs index b80af9e122..b5355d9aad 100644 --- a/src/Tgstation.Server.Host/IO/PosixFilesystemLinkFactory.cs +++ b/src/Tgstation.Server.Host/IO/PosixFilesystemLinkFactory.cs @@ -5,6 +5,8 @@ using System.Threading.Tasks; using Mono.Unix; +#nullable disable + namespace Tgstation.Server.Host.IO { /// diff --git a/src/Tgstation.Server.Host/IO/PosixPostWriteHandler.cs b/src/Tgstation.Server.Host/IO/PosixPostWriteHandler.cs index a0f4f5a4c8..ec441813b1 100644 --- a/src/Tgstation.Server.Host/IO/PosixPostWriteHandler.cs +++ b/src/Tgstation.Server.Host/IO/PosixPostWriteHandler.cs @@ -4,6 +4,8 @@ using Microsoft.Extensions.Logging; using Mono.Unix; using Mono.Unix.Native; +#nullable disable + namespace Tgstation.Server.Host.IO { /// diff --git a/src/Tgstation.Server.Host/IO/RequestFileStreamProvider.cs b/src/Tgstation.Server.Host/IO/RequestFileStreamProvider.cs index c0c100cfcf..ef4ddb0d14 100644 --- a/src/Tgstation.Server.Host/IO/RequestFileStreamProvider.cs +++ b/src/Tgstation.Server.Host/IO/RequestFileStreamProvider.cs @@ -6,6 +6,8 @@ using System.Threading.Tasks; using Tgstation.Server.Common.Http; +#nullable disable + namespace Tgstation.Server.Host.IO { /// diff --git a/src/Tgstation.Server.Host/IO/ResolvingIOManager.cs b/src/Tgstation.Server.Host/IO/ResolvingIOManager.cs index 3b86b92c36..665a5b6bc4 100644 --- a/src/Tgstation.Server.Host/IO/ResolvingIOManager.cs +++ b/src/Tgstation.Server.Host/IO/ResolvingIOManager.cs @@ -1,6 +1,8 @@ using System; using System.IO; +#nullable disable + namespace Tgstation.Server.Host.IO { /// diff --git a/src/Tgstation.Server.Host/IO/SynchronousIOManager.cs b/src/Tgstation.Server.Host/IO/SynchronousIOManager.cs index a629ddcff4..590cbfbb6f 100644 --- a/src/Tgstation.Server.Host/IO/SynchronousIOManager.cs +++ b/src/Tgstation.Server.Host/IO/SynchronousIOManager.cs @@ -6,6 +6,8 @@ using System.Linq; using System.Security.Cryptography; using System.Threading; +#nullable disable + namespace Tgstation.Server.Host.IO { /// diff --git a/src/Tgstation.Server.Host/IO/WindowsFilesystemLinkFactory.cs b/src/Tgstation.Server.Host/IO/WindowsFilesystemLinkFactory.cs index 1513f4e166..5a410ab3d7 100644 --- a/src/Tgstation.Server.Host/IO/WindowsFilesystemLinkFactory.cs +++ b/src/Tgstation.Server.Host/IO/WindowsFilesystemLinkFactory.cs @@ -6,6 +6,8 @@ using System.Threading.Tasks; using BetterWin32Errors; using Tgstation.Server.Host.System; +#nullable disable + namespace Tgstation.Server.Host.IO { /// diff --git a/src/Tgstation.Server.Host/IO/WindowsPostWriteHandler.cs b/src/Tgstation.Server.Host/IO/WindowsPostWriteHandler.cs index 2a94e42a2f..a2b6b0d4ae 100644 --- a/src/Tgstation.Server.Host/IO/WindowsPostWriteHandler.cs +++ b/src/Tgstation.Server.Host/IO/WindowsPostWriteHandler.cs @@ -1,5 +1,7 @@ using System; +#nullable disable + namespace Tgstation.Server.Host.IO { /// diff --git a/src/Tgstation.Server.Host/IServer.cs b/src/Tgstation.Server.Host/IServer.cs index e13364831f..105b14f773 100644 --- a/src/Tgstation.Server.Host/IServer.cs +++ b/src/Tgstation.Server.Host/IServer.cs @@ -1,6 +1,8 @@ using System.Threading; using System.Threading.Tasks; +#nullable disable + namespace Tgstation.Server.Host { /// diff --git a/src/Tgstation.Server.Host/IServerFactory.cs b/src/Tgstation.Server.Host/IServerFactory.cs index 46f9510523..937fee7184 100644 --- a/src/Tgstation.Server.Host/IServerFactory.cs +++ b/src/Tgstation.Server.Host/IServerFactory.cs @@ -3,6 +3,8 @@ using System.Threading.Tasks; using Tgstation.Server.Host.IO; +#nullable disable + namespace Tgstation.Server.Host { /// diff --git a/src/Tgstation.Server.Host/Jobs/IJobManager.cs b/src/Tgstation.Server.Host/Jobs/IJobManager.cs index 80ef200859..e8d0a83baf 100644 --- a/src/Tgstation.Server.Host/Jobs/IJobManager.cs +++ b/src/Tgstation.Server.Host/Jobs/IJobManager.cs @@ -4,6 +4,8 @@ using System.Threading.Tasks; using Tgstation.Server.Api.Models.Response; using Tgstation.Server.Host.Models; +#nullable disable + namespace Tgstation.Server.Host.Jobs { /// diff --git a/src/Tgstation.Server.Host/Jobs/IJobService.cs b/src/Tgstation.Server.Host/Jobs/IJobService.cs index e92ead5e6a..847adff98c 100644 --- a/src/Tgstation.Server.Host/Jobs/IJobService.cs +++ b/src/Tgstation.Server.Host/Jobs/IJobService.cs @@ -1,5 +1,7 @@ using Tgstation.Server.Host.Components; +#nullable disable + namespace Tgstation.Server.Host.Jobs { /// diff --git a/src/Tgstation.Server.Host/Jobs/JobEntrypoint.cs b/src/Tgstation.Server.Host/Jobs/JobEntrypoint.cs index 79e71b5048..1a27215306 100644 --- a/src/Tgstation.Server.Host/Jobs/JobEntrypoint.cs +++ b/src/Tgstation.Server.Host/Jobs/JobEntrypoint.cs @@ -5,6 +5,8 @@ using Tgstation.Server.Host.Components; using Tgstation.Server.Host.Database; using Tgstation.Server.Host.Models; +#nullable disable + namespace Tgstation.Server.Host.Jobs { /// diff --git a/src/Tgstation.Server.Host/Jobs/JobException.cs b/src/Tgstation.Server.Host/Jobs/JobException.cs index 0eb62f2e29..d29697252f 100644 --- a/src/Tgstation.Server.Host/Jobs/JobException.cs +++ b/src/Tgstation.Server.Host/Jobs/JobException.cs @@ -2,6 +2,8 @@ using Tgstation.Server.Api.Models; +#nullable disable + namespace Tgstation.Server.Host.Jobs { /// diff --git a/src/Tgstation.Server.Host/Jobs/JobHandler.cs b/src/Tgstation.Server.Host/Jobs/JobHandler.cs index 9d9c692c07..3a290d48ce 100644 --- a/src/Tgstation.Server.Host/Jobs/JobHandler.cs +++ b/src/Tgstation.Server.Host/Jobs/JobHandler.cs @@ -2,6 +2,8 @@ using System.Threading; using System.Threading.Tasks; +#nullable disable + namespace Tgstation.Server.Host.Jobs { /// diff --git a/src/Tgstation.Server.Host/Jobs/JobProgressReporter.cs b/src/Tgstation.Server.Host/Jobs/JobProgressReporter.cs index 4d23385e63..37b7ae03e2 100644 --- a/src/Tgstation.Server.Host/Jobs/JobProgressReporter.cs +++ b/src/Tgstation.Server.Host/Jobs/JobProgressReporter.cs @@ -4,6 +4,8 @@ using Microsoft.Extensions.Logging; using Tgstation.Server.Host.Models; +#nullable disable + namespace Tgstation.Server.Host.Jobs { /// diff --git a/src/Tgstation.Server.Host/Jobs/JobService.cs b/src/Tgstation.Server.Host/Jobs/JobService.cs index 87387c60a9..e383bf1746 100644 --- a/src/Tgstation.Server.Host/Jobs/JobService.cs +++ b/src/Tgstation.Server.Host/Jobs/JobService.cs @@ -21,6 +21,8 @@ using Tgstation.Server.Host.Models; using Tgstation.Server.Host.Utils; using Tgstation.Server.Host.Utils.SignalR; +#nullable disable + namespace Tgstation.Server.Host.Jobs { /// diff --git a/src/Tgstation.Server.Host/Jobs/JobsHub.cs b/src/Tgstation.Server.Host/Jobs/JobsHub.cs index b74e19d22b..373fcc5af7 100644 --- a/src/Tgstation.Server.Host/Jobs/JobsHub.cs +++ b/src/Tgstation.Server.Host/Jobs/JobsHub.cs @@ -7,6 +7,8 @@ using Tgstation.Server.Host.Models; using Tgstation.Server.Host.Security; using Tgstation.Server.Host.Utils.SignalR; +#nullable disable + namespace Tgstation.Server.Host.Jobs { /// diff --git a/src/Tgstation.Server.Host/Jobs/JobsHubGroupMapper.cs b/src/Tgstation.Server.Host/Jobs/JobsHubGroupMapper.cs index 2e2a5da93d..4fe5c71012 100644 --- a/src/Tgstation.Server.Host/Jobs/JobsHubGroupMapper.cs +++ b/src/Tgstation.Server.Host/Jobs/JobsHubGroupMapper.cs @@ -15,6 +15,8 @@ using Tgstation.Server.Host.Models; using Tgstation.Server.Host.Security; using Tgstation.Server.Host.Utils.SignalR; +#nullable disable + namespace Tgstation.Server.Host.Jobs { /// diff --git a/src/Tgstation.Server.Host/Models/ChatBot.cs b/src/Tgstation.Server.Host/Models/ChatBot.cs index f98f4a43c3..8b5fe59f7d 100644 --- a/src/Tgstation.Server.Host/Models/ChatBot.cs +++ b/src/Tgstation.Server.Host/Models/ChatBot.cs @@ -4,6 +4,8 @@ using System.Linq; using Tgstation.Server.Api.Models.Response; +#nullable disable + namespace Tgstation.Server.Host.Models { /// diff --git a/src/Tgstation.Server.Host/Models/ChatChannel.cs b/src/Tgstation.Server.Host/Models/ChatChannel.cs index a4cbea0952..85823089cf 100644 --- a/src/Tgstation.Server.Host/Models/ChatChannel.cs +++ b/src/Tgstation.Server.Host/Models/ChatChannel.cs @@ -4,6 +4,8 @@ using System.Globalization; using Tgstation.Server.Api.Models; using Tgstation.Server.Api.Models.Internal; +#nullable disable + namespace Tgstation.Server.Host.Models { /// diff --git a/src/Tgstation.Server.Host/Models/CompileJob.cs b/src/Tgstation.Server.Host/Models/CompileJob.cs index 59bc7c4d01..5883302c59 100644 --- a/src/Tgstation.Server.Host/Models/CompileJob.cs +++ b/src/Tgstation.Server.Host/Models/CompileJob.cs @@ -4,6 +4,8 @@ using System.ComponentModel.DataAnnotations; using Tgstation.Server.Api.Models; using Tgstation.Server.Api.Models.Response; +#nullable disable + namespace Tgstation.Server.Host.Models { /// diff --git a/src/Tgstation.Server.Host/Models/DreamDaemonSettings.cs b/src/Tgstation.Server.Host/Models/DreamDaemonSettings.cs index 5a26391015..c58642fd95 100644 --- a/src/Tgstation.Server.Host/Models/DreamDaemonSettings.cs +++ b/src/Tgstation.Server.Host/Models/DreamDaemonSettings.cs @@ -1,5 +1,7 @@ using System.ComponentModel.DataAnnotations; +#nullable disable + namespace Tgstation.Server.Host.Models { /// diff --git a/src/Tgstation.Server.Host/Models/DreamMakerSettings.cs b/src/Tgstation.Server.Host/Models/DreamMakerSettings.cs index 3a55c433d0..88bfe61344 100644 --- a/src/Tgstation.Server.Host/Models/DreamMakerSettings.cs +++ b/src/Tgstation.Server.Host/Models/DreamMakerSettings.cs @@ -2,6 +2,8 @@ using Tgstation.Server.Api.Models.Response; +#nullable disable + namespace Tgstation.Server.Host.Models { /// diff --git a/src/Tgstation.Server.Host/Models/Instance.cs b/src/Tgstation.Server.Host/Models/Instance.cs index 82cfd5c707..d098b60e70 100644 --- a/src/Tgstation.Server.Host/Models/Instance.cs +++ b/src/Tgstation.Server.Host/Models/Instance.cs @@ -2,6 +2,8 @@ using Tgstation.Server.Api.Models.Response; +#nullable disable + namespace Tgstation.Server.Host.Models { /// diff --git a/src/Tgstation.Server.Host/Models/InstancePermissionSet.cs b/src/Tgstation.Server.Host/Models/InstancePermissionSet.cs index 623e920734..01bc99ae42 100644 --- a/src/Tgstation.Server.Host/Models/InstancePermissionSet.cs +++ b/src/Tgstation.Server.Host/Models/InstancePermissionSet.cs @@ -2,6 +2,8 @@ using Tgstation.Server.Api.Models.Response; +#nullable disable + namespace Tgstation.Server.Host.Models { /// diff --git a/src/Tgstation.Server.Host/Models/Job.cs b/src/Tgstation.Server.Host/Models/Job.cs index 674330ee15..c9af1ffa50 100644 --- a/src/Tgstation.Server.Host/Models/Job.cs +++ b/src/Tgstation.Server.Host/Models/Job.cs @@ -7,6 +7,8 @@ using Tgstation.Server.Api.Models; using Tgstation.Server.Api.Models.Response; using Tgstation.Server.Api.Rights; +#nullable disable + namespace Tgstation.Server.Host.Models { /// diff --git a/src/Tgstation.Server.Host/Models/OAuthConnection.cs b/src/Tgstation.Server.Host/Models/OAuthConnection.cs index e72476c134..df9a15732e 100644 --- a/src/Tgstation.Server.Host/Models/OAuthConnection.cs +++ b/src/Tgstation.Server.Host/Models/OAuthConnection.cs @@ -1,4 +1,6 @@ -namespace Tgstation.Server.Host.Models +#nullable disable + +namespace Tgstation.Server.Host.Models { /// public sealed class OAuthConnection : Api.Models.OAuthConnection, IApiTransformable diff --git a/src/Tgstation.Server.Host/Models/PermissionSet.cs b/src/Tgstation.Server.Host/Models/PermissionSet.cs index 021a8239f2..704412c174 100644 --- a/src/Tgstation.Server.Host/Models/PermissionSet.cs +++ b/src/Tgstation.Server.Host/Models/PermissionSet.cs @@ -1,5 +1,7 @@ using System.Collections.Generic; +#nullable disable + namespace Tgstation.Server.Host.Models { /// diff --git a/src/Tgstation.Server.Host/Models/ReattachInformation.cs b/src/Tgstation.Server.Host/Models/ReattachInformation.cs index d4d1520d08..80137b5004 100644 --- a/src/Tgstation.Server.Host/Models/ReattachInformation.cs +++ b/src/Tgstation.Server.Host/Models/ReattachInformation.cs @@ -1,5 +1,7 @@ using System.ComponentModel.DataAnnotations; +#nullable disable + namespace Tgstation.Server.Host.Models { /// diff --git a/src/Tgstation.Server.Host/Models/ReattachInformationBase.cs b/src/Tgstation.Server.Host/Models/ReattachInformationBase.cs index b233f0c017..0f8106aa7b 100644 --- a/src/Tgstation.Server.Host/Models/ReattachInformationBase.cs +++ b/src/Tgstation.Server.Host/Models/ReattachInformationBase.cs @@ -4,6 +4,8 @@ using Tgstation.Server.Api.Models; using Tgstation.Server.Host.Components.Interop; using Tgstation.Server.Host.Components.Session; +#nullable disable + namespace Tgstation.Server.Host.Models { /// diff --git a/src/Tgstation.Server.Host/Models/RepositorySettings.cs b/src/Tgstation.Server.Host/Models/RepositorySettings.cs index b62f235d5e..c5e1d904c2 100644 --- a/src/Tgstation.Server.Host/Models/RepositorySettings.cs +++ b/src/Tgstation.Server.Host/Models/RepositorySettings.cs @@ -2,6 +2,8 @@ using Tgstation.Server.Api.Models.Response; +#nullable disable + namespace Tgstation.Server.Host.Models { /// diff --git a/src/Tgstation.Server.Host/Models/RevInfoTestMerge.cs b/src/Tgstation.Server.Host/Models/RevInfoTestMerge.cs index 4328910d0c..64b088343a 100644 --- a/src/Tgstation.Server.Host/Models/RevInfoTestMerge.cs +++ b/src/Tgstation.Server.Host/Models/RevInfoTestMerge.cs @@ -1,5 +1,7 @@ using System.ComponentModel.DataAnnotations; +#nullable disable + namespace Tgstation.Server.Host.Models { /// diff --git a/src/Tgstation.Server.Host/Models/RevisionInformation.cs b/src/Tgstation.Server.Host/Models/RevisionInformation.cs index 290e118ae9..8813e4c5bc 100644 --- a/src/Tgstation.Server.Host/Models/RevisionInformation.cs +++ b/src/Tgstation.Server.Host/Models/RevisionInformation.cs @@ -2,6 +2,8 @@ using System.ComponentModel.DataAnnotations; using System.Linq; +#nullable disable + namespace Tgstation.Server.Host.Models { /// diff --git a/src/Tgstation.Server.Host/Models/TestMerge.cs b/src/Tgstation.Server.Host/Models/TestMerge.cs index 43d7f35b28..3733ca62fc 100644 --- a/src/Tgstation.Server.Host/Models/TestMerge.cs +++ b/src/Tgstation.Server.Host/Models/TestMerge.cs @@ -1,6 +1,8 @@ using System.Collections.Generic; using System.ComponentModel.DataAnnotations; +#nullable disable + namespace Tgstation.Server.Host.Models { /// diff --git a/src/Tgstation.Server.Host/Models/User.cs b/src/Tgstation.Server.Host/Models/User.cs index 0d275c7d18..4c4e2c03b0 100644 --- a/src/Tgstation.Server.Host/Models/User.cs +++ b/src/Tgstation.Server.Host/Models/User.cs @@ -6,6 +6,8 @@ using System.Linq; using Tgstation.Server.Api.Models; using Tgstation.Server.Api.Models.Response; +#nullable disable + namespace Tgstation.Server.Host.Models { /// diff --git a/src/Tgstation.Server.Host/Models/UserGroup.cs b/src/Tgstation.Server.Host/Models/UserGroup.cs index 63f351c329..65c18474fa 100644 --- a/src/Tgstation.Server.Host/Models/UserGroup.cs +++ b/src/Tgstation.Server.Host/Models/UserGroup.cs @@ -5,6 +5,8 @@ using System.Linq; using Tgstation.Server.Api.Models; using Tgstation.Server.Api.Models.Response; +#nullable disable + namespace Tgstation.Server.Host.Models { /// diff --git a/src/Tgstation.Server.Host/Program.cs b/src/Tgstation.Server.Host/Program.cs index e372c0563d..fb5cf8a1c0 100644 --- a/src/Tgstation.Server.Host/Program.cs +++ b/src/Tgstation.Server.Host/Program.cs @@ -11,6 +11,8 @@ using Tgstation.Server.Host.Core; using Tgstation.Server.Host.Properties; using Tgstation.Server.Host.System; +#nullable disable + namespace Tgstation.Server.Host { /// diff --git a/src/Tgstation.Server.Host/Properties/MasterVersionsAttribute.cs b/src/Tgstation.Server.Host/Properties/MasterVersionsAttribute.cs index d6461713bb..042b679202 100644 --- a/src/Tgstation.Server.Host/Properties/MasterVersionsAttribute.cs +++ b/src/Tgstation.Server.Host/Properties/MasterVersionsAttribute.cs @@ -1,6 +1,8 @@ using System; using System.Reflection; +#nullable disable + namespace Tgstation.Server.Host.Properties { /// diff --git a/src/Tgstation.Server.Host/Security/AuthenticationContext.cs b/src/Tgstation.Server.Host/Security/AuthenticationContext.cs index 5ed4dafe3f..b8719d5cc8 100644 --- a/src/Tgstation.Server.Host/Security/AuthenticationContext.cs +++ b/src/Tgstation.Server.Host/Security/AuthenticationContext.cs @@ -4,6 +4,8 @@ using System.Linq; using Tgstation.Server.Api.Rights; using Tgstation.Server.Host.Models; +#nullable disable + namespace Tgstation.Server.Host.Security { /// diff --git a/src/Tgstation.Server.Host/Security/AuthenticationContextAuthorizationFilter.cs b/src/Tgstation.Server.Host/Security/AuthenticationContextAuthorizationFilter.cs index 562f49f443..a3191770e4 100644 --- a/src/Tgstation.Server.Host/Security/AuthenticationContextAuthorizationFilter.cs +++ b/src/Tgstation.Server.Host/Security/AuthenticationContextAuthorizationFilter.cs @@ -5,6 +5,8 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Filters; using Microsoft.Extensions.Logging; +#nullable disable + namespace Tgstation.Server.Host.Security { /// diff --git a/src/Tgstation.Server.Host/Security/AuthenticationContextClaimsTransformation.cs b/src/Tgstation.Server.Host/Security/AuthenticationContextClaimsTransformation.cs index 4f02bb0b0d..9cf5de9de7 100644 --- a/src/Tgstation.Server.Host/Security/AuthenticationContextClaimsTransformation.cs +++ b/src/Tgstation.Server.Host/Security/AuthenticationContextClaimsTransformation.cs @@ -13,6 +13,8 @@ using Tgstation.Server.Api; using Tgstation.Server.Api.Rights; using Tgstation.Server.Host.Utils; +#nullable disable + namespace Tgstation.Server.Host.Security { /// diff --git a/src/Tgstation.Server.Host/Security/AuthenticationContextFactory.cs b/src/Tgstation.Server.Host/Security/AuthenticationContextFactory.cs index f39daaa989..3be3bc8061 100644 --- a/src/Tgstation.Server.Host/Security/AuthenticationContextFactory.cs +++ b/src/Tgstation.Server.Host/Security/AuthenticationContextFactory.cs @@ -11,6 +11,8 @@ using Tgstation.Server.Host.Configuration; using Tgstation.Server.Host.Database; using Tgstation.Server.Host.Models; +#nullable disable + namespace Tgstation.Server.Host.Security { /// diff --git a/src/Tgstation.Server.Host/Security/AuthorizationContextHubFilter.cs b/src/Tgstation.Server.Host/Security/AuthorizationContextHubFilter.cs index 38360cab9b..a64f3d4cdb 100644 --- a/src/Tgstation.Server.Host/Security/AuthorizationContextHubFilter.cs +++ b/src/Tgstation.Server.Host/Security/AuthorizationContextHubFilter.cs @@ -5,6 +5,8 @@ using System.Threading.Tasks; using Microsoft.AspNetCore.SignalR; using Microsoft.Extensions.Logging; +#nullable disable + namespace Tgstation.Server.Host.Security { /// diff --git a/src/Tgstation.Server.Host/Security/CryptographySuite.cs b/src/Tgstation.Server.Host/Security/CryptographySuite.cs index d98e61c303..8d2f6eeca5 100644 --- a/src/Tgstation.Server.Host/Security/CryptographySuite.cs +++ b/src/Tgstation.Server.Host/Security/CryptographySuite.cs @@ -6,6 +6,8 @@ using Microsoft.AspNetCore.Identity; using Tgstation.Server.Host.Models; +#nullable disable + namespace Tgstation.Server.Host.Security { /// diff --git a/src/Tgstation.Server.Host/Security/IAuthenticationContext.cs b/src/Tgstation.Server.Host/Security/IAuthenticationContext.cs index 36abee2b2c..39da97b00e 100644 --- a/src/Tgstation.Server.Host/Security/IAuthenticationContext.cs +++ b/src/Tgstation.Server.Host/Security/IAuthenticationContext.cs @@ -1,6 +1,8 @@ using Tgstation.Server.Api.Rights; using Tgstation.Server.Host.Models; +#nullable disable + namespace Tgstation.Server.Host.Security { /// diff --git a/src/Tgstation.Server.Host/Security/IAuthenticationContextFactory.cs b/src/Tgstation.Server.Host/Security/IAuthenticationContextFactory.cs index cb70a50b18..945b4e09ad 100644 --- a/src/Tgstation.Server.Host/Security/IAuthenticationContextFactory.cs +++ b/src/Tgstation.Server.Host/Security/IAuthenticationContextFactory.cs @@ -2,6 +2,8 @@ using System.Threading; using System.Threading.Tasks; +#nullable disable + namespace Tgstation.Server.Host.Security { /// diff --git a/src/Tgstation.Server.Host/Security/ICryptographySuite.cs b/src/Tgstation.Server.Host/Security/ICryptographySuite.cs index 257a78f4d1..955fdac6ae 100644 --- a/src/Tgstation.Server.Host/Security/ICryptographySuite.cs +++ b/src/Tgstation.Server.Host/Security/ICryptographySuite.cs @@ -1,5 +1,7 @@ using Tgstation.Server.Host.Models; +#nullable disable + namespace Tgstation.Server.Host.Security { /// diff --git a/src/Tgstation.Server.Host/Security/IIdentityCache.cs b/src/Tgstation.Server.Host/Security/IIdentityCache.cs index 0832189f83..64fd3f39a9 100644 --- a/src/Tgstation.Server.Host/Security/IIdentityCache.cs +++ b/src/Tgstation.Server.Host/Security/IIdentityCache.cs @@ -2,6 +2,8 @@ using Tgstation.Server.Host.Models; +#nullable disable + namespace Tgstation.Server.Host.Security { /// diff --git a/src/Tgstation.Server.Host/Security/IPermissionsUpdateNotifyee.cs b/src/Tgstation.Server.Host/Security/IPermissionsUpdateNotifyee.cs index 7a95f7f076..dd313adc86 100644 --- a/src/Tgstation.Server.Host/Security/IPermissionsUpdateNotifyee.cs +++ b/src/Tgstation.Server.Host/Security/IPermissionsUpdateNotifyee.cs @@ -3,6 +3,8 @@ using System.Threading.Tasks; using Tgstation.Server.Host.Models; +#nullable disable + namespace Tgstation.Server.Host.Security { /// diff --git a/src/Tgstation.Server.Host/Security/ISystemIdentity.cs b/src/Tgstation.Server.Host/Security/ISystemIdentity.cs index bd63d784de..e865b0345b 100644 --- a/src/Tgstation.Server.Host/Security/ISystemIdentity.cs +++ b/src/Tgstation.Server.Host/Security/ISystemIdentity.cs @@ -2,6 +2,8 @@ using System.Threading; using System.Threading.Tasks; +#nullable disable + namespace Tgstation.Server.Host.Security { /// diff --git a/src/Tgstation.Server.Host/Security/ISystemIdentityFactory.cs b/src/Tgstation.Server.Host/Security/ISystemIdentityFactory.cs index 2568861e53..de6e58d431 100644 --- a/src/Tgstation.Server.Host/Security/ISystemIdentityFactory.cs +++ b/src/Tgstation.Server.Host/Security/ISystemIdentityFactory.cs @@ -3,6 +3,8 @@ using System.Threading.Tasks; using Tgstation.Server.Host.Models; +#nullable disable + namespace Tgstation.Server.Host.Security { /// diff --git a/src/Tgstation.Server.Host/Security/ITokenFactory.cs b/src/Tgstation.Server.Host/Security/ITokenFactory.cs index bf9a70fab1..107965394c 100644 --- a/src/Tgstation.Server.Host/Security/ITokenFactory.cs +++ b/src/Tgstation.Server.Host/Security/ITokenFactory.cs @@ -2,6 +2,8 @@ using Tgstation.Server.Api.Models.Response; +#nullable disable + namespace Tgstation.Server.Host.Security { /// diff --git a/src/Tgstation.Server.Host/Security/IdentityCache.cs b/src/Tgstation.Server.Host/Security/IdentityCache.cs index 0db031aba2..6c2a98b200 100644 --- a/src/Tgstation.Server.Host/Security/IdentityCache.cs +++ b/src/Tgstation.Server.Host/Security/IdentityCache.cs @@ -7,6 +7,8 @@ using Microsoft.Extensions.Logging; using Tgstation.Server.Host.Models; using Tgstation.Server.Host.Utils; +#nullable disable + namespace Tgstation.Server.Host.Security { /// diff --git a/src/Tgstation.Server.Host/Security/IdentityCacheObject.cs b/src/Tgstation.Server.Host/Security/IdentityCacheObject.cs index 7cc10664e5..d7125b877f 100644 --- a/src/Tgstation.Server.Host/Security/IdentityCacheObject.cs +++ b/src/Tgstation.Server.Host/Security/IdentityCacheObject.cs @@ -4,6 +4,8 @@ using System.Threading.Tasks; using Tgstation.Server.Host.Utils; +#nullable disable + namespace Tgstation.Server.Host.Security { /// diff --git a/src/Tgstation.Server.Host/Security/OAuth/DiscordOAuthValidator.cs b/src/Tgstation.Server.Host/Security/OAuth/DiscordOAuthValidator.cs index 3195ec9dcf..166ff85f27 100644 --- a/src/Tgstation.Server.Host/Security/OAuth/DiscordOAuthValidator.cs +++ b/src/Tgstation.Server.Host/Security/OAuth/DiscordOAuthValidator.cs @@ -6,6 +6,8 @@ using Tgstation.Server.Api.Models; using Tgstation.Server.Common.Http; using Tgstation.Server.Host.Configuration; +#nullable disable + namespace Tgstation.Server.Host.Security.OAuth { /// diff --git a/src/Tgstation.Server.Host/Security/OAuth/GenericOAuthValidator.cs b/src/Tgstation.Server.Host/Security/OAuth/GenericOAuthValidator.cs index 668a96240f..0885546d11 100644 --- a/src/Tgstation.Server.Host/Security/OAuth/GenericOAuthValidator.cs +++ b/src/Tgstation.Server.Host/Security/OAuth/GenericOAuthValidator.cs @@ -16,6 +16,8 @@ using Tgstation.Server.Api.Models; using Tgstation.Server.Common.Http; using Tgstation.Server.Host.Configuration; +#nullable disable + namespace Tgstation.Server.Host.Security.OAuth { /// diff --git a/src/Tgstation.Server.Host/Security/OAuth/GitHubOAuthValidator.cs b/src/Tgstation.Server.Host/Security/OAuth/GitHubOAuthValidator.cs index 567887b06f..d6ed38808b 100644 --- a/src/Tgstation.Server.Host/Security/OAuth/GitHubOAuthValidator.cs +++ b/src/Tgstation.Server.Host/Security/OAuth/GitHubOAuthValidator.cs @@ -10,6 +10,8 @@ using Tgstation.Server.Api.Models; using Tgstation.Server.Host.Configuration; using Tgstation.Server.Host.Utils.GitHub; +#nullable disable + namespace Tgstation.Server.Host.Security.OAuth { /// diff --git a/src/Tgstation.Server.Host/Security/OAuth/IOAuthProviders.cs b/src/Tgstation.Server.Host/Security/OAuth/IOAuthProviders.cs index c8b8a7b161..c7e9a06274 100644 --- a/src/Tgstation.Server.Host/Security/OAuth/IOAuthProviders.cs +++ b/src/Tgstation.Server.Host/Security/OAuth/IOAuthProviders.cs @@ -2,6 +2,8 @@ using Tgstation.Server.Api.Models; +#nullable disable + namespace Tgstation.Server.Host.Security.OAuth { /// diff --git a/src/Tgstation.Server.Host/Security/OAuth/IOAuthValidator.cs b/src/Tgstation.Server.Host/Security/OAuth/IOAuthValidator.cs index 7f3ca57287..402fb5efe7 100644 --- a/src/Tgstation.Server.Host/Security/OAuth/IOAuthValidator.cs +++ b/src/Tgstation.Server.Host/Security/OAuth/IOAuthValidator.cs @@ -3,6 +3,8 @@ using System.Threading.Tasks; using Tgstation.Server.Api.Models; +#nullable disable + namespace Tgstation.Server.Host.Security.OAuth { /// diff --git a/src/Tgstation.Server.Host/Security/OAuth/InvisionCommunityOAuthValidator.cs b/src/Tgstation.Server.Host/Security/OAuth/InvisionCommunityOAuthValidator.cs index a0c8cdd0e2..14382d5838 100644 --- a/src/Tgstation.Server.Host/Security/OAuth/InvisionCommunityOAuthValidator.cs +++ b/src/Tgstation.Server.Host/Security/OAuth/InvisionCommunityOAuthValidator.cs @@ -6,6 +6,8 @@ using Tgstation.Server.Api.Models; using Tgstation.Server.Common.Http; using Tgstation.Server.Host.Configuration; +#nullable disable + namespace Tgstation.Server.Host.Security.OAuth { /// diff --git a/src/Tgstation.Server.Host/Security/OAuth/KeycloakOAuthValidator.cs b/src/Tgstation.Server.Host/Security/OAuth/KeycloakOAuthValidator.cs index f4e61b4b5c..1152398d6a 100644 --- a/src/Tgstation.Server.Host/Security/OAuth/KeycloakOAuthValidator.cs +++ b/src/Tgstation.Server.Host/Security/OAuth/KeycloakOAuthValidator.cs @@ -6,6 +6,8 @@ using Tgstation.Server.Api.Models; using Tgstation.Server.Common.Http; using Tgstation.Server.Host.Configuration; +#nullable disable + namespace Tgstation.Server.Host.Security.OAuth { /// diff --git a/src/Tgstation.Server.Host/Security/OAuth/OAuthProviders.cs b/src/Tgstation.Server.Host/Security/OAuth/OAuthProviders.cs index 7a562668ee..7e0e1a308c 100644 --- a/src/Tgstation.Server.Host/Security/OAuth/OAuthProviders.cs +++ b/src/Tgstation.Server.Host/Security/OAuth/OAuthProviders.cs @@ -10,6 +10,8 @@ using Tgstation.Server.Common.Http; using Tgstation.Server.Host.Configuration; using Tgstation.Server.Host.Utils.GitHub; +#nullable disable + namespace Tgstation.Server.Host.Security.OAuth { /// diff --git a/src/Tgstation.Server.Host/Security/OAuth/OAuthTokenRequest.cs b/src/Tgstation.Server.Host/Security/OAuth/OAuthTokenRequest.cs index 9256092f10..2c7721f4af 100644 --- a/src/Tgstation.Server.Host/Security/OAuth/OAuthTokenRequest.cs +++ b/src/Tgstation.Server.Host/Security/OAuth/OAuthTokenRequest.cs @@ -2,6 +2,8 @@ using Tgstation.Server.Host.Configuration; +#nullable disable + namespace Tgstation.Server.Host.Security.OAuth { /// diff --git a/src/Tgstation.Server.Host/Security/OAuth/TGForumsOAuthValidator.cs b/src/Tgstation.Server.Host/Security/OAuth/TGForumsOAuthValidator.cs index c81a54ec73..36b213b6d9 100644 --- a/src/Tgstation.Server.Host/Security/OAuth/TGForumsOAuthValidator.cs +++ b/src/Tgstation.Server.Host/Security/OAuth/TGForumsOAuthValidator.cs @@ -6,6 +6,8 @@ using Tgstation.Server.Api.Models; using Tgstation.Server.Common.Http; using Tgstation.Server.Host.Configuration; +#nullable disable + namespace Tgstation.Server.Host.Security.OAuth { /// diff --git a/src/Tgstation.Server.Host/Security/PosixSystemIdentity.cs b/src/Tgstation.Server.Host/Security/PosixSystemIdentity.cs index 67f0e3ac83..4f978e76d1 100644 --- a/src/Tgstation.Server.Host/Security/PosixSystemIdentity.cs +++ b/src/Tgstation.Server.Host/Security/PosixSystemIdentity.cs @@ -2,6 +2,8 @@ using System.Threading; using System.Threading.Tasks; +#nullable disable + namespace Tgstation.Server.Host.Security { /// diff --git a/src/Tgstation.Server.Host/Security/PosixSystemIdentityFactory.cs b/src/Tgstation.Server.Host/Security/PosixSystemIdentityFactory.cs index e85882665b..876cca613e 100644 --- a/src/Tgstation.Server.Host/Security/PosixSystemIdentityFactory.cs +++ b/src/Tgstation.Server.Host/Security/PosixSystemIdentityFactory.cs @@ -4,6 +4,8 @@ using System.Threading.Tasks; using Tgstation.Server.Host.Models; +#nullable disable + namespace Tgstation.Server.Host.Security { /// diff --git a/src/Tgstation.Server.Host/Security/TgsAuthorizeAttribute.cs b/src/Tgstation.Server.Host/Security/TgsAuthorizeAttribute.cs index 0fc4c11c1a..a80205bb6e 100644 --- a/src/Tgstation.Server.Host/Security/TgsAuthorizeAttribute.cs +++ b/src/Tgstation.Server.Host/Security/TgsAuthorizeAttribute.cs @@ -4,6 +4,8 @@ using Microsoft.AspNetCore.Authorization; using Tgstation.Server.Api.Rights; +#nullable disable + namespace Tgstation.Server.Host.Security { /// diff --git a/src/Tgstation.Server.Host/Security/TokenFactory.cs b/src/Tgstation.Server.Host/Security/TokenFactory.cs index cc18c3298a..3a17f2ac86 100644 --- a/src/Tgstation.Server.Host/Security/TokenFactory.cs +++ b/src/Tgstation.Server.Host/Security/TokenFactory.cs @@ -12,6 +12,8 @@ using Tgstation.Server.Api.Models.Response; using Tgstation.Server.Host.Configuration; using Tgstation.Server.Host.System; +#nullable disable + namespace Tgstation.Server.Host.Security { /// diff --git a/src/Tgstation.Server.Host/Security/WindowsSystemIdentity.cs b/src/Tgstation.Server.Host/Security/WindowsSystemIdentity.cs index 28b6bbcec7..f4ac20da19 100644 --- a/src/Tgstation.Server.Host/Security/WindowsSystemIdentity.cs +++ b/src/Tgstation.Server.Host/Security/WindowsSystemIdentity.cs @@ -7,6 +7,8 @@ using System.Threading.Tasks; using Tgstation.Server.Host.IO; +#nullable disable + namespace Tgstation.Server.Host.Security { /// diff --git a/src/Tgstation.Server.Host/Security/WindowsSystemIdentityFactory.cs b/src/Tgstation.Server.Host/Security/WindowsSystemIdentityFactory.cs index b677a56413..56b0435651 100644 --- a/src/Tgstation.Server.Host/Security/WindowsSystemIdentityFactory.cs +++ b/src/Tgstation.Server.Host/Security/WindowsSystemIdentityFactory.cs @@ -12,6 +12,8 @@ using Tgstation.Server.Host.IO; using Tgstation.Server.Host.Models; using Tgstation.Server.Host.System; +#nullable disable + namespace Tgstation.Server.Host.Security { /// diff --git a/src/Tgstation.Server.Host/Server.cs b/src/Tgstation.Server.Host/Server.cs index e6ea8c04b1..b57045078d 100644 --- a/src/Tgstation.Server.Host/Server.cs +++ b/src/Tgstation.Server.Host/Server.cs @@ -14,6 +14,8 @@ using Tgstation.Server.Common.Extensions; using Tgstation.Server.Host.Configuration; using Tgstation.Server.Host.Core; +#nullable disable + namespace Tgstation.Server.Host { /// diff --git a/src/Tgstation.Server.Host/ServerFactory.cs b/src/Tgstation.Server.Host/ServerFactory.cs index a466a97fb5..4b25e07fea 100644 --- a/src/Tgstation.Server.Host/ServerFactory.cs +++ b/src/Tgstation.Server.Host/ServerFactory.cs @@ -17,6 +17,8 @@ using Tgstation.Server.Host.IO; using Tgstation.Server.Host.Setup; using Tgstation.Server.Host.System; +#nullable disable + namespace Tgstation.Server.Host { /// diff --git a/src/Tgstation.Server.Host/Setup/IPostSetupServices.cs b/src/Tgstation.Server.Host/Setup/IPostSetupServices.cs index 21264d9277..aaa785f413 100644 --- a/src/Tgstation.Server.Host/Setup/IPostSetupServices.cs +++ b/src/Tgstation.Server.Host/Setup/IPostSetupServices.cs @@ -1,6 +1,8 @@ using Tgstation.Server.Host.Configuration; using Tgstation.Server.Host.System; +#nullable disable + namespace Tgstation.Server.Host.Setup { /// diff --git a/src/Tgstation.Server.Host/Setup/IPostSetupServices{TLoggerType}.cs b/src/Tgstation.Server.Host/Setup/IPostSetupServices{TLoggerType}.cs index f36d9526e7..25024af43d 100644 --- a/src/Tgstation.Server.Host/Setup/IPostSetupServices{TLoggerType}.cs +++ b/src/Tgstation.Server.Host/Setup/IPostSetupServices{TLoggerType}.cs @@ -1,5 +1,7 @@ using Microsoft.Extensions.Logging; +#nullable disable + namespace Tgstation.Server.Host.Setup { /// diff --git a/src/Tgstation.Server.Host/Setup/PostSetupServices.cs b/src/Tgstation.Server.Host/Setup/PostSetupServices.cs index c1ace340ec..4fce4e6075 100644 --- a/src/Tgstation.Server.Host/Setup/PostSetupServices.cs +++ b/src/Tgstation.Server.Host/Setup/PostSetupServices.cs @@ -6,6 +6,8 @@ using Microsoft.Extensions.Options; using Tgstation.Server.Host.Configuration; using Tgstation.Server.Host.System; +#nullable disable + namespace Tgstation.Server.Host.Setup { /// diff --git a/src/Tgstation.Server.Host/Setup/SetupApplication.cs b/src/Tgstation.Server.Host/Setup/SetupApplication.cs index 56c590ce7d..ca4b64be58 100644 --- a/src/Tgstation.Server.Host/Setup/SetupApplication.cs +++ b/src/Tgstation.Server.Host/Setup/SetupApplication.cs @@ -12,6 +12,8 @@ using Tgstation.Server.Host.IO; using Tgstation.Server.Host.System; using Tgstation.Server.Host.Utils; +#nullable disable + namespace Tgstation.Server.Host.Setup { /// diff --git a/src/Tgstation.Server.Host/Setup/SetupWizard.cs b/src/Tgstation.Server.Host/Setup/SetupWizard.cs index b9671572b2..d4611f4465 100644 --- a/src/Tgstation.Server.Host/Setup/SetupWizard.cs +++ b/src/Tgstation.Server.Host/Setup/SetupWizard.cs @@ -31,6 +31,8 @@ using Tgstation.Server.Host.Utils; using YamlDotNet.Serialization; +#nullable disable + namespace Tgstation.Server.Host.Setup { /// diff --git a/src/Tgstation.Server.Host/Swarm/ISwarmOperations.cs b/src/Tgstation.Server.Host/Swarm/ISwarmOperations.cs index dd9c01b783..8d3e198006 100644 --- a/src/Tgstation.Server.Host/Swarm/ISwarmOperations.cs +++ b/src/Tgstation.Server.Host/Swarm/ISwarmOperations.cs @@ -5,6 +5,8 @@ using System.Threading.Tasks; using Tgstation.Server.Api.Models.Response; +#nullable disable + namespace Tgstation.Server.Host.Swarm { /// diff --git a/src/Tgstation.Server.Host/Swarm/ISwarmService.cs b/src/Tgstation.Server.Host/Swarm/ISwarmService.cs index 9b86389540..c9e29bd052 100644 --- a/src/Tgstation.Server.Host/Swarm/ISwarmService.cs +++ b/src/Tgstation.Server.Host/Swarm/ISwarmService.cs @@ -6,6 +6,8 @@ using System.Threading.Tasks; using Tgstation.Server.Api.Models.Response; using Tgstation.Server.Host.IO; +#nullable disable + namespace Tgstation.Server.Host.Swarm { /// diff --git a/src/Tgstation.Server.Host/Swarm/ISwarmServiceController.cs b/src/Tgstation.Server.Host/Swarm/ISwarmServiceController.cs index 34babd945b..9f875ce05b 100644 --- a/src/Tgstation.Server.Host/Swarm/ISwarmServiceController.cs +++ b/src/Tgstation.Server.Host/Swarm/ISwarmServiceController.cs @@ -1,6 +1,8 @@ using System.Threading; using System.Threading.Tasks; +#nullable disable + namespace Tgstation.Server.Host.Swarm { /// diff --git a/src/Tgstation.Server.Host/Swarm/ISwarmUpdateAborter.cs b/src/Tgstation.Server.Host/Swarm/ISwarmUpdateAborter.cs index 8d69505f27..6cd79b9956 100644 --- a/src/Tgstation.Server.Host/Swarm/ISwarmUpdateAborter.cs +++ b/src/Tgstation.Server.Host/Swarm/ISwarmUpdateAborter.cs @@ -1,5 +1,7 @@ using System.Threading.Tasks; +#nullable disable + namespace Tgstation.Server.Host.Swarm { /// diff --git a/src/Tgstation.Server.Host/Swarm/SwarmConstants.cs b/src/Tgstation.Server.Host/Swarm/SwarmConstants.cs index 988c60243e..ec61a982bb 100644 --- a/src/Tgstation.Server.Host/Swarm/SwarmConstants.cs +++ b/src/Tgstation.Server.Host/Swarm/SwarmConstants.cs @@ -4,6 +4,8 @@ using Newtonsoft.Json.Serialization; using Tgstation.Server.Api; using Tgstation.Server.Host.Extensions.Converters; +#nullable disable + namespace Tgstation.Server.Host.Swarm { /// diff --git a/src/Tgstation.Server.Host/Swarm/SwarmRegistrationRequest.cs b/src/Tgstation.Server.Host/Swarm/SwarmRegistrationRequest.cs index cad1cebe27..93f5ed92db 100644 --- a/src/Tgstation.Server.Host/Swarm/SwarmRegistrationRequest.cs +++ b/src/Tgstation.Server.Host/Swarm/SwarmRegistrationRequest.cs @@ -3,6 +3,8 @@ using System.ComponentModel.DataAnnotations; using Tgstation.Server.Api.Models.Internal; +#nullable disable + namespace Tgstation.Server.Host.Swarm { /// diff --git a/src/Tgstation.Server.Host/Swarm/SwarmServersUpdateRequest.cs b/src/Tgstation.Server.Host/Swarm/SwarmServersUpdateRequest.cs index 61b60cc024..2b3cdeaa23 100644 --- a/src/Tgstation.Server.Host/Swarm/SwarmServersUpdateRequest.cs +++ b/src/Tgstation.Server.Host/Swarm/SwarmServersUpdateRequest.cs @@ -3,6 +3,8 @@ using System.ComponentModel.DataAnnotations; using Tgstation.Server.Api.Models.Response; +#nullable disable + namespace Tgstation.Server.Host.Swarm { /// diff --git a/src/Tgstation.Server.Host/Swarm/SwarmService.cs b/src/Tgstation.Server.Host/Swarm/SwarmService.cs index dc4dfa2251..d081050754 100644 --- a/src/Tgstation.Server.Host/Swarm/SwarmService.cs +++ b/src/Tgstation.Server.Host/Swarm/SwarmService.cs @@ -26,6 +26,8 @@ using Tgstation.Server.Host.System; using Tgstation.Server.Host.Transfer; using Tgstation.Server.Host.Utils; +#nullable disable + namespace Tgstation.Server.Host.Swarm { /// diff --git a/src/Tgstation.Server.Host/Swarm/SwarmUpdateOperation.cs b/src/Tgstation.Server.Host/Swarm/SwarmUpdateOperation.cs index 01b9f28d18..3ebe8576e2 100644 --- a/src/Tgstation.Server.Host/Swarm/SwarmUpdateOperation.cs +++ b/src/Tgstation.Server.Host/Swarm/SwarmUpdateOperation.cs @@ -6,6 +6,8 @@ using System.Threading.Tasks; using Tgstation.Server.Api.Models.Internal; using Tgstation.Server.Api.Models.Response; +#nullable disable + namespace Tgstation.Server.Host.Swarm { /// diff --git a/src/Tgstation.Server.Host/Swarm/SwarmUpdateRequest.cs b/src/Tgstation.Server.Host/Swarm/SwarmUpdateRequest.cs index 1da49cea3c..a0d7b0fe5c 100644 --- a/src/Tgstation.Server.Host/Swarm/SwarmUpdateRequest.cs +++ b/src/Tgstation.Server.Host/Swarm/SwarmUpdateRequest.cs @@ -4,6 +4,8 @@ using System.ComponentModel.DataAnnotations; using Tgstation.Server.Api.Models.Response; +#nullable disable + namespace Tgstation.Server.Host.Swarm { /// diff --git a/src/Tgstation.Server.Host/System/AssemblyInformationProvider.cs b/src/Tgstation.Server.Host/System/AssemblyInformationProvider.cs index 88d1a3a627..4d072772e5 100644 --- a/src/Tgstation.Server.Host/System/AssemblyInformationProvider.cs +++ b/src/Tgstation.Server.Host/System/AssemblyInformationProvider.cs @@ -5,6 +5,8 @@ using System.Reflection; using Tgstation.Server.Common; using Tgstation.Server.Common.Extensions; +#nullable disable + namespace Tgstation.Server.Host.System { /// diff --git a/src/Tgstation.Server.Host/System/IAssemblyInformationProvider.cs b/src/Tgstation.Server.Host/System/IAssemblyInformationProvider.cs index 184dd9f60a..7b092f8aea 100644 --- a/src/Tgstation.Server.Host/System/IAssemblyInformationProvider.cs +++ b/src/Tgstation.Server.Host/System/IAssemblyInformationProvider.cs @@ -2,6 +2,8 @@ using System.Net.Http.Headers; using System.Reflection; +#nullable disable + namespace Tgstation.Server.Host.System { /// diff --git a/src/Tgstation.Server.Host/System/IPlatformIdentifier.cs b/src/Tgstation.Server.Host/System/IPlatformIdentifier.cs index 805b93b97d..104bb0dc32 100644 --- a/src/Tgstation.Server.Host/System/IPlatformIdentifier.cs +++ b/src/Tgstation.Server.Host/System/IPlatformIdentifier.cs @@ -1,5 +1,7 @@ using System.Runtime.Versioning; +#nullable disable + namespace Tgstation.Server.Host.System { /// diff --git a/src/Tgstation.Server.Host/System/IProcess.cs b/src/Tgstation.Server.Host/System/IProcess.cs index 8df102b2b2..7b033f3e9d 100644 --- a/src/Tgstation.Server.Host/System/IProcess.cs +++ b/src/Tgstation.Server.Host/System/IProcess.cs @@ -2,6 +2,8 @@ using System.Threading; using System.Threading.Tasks; +#nullable disable + namespace Tgstation.Server.Host.System { /// diff --git a/src/Tgstation.Server.Host/System/IProcessBase.cs b/src/Tgstation.Server.Host/System/IProcessBase.cs index 8fc0bd4484..91feee546e 100644 --- a/src/Tgstation.Server.Host/System/IProcessBase.cs +++ b/src/Tgstation.Server.Host/System/IProcessBase.cs @@ -1,6 +1,8 @@ using System.Threading; using System.Threading.Tasks; +#nullable disable + namespace Tgstation.Server.Host.System { /// diff --git a/src/Tgstation.Server.Host/System/IProcessExecutor.cs b/src/Tgstation.Server.Host/System/IProcessExecutor.cs index 81593dbe37..a0418aea0d 100644 --- a/src/Tgstation.Server.Host/System/IProcessExecutor.cs +++ b/src/Tgstation.Server.Host/System/IProcessExecutor.cs @@ -1,4 +1,6 @@ -namespace Tgstation.Server.Host.System +#nullable disable + +namespace Tgstation.Server.Host.System { /// /// For launching '. diff --git a/src/Tgstation.Server.Host/System/IProcessFeatures.cs b/src/Tgstation.Server.Host/System/IProcessFeatures.cs index abfaca6b7b..8d4a9258c6 100644 --- a/src/Tgstation.Server.Host/System/IProcessFeatures.cs +++ b/src/Tgstation.Server.Host/System/IProcessFeatures.cs @@ -1,6 +1,8 @@ using System.Threading; using System.Threading.Tasks; +#nullable disable + namespace Tgstation.Server.Host.System { /// diff --git a/src/Tgstation.Server.Host/System/NativeMethods.cs b/src/Tgstation.Server.Host/System/NativeMethods.cs index dc5046d133..11f465fb13 100644 --- a/src/Tgstation.Server.Host/System/NativeMethods.cs +++ b/src/Tgstation.Server.Host/System/NativeMethods.cs @@ -2,6 +2,8 @@ using System.Runtime.InteropServices; using System.Text; +#nullable disable + namespace Tgstation.Server.Host.System { /// diff --git a/src/Tgstation.Server.Host/System/PlatformIdentifier.cs b/src/Tgstation.Server.Host/System/PlatformIdentifier.cs index 22931b97ce..6391932f1c 100644 --- a/src/Tgstation.Server.Host/System/PlatformIdentifier.cs +++ b/src/Tgstation.Server.Host/System/PlatformIdentifier.cs @@ -1,6 +1,8 @@ using System.Runtime.InteropServices; using System.Runtime.Versioning; +#nullable disable + namespace Tgstation.Server.Host.System { /// diff --git a/src/Tgstation.Server.Host/System/PosixProcessFeatures.cs b/src/Tgstation.Server.Host/System/PosixProcessFeatures.cs index b45c845fa4..c1999c4545 100644 --- a/src/Tgstation.Server.Host/System/PosixProcessFeatures.cs +++ b/src/Tgstation.Server.Host/System/PosixProcessFeatures.cs @@ -10,6 +10,8 @@ using Tgstation.Server.Api.Models; using Tgstation.Server.Host.IO; using Tgstation.Server.Host.Jobs; +#nullable disable + namespace Tgstation.Server.Host.System { /// diff --git a/src/Tgstation.Server.Host/System/PosixSignalHandler.cs b/src/Tgstation.Server.Host/System/PosixSignalHandler.cs index 693324d679..5342f68d39 100644 --- a/src/Tgstation.Server.Host/System/PosixSignalHandler.cs +++ b/src/Tgstation.Server.Host/System/PosixSignalHandler.cs @@ -10,6 +10,8 @@ using Mono.Unix.Native; using Tgstation.Server.Host.Core; using Tgstation.Server.Host.Utils; +#nullable disable + namespace Tgstation.Server.Host.System { /// diff --git a/src/Tgstation.Server.Host/System/Process.cs b/src/Tgstation.Server.Host/System/Process.cs index 003f3b12e4..a505cee878 100644 --- a/src/Tgstation.Server.Host/System/Process.cs +++ b/src/Tgstation.Server.Host/System/Process.cs @@ -9,6 +9,8 @@ using Microsoft.Win32.SafeHandles; using Tgstation.Server.Host.IO; using Tgstation.Server.Host.Utils; +#nullable disable + namespace Tgstation.Server.Host.System { /// diff --git a/src/Tgstation.Server.Host/System/ProcessExecutor.cs b/src/Tgstation.Server.Host/System/ProcessExecutor.cs index 7a00b31d10..94e4af31b7 100644 --- a/src/Tgstation.Server.Host/System/ProcessExecutor.cs +++ b/src/Tgstation.Server.Host/System/ProcessExecutor.cs @@ -9,6 +9,8 @@ using Microsoft.Extensions.Logging; using Tgstation.Server.Host.IO; using Tgstation.Server.Host.Utils; +#nullable disable + namespace Tgstation.Server.Host.System { /// diff --git a/src/Tgstation.Server.Host/System/ProgramShutdownTokenSource.cs b/src/Tgstation.Server.Host/System/ProgramShutdownTokenSource.cs index fb68be4ac9..0f0dfb13b1 100644 --- a/src/Tgstation.Server.Host/System/ProgramShutdownTokenSource.cs +++ b/src/Tgstation.Server.Host/System/ProgramShutdownTokenSource.cs @@ -1,6 +1,8 @@ using System; using System.Threading; +#nullable disable + namespace Tgstation.Server.Host.System { /// diff --git a/src/Tgstation.Server.Host/System/SystemDManager.cs b/src/Tgstation.Server.Host/System/SystemDManager.cs index 28fb4e4d25..4e3b86972c 100644 --- a/src/Tgstation.Server.Host/System/SystemDManager.cs +++ b/src/Tgstation.Server.Host/System/SystemDManager.cs @@ -11,6 +11,8 @@ using Mono.Unix; using Tgstation.Server.Host.Components; using Tgstation.Server.Host.Core; +#nullable disable + namespace Tgstation.Server.Host.System { /// diff --git a/src/Tgstation.Server.Host/System/WindowsFirewallHelper.cs b/src/Tgstation.Server.Host/System/WindowsFirewallHelper.cs index 74964a5569..7a5e82742f 100644 --- a/src/Tgstation.Server.Host/System/WindowsFirewallHelper.cs +++ b/src/Tgstation.Server.Host/System/WindowsFirewallHelper.cs @@ -4,6 +4,8 @@ using System.Threading.Tasks; using Microsoft.Extensions.Logging; +#nullable disable + namespace Tgstation.Server.Host.System { /// diff --git a/src/Tgstation.Server.Host/System/WindowsNetworkPromptReaper.cs b/src/Tgstation.Server.Host/System/WindowsNetworkPromptReaper.cs index 4892415571..c30bbb0359 100644 --- a/src/Tgstation.Server.Host/System/WindowsNetworkPromptReaper.cs +++ b/src/Tgstation.Server.Host/System/WindowsNetworkPromptReaper.cs @@ -13,6 +13,8 @@ using Microsoft.Extensions.Logging; using Tgstation.Server.Host.Utils; +#nullable disable + namespace Tgstation.Server.Host.System { /// diff --git a/src/Tgstation.Server.Host/System/WindowsProcessFeatures.cs b/src/Tgstation.Server.Host/System/WindowsProcessFeatures.cs index 41789aec8c..c3a3b31d9b 100644 --- a/src/Tgstation.Server.Host/System/WindowsProcessFeatures.cs +++ b/src/Tgstation.Server.Host/System/WindowsProcessFeatures.cs @@ -14,6 +14,8 @@ using Tgstation.Server.Api.Models; using Tgstation.Server.Host.IO; using Tgstation.Server.Host.Jobs; +#nullable disable + namespace Tgstation.Server.Host.System { /// diff --git a/src/Tgstation.Server.Host/Tgstation.Server.Host.csproj b/src/Tgstation.Server.Host/Tgstation.Server.Host.csproj index 9890be89d0..e293d81025 100644 --- a/src/Tgstation.Server.Host/Tgstation.Server.Host.csproj +++ b/src/Tgstation.Server.Host/Tgstation.Server.Host.csproj @@ -9,6 +9,7 @@ API1000;ASP0019 ClientApp/node_modules ClientApp/node_modules/.install-stamp + enable Linux ..\.. ../../build/uac_elevation_manifest.xml diff --git a/src/Tgstation.Server.Host/Transfer/FileDownloadProvider.cs b/src/Tgstation.Server.Host/Transfer/FileDownloadProvider.cs index 603e099c07..eee92cce02 100644 --- a/src/Tgstation.Server.Host/Transfer/FileDownloadProvider.cs +++ b/src/Tgstation.Server.Host/Transfer/FileDownloadProvider.cs @@ -5,6 +5,8 @@ using System.Threading.Tasks; using Tgstation.Server.Api.Models; +#nullable disable + namespace Tgstation.Server.Host.Transfer { /// diff --git a/src/Tgstation.Server.Host/Transfer/FileTransferService.cs b/src/Tgstation.Server.Host/Transfer/FileTransferService.cs index fc0201b48d..cbdc528480 100644 --- a/src/Tgstation.Server.Host/Transfer/FileTransferService.cs +++ b/src/Tgstation.Server.Host/Transfer/FileTransferService.cs @@ -12,6 +12,8 @@ using Tgstation.Server.Host.IO; using Tgstation.Server.Host.Security; using Tgstation.Server.Host.Utils; +#nullable disable + namespace Tgstation.Server.Host.Transfer { /// diff --git a/src/Tgstation.Server.Host/Transfer/FileUploadProvider.cs b/src/Tgstation.Server.Host/Transfer/FileUploadProvider.cs index 9fe8250da5..31a691b36a 100644 --- a/src/Tgstation.Server.Host/Transfer/FileUploadProvider.cs +++ b/src/Tgstation.Server.Host/Transfer/FileUploadProvider.cs @@ -9,6 +9,8 @@ using Tgstation.Server.Api.Models; using Tgstation.Server.Api.Models.Response; using Tgstation.Server.Host.IO; +#nullable disable + namespace Tgstation.Server.Host.Transfer { /// diff --git a/src/Tgstation.Server.Host/Transfer/IFileTransferStreamHandler.cs b/src/Tgstation.Server.Host/Transfer/IFileTransferStreamHandler.cs index 75603c8684..f0ba7a396d 100644 --- a/src/Tgstation.Server.Host/Transfer/IFileTransferStreamHandler.cs +++ b/src/Tgstation.Server.Host/Transfer/IFileTransferStreamHandler.cs @@ -5,6 +5,8 @@ using System.Threading.Tasks; using Tgstation.Server.Api.Models.Response; +#nullable disable + namespace Tgstation.Server.Host.Transfer { /// diff --git a/src/Tgstation.Server.Host/Transfer/IFileTransferTicketProvider.cs b/src/Tgstation.Server.Host/Transfer/IFileTransferTicketProvider.cs index 1a13cb9f87..98a2bfd913 100644 --- a/src/Tgstation.Server.Host/Transfer/IFileTransferTicketProvider.cs +++ b/src/Tgstation.Server.Host/Transfer/IFileTransferTicketProvider.cs @@ -1,5 +1,7 @@ using Tgstation.Server.Api.Models.Response; +#nullable disable + namespace Tgstation.Server.Host.Transfer { /// diff --git a/src/Tgstation.Server.Host/Transfer/IFileUploadTicket.cs b/src/Tgstation.Server.Host/Transfer/IFileUploadTicket.cs index c1bd6e5725..260be9573f 100644 --- a/src/Tgstation.Server.Host/Transfer/IFileUploadTicket.cs +++ b/src/Tgstation.Server.Host/Transfer/IFileUploadTicket.cs @@ -2,6 +2,8 @@ using Tgstation.Server.Api.Models.Response; using Tgstation.Server.Host.IO; +#nullable disable + namespace Tgstation.Server.Host.Transfer { /// diff --git a/src/Tgstation.Server.Host/Utils/AbstractHttpClientFactory.cs b/src/Tgstation.Server.Host/Utils/AbstractHttpClientFactory.cs index 973551e1d4..0bb43edf28 100644 --- a/src/Tgstation.Server.Host/Utils/AbstractHttpClientFactory.cs +++ b/src/Tgstation.Server.Host/Utils/AbstractHttpClientFactory.cs @@ -6,6 +6,8 @@ using Microsoft.Extensions.Logging; using Tgstation.Server.Common.Http; using Tgstation.Server.Host.System; +#nullable disable + namespace Tgstation.Server.Host.Utils { /// diff --git a/src/Tgstation.Server.Host/Utils/ApiHeadersProvider.cs b/src/Tgstation.Server.Host/Utils/ApiHeadersProvider.cs index 56aa288619..95190dc500 100644 --- a/src/Tgstation.Server.Host/Utils/ApiHeadersProvider.cs +++ b/src/Tgstation.Server.Host/Utils/ApiHeadersProvider.cs @@ -4,6 +4,8 @@ using Microsoft.AspNetCore.Http; using Tgstation.Server.Api; +#nullable disable + namespace Tgstation.Server.Host.Utils { /// diff --git a/src/Tgstation.Server.Host/Utils/AsyncDelayer.cs b/src/Tgstation.Server.Host/Utils/AsyncDelayer.cs index 79ffce1838..a435e38e9e 100644 --- a/src/Tgstation.Server.Host/Utils/AsyncDelayer.cs +++ b/src/Tgstation.Server.Host/Utils/AsyncDelayer.cs @@ -2,6 +2,8 @@ using System.Threading; using System.Threading.Tasks; +#nullable disable + namespace Tgstation.Server.Host.Utils { /// diff --git a/src/Tgstation.Server.Host/Utils/FifoSemaphore.cs b/src/Tgstation.Server.Host/Utils/FifoSemaphore.cs index 7a4e200c9c..099eea7d37 100644 --- a/src/Tgstation.Server.Host/Utils/FifoSemaphore.cs +++ b/src/Tgstation.Server.Host/Utils/FifoSemaphore.cs @@ -3,6 +3,8 @@ using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; +#nullable disable + namespace Tgstation.Server.Host.Utils { /// diff --git a/src/Tgstation.Server.Host/Utils/GitHub/GitHubClientFactory.cs b/src/Tgstation.Server.Host/Utils/GitHub/GitHubClientFactory.cs index 38fb72ffd6..40f76ecb57 100644 --- a/src/Tgstation.Server.Host/Utils/GitHub/GitHubClientFactory.cs +++ b/src/Tgstation.Server.Host/Utils/GitHub/GitHubClientFactory.cs @@ -9,6 +9,8 @@ using Octokit; using Tgstation.Server.Host.Configuration; using Tgstation.Server.Host.System; +#nullable disable + namespace Tgstation.Server.Host.Utils.GitHub { /// diff --git a/src/Tgstation.Server.Host/Utils/GitHub/GitHubService.cs b/src/Tgstation.Server.Host/Utils/GitHub/GitHubService.cs index 7429112712..4e95f01820 100644 --- a/src/Tgstation.Server.Host/Utils/GitHub/GitHubService.cs +++ b/src/Tgstation.Server.Host/Utils/GitHub/GitHubService.cs @@ -10,6 +10,8 @@ using Octokit; using Tgstation.Server.Host.Configuration; +#nullable disable + namespace Tgstation.Server.Host.Utils.GitHub { /// diff --git a/src/Tgstation.Server.Host/Utils/GitHub/GitHubServiceFactory.cs b/src/Tgstation.Server.Host/Utils/GitHub/GitHubServiceFactory.cs index efa08d13bb..adb8d32c47 100644 --- a/src/Tgstation.Server.Host/Utils/GitHub/GitHubServiceFactory.cs +++ b/src/Tgstation.Server.Host/Utils/GitHub/GitHubServiceFactory.cs @@ -7,6 +7,8 @@ using Octokit; using Tgstation.Server.Host.Configuration; +#nullable disable + namespace Tgstation.Server.Host.Utils.GitHub { /// diff --git a/src/Tgstation.Server.Host/Utils/GitHub/IAuthenticatedGitHubService.cs b/src/Tgstation.Server.Host/Utils/GitHub/IAuthenticatedGitHubService.cs index 619bcead20..046ef67e77 100644 --- a/src/Tgstation.Server.Host/Utils/GitHub/IAuthenticatedGitHubService.cs +++ b/src/Tgstation.Server.Host/Utils/GitHub/IAuthenticatedGitHubService.cs @@ -3,6 +3,8 @@ using System.Threading.Tasks; using Octokit; +#nullable disable + namespace Tgstation.Server.Host.Utils.GitHub { /// diff --git a/src/Tgstation.Server.Host/Utils/GitHub/IGitHubClientFactory.cs b/src/Tgstation.Server.Host/Utils/GitHub/IGitHubClientFactory.cs index ec95fd16ab..8ffea0fbd2 100644 --- a/src/Tgstation.Server.Host/Utils/GitHub/IGitHubClientFactory.cs +++ b/src/Tgstation.Server.Host/Utils/GitHub/IGitHubClientFactory.cs @@ -1,5 +1,7 @@ using Octokit; +#nullable disable + namespace Tgstation.Server.Host.Utils.GitHub { /// diff --git a/src/Tgstation.Server.Host/Utils/GitHub/IGitHubService.cs b/src/Tgstation.Server.Host/Utils/GitHub/IGitHubService.cs index e2f338d77a..b7bda78b31 100644 --- a/src/Tgstation.Server.Host/Utils/GitHub/IGitHubService.cs +++ b/src/Tgstation.Server.Host/Utils/GitHub/IGitHubService.cs @@ -7,6 +7,8 @@ using Octokit; using Tgstation.Server.Host.Configuration; +#nullable disable + namespace Tgstation.Server.Host.Utils.GitHub { /// diff --git a/src/Tgstation.Server.Host/Utils/IApiHeadersProvider.cs b/src/Tgstation.Server.Host/Utils/IApiHeadersProvider.cs index 7de65834d3..ea58c98199 100644 --- a/src/Tgstation.Server.Host/Utils/IApiHeadersProvider.cs +++ b/src/Tgstation.Server.Host/Utils/IApiHeadersProvider.cs @@ -1,5 +1,7 @@ using Tgstation.Server.Api; +#nullable disable + namespace Tgstation.Server.Host.Utils { /// diff --git a/src/Tgstation.Server.Host/Utils/IAsyncDelayer.cs b/src/Tgstation.Server.Host/Utils/IAsyncDelayer.cs index d47c5cbc62..38e738f5a2 100644 --- a/src/Tgstation.Server.Host/Utils/IAsyncDelayer.cs +++ b/src/Tgstation.Server.Host/Utils/IAsyncDelayer.cs @@ -2,6 +2,8 @@ using System.Threading; using System.Threading.Tasks; +#nullable disable + namespace Tgstation.Server.Host.Utils { /// diff --git a/src/Tgstation.Server.Host/Utils/IPortAllocator.cs b/src/Tgstation.Server.Host/Utils/IPortAllocator.cs index 29d234ec62..92a0f480b2 100644 --- a/src/Tgstation.Server.Host/Utils/IPortAllocator.cs +++ b/src/Tgstation.Server.Host/Utils/IPortAllocator.cs @@ -1,6 +1,8 @@ using System.Threading; using System.Threading.Tasks; +#nullable disable + namespace Tgstation.Server.Host.Utils { /// diff --git a/src/Tgstation.Server.Host/Utils/OpenApiEnumVarNamesExtension.cs b/src/Tgstation.Server.Host/Utils/OpenApiEnumVarNamesExtension.cs index a81beb8339..75c71c7561 100644 --- a/src/Tgstation.Server.Host/Utils/OpenApiEnumVarNamesExtension.cs +++ b/src/Tgstation.Server.Host/Utils/OpenApiEnumVarNamesExtension.cs @@ -5,6 +5,8 @@ using Microsoft.OpenApi.Interfaces; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Writers; +#nullable disable + namespace Tgstation.Server.Host.Utils { /// diff --git a/src/Tgstation.Server.Host/Utils/PortAllocator.cs b/src/Tgstation.Server.Host/Utils/PortAllocator.cs index 310cfbfe3d..546668e8d2 100644 --- a/src/Tgstation.Server.Host/Utils/PortAllocator.cs +++ b/src/Tgstation.Server.Host/Utils/PortAllocator.cs @@ -14,6 +14,8 @@ using Tgstation.Server.Host.Database; using Tgstation.Server.Host.Extensions; using Tgstation.Server.Host.System; +#nullable disable + namespace Tgstation.Server.Host.Utils { /// diff --git a/src/Tgstation.Server.Host/Utils/ReferenceCounter.cs b/src/Tgstation.Server.Host/Utils/ReferenceCounter.cs index 4351c65db6..19f8408eed 100644 --- a/src/Tgstation.Server.Host/Utils/ReferenceCounter.cs +++ b/src/Tgstation.Server.Host/Utils/ReferenceCounter.cs @@ -1,5 +1,7 @@ using System; +#nullable disable + namespace Tgstation.Server.Host.Utils { /// diff --git a/src/Tgstation.Server.Host/Utils/ReferenceCountingContainer.cs b/src/Tgstation.Server.Host/Utils/ReferenceCountingContainer.cs index 121411bd1d..2389435a6f 100644 --- a/src/Tgstation.Server.Host/Utils/ReferenceCountingContainer.cs +++ b/src/Tgstation.Server.Host/Utils/ReferenceCountingContainer.cs @@ -1,6 +1,8 @@ using System; using System.Threading.Tasks; +#nullable disable + namespace Tgstation.Server.Host.Utils { /// diff --git a/src/Tgstation.Server.Host/Utils/SemaphoreSlimContext.cs b/src/Tgstation.Server.Host/Utils/SemaphoreSlimContext.cs index 25f070cc4b..4339515859 100644 --- a/src/Tgstation.Server.Host/Utils/SemaphoreSlimContext.cs +++ b/src/Tgstation.Server.Host/Utils/SemaphoreSlimContext.cs @@ -2,6 +2,8 @@ using System.Threading; using System.Threading.Tasks; +#nullable disable + namespace Tgstation.Server.Host.Utils { /// diff --git a/src/Tgstation.Server.Host/Utils/SignalR/ComprehensiveHubContext.cs b/src/Tgstation.Server.Host/Utils/SignalR/ComprehensiveHubContext.cs index 1f09be3571..27d842c3e1 100644 --- a/src/Tgstation.Server.Host/Utils/SignalR/ComprehensiveHubContext.cs +++ b/src/Tgstation.Server.Host/Utils/SignalR/ComprehensiveHubContext.cs @@ -11,6 +11,8 @@ using Microsoft.Extensions.Logging; using Tgstation.Server.Host.Models; using Tgstation.Server.Host.Security; +#nullable disable + namespace Tgstation.Server.Host.Utils.SignalR { /// diff --git a/src/Tgstation.Server.Host/Utils/SignalR/ConnectionMappingHub.cs b/src/Tgstation.Server.Host/Utils/SignalR/ConnectionMappingHub.cs index 05e2eb8742..8684901820 100644 --- a/src/Tgstation.Server.Host/Utils/SignalR/ConnectionMappingHub.cs +++ b/src/Tgstation.Server.Host/Utils/SignalR/ConnectionMappingHub.cs @@ -6,6 +6,8 @@ using Microsoft.AspNetCore.SignalR; using Tgstation.Server.Host.Security; +#nullable disable + namespace Tgstation.Server.Host.Utils.SignalR { /// diff --git a/src/Tgstation.Server.Host/Utils/SignalR/IConnectionMappedHubContext.cs b/src/Tgstation.Server.Host/Utils/SignalR/IConnectionMappedHubContext.cs index 101e8e599e..bdf89de277 100644 --- a/src/Tgstation.Server.Host/Utils/SignalR/IConnectionMappedHubContext.cs +++ b/src/Tgstation.Server.Host/Utils/SignalR/IConnectionMappedHubContext.cs @@ -8,6 +8,8 @@ using Microsoft.AspNetCore.SignalR; using Tgstation.Server.Host.Models; using Tgstation.Server.Host.Security; +#nullable disable + namespace Tgstation.Server.Host.Utils.SignalR { /// diff --git a/src/Tgstation.Server.Host/Utils/SignalR/IHubConnectionMapper.cs b/src/Tgstation.Server.Host/Utils/SignalR/IHubConnectionMapper.cs index 4521c87fcc..8163a737e4 100644 --- a/src/Tgstation.Server.Host/Utils/SignalR/IHubConnectionMapper.cs +++ b/src/Tgstation.Server.Host/Utils/SignalR/IHubConnectionMapper.cs @@ -6,6 +6,8 @@ using Microsoft.AspNetCore.SignalR; using Tgstation.Server.Host.Models; using Tgstation.Server.Host.Security; +#nullable disable + namespace Tgstation.Server.Host.Utils.SignalR { /// diff --git a/src/Tgstation.Server.Host/Utils/SwaggerConfiguration.cs b/src/Tgstation.Server.Host/Utils/SwaggerConfiguration.cs index 8f8b0195bd..aeaa86db10 100644 --- a/src/Tgstation.Server.Host/Utils/SwaggerConfiguration.cs +++ b/src/Tgstation.Server.Host/Utils/SwaggerConfiguration.cs @@ -20,6 +20,8 @@ using Tgstation.Server.Common.Extensions; using Tgstation.Server.Host.Controllers; using Tgstation.Server.Host.Security; +#nullable disable + namespace Tgstation.Server.Host.Utils { /// From c6d17a1fa5c89e6ce7a0218992e816d9eceea4eb Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 23 Nov 2023 17:40:51 -0500 Subject: [PATCH 002/425] Nullify `Program` --- src/Tgstation.Server.Host/Program.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Tgstation.Server.Host/Program.cs b/src/Tgstation.Server.Host/Program.cs index fb5cf8a1c0..8f0c5a3867 100644 --- a/src/Tgstation.Server.Host/Program.cs +++ b/src/Tgstation.Server.Host/Program.cs @@ -11,8 +11,6 @@ using Tgstation.Server.Host.Core; using Tgstation.Server.Host.Properties; using Tgstation.Server.Host.System; -#nullable disable - namespace Tgstation.Server.Host { /// @@ -46,7 +44,7 @@ namespace Tgstation.Server.Host public static async Task Main(string[] args) { // first arg is 100% always the update path, starting it otherwise is solely for debugging purposes - string updatePath = null; + string? updatePath = null; if (args.Length > 0) { var listArgs = new List(args); @@ -79,7 +77,7 @@ namespace Tgstation.Server.Host /// The command line arguments, minus the . /// The path to extract server updates to be applied to. /// A resulting in the . - internal async ValueTask Main(string[] args, string updatePath) + internal async ValueTask Main(string[] args, string? updatePath) { try { From f8b0d62c601fb33347c03404850221d94e8fd247 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 23 Nov 2023 18:03:40 -0500 Subject: [PATCH 003/425] Nullify `ServerFactory` --- src/Tgstation.Server.Host/IServerFactory.cs | 4 +--- src/Tgstation.Server.Host/Program.cs | 2 +- src/Tgstation.Server.Host/ServerFactory.cs | 7 +++---- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/Tgstation.Server.Host/IServerFactory.cs b/src/Tgstation.Server.Host/IServerFactory.cs index 937fee7184..b205d6b62e 100644 --- a/src/Tgstation.Server.Host/IServerFactory.cs +++ b/src/Tgstation.Server.Host/IServerFactory.cs @@ -3,8 +3,6 @@ using System.Threading.Tasks; using Tgstation.Server.Host.IO; -#nullable disable - namespace Tgstation.Server.Host { /// @@ -24,6 +22,6 @@ namespace Tgstation.Server.Host /// The directory in which to install server updates. /// The for the operation. /// A resulting in a new if it should be run, otherwise. - ValueTask CreateServer(string[] args, string updatePath, CancellationToken cancellationToken); + ValueTask CreateServer(string[] args, string? updatePath, CancellationToken cancellationToken); } } diff --git a/src/Tgstation.Server.Host/Program.cs b/src/Tgstation.Server.Host/Program.cs index 8f0c5a3867..b23633b7df 100644 --- a/src/Tgstation.Server.Host/Program.cs +++ b/src/Tgstation.Server.Host/Program.cs @@ -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( diff --git a/src/Tgstation.Server.Host/ServerFactory.cs b/src/Tgstation.Server.Host/ServerFactory.cs index 4b25e07fea..f92298da10 100644 --- a/src/Tgstation.Server.Host/ServerFactory.cs +++ b/src/Tgstation.Server.Host/ServerFactory.cs @@ -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 { /// @@ -53,7 +51,7 @@ namespace Tgstation.Server.Host /// // TODO: Decomplexify #pragma warning disable CA1506 - public async ValueTask CreateServer(string[] args, string updatePath, CancellationToken cancellationToken) + public async ValueTask 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; From 4ff13f05f817cc465d11a4380baab493f01f3231 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 23 Nov 2023 18:33:04 -0500 Subject: [PATCH 004/425] Nullify `Server` Not a fan of this one --- src/Tgstation.Server.Host/Server.cs | 45 ++++++++++++++++------------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/src/Tgstation.Server.Host/Server.cs b/src/Tgstation.Server.Host/Server.cs index b57045078d..3e43fe83f3 100644 --- a/src/Tgstation.Server.Host/Server.cs +++ b/src/Tgstation.Server.Host/Server.cs @@ -14,8 +14,6 @@ using Tgstation.Server.Common.Extensions; using Tgstation.Server.Host.Configuration; using Tgstation.Server.Host.Core; -#nullable disable - namespace Tgstation.Server.Host { /// @@ -38,7 +36,7 @@ namespace Tgstation.Server.Host /// /// The of the running server. /// - internal IHost Host { get; private set; } + internal IHost? Host { get; private set; } /// /// The for the . @@ -53,7 +51,7 @@ namespace Tgstation.Server.Host /// /// The absolute path to install updates to. /// - readonly string updatePath; + readonly string? updatePath; /// /// for certain restart related operations. @@ -63,27 +61,27 @@ namespace Tgstation.Server.Host /// /// The for the . /// - ILogger logger; + ILogger? logger; /// /// The for the . /// - GeneralConfiguration generalConfiguration; + GeneralConfiguration? generalConfiguration; /// /// The for the . /// - CancellationTokenSource cancellationTokenSource; + CancellationTokenSource? cancellationTokenSource; /// /// The to propagate when the server terminates. /// - Exception propagatedException; + Exception? propagatedException; /// /// The that is used for asynchronously updating the server. /// - Task updateTask; + Task? updateTask; /// /// If the server is being shut down or restarted. @@ -100,7 +98,7 @@ namespace Tgstation.Server.Host /// /// The value of . /// The value of . - public Server(IHostBuilder hostBuilder, string updatePath) + public Server(IHostBuilder hostBuilder, string? updatePath) { this.hostBuilder = hostBuilder ?? throw new ArgumentNullException(nameof(hostBuilder)); this.updatePath = updatePath; @@ -109,15 +107,17 @@ namespace Tgstation.Server.Host restartHandlers = new List(); restartLock = new object(); + logger = null; } /// public async ValueTask Run(CancellationToken cancellationToken) { + var updateDirectory = updatePath != null ? Path.GetDirectoryName(updatePath) : null; using (cancellationTokenSource = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken)) - using (var fsWatcher = updatePath != null ? new FileSystemWatcher(Path.GetDirectoryName(updatePath)) : null) + using (var fsWatcher = updateDirectory != null ? new FileSystemWatcher(updateDirectory) : null) { - if (updatePath != null) + if (fsWatcher != null) { // If ever there is a NECESSARY update to the Host Watchdog, change this to use a pipe // I don't know why I'm only realizing this in 2023 when this is 2019 code @@ -130,9 +130,10 @@ namespace Tgstation.Server.Host try { using (Host = hostBuilder.Build()) + { + logger = Host.Services.GetRequiredService>(); try { - logger = Host.Services.GetRequiredService>(); using (cancellationToken.Register(() => logger.LogInformation("Server termination requested!"))) { var generalConfigurationOptions = Host.Services.GetRequiredService>(); @@ -156,6 +157,7 @@ namespace Tgstation.Server.Host { logger = null; } + } } finally { @@ -174,6 +176,7 @@ namespace Tgstation.Server.Host CheckSanity(true); + var logger = this.logger!; logger.LogTrace("Begin ApplyUpdate..."); CancellationToken criticalCancellationToken; @@ -222,6 +225,7 @@ namespace Tgstation.Server.Host CheckSanity(false); + var logger = this.logger!; lock (restartLock) if (!shutdownInProgress) { @@ -272,7 +276,7 @@ namespace Tgstation.Server.Host /// Re-throw if it exists. /// /// An existing that should be thrown as well, but not by itself. - void CheckExceptionPropagation(Exception otherException) + void CheckExceptionPropagation(Exception? otherException) { if (propagatedException == null) return; @@ -291,12 +295,13 @@ namespace Tgstation.Server.Host /// If the host watchdog is required for this "restart". /// If the restart should wait for extremely long running tasks to complete (Like the current DreamDaemon world). /// A representing the running operation. - async ValueTask RestartImpl(Version newVersion, Exception exception, bool requireWatchdog, bool completeAsap) + async ValueTask RestartImpl(Version? newVersion, Exception? exception, bool requireWatchdog, bool completeAsap) { CheckSanity(requireWatchdog); // if the watchdog isn't required and there's no issue, this is just a graceful shutdown bool isGracefulShutdown = !requireWatchdog && exception == null; + var logger = this.logger!; logger.LogTrace( "Begin {restartType}...", isGracefulShutdown @@ -324,8 +329,8 @@ namespace Tgstation.Server.Host using var cts = new CancellationTokenSource( TimeSpan.FromMinutes( giveHandlersTimeToWaitAround - ? generalConfiguration.ShutdownTimeoutMinutes - : generalConfiguration.RestartTimeoutMinutes)); + ? generalConfiguration!.ShutdownTimeoutMinutes + : generalConfiguration!.RestartTimeoutMinutes)); var cancellationToken = cts.Token; try { @@ -368,7 +373,7 @@ namespace Tgstation.Server.Host logger?.LogTrace("FileSystemWatcher triggered."); // TODO: Refactor this to not use System.IO function here. - if (eventArgs.FullPath == Path.GetFullPath(updatePath) && File.Exists(eventArgs.FullPath)) + if (eventArgs.FullPath == Path.GetFullPath(updatePath!) && File.Exists(eventArgs.FullPath)) { logger?.LogInformation("Host watchdog appears to be requesting server termination!"); lock (restartLock) @@ -392,8 +397,8 @@ namespace Tgstation.Server.Host void StopServerImmediate() { shutdownInProgress = true; - logger.LogDebug("Stopping host..."); - cancellationTokenSource.Cancel(); + logger!.LogDebug("Stopping host..."); + cancellationTokenSource!.Cancel(); } } } From 8bdb8a4575e54170d85e81dfe2dbb8e3fbf4d049 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 23 Nov 2023 18:35:34 -0500 Subject: [PATCH 005/425] Nullify `Application` That was easy --- src/Tgstation.Server.Host/Core/Application.cs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/Tgstation.Server.Host/Core/Application.cs b/src/Tgstation.Server.Host/Core/Application.cs index 404655f379..a4deff4806 100644 --- a/src/Tgstation.Server.Host/Core/Application.cs +++ b/src/Tgstation.Server.Host/Core/Application.cs @@ -63,8 +63,6 @@ using Tgstation.Server.Host.System; using Tgstation.Server.Host.Transfer; using Tgstation.Server.Host.Utils; -#nullable disable - namespace Tgstation.Server.Host.Core { /// @@ -81,7 +79,7 @@ namespace Tgstation.Server.Host.Core /// /// The for the . /// - ITokenFactory tokenFactory; + ITokenFactory? tokenFactory; /// /// Create the default . @@ -537,7 +535,7 @@ namespace Tgstation.Server.Host.Core applicationBuilder.UseRouting(); // Set up CORS based on configuration if necessary - Action corsBuilder = null; + Action? corsBuilder = null; if (controlPanelConfiguration.AllowAnyOrigin) { logger.LogTrace("Access-Control-Allow-Origin: *"); @@ -621,9 +619,9 @@ namespace Tgstation.Server.Host.Core // return provider.GetRequiredService().CurrentAuthenticationContext // But M$ said // https://stackoverflow.com/questions/56792917/scoped-services-in-asp-net-core-with-signalr-hubs - services.AddScoped(provider => provider + services.AddScoped(provider => (provider .GetRequiredService() - .HttpContext + .HttpContext ?? throw new InvalidOperationException($"Unable to resolve {nameof(IAuthenticationContext)} due to no HttpContext being available!")) .RequestServices .GetRequiredService() .CurrentAuthenticationContext); From 68792b1cdf34bad5691a4a3761f4e21d2bb6bf81 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 23 Nov 2023 18:43:20 -0500 Subject: [PATCH 006/425] Nullify `CommandPipeManager` --- .../Core/CommandPipeManager.cs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/Tgstation.Server.Host/Core/CommandPipeManager.cs b/src/Tgstation.Server.Host/Core/CommandPipeManager.cs index 798b7db57c..fce8fa9ccd 100644 --- a/src/Tgstation.Server.Host/Core/CommandPipeManager.cs +++ b/src/Tgstation.Server.Host/Core/CommandPipeManager.cs @@ -13,8 +13,6 @@ using Tgstation.Server.Host.Common; using Tgstation.Server.Host.Components; using Tgstation.Server.Host.Configuration; -#nullable disable - namespace Tgstation.Server.Host.Core { /// @@ -98,13 +96,13 @@ namespace Tgstation.Server.Host.Core try { - using var streamReader = new StreamReader(commandPipeClient, Encoding.UTF8, leaveOpen: true); + using var streamReader = new StreamReader(commandPipeClient!, Encoding.UTF8, leaveOpen: true); while (!cancellationToken.IsCancellationRequested) { logger.LogTrace("Waiting to read command line..."); var line = await streamReader.ReadLineAsync().WaitAsync(cancellationToken); - logger?.LogInformation("Received pipe command: {command}", line); + logger.LogInformation("Received pipe command: {command}", line); switch (line) { case PipeCommands.CommandStop: @@ -120,22 +118,22 @@ namespace Tgstation.Server.Host.Core logger.LogError("Read null from pipe!"); return; default: - logger?.LogWarning("Unrecognized pipe command: {command}", line); + logger.LogWarning("Unrecognized pipe command: {command}", line); break; } } } catch (OperationCanceledException ex) { - logger?.LogTrace(ex, "Command read task cancelled!"); + logger.LogTrace(ex, "Command read task cancelled!"); } catch (Exception ex) { - logger?.LogError(ex, "Command read task errored!"); + logger.LogError(ex, "Command read task errored!"); } finally { - logger?.LogTrace("Command read task exiting..."); + logger.LogTrace("Command read task exiting..."); } } } From 010c0e07781a6a5c6f39b732b26d2e0cdd56b54e Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 23 Nov 2023 18:44:27 -0500 Subject: [PATCH 007/425] Nullify `IRestartHandler` --- src/Tgstation.Server.Host/Core/IRestartHandler.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Tgstation.Server.Host/Core/IRestartHandler.cs b/src/Tgstation.Server.Host/Core/IRestartHandler.cs index 4db9ad18c3..b663ae5d22 100644 --- a/src/Tgstation.Server.Host/Core/IRestartHandler.cs +++ b/src/Tgstation.Server.Host/Core/IRestartHandler.cs @@ -2,8 +2,6 @@ using System.Threading; using System.Threading.Tasks; -#nullable disable - namespace Tgstation.Server.Host.Core { /// @@ -18,6 +16,6 @@ namespace Tgstation.Server.Host.Core /// If the should aim to complete the returned from this function ASAP. /// The for the operation. /// A representing the running operation. - ValueTask HandleRestart(Version updateVersion, bool handlerMayDelayShutdownWithExtremelyLongRunningTasks, CancellationToken cancellationToken); + ValueTask HandleRestart(Version? updateVersion, bool handlerMayDelayShutdownWithExtremelyLongRunningTasks, CancellationToken cancellationToken); } } From 6092baf408e20be271398d6e8bac9a35f47516d7 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 23 Nov 2023 18:44:59 -0500 Subject: [PATCH 008/425] Nullify `IServerControl` --- src/Tgstation.Server.Host/Core/IServerControl.cs | 4 +--- src/Tgstation.Server.Host/Server.cs | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Tgstation.Server.Host/Core/IServerControl.cs b/src/Tgstation.Server.Host/Core/IServerControl.cs index 8eca773ecb..92bbfe75f5 100644 --- a/src/Tgstation.Server.Host/Core/IServerControl.cs +++ b/src/Tgstation.Server.Host/Core/IServerControl.cs @@ -1,8 +1,6 @@ using System; using System.Threading.Tasks; -#nullable disable - namespace Tgstation.Server.Host.Core { /// @@ -53,6 +51,6 @@ namespace Tgstation.Server.Host.Core /// /// The to propagate to the watchdog if any. /// A representing the running operation. - ValueTask Die(Exception exception); + ValueTask Die(Exception? exception); } } diff --git a/src/Tgstation.Server.Host/Server.cs b/src/Tgstation.Server.Host/Server.cs index 3e43fe83f3..b1432bc816 100644 --- a/src/Tgstation.Server.Host/Server.cs +++ b/src/Tgstation.Server.Host/Server.cs @@ -250,7 +250,7 @@ namespace Tgstation.Server.Host public ValueTask GracefulShutdown(bool detach) => RestartImpl(null, null, false, detach); /// - public ValueTask Die(Exception exception) + public ValueTask Die(Exception? exception) { if (exception != null) return RestartImpl(null, exception, false, true); From 2a1f3179f5d64d77cd63093b231e15628b40b9cb Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 23 Nov 2023 18:46:41 -0500 Subject: [PATCH 009/425] Nullify `IServerUpdateExecutor` --- src/Tgstation.Server.Host/Core/IServerUpdateExecutor.cs | 2 -- src/Tgstation.Server.Host/Server.cs | 3 +++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Core/IServerUpdateExecutor.cs b/src/Tgstation.Server.Host/Core/IServerUpdateExecutor.cs index 9a1ea2d011..c2bf6f2090 100644 --- a/src/Tgstation.Server.Host/Core/IServerUpdateExecutor.cs +++ b/src/Tgstation.Server.Host/Core/IServerUpdateExecutor.cs @@ -1,8 +1,6 @@ using System.Threading; using System.Threading.Tasks; -#nullable disable - namespace Tgstation.Server.Host.Core { /// diff --git a/src/Tgstation.Server.Host/Server.cs b/src/Tgstation.Server.Host/Server.cs index b1432bc816..b832be6e87 100644 --- a/src/Tgstation.Server.Host/Server.cs +++ b/src/Tgstation.Server.Host/Server.cs @@ -176,6 +176,9 @@ namespace Tgstation.Server.Host CheckSanity(true); + if (updatePath == null) + throw new InvalidOperationException("Tried to start update when server was initialized without an updatePath set!"); + var logger = this.logger!; logger.LogTrace("Begin ApplyUpdate..."); From c106e06c256f54b0f8d5e9de21dcc7b2fb178d05 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 23 Nov 2023 18:47:10 -0500 Subject: [PATCH 010/425] Nullify `IServerUpdateInitiator` --- src/Tgstation.Server.Host/Core/IServerUpdateInitiator.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Tgstation.Server.Host/Core/IServerUpdateInitiator.cs b/src/Tgstation.Server.Host/Core/IServerUpdateInitiator.cs index f9af6f34de..35aaa4037b 100644 --- a/src/Tgstation.Server.Host/Core/IServerUpdateInitiator.cs +++ b/src/Tgstation.Server.Host/Core/IServerUpdateInitiator.cs @@ -4,8 +4,6 @@ using System.Threading.Tasks; using Tgstation.Server.Host.IO; -#nullable disable - namespace Tgstation.Server.Host.Core { /// @@ -20,6 +18,6 @@ namespace Tgstation.Server.Host.Core /// The TGS to update to. /// The for the operation. /// A resulting in the . - ValueTask InitiateUpdate(IFileStreamProvider fileStreamProvider, Version version, CancellationToken cancellationToken); + ValueTask InitiateUpdate(IFileStreamProvider? fileStreamProvider, Version version, CancellationToken cancellationToken); } } From 5b2bb10d9142f5fc55ef92055bc0e97c5f7d08a1 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 23 Nov 2023 18:47:50 -0500 Subject: [PATCH 011/425] Nullify `IServerUpdater` --- src/Tgstation.Server.Host/Core/IServerUpdater.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Tgstation.Server.Host/Core/IServerUpdater.cs b/src/Tgstation.Server.Host/Core/IServerUpdater.cs index de0e38b67d..4a7a7c0519 100644 --- a/src/Tgstation.Server.Host/Core/IServerUpdater.cs +++ b/src/Tgstation.Server.Host/Core/IServerUpdater.cs @@ -5,8 +5,6 @@ using System.Threading.Tasks; using Tgstation.Server.Host.IO; using Tgstation.Server.Host.Swarm; -#nullable disable - namespace Tgstation.Server.Host.Core { /// @@ -22,6 +20,6 @@ namespace Tgstation.Server.Host.Core /// The TGS to update to. /// The for the operation. /// A resulting in the . - ValueTask BeginUpdate(ISwarmService swarmService, IFileStreamProvider fileStreamProvider, Version version, CancellationToken cancellationToken); + ValueTask BeginUpdate(ISwarmService swarmService, IFileStreamProvider? fileStreamProvider, Version version, CancellationToken cancellationToken); } } From 45a8371acfce0d9b4eca79e2c0da7ff8d7a2a9af Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 23 Nov 2023 18:54:18 -0500 Subject: [PATCH 012/425] Nullify `RestartRegistration` --- src/Tgstation.Server.Host/Core/RestartRegistration.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Tgstation.Server.Host/Core/RestartRegistration.cs b/src/Tgstation.Server.Host/Core/RestartRegistration.cs index d685fe590b..8f4ab937d6 100644 --- a/src/Tgstation.Server.Host/Core/RestartRegistration.cs +++ b/src/Tgstation.Server.Host/Core/RestartRegistration.cs @@ -1,7 +1,5 @@ using System; -#nullable disable - namespace Tgstation.Server.Host.Core { /// @@ -10,13 +8,13 @@ namespace Tgstation.Server.Host.Core /// /// The . /// - readonly Action onDispose; + readonly Action? onDispose; /// /// Initializes a new instance of the class. /// /// The value of . - public RestartRegistration(Action onDispose) + public RestartRegistration(Action? onDispose) { this.onDispose = onDispose; } From 34f47edbabd893a3ddb70eb38beda855c4a852a0 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 23 Nov 2023 18:56:26 -0500 Subject: [PATCH 013/425] Nullify `ServerPortProvider` --- .../Core/ServerPortProivder.cs | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/Tgstation.Server.Host/Core/ServerPortProivder.cs b/src/Tgstation.Server.Host/Core/ServerPortProivder.cs index 0b97105c43..a3f39a4ab8 100644 --- a/src/Tgstation.Server.Host/Core/ServerPortProivder.cs +++ b/src/Tgstation.Server.Host/Core/ServerPortProivder.cs @@ -7,8 +7,6 @@ using Microsoft.Extensions.Options; using Tgstation.Server.Host.Configuration; -#nullable disable - namespace Tgstation.Server.Host.Core { /// @@ -36,18 +34,17 @@ namespace Tgstation.Server.Host.Core generalConfiguration = generalConfigurationOptions?.Value ?? throw new ArgumentNullException(nameof(generalConfigurationOptions)); ArgumentNullException.ThrowIfNull(configuration); + var usingDefaultPort = generalConfiguration.ApiPort == default; + if (!usingDefaultPort) + return; + var httpEndpoint = configuration .GetSection("Kestrel") .GetSection("EndPoints") .GetSection("Http") .GetSection("Url") - .Value; - - if (generalConfiguration.ApiPort == default && httpEndpoint == null) - throw new InvalidOperationException("Missing required configuration option General:ApiPort!"); - - if (generalConfiguration.ApiPort != default) - return; + .Value + ?? throw new InvalidOperationException("Missing required configuration option General:ApiPort!"); logger.LogWarning("The \"Kestrel\" configuration section is deprecated! Please set your API port using the \"General:ApiPort\" configuration option!"); From 29fdb487e2b638d21ee18a5838e6c8432e92671a Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 23 Nov 2023 18:56:56 -0500 Subject: [PATCH 014/425] Nullify `ServerUpdateInitiator` --- src/Tgstation.Server.Host/Core/ServerUpdateInitiator.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Tgstation.Server.Host/Core/ServerUpdateInitiator.cs b/src/Tgstation.Server.Host/Core/ServerUpdateInitiator.cs index 0819b4ddd5..fc1dc084cc 100644 --- a/src/Tgstation.Server.Host/Core/ServerUpdateInitiator.cs +++ b/src/Tgstation.Server.Host/Core/ServerUpdateInitiator.cs @@ -5,8 +5,6 @@ using System.Threading.Tasks; using Tgstation.Server.Host.IO; using Tgstation.Server.Host.Swarm; -#nullable disable - namespace Tgstation.Server.Host.Core { /// @@ -34,7 +32,7 @@ namespace Tgstation.Server.Host.Core } /// - public ValueTask InitiateUpdate(IFileStreamProvider fileStreamProvider, Version version, CancellationToken cancellationToken) + public ValueTask InitiateUpdate(IFileStreamProvider? fileStreamProvider, Version version, CancellationToken cancellationToken) => serverUpdater.BeginUpdate(swarmService, fileStreamProvider, version, cancellationToken); } } From eae3a3a5ec09fd8e94f749a087686f690cdafc1d Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 23 Nov 2023 18:57:16 -0500 Subject: [PATCH 015/425] Nullify `ServerUpdateOperation` --- src/Tgstation.Server.Host/Core/ServerUpdateOperation.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Core/ServerUpdateOperation.cs b/src/Tgstation.Server.Host/Core/ServerUpdateOperation.cs index 1e673f8239..f14d85ec75 100644 --- a/src/Tgstation.Server.Host/Core/ServerUpdateOperation.cs +++ b/src/Tgstation.Server.Host/Core/ServerUpdateOperation.cs @@ -3,8 +3,6 @@ using Tgstation.Server.Host.IO; using Tgstation.Server.Host.Swarm; -#nullable disable - namespace Tgstation.Server.Host.Core { /// From 0bd4eaf9db46268e9cb5ac26ecb26a9d556477ae Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 23 Nov 2023 18:59:40 -0500 Subject: [PATCH 016/425] Nullify `ServerUpdater` --- .../Core/ServerUpdater.cs | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/Tgstation.Server.Host/Core/ServerUpdater.cs b/src/Tgstation.Server.Host/Core/ServerUpdater.cs index be3b9f033c..8c9d968168 100644 --- a/src/Tgstation.Server.Host/Core/ServerUpdater.cs +++ b/src/Tgstation.Server.Host/Core/ServerUpdater.cs @@ -11,8 +11,6 @@ using Tgstation.Server.Host.IO; using Tgstation.Server.Host.Swarm; using Tgstation.Server.Host.Utils.GitHub; -#nullable disable - namespace Tgstation.Server.Host.Core { /// @@ -61,7 +59,7 @@ namespace Tgstation.Server.Host.Core /// /// for an in-progress update operation. /// - ServerUpdateOperation serverUpdateOperation; + ServerUpdateOperation? serverUpdateOperation; /// /// Initializes a new instance of the class. @@ -94,7 +92,7 @@ namespace Tgstation.Server.Host.Core } /// - public async ValueTask BeginUpdate(ISwarmService swarmService, IFileStreamProvider fileStreamProvider, Version version, CancellationToken cancellationToken) + public async ValueTask BeginUpdate(ISwarmService swarmService, IFileStreamProvider? fileStreamProvider, Version version, CancellationToken cancellationToken) { ArgumentNullException.ThrowIfNull(swarmService); @@ -203,7 +201,7 @@ namespace Tgstation.Server.Host.Core { try { - await serverUpdateOperation.SwarmService.AbortUpdate(); + await serverUpdateOperation!.SwarmService.AbortUpdate(); } catch (Exception e2) { @@ -216,11 +214,11 @@ namespace Tgstation.Server.Host.Core /// /// The directory the server update is initially extracted to. /// The for the operation. - /// A resulting in containing a new based on the of and if it needs to be kept active until the swarm commit. + /// A resulting in containing a new based on the of and if it needs to be kept active until the swarm commit. If , the update failed to prepare. /// Requires to be populated. - async ValueTask> PrepareUpdateClearStagingAndBufferStream(string stagingDirectory, CancellationToken cancellationToken) + async ValueTask?> PrepareUpdateClearStagingAndBufferStream(string stagingDirectory, CancellationToken cancellationToken) { - await using var fileStreamProvider = serverUpdateOperation.FileStreamProvider; + await using var fileStreamProvider = serverUpdateOperation!.FileStreamProvider; var bufferedStream = new BufferedFileStreamProvider( await fileStreamProvider.GetResult(cancellationToken)); @@ -278,12 +276,12 @@ namespace Tgstation.Server.Host.Core /// A resulting in the . async ValueTask BeginUpdateImpl( ISwarmService swarmService, - IFileStreamProvider fileStreamProvider, + IFileStreamProvider? fileStreamProvider, Version newVersion, bool recursed, CancellationToken cancellationToken) { - ServerUpdateOperation ourUpdateOperation = null; + ServerUpdateOperation? ourUpdateOperation = null; try { if (fileStreamProvider == null) From f885a4e292d2bb90c88bd990316f2d86f4498620 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 23 Nov 2023 19:00:41 -0500 Subject: [PATCH 017/425] Nullify `ControlPanelConfiguration` --- .../Configuration/ControlPanelConfiguration.cs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/Tgstation.Server.Host/Configuration/ControlPanelConfiguration.cs b/src/Tgstation.Server.Host/Configuration/ControlPanelConfiguration.cs index 437a420495..12da65e312 100644 --- a/src/Tgstation.Server.Host/Configuration/ControlPanelConfiguration.cs +++ b/src/Tgstation.Server.Host/Configuration/ControlPanelConfiguration.cs @@ -1,7 +1,5 @@ using System.Collections.Generic; -#nullable disable - namespace Tgstation.Server.Host.Configuration { /// @@ -38,16 +36,16 @@ namespace Tgstation.Server.Host.Configuration /// /// The channel to retrieve the webpanel from. "local" uses the bundled version. /// - public string Channel { get; set; } + public string? Channel { get; set; } /// /// The public path to the TGS control panel from a wider network. /// - public string PublicPath { get; set; } + public string? PublicPath { get; set; } /// /// Origins allowed for CORS requests. /// - public ICollection AllowedOrigins { get; set; } + public ICollection? AllowedOrigins { get; set; } } } From 954b421a5dad866bea90d3bb6b14377bb4e1a500 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 23 Nov 2023 19:01:35 -0500 Subject: [PATCH 018/425] Nullify `DatabaseConfiguration` --- .../Configuration/DatabaseConfiguration.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Tgstation.Server.Host/Configuration/DatabaseConfiguration.cs b/src/Tgstation.Server.Host/Configuration/DatabaseConfiguration.cs index 51e78a2494..ea699cd4ad 100644 --- a/src/Tgstation.Server.Host/Configuration/DatabaseConfiguration.cs +++ b/src/Tgstation.Server.Host/Configuration/DatabaseConfiguration.cs @@ -1,8 +1,6 @@ using Newtonsoft.Json; using Newtonsoft.Json.Converters; -#nullable disable - namespace Tgstation.Server.Host.Configuration { /// @@ -29,7 +27,7 @@ namespace Tgstation.Server.Host.Configuration /// /// The connection string for the database. /// - public string ConnectionString { get; set; } + public string? ConnectionString { get; set; } /// /// If the database should be deleted on application startup. Should not be used in production!. @@ -39,6 +37,6 @@ namespace Tgstation.Server.Host.Configuration /// /// The form of the of the target server. /// - public string ServerVersion { get; set; } + public string? ServerVersion { get; set; } } } From 174d0ecf1feef2c92b6ab729846ebc2e451fcbfa Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 23 Nov 2023 19:03:16 -0500 Subject: [PATCH 019/425] Nullify `ElasticsearchConfiguration` --- .../Configuration/ElasticsearchConfiguration.cs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/Tgstation.Server.Host/Configuration/ElasticsearchConfiguration.cs b/src/Tgstation.Server.Host/Configuration/ElasticsearchConfiguration.cs index 424d746a67..a99f3b03e8 100644 --- a/src/Tgstation.Server.Host/Configuration/ElasticsearchConfiguration.cs +++ b/src/Tgstation.Server.Host/Configuration/ElasticsearchConfiguration.cs @@ -1,9 +1,7 @@ using System; -#nullable disable - namespace Tgstation.Server.Host.Configuration - { +{ /// /// Configuration options pertaining to elasticsearch log storage. /// @@ -22,16 +20,16 @@ namespace Tgstation.Server.Host.Configuration /// /// The host of the elasticsearch endpoint. /// - public Uri Host { get; set; } + public Uri? Host { get; set; } /// /// Username for elasticsearch. /// - public string Username { get; set; } + public string? Username { get; set; } /// /// Password for elasticsearch. /// - public string Password { get; set; } + public string? Password { get; set; } } } From da5adac6682009c8f86917310be795cae3e38e2a Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 23 Nov 2023 19:04:02 -0500 Subject: [PATCH 020/425] Nullify `FileLoggingConfiguration` --- .../Configuration/FileLoggingConfiguration.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Tgstation.Server.Host/Configuration/FileLoggingConfiguration.cs b/src/Tgstation.Server.Host/Configuration/FileLoggingConfiguration.cs index 6d73d95ad9..61dfe777c7 100644 --- a/src/Tgstation.Server.Host/Configuration/FileLoggingConfiguration.cs +++ b/src/Tgstation.Server.Host/Configuration/FileLoggingConfiguration.cs @@ -7,8 +7,6 @@ using Newtonsoft.Json.Converters; using Tgstation.Server.Host.IO; using Tgstation.Server.Host.System; -#nullable disable - namespace Tgstation.Server.Host.Configuration { /// @@ -24,7 +22,7 @@ namespace Tgstation.Server.Host.Configuration /// /// Where log files are stored. /// - public string Directory { get; set; } + public string? Directory { get; set; } /// /// If file logging is disabled. From e8a1009a46703f8ceb1c4931f98c8a0d6dbe849a Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 23 Nov 2023 19:06:00 -0500 Subject: [PATCH 021/425] Nullify `GeneralConfiguration` --- .../Configuration/GeneralConfiguration.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Tgstation.Server.Host/Configuration/GeneralConfiguration.cs b/src/Tgstation.Server.Host/Configuration/GeneralConfiguration.cs index a21f796dc7..ce32b46a0f 100644 --- a/src/Tgstation.Server.Host/Configuration/GeneralConfiguration.cs +++ b/src/Tgstation.Server.Host/Configuration/GeneralConfiguration.cs @@ -11,8 +11,6 @@ using Tgstation.Server.Host.Setup; using YamlDotNet.Serialization; -#nullable disable - namespace Tgstation.Server.Host.Configuration { /// @@ -83,7 +81,7 @@ namespace Tgstation.Server.Host.Configuration /// /// The the file says it is. /// - public Version ConfigVersion { get; set; } + public Version? ConfigVersion { get; set; } /// /// The port the TGS API listens on. @@ -93,7 +91,7 @@ namespace Tgstation.Server.Host.Configuration /// /// A GitHub personal access token to use for bypassing rate limits on requests. Requires no scopes. /// - public string GitHubAccessToken { get; set; } + public string? GitHubAccessToken { get; set; } /// /// The . From a3b81f83770e7062ff202fdb48fe2be135c515b6 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 23 Nov 2023 19:08:31 -0500 Subject: [PATCH 022/425] Nullify `InternalConfiguration` --- .../Configuration/InternalConfiguration.cs | 12 +++++------- src/Tgstation.Server.Host/Core/CommandPipeManager.cs | 10 ++++++---- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/Tgstation.Server.Host/Configuration/InternalConfiguration.cs b/src/Tgstation.Server.Host/Configuration/InternalConfiguration.cs index 315cdad35c..832041deba 100644 --- a/src/Tgstation.Server.Host/Configuration/InternalConfiguration.cs +++ b/src/Tgstation.Server.Host/Configuration/InternalConfiguration.cs @@ -1,6 +1,4 @@ -#nullable disable - -namespace Tgstation.Server.Host.Configuration +namespace Tgstation.Server.Host.Configuration { /// /// Unstable configuration options used internally by TGS. @@ -15,12 +13,12 @@ namespace Tgstation.Server.Host.Configuration /// /// The name of the pipe opened by the host watchdog for sending commands, if any. /// - public string CommandPipe { get; set; } + public string? CommandPipe { get; set; } /// /// The name of the pipe opened by the host watchdog for receiving commands, if any. /// - public string ReadyPipe { get; set; } + public string? ReadyPipe { get; set; } /// /// If the server is running under SystemD. @@ -30,7 +28,7 @@ namespace Tgstation.Server.Host.Configuration /// /// The base path for the app settings configuration files. /// - public string AppSettingsBasePath { get; set; } + public string? AppSettingsBasePath { get; set; } /// /// Coerce the to select . @@ -40,6 +38,6 @@ namespace Tgstation.Server.Host.Configuration /// /// Generate default configuration using the given default password. /// - public string MariaDBDefaultRootPassword { get; set; } + public string? MariaDBDefaultRootPassword { get; set; } } } diff --git a/src/Tgstation.Server.Host/Core/CommandPipeManager.cs b/src/Tgstation.Server.Host/Core/CommandPipeManager.cs index fce8fa9ccd..298e6c28ca 100644 --- a/src/Tgstation.Server.Host/Core/CommandPipeManager.cs +++ b/src/Tgstation.Server.Host/Core/CommandPipeManager.cs @@ -65,22 +65,24 @@ namespace Tgstation.Server.Host.Core logger.LogTrace("Starting..."); // grab both pipes asap so we can close them on error - var supportsPipeCommands = !String.IsNullOrWhiteSpace(internalConfiguration.CommandPipe); + var commandPipe = internalConfiguration.CommandPipe; + var supportsPipeCommands = !String.IsNullOrWhiteSpace(commandPipe); await using var commandPipeClient = supportsPipeCommands ? new AnonymousPipeClientStream( PipeDirection.In, - internalConfiguration.CommandPipe) + commandPipe!) : null; if (!supportsPipeCommands) logger.LogDebug("No command pipe name specified in configuration"); - var supportsReadyNotification = !String.IsNullOrWhiteSpace(internalConfiguration.ReadyPipe); + var readyPipe = internalConfiguration.ReadyPipe; + var supportsReadyNotification = !String.IsNullOrWhiteSpace(readyPipe); if (supportsReadyNotification) { await using var readyPipeClient = new AnonymousPipeClientStream( PipeDirection.Out, - internalConfiguration.ReadyPipe); + readyPipe!); logger.LogTrace("Waiting to send ready notification..."); await instanceManager.Ready.WaitAsync(cancellationToken); From a143006c8a498efc6f5063e443bfcc9d53b601e9 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 23 Nov 2023 19:09:17 -0500 Subject: [PATCH 023/425] Nullify `OAuthConfiguration` --- .../Configuration/OAuthConfiguration.cs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/Tgstation.Server.Host/Configuration/OAuthConfiguration.cs b/src/Tgstation.Server.Host/Configuration/OAuthConfiguration.cs index ae1005b00e..2d4c781102 100644 --- a/src/Tgstation.Server.Host/Configuration/OAuthConfiguration.cs +++ b/src/Tgstation.Server.Host/Configuration/OAuthConfiguration.cs @@ -1,7 +1,5 @@ using System; -#nullable disable - namespace Tgstation.Server.Host.Configuration { /// @@ -12,16 +10,16 @@ namespace Tgstation.Server.Host.Configuration /// /// The client redirect URL. Not used by all providers. /// - public Uri ServerUrl { get; set; } + public Uri? ServerUrl { get; set; } /// /// The authentication server URL. Not used by all providers. /// - public Uri RedirectUrl { get; set; } + public Uri? RedirectUrl { get; set; } /// /// User information URL override. Not supported by the provider. /// - public Uri UserInformationUrlOverride { get; set; } + public Uri? UserInformationUrlOverride { get; set; } } } From 37267c0cf82f6aa95840fac36719ce971c556b49 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 23 Nov 2023 19:10:11 -0500 Subject: [PATCH 024/425] Nullify `OAuthConfigurationBase` --- .../Configuration/OAuthConfigurationBase.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Tgstation.Server.Host/Configuration/OAuthConfigurationBase.cs b/src/Tgstation.Server.Host/Configuration/OAuthConfigurationBase.cs index ab77c0fcbc..a170cd235f 100644 --- a/src/Tgstation.Server.Host/Configuration/OAuthConfigurationBase.cs +++ b/src/Tgstation.Server.Host/Configuration/OAuthConfigurationBase.cs @@ -1,7 +1,5 @@ using System; -#nullable disable - namespace Tgstation.Server.Host.Configuration { /// @@ -12,12 +10,12 @@ namespace Tgstation.Server.Host.Configuration /// /// The client ID. /// - public string ClientId { get; set; } + public string? ClientId { get; set; } /// /// The client secret. /// - public string ClientSecret { get; set; } + public string? ClientSecret { get; set; } /// /// Initializes a new instance of the class. From ce1ff919a927c6c16f36f8e582d25dd784d37975 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 23 Nov 2023 19:12:15 -0500 Subject: [PATCH 025/425] Nullify `SecurityConfiguration` Fix a `NullReferenceException` --- .../Configuration/SecurityConfiguration.cs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/Tgstation.Server.Host/Configuration/SecurityConfiguration.cs b/src/Tgstation.Server.Host/Configuration/SecurityConfiguration.cs index f6df85278c..35585612c0 100644 --- a/src/Tgstation.Server.Host/Configuration/SecurityConfiguration.cs +++ b/src/Tgstation.Server.Host/Configuration/SecurityConfiguration.cs @@ -5,8 +5,6 @@ using Swashbuckle.AspNetCore.SwaggerGen; using Tgstation.Server.Api.Models; -#nullable disable - namespace Tgstation.Server.Host.Configuration { /// @@ -62,12 +60,12 @@ namespace Tgstation.Server.Host.Configuration /// /// A custom token signing key. Overrides . /// - public string CustomTokenSigningKeyBase64 { get; set; } + public string? CustomTokenSigningKeyBase64 { get; set; } /// /// OAuth provider settings. /// - public IDictionary OAuth + public IDictionary? OAuth { get => oAuth; set @@ -75,10 +73,10 @@ namespace Tgstation.Server.Host.Configuration // Workaround for https://github.com/dotnet/runtime/issues/89547 var publicProperties = typeof(OAuthConfiguration) .GetProperties() - .Where(property => property.CanWrite && property.SetMethod.IsPublic) + .Where(property => property.CanWrite && property.SetMethod!.IsPublic) .ToList(); oAuth = value - .Where( + ?.Where( kvp => !publicProperties.All( prop => prop.GetValue(kvp.Value) == prop.PropertyType.GetDefaultValue())) .ToDictionary(kvp => kvp.Key, kvp => kvp.Value); @@ -88,6 +86,6 @@ namespace Tgstation.Server.Host.Configuration /// /// Backing field for . /// - IDictionary oAuth; + IDictionary? oAuth; } } From e62f42c228a8f6f85abfbd6282c7e9da4410fedd Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 23 Nov 2023 19:13:15 -0500 Subject: [PATCH 026/425] Nullify `SwarmConfiguration` --- .../Configuration/SwarmConfiguration.cs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/Tgstation.Server.Host/Configuration/SwarmConfiguration.cs b/src/Tgstation.Server.Host/Configuration/SwarmConfiguration.cs index 417203bd1b..12c9cf25a0 100644 --- a/src/Tgstation.Server.Host/Configuration/SwarmConfiguration.cs +++ b/src/Tgstation.Server.Host/Configuration/SwarmConfiguration.cs @@ -1,9 +1,8 @@ using System; using Tgstation.Server.Api.Models.Internal; -using YamlDotNet.Serialization; -#nullable disable +using YamlDotNet.Serialization; namespace Tgstation.Server.Host.Configuration { @@ -19,7 +18,7 @@ namespace Tgstation.Server.Host.Configuration /// [YamlMember(SerializeAs = typeof(string))] - public override Uri Address + public override Uri? Address { get => base.Address; set => base.Address = value; @@ -27,7 +26,7 @@ namespace Tgstation.Server.Host.Configuration /// [YamlMember(SerializeAs = typeof(string))] - public override Uri PublicAddress + public override Uri? PublicAddress { get => base.PublicAddress; set => base.PublicAddress = value; @@ -37,12 +36,12 @@ namespace Tgstation.Server.Host.Configuration /// The of the swarm controller. If , the current server is considered the controller. /// [YamlMember(SerializeAs = typeof(string))] - public Uri ControllerAddress { get; set; } + public Uri? ControllerAddress { get; set; } /// /// The private key used for swarm communication. /// - public string PrivateKey { get; set; } + public string? PrivateKey { get; set; } /// /// The number of nodes in addition to the controller required to be connected a server swarm before performing an update. From 2251b11db9ea4a72d7d1c5d9c61872482fac93a0 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 23 Nov 2023 19:13:43 -0500 Subject: [PATCH 027/425] Nullify `UpdatesConfiguration` --- .../Configuration/UpdatesConfiguration.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Tgstation.Server.Host/Configuration/UpdatesConfiguration.cs b/src/Tgstation.Server.Host/Configuration/UpdatesConfiguration.cs index a8a4b6c932..af475412ee 100644 --- a/src/Tgstation.Server.Host/Configuration/UpdatesConfiguration.cs +++ b/src/Tgstation.Server.Host/Configuration/UpdatesConfiguration.cs @@ -1,7 +1,5 @@ using Tgstation.Server.Common; -#nullable disable - namespace Tgstation.Server.Host.Configuration { /// @@ -37,11 +35,11 @@ namespace Tgstation.Server.Host.Configuration /// /// Prefix before the of TGS published in git tags. /// - public string GitTagPrefix { get; set; } = DefaultGitTagPrefix; + public string? GitTagPrefix { get; set; } = DefaultGitTagPrefix; /// /// Asset package containing the new assembly in zip form. /// - public string UpdatePackageAssetName { get; set; } = DefaultUpdatePackageAssetName; + public string? UpdatePackageAssetName { get; set; } = DefaultUpdatePackageAssetName; } } From 6659a7282b842f49898e58ca0ef51e441230505d Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 23 Nov 2023 19:17:52 -0500 Subject: [PATCH 028/425] Nullify `AbstractHttpClientFactory` --- src/Tgstation.Server.Host/Utils/AbstractHttpClientFactory.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Utils/AbstractHttpClientFactory.cs b/src/Tgstation.Server.Host/Utils/AbstractHttpClientFactory.cs index 0bb43edf28..973551e1d4 100644 --- a/src/Tgstation.Server.Host/Utils/AbstractHttpClientFactory.cs +++ b/src/Tgstation.Server.Host/Utils/AbstractHttpClientFactory.cs @@ -6,8 +6,6 @@ using Microsoft.Extensions.Logging; using Tgstation.Server.Common.Http; using Tgstation.Server.Host.System; -#nullable disable - namespace Tgstation.Server.Host.Utils { /// From 474fc97c6d08c5f3335f77bb7fd75bf146898c58 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 23 Nov 2023 19:23:27 -0500 Subject: [PATCH 029/425] Nullify `ApiHeadersProvider` --- .../Utils/ApiHeadersProvider.cs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/Tgstation.Server.Host/Utils/ApiHeadersProvider.cs b/src/Tgstation.Server.Host/Utils/ApiHeadersProvider.cs index 95190dc500..1805d337c1 100644 --- a/src/Tgstation.Server.Host/Utils/ApiHeadersProvider.cs +++ b/src/Tgstation.Server.Host/Utils/ApiHeadersProvider.cs @@ -4,20 +4,18 @@ using Microsoft.AspNetCore.Http; using Tgstation.Server.Api; -#nullable disable - namespace Tgstation.Server.Host.Utils { /// sealed class ApiHeadersProvider : IApiHeadersProvider { /// - public ApiHeaders ApiHeaders => attemptedApiHeadersCreation + public ApiHeaders? ApiHeaders => attemptedApiHeadersCreation ? apiHeaders : CreateApiHeaders(false); /// - public HeadersException HeadersException { get; private set; } + public HeadersException? HeadersException { get; private set; } /// /// The for the . @@ -27,7 +25,7 @@ namespace Tgstation.Server.Host.Utils /// /// Backing field for . /// - ApiHeaders apiHeaders; + ApiHeaders? apiHeaders; /// /// If populating was previously attempted. @@ -44,14 +42,14 @@ namespace Tgstation.Server.Host.Utils } /// - public ApiHeaders CreateAuthlessHeaders() => CreateApiHeaders(true); + public ApiHeaders CreateAuthlessHeaders() => CreateApiHeaders(true)!; /// /// Attempt to parse from the , optionally populating the properties. /// /// If the error should be ignored and / should not be populated. /// A newly parsed or if was set and the parse failed. - ApiHeaders CreateApiHeaders(bool authless) + ApiHeaders? CreateApiHeaders(bool authless) { if (httpContextAccessor.HttpContext == null) throw new InvalidOperationException("httpContextAccessor has no HttpContext!"); From ad24b5729ea84635ba3bc51ff5bcee32a23e9184 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 23 Nov 2023 19:26:51 -0500 Subject: [PATCH 030/425] Nullify `AsyncDelayer` --- src/Tgstation.Server.Host/Utils/AsyncDelayer.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Utils/AsyncDelayer.cs b/src/Tgstation.Server.Host/Utils/AsyncDelayer.cs index a435e38e9e..79ffce1838 100644 --- a/src/Tgstation.Server.Host/Utils/AsyncDelayer.cs +++ b/src/Tgstation.Server.Host/Utils/AsyncDelayer.cs @@ -2,8 +2,6 @@ using System.Threading; using System.Threading.Tasks; -#nullable disable - namespace Tgstation.Server.Host.Utils { /// From c70d911994ce417a172cb1b9eabddb09b4d37fd5 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 23 Nov 2023 19:28:19 -0500 Subject: [PATCH 031/425] Nullify `FifoSemaphore` --- src/Tgstation.Server.Host/Utils/FifoSemaphore.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Tgstation.Server.Host/Utils/FifoSemaphore.cs b/src/Tgstation.Server.Host/Utils/FifoSemaphore.cs index 099eea7d37..0bb696680a 100644 --- a/src/Tgstation.Server.Host/Utils/FifoSemaphore.cs +++ b/src/Tgstation.Server.Host/Utils/FifoSemaphore.cs @@ -3,8 +3,6 @@ using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; -#nullable disable - namespace Tgstation.Server.Host.Utils { /// @@ -53,7 +51,7 @@ namespace Tgstation.Server.Host.Utils /// A resulting in the locked . public async ValueTask Lock(CancellationToken cancellationToken) { - FifoSemaphoreTicket ticket = null; + FifoSemaphoreTicket? ticket = null; using (cancellationToken.Register( () => { @@ -65,7 +63,7 @@ namespace Tgstation.Server.Host.Utils var context = await SemaphoreSlimContext.Lock(semaphore, cancellationToken); try { - FifoSemaphoreTicket peekedTicket = null; + FifoSemaphoreTicket? peekedTicket = null; while (ticketQueue.Count > 0) { peekedTicket = ticketQueue.Peek(); From c007c24a91b412917128cfbd268c3e34e68f8994 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 23 Nov 2023 19:29:03 -0500 Subject: [PATCH 032/425] Nullify `IApiHeadersProvider` --- src/Tgstation.Server.Host/Utils/IApiHeadersProvider.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Tgstation.Server.Host/Utils/IApiHeadersProvider.cs b/src/Tgstation.Server.Host/Utils/IApiHeadersProvider.cs index ea58c98199..bf3aa714bf 100644 --- a/src/Tgstation.Server.Host/Utils/IApiHeadersProvider.cs +++ b/src/Tgstation.Server.Host/Utils/IApiHeadersProvider.cs @@ -1,7 +1,5 @@ using Tgstation.Server.Api; -#nullable disable - namespace Tgstation.Server.Host.Utils { /// @@ -12,12 +10,12 @@ namespace Tgstation.Server.Host.Utils /// /// The created , if any. /// - ApiHeaders ApiHeaders { get; } + ApiHeaders? ApiHeaders { get; } /// /// The thrown when attempting to parse the if any. /// - HeadersException HeadersException { get; } + HeadersException? HeadersException { get; } /// /// Attempt to create without checking for the presence of an header. From a88c55be4970d25a729e51488fcbde871102b3ea Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 23 Nov 2023 19:29:13 -0500 Subject: [PATCH 033/425] Nullify `IAsyncDelayer` --- src/Tgstation.Server.Host/Utils/IAsyncDelayer.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Utils/IAsyncDelayer.cs b/src/Tgstation.Server.Host/Utils/IAsyncDelayer.cs index 38e738f5a2..d47c5cbc62 100644 --- a/src/Tgstation.Server.Host/Utils/IAsyncDelayer.cs +++ b/src/Tgstation.Server.Host/Utils/IAsyncDelayer.cs @@ -2,8 +2,6 @@ using System.Threading; using System.Threading.Tasks; -#nullable disable - namespace Tgstation.Server.Host.Utils { /// From e964606589125849533b4df63e98c13b210bf73f Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 23 Nov 2023 19:29:26 -0500 Subject: [PATCH 034/425] Nullify `IPortAllocator` --- src/Tgstation.Server.Host/Utils/IPortAllocator.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Utils/IPortAllocator.cs b/src/Tgstation.Server.Host/Utils/IPortAllocator.cs index 92a0f480b2..29d234ec62 100644 --- a/src/Tgstation.Server.Host/Utils/IPortAllocator.cs +++ b/src/Tgstation.Server.Host/Utils/IPortAllocator.cs @@ -1,8 +1,6 @@ using System.Threading; using System.Threading.Tasks; -#nullable disable - namespace Tgstation.Server.Host.Utils { /// From 0ebb0b1ee68e4f42a416f8a753277276cbaac733 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 23 Nov 2023 19:31:19 -0500 Subject: [PATCH 035/425] Nullify `OpenApiEnumVarNamesExtension` --- .../Utils/OpenApiEnumVarNamesExtension.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Tgstation.Server.Host/Utils/OpenApiEnumVarNamesExtension.cs b/src/Tgstation.Server.Host/Utils/OpenApiEnumVarNamesExtension.cs index 75c71c7561..6953cc6480 100644 --- a/src/Tgstation.Server.Host/Utils/OpenApiEnumVarNamesExtension.cs +++ b/src/Tgstation.Server.Host/Utils/OpenApiEnumVarNamesExtension.cs @@ -5,8 +5,6 @@ using Microsoft.OpenApi.Interfaces; using Microsoft.OpenApi.Models; using Microsoft.OpenApi.Writers; -#nullable disable - namespace Tgstation.Server.Host.Utils { /// @@ -51,8 +49,8 @@ namespace Tgstation.Server.Host.Utils writer.WriteStartArray(); foreach (var enumValue in Enum.GetValues(enumType)) { - var enumName = enumValue.ToString(); - var field = enumType.GetField(enumName); + var enumName = enumValue.ToString()!; + var field = enumType.GetField(enumName)!; if (field.IsDefined(typeof(ObsoleteAttribute), false)) enumName = $"DEPRECATED_{enumName}"; From 260c89bb09b213bd49f5955da53897cb4f9ada23 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 23 Nov 2023 19:31:42 -0500 Subject: [PATCH 036/425] Nullify `PortAllocator` --- src/Tgstation.Server.Host/Utils/PortAllocator.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Utils/PortAllocator.cs b/src/Tgstation.Server.Host/Utils/PortAllocator.cs index 546668e8d2..310cfbfe3d 100644 --- a/src/Tgstation.Server.Host/Utils/PortAllocator.cs +++ b/src/Tgstation.Server.Host/Utils/PortAllocator.cs @@ -14,8 +14,6 @@ using Tgstation.Server.Host.Database; using Tgstation.Server.Host.Extensions; using Tgstation.Server.Host.System; -#nullable disable - namespace Tgstation.Server.Host.Utils { /// From 55acf36edf022691d2ddf4747713a12c0b95dd59 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 23 Nov 2023 19:34:59 -0500 Subject: [PATCH 037/425] Nullify `ReferenceCounter` --- src/Tgstation.Server.Host/Utils/ReferenceCounter.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Tgstation.Server.Host/Utils/ReferenceCounter.cs b/src/Tgstation.Server.Host/Utils/ReferenceCounter.cs index 19f8408eed..6377c0295f 100644 --- a/src/Tgstation.Server.Host/Utils/ReferenceCounter.cs +++ b/src/Tgstation.Server.Host/Utils/ReferenceCounter.cs @@ -1,7 +1,5 @@ using System; -#nullable disable - namespace Tgstation.Server.Host.Utils { /// @@ -24,12 +22,12 @@ namespace Tgstation.Server.Host.Utils /// /// Backing field for . /// - TInstance actualInstance; + TInstance? actualInstance; /// /// The to take when is called. /// - Action referenceCleanupAction; + Action? referenceCleanupAction; /// /// If the was initialized. From bcd875e606e45f74db32005507e35ae927d84a34 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 23 Nov 2023 19:37:09 -0500 Subject: [PATCH 038/425] Nullify `ReferenceCountingContainer` --- .../Utils/ReferenceCountingContainer.cs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/Tgstation.Server.Host/Utils/ReferenceCountingContainer.cs b/src/Tgstation.Server.Host/Utils/ReferenceCountingContainer.cs index 2389435a6f..798fc2d16b 100644 --- a/src/Tgstation.Server.Host/Utils/ReferenceCountingContainer.cs +++ b/src/Tgstation.Server.Host/Utils/ReferenceCountingContainer.cs @@ -1,8 +1,6 @@ using System; using System.Threading.Tasks; -#nullable disable - namespace Tgstation.Server.Host.Utils { /// @@ -30,7 +28,7 @@ namespace Tgstation.Server.Host.Utils { if (referenceCount == 0) return Task.CompletedTask; - return onZeroReferencesTcs.Task; + return onZeroReferencesTcs!.Task; } } } @@ -43,7 +41,7 @@ namespace Tgstation.Server.Host.Utils /// /// Backing for . /// - TaskCompletionSource onZeroReferencesTcs; + TaskCompletionSource? onZeroReferencesTcs; /// /// Count of active s. @@ -79,7 +77,7 @@ namespace Tgstation.Server.Host.Utils { lock (referenceCountLock) if (--referenceCount == 0) - onZeroReferencesTcs.SetResult(); + onZeroReferencesTcs!.SetResult(); }); return reference; } From b191d0a0c95608b09efb39e87cdddc3ce215c142 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 23 Nov 2023 19:37:35 -0500 Subject: [PATCH 039/425] Nullify `SemaphoreSlimContext` --- src/Tgstation.Server.Host/Utils/SemaphoreSlimContext.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Tgstation.Server.Host/Utils/SemaphoreSlimContext.cs b/src/Tgstation.Server.Host/Utils/SemaphoreSlimContext.cs index 4339515859..e9a40d7c68 100644 --- a/src/Tgstation.Server.Host/Utils/SemaphoreSlimContext.cs +++ b/src/Tgstation.Server.Host/Utils/SemaphoreSlimContext.cs @@ -2,8 +2,6 @@ using System.Threading; using System.Threading.Tasks; -#nullable disable - namespace Tgstation.Server.Host.Utils { /// @@ -30,7 +28,7 @@ namespace Tgstation.Server.Host.Utils /// The to lock. /// The result of the lock attempt. /// A for the lock on success, or if it was not acquired. - public static SemaphoreSlimContext TryLock(SemaphoreSlim semaphore, out bool locked) + public static SemaphoreSlimContext? TryLock(SemaphoreSlim semaphore, out bool locked) { ArgumentNullException.ThrowIfNull(semaphore); locked = semaphore.Wait(TimeSpan.Zero); From 7cd4af72b79204ffe07224a46a5a7238236194f9 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 23 Nov 2023 19:38:41 -0500 Subject: [PATCH 040/425] Nullify `SwaggerConfiguration` --- src/Tgstation.Server.Host/Utils/SwaggerConfiguration.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Tgstation.Server.Host/Utils/SwaggerConfiguration.cs b/src/Tgstation.Server.Host/Utils/SwaggerConfiguration.cs index aeaa86db10..a700ccc9cb 100644 --- a/src/Tgstation.Server.Host/Utils/SwaggerConfiguration.cs +++ b/src/Tgstation.Server.Host/Utils/SwaggerConfiguration.cs @@ -20,8 +20,6 @@ using Tgstation.Server.Common.Extensions; using Tgstation.Server.Host.Controllers; using Tgstation.Server.Host.Security; -#nullable disable - namespace Tgstation.Server.Host.Utils { /// @@ -347,7 +345,7 @@ namespace Tgstation.Server.Host.Utils ArgumentNullException.ThrowIfNull(operation); ArgumentNullException.ThrowIfNull(context); - operation.OperationId = $"{context.MethodInfo.DeclaringType.Name}.{context.MethodInfo.Name}"; + operation.OperationId = $"{context.MethodInfo.DeclaringType!.Name}.{context.MethodInfo.Name}"; var authAttributes = context .MethodInfo From 5874475e5991d60c187a47d9f450697196dd4767 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 23 Nov 2023 19:54:11 -0500 Subject: [PATCH 041/425] Add `.Require` Model extension --- .../Models/ModelExtensions.cs | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 src/Tgstation.Server.Host/Models/ModelExtensions.cs diff --git a/src/Tgstation.Server.Host/Models/ModelExtensions.cs b/src/Tgstation.Server.Host/Models/ModelExtensions.cs new file mode 100644 index 0000000000..0c88a1ab07 --- /dev/null +++ b/src/Tgstation.Server.Host/Models/ModelExtensions.cs @@ -0,0 +1,40 @@ +using System; +using System.Linq.Expressions; +using System.Reflection; + +using Tgstation.Server.Api.Models; + +namespace Tgstation.Server.Host.Models +{ + /// + /// Extensions for . + /// + static class ModelExtensions + { + /// + /// Require a given property of a given be non-. + /// + /// The of the being accessed. + /// The of the property being accessed. + /// The . + /// The access . + /// The value of in . + /// When in is . + public static TProperty Require(this TModel model, Expression> accessor) + where TModel : EntityId + where TProperty : struct + { + ArgumentNullException.ThrowIfNull(model); + ArgumentNullException.ThrowIfNull(accessor); + + var memberSelectorExpression = (MemberExpression)accessor.Body; + var property = (PropertyInfo)memberSelectorExpression.Member; + + var nullableValue = (TProperty?)property.GetValue(model); + if (!nullableValue.HasValue) + throw new InvalidOperationException($"Expected {model.GetType().Name}.{property.Name} to be set here!"); + + return nullableValue.Value; + } + } +} From 874e012f1b7da66f8b4fe6d4ffcdc416490e0f07 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 23 Nov 2023 19:54:26 -0500 Subject: [PATCH 042/425] Nullify `ComprehensiveHubContext` --- .../Utils/SignalR/ComprehensiveHubContext.cs | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/Tgstation.Server.Host/Utils/SignalR/ComprehensiveHubContext.cs b/src/Tgstation.Server.Host/Utils/SignalR/ComprehensiveHubContext.cs index 27d842c3e1..d9c32143ce 100644 --- a/src/Tgstation.Server.Host/Utils/SignalR/ComprehensiveHubContext.cs +++ b/src/Tgstation.Server.Host/Utils/SignalR/ComprehensiveHubContext.cs @@ -11,8 +11,6 @@ using Microsoft.Extensions.Logging; using Tgstation.Server.Host.Models; using Tgstation.Server.Host.Security; -#nullable disable - namespace Tgstation.Server.Host.Utils.SignalR { /// @@ -46,7 +44,7 @@ namespace Tgstation.Server.Host.Utils.SignalR readonly ConcurrentDictionary> userConnections; /// - public event Func, Task>, CancellationToken, ValueTask> OnConnectionMapGroups; + public event Func, Task>, CancellationToken, ValueTask>? OnConnectionMapGroups; /// /// Initializes a new instance of the class. @@ -67,7 +65,7 @@ namespace Tgstation.Server.Host.Utils.SignalR public List UserConnectionIds(User user) { ArgumentNullException.ThrowIfNull(user); - var connectionIds = userConnections.GetOrAdd(user.Id.Value, _ => new Dictionary()); + var connectionIds = userConnections.GetOrAdd(user.Require(x => x.Id), _ => new Dictionary()); lock (connectionIds) return connectionIds.Keys.ToList(); } @@ -78,7 +76,7 @@ namespace Tgstation.Server.Host.Utils.SignalR ArgumentNullException.ThrowIfNull(authenticationContext); ArgumentNullException.ThrowIfNull(hub); - var userId = authenticationContext.User.Id.Value; + var userId = authenticationContext.User.Require(x => x.Id); var context = hub.Context; logger.LogTrace( "Mapping user {userId} to hub connection ID: {connectionId}", @@ -131,11 +129,12 @@ namespace Tgstation.Server.Host.Utils.SignalR public void AbortUnauthedConnections(User user) { ArgumentNullException.ThrowIfNull(user); - logger.LogTrace("NotifyAndAbortUnauthedConnections. UID {userId}", user.Id.Value); + var uid = user.Require(x => x.Id); + logger.LogTrace("NotifyAndAbortUnauthedConnections. UID {userId}", uid); - List connections = null; + List? connections = null; userConnections.AddOrUpdate( - user.Id.Value, + uid, _ => new Dictionary(), (_, old) => { @@ -148,7 +147,7 @@ namespace Tgstation.Server.Host.Utils.SignalR return old; }); - foreach (var context in connections) + foreach (var context in connections!) context.Abort(); } } From f1256bc7305af1b1ae9cb37afda1c7485b75f7fc Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 23 Nov 2023 19:55:01 -0500 Subject: [PATCH 043/425] Nullify `ConnectionMappingHub` --- .../Utils/SignalR/ConnectionMappingHub.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Tgstation.Server.Host/Utils/SignalR/ConnectionMappingHub.cs b/src/Tgstation.Server.Host/Utils/SignalR/ConnectionMappingHub.cs index 8684901820..80e89089fa 100644 --- a/src/Tgstation.Server.Host/Utils/SignalR/ConnectionMappingHub.cs +++ b/src/Tgstation.Server.Host/Utils/SignalR/ConnectionMappingHub.cs @@ -6,8 +6,6 @@ using Microsoft.AspNetCore.SignalR; using Tgstation.Server.Host.Security; -#nullable disable - namespace Tgstation.Server.Host.Utils.SignalR { /// @@ -52,7 +50,7 @@ namespace Tgstation.Server.Host.Utils.SignalR /// [AllowAnonymous] - public override Task OnDisconnectedAsync(Exception exception) + public override Task OnDisconnectedAsync(Exception? exception) { connectionMapper.UserDisconnected(Context.ConnectionId); return base.OnDisconnectedAsync(exception); From fc53e3cf67b1fc264f60af5efa65ea9f32169b16 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 23 Nov 2023 19:55:24 -0500 Subject: [PATCH 044/425] Nullify `IConnectionMappedHubContext` --- .../Utils/SignalR/IConnectionMappedHubContext.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Utils/SignalR/IConnectionMappedHubContext.cs b/src/Tgstation.Server.Host/Utils/SignalR/IConnectionMappedHubContext.cs index bdf89de277..101e8e599e 100644 --- a/src/Tgstation.Server.Host/Utils/SignalR/IConnectionMappedHubContext.cs +++ b/src/Tgstation.Server.Host/Utils/SignalR/IConnectionMappedHubContext.cs @@ -8,8 +8,6 @@ using Microsoft.AspNetCore.SignalR; using Tgstation.Server.Host.Models; using Tgstation.Server.Host.Security; -#nullable disable - namespace Tgstation.Server.Host.Utils.SignalR { /// From e8d45282a8700412029be9333a1a3270a1a43979 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 23 Nov 2023 19:55:41 -0500 Subject: [PATCH 045/425] Nullify `IHubConnectionMapper` --- src/Tgstation.Server.Host/Utils/SignalR/IHubConnectionMapper.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Utils/SignalR/IHubConnectionMapper.cs b/src/Tgstation.Server.Host/Utils/SignalR/IHubConnectionMapper.cs index 8163a737e4..4521c87fcc 100644 --- a/src/Tgstation.Server.Host/Utils/SignalR/IHubConnectionMapper.cs +++ b/src/Tgstation.Server.Host/Utils/SignalR/IHubConnectionMapper.cs @@ -6,8 +6,6 @@ using Microsoft.AspNetCore.SignalR; using Tgstation.Server.Host.Models; using Tgstation.Server.Host.Security; -#nullable disable - namespace Tgstation.Server.Host.Utils.SignalR { /// From 808ccc66433bb4842a7f314ca776bdc731e7d188 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 23 Nov 2023 20:07:46 -0500 Subject: [PATCH 046/425] Nullify `GitHubClientFactory` --- .../Utils/GitHub/GitHubClientFactory.cs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/Tgstation.Server.Host/Utils/GitHub/GitHubClientFactory.cs b/src/Tgstation.Server.Host/Utils/GitHub/GitHubClientFactory.cs index 40f76ecb57..e479388b79 100644 --- a/src/Tgstation.Server.Host/Utils/GitHub/GitHubClientFactory.cs +++ b/src/Tgstation.Server.Host/Utils/GitHub/GitHubClientFactory.cs @@ -9,8 +9,6 @@ using Octokit; using Tgstation.Server.Host.Configuration; using Tgstation.Server.Host.System; -#nullable disable - namespace Tgstation.Server.Host.Utils.GitHub { /// @@ -78,7 +76,7 @@ namespace Tgstation.Server.Host.Utils.GitHub /// /// Optional access token to use as credentials. /// The for the given . - GitHubClient GetOrCreateClient(string accessToken) + GitHubClient GetOrCreateClient(string? accessToken) { GitHubClient client; bool cacheHit; @@ -99,10 +97,11 @@ namespace Tgstation.Server.Host.Utils.GitHub var now = DateTimeOffset.UtcNow; if (!cacheHit) { + var product = assemblyInformationProvider.ProductInfoHeaderValue.Product!; client = new GitHubClient( new ProductHeaderValue( - assemblyInformationProvider.ProductInfoHeaderValue.Product.Name, - assemblyInformationProvider.ProductInfoHeaderValue.Product.Version)); + product.Name, + product.Version)); if (accessToken != null) client.Credentials = new Credentials(accessToken); From 0ee812a833887d0acb2f711d68571f92ad3aa766 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 23 Nov 2023 20:12:25 -0500 Subject: [PATCH 047/425] Nullify `GitHubService` --- .../Utils/GitHub/GitHubService.cs | 50 +++++++++---------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/src/Tgstation.Server.Host/Utils/GitHub/GitHubService.cs b/src/Tgstation.Server.Host/Utils/GitHub/GitHubService.cs index 4e95f01820..a56c956ebf 100644 --- a/src/Tgstation.Server.Host/Utils/GitHub/GitHubService.cs +++ b/src/Tgstation.Server.Host/Utils/GitHub/GitHubService.cs @@ -10,8 +10,6 @@ using Octokit; using Tgstation.Server.Host.Configuration; -#nullable disable - namespace Tgstation.Server.Host.Utils.GitHub { /// @@ -82,36 +80,38 @@ namespace Tgstation.Server.Host.Utils.GitHub .GetAll(updatesConfiguration.GitHubRepositoryId) .WaitAsync(cancellationToken); + var gitPrefix = updatesConfiguration.GitTagPrefix ?? String.Empty; + logger.LogTrace("{totalReleases} total releases", allReleases.Count); - var releases = allReleases - .Where(release => + var releases = allReleases! + .Where(release => + { + if (!release.PublishedAt.HasValue) { - if (!release.PublishedAt.HasValue) - { - logger.LogDebug("Release tag without PublishedAt: {releaseTag}", release.TagName); - return false; - } + logger.LogDebug("Release tag without PublishedAt: {releaseTag}", release.TagName); + return false; + } - if (!release.TagName.StartsWith(updatesConfiguration.GitTagPrefix, StringComparison.InvariantCulture)) - return false; + if (!release.TagName.StartsWith(gitPrefix, StringComparison.InvariantCulture)) + return false; - return true; - }) - .GroupBy(release => + return true; + }) + .GroupBy(release => + { + if (!Version.TryParse(release.TagName.Replace(gitPrefix, String.Empty, StringComparison.Ordinal), out var version)) { - if (!Version.TryParse(release.TagName.Replace(updatesConfiguration.GitTagPrefix, String.Empty, StringComparison.Ordinal), out var version)) - { - logger.LogDebug("Unparsable release tag: {releaseTag}", release.TagName); - return null; - } + logger.LogDebug("Unparsable release tag: {releaseTag}", release.TagName); + return null; + } - return version; - }) - .Where(grouping => grouping.Key != null) + return version; + }) + .Where(grouping => grouping.Key != null) - // GitHub can return the same result twice or some other nonsense - .Select(grouping => Tuple.Create(grouping.Key, grouping.OrderBy(x => x.PublishedAt.Value).First())) - .ToDictionary(tuple => tuple.Item1, tuple => tuple.Item2); + // GitHub can return the same result twice or some other nonsense + .Select(grouping => Tuple.Create(grouping.Key!, grouping.OrderBy(x => x.PublishedAt ?? DateTimeOffset.MinValue).First())) + .ToDictionary(tuple => tuple.Item1, tuple => tuple.Item2); logger.LogTrace("{parsedReleases} parsed releases", releases.Count); return releases; From 0bffaea6dbeff246be4804d6b286fc1eccdd951d Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 23 Nov 2023 20:12:47 -0500 Subject: [PATCH 048/425] Nullify `GitHubServiceFactory` --- src/Tgstation.Server.Host/Utils/GitHub/GitHubServiceFactory.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Utils/GitHub/GitHubServiceFactory.cs b/src/Tgstation.Server.Host/Utils/GitHub/GitHubServiceFactory.cs index adb8d32c47..efa08d13bb 100644 --- a/src/Tgstation.Server.Host/Utils/GitHub/GitHubServiceFactory.cs +++ b/src/Tgstation.Server.Host/Utils/GitHub/GitHubServiceFactory.cs @@ -7,8 +7,6 @@ using Octokit; using Tgstation.Server.Host.Configuration; -#nullable disable - namespace Tgstation.Server.Host.Utils.GitHub { /// From 707766a934316c119d13feded060a03f434446f7 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 23 Nov 2023 20:13:07 -0500 Subject: [PATCH 049/425] Nullify `IAuthenticatedGitHubService` --- .../Utils/GitHub/IAuthenticatedGitHubService.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Utils/GitHub/IAuthenticatedGitHubService.cs b/src/Tgstation.Server.Host/Utils/GitHub/IAuthenticatedGitHubService.cs index 046ef67e77..619bcead20 100644 --- a/src/Tgstation.Server.Host/Utils/GitHub/IAuthenticatedGitHubService.cs +++ b/src/Tgstation.Server.Host/Utils/GitHub/IAuthenticatedGitHubService.cs @@ -3,8 +3,6 @@ using System.Threading.Tasks; using Octokit; -#nullable disable - namespace Tgstation.Server.Host.Utils.GitHub { /// From d07f5b4cd79be1fbb5456624c99377eae8abad39 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 23 Nov 2023 20:13:32 -0500 Subject: [PATCH 050/425] Nullify `IGitHubClientFactory` --- src/Tgstation.Server.Host/Utils/GitHub/IGitHubClientFactory.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Utils/GitHub/IGitHubClientFactory.cs b/src/Tgstation.Server.Host/Utils/GitHub/IGitHubClientFactory.cs index 8ffea0fbd2..ec95fd16ab 100644 --- a/src/Tgstation.Server.Host/Utils/GitHub/IGitHubClientFactory.cs +++ b/src/Tgstation.Server.Host/Utils/GitHub/IGitHubClientFactory.cs @@ -1,7 +1,5 @@ using Octokit; -#nullable disable - namespace Tgstation.Server.Host.Utils.GitHub { /// From 090dd825942c44ccd315711f2c6e9435736bee25 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 23 Nov 2023 20:14:02 -0500 Subject: [PATCH 051/425] Nullify `IGitHubService` --- src/Tgstation.Server.Host/Utils/GitHub/IGitHubService.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Utils/GitHub/IGitHubService.cs b/src/Tgstation.Server.Host/Utils/GitHub/IGitHubService.cs index b7bda78b31..e2f338d77a 100644 --- a/src/Tgstation.Server.Host/Utils/GitHub/IGitHubService.cs +++ b/src/Tgstation.Server.Host/Utils/GitHub/IGitHubService.cs @@ -7,8 +7,6 @@ using Octokit; using Tgstation.Server.Host.Configuration; -#nullable disable - namespace Tgstation.Server.Host.Utils.GitHub { /// From a310fd8ec9041096d61b5c8461706574e2611a7b Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 23 Nov 2023 20:16:31 -0500 Subject: [PATCH 052/425] Nullify `FileDownloadProvider` --- src/Tgstation.Server.Host/Transfer/FileDownloadProvider.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Tgstation.Server.Host/Transfer/FileDownloadProvider.cs b/src/Tgstation.Server.Host/Transfer/FileDownloadProvider.cs index eee92cce02..1b0428665a 100644 --- a/src/Tgstation.Server.Host/Transfer/FileDownloadProvider.cs +++ b/src/Tgstation.Server.Host/Transfer/FileDownloadProvider.cs @@ -5,8 +5,6 @@ using System.Threading.Tasks; using Tgstation.Server.Api.Models; -#nullable disable - namespace Tgstation.Server.Host.Transfer { /// @@ -22,7 +20,7 @@ namespace Tgstation.Server.Host.Transfer /// /// A to specially provide a returning the of the file download. The caller will own the resulting . /// - public Func> StreamProvider { get; } + public Func>? StreamProvider { get; } /// /// The full path to the file on disk to download. @@ -43,7 +41,7 @@ namespace Tgstation.Server.Host.Transfer /// The value of . public FileDownloadProvider( Func activationCallback, - Func> streamProvider, + Func>? streamProvider, string filePath, bool shareWrite) { From dffe0d1d0880e901f21d07a0924af1c96b304ebe Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 23 Nov 2023 20:24:23 -0500 Subject: [PATCH 053/425] Nullify `FileTransferService` --- .../Transfer/FileTransferService.cs | 95 +++++++++++-------- .../Transfer/IFileTransferStreamHandler.cs | 12 +-- 2 files changed, 59 insertions(+), 48 deletions(-) diff --git a/src/Tgstation.Server.Host/Transfer/FileTransferService.cs b/src/Tgstation.Server.Host/Transfer/FileTransferService.cs index cbdc528480..bb1cafa171 100644 --- a/src/Tgstation.Server.Host/Transfer/FileTransferService.cs +++ b/src/Tgstation.Server.Host/Transfer/FileTransferService.cs @@ -12,8 +12,6 @@ using Tgstation.Server.Host.IO; using Tgstation.Server.Host.Security; using Tgstation.Server.Host.Utils; -#nullable disable - namespace Tgstation.Server.Host.Transfer { /// @@ -71,6 +69,11 @@ namespace Tgstation.Server.Host.Transfer /// Task expireTask; + /// + /// If the is disposed. + /// + bool disposed; + /// /// Initializes a new instance of the class. /// @@ -103,12 +106,13 @@ namespace Tgstation.Server.Host.Transfer { Task toAwait; lock (synchronizationLock) - if (expireTask != null) + if (!disposed) { disposeCts.Cancel(); disposeCts.Dispose(); + disposed = true; toAwait = expireTask; - expireTask = null; + expireTask = Task.CompletedTask; } else toAwait = Task.CompletedTask; @@ -120,72 +124,86 @@ namespace Tgstation.Server.Host.Transfer public FileTicketResponse CreateDownload(FileDownloadProvider downloadProvider) { ArgumentNullException.ThrowIfNull(downloadProvider); + ObjectDisposedException.ThrowIf(disposed, this); logger.LogDebug("Creating download ticket for path {filePath}", downloadProvider.FilePath); - var ticketResult = CreateTicket(); + var ticket = cryptographySuite.GetSecureString(); lock (downloadTickets) - downloadTickets.Add(ticketResult.FileTicket, downloadProvider); + downloadTickets.Add(ticket, downloadProvider); QueueExpiry(() => { lock (downloadTickets) - if (downloadTickets.Remove(ticketResult.FileTicket)) - logger.LogTrace("Expired download ticket {ticket}...", ticketResult.FileTicket); + if (downloadTickets.Remove(ticket)) + logger.LogTrace("Expired download ticket {ticket}...", ticket); }); - logger.LogTrace("Created download ticket {ticket}", ticketResult.FileTicket); + logger.LogTrace("Created download ticket {ticket}", ticket); - return ticketResult; + return new FileTicketResponse + { + FileTicket = ticket, + }; } /// public IFileUploadTicket CreateUpload(FileUploadStreamKind streamKind) { + ObjectDisposedException.ThrowIf(disposed, this); + logger.LogDebug("Creating upload ticket..."); - var uploadTicket = new FileUploadProvider(CreateTicket(), streamKind); + var ticket = cryptographySuite.GetSecureString(); + var uploadTicket = new FileUploadProvider( + new FileTicketResponse + { + FileTicket = ticket, + }, + streamKind); lock (uploadTickets) - uploadTickets.Add(uploadTicket.Ticket.FileTicket, uploadTicket); + uploadTickets.Add(ticket, uploadTicket); QueueExpiry(() => { lock (uploadTickets) - if (uploadTickets.Remove(uploadTicket.Ticket.FileTicket)) - logger.LogTrace("Expired upload ticket {ticket}...", uploadTicket.Ticket.FileTicket); + if (uploadTickets.Remove(ticket)) + logger.LogTrace("Expired upload ticket {ticket}...", ticket); else return; uploadTicket.Expire(); }); - logger.LogTrace("Created upload ticket {ticket}", uploadTicket.Ticket.FileTicket); + logger.LogTrace("Created upload ticket {ticket}", ticket); return uploadTicket; } /// - public async ValueTask> RetrieveDownloadStream(FileTicketResponse ticket, CancellationToken cancellationToken) + public async ValueTask> RetrieveDownloadStream(FileTicketResponse ticketResponse, CancellationToken cancellationToken) { - ArgumentNullException.ThrowIfNull(ticket); + ArgumentNullException.ThrowIfNull(ticketResponse); + ObjectDisposedException.ThrowIf(disposed, this); - FileDownloadProvider downloadProvider; + var ticket = ticketResponse.FileTicket ?? throw new InvalidOperationException("ticketResponse must have FileTicket!"); + FileDownloadProvider? downloadProvider; lock (downloadTickets) { - if (!downloadTickets.TryGetValue(ticket.FileTicket, out downloadProvider)) + if (!downloadTickets.TryGetValue(ticket, out downloadProvider)) { - logger.LogTrace("Download ticket {ticket} not found!", ticket.FileTicket); - return Tuple.Create(null, null); + logger.LogTrace("Download ticket {ticket} not found!", ticket); + return Tuple.Create(null, null); } - downloadTickets.Remove(ticket.FileTicket); + downloadTickets.Remove(ticket); } var errorCode = downloadProvider.ActivationCallback(); if (errorCode.HasValue) { - logger.LogDebug("Download ticket {ticket} failed activation!", ticket.FileTicket); - return Tuple.Create(null, new ErrorMessageResponse(errorCode.Value)); + logger.LogDebug("Download ticket {ticket} failed activation!", ticket); + return Tuple.Create(null, new ErrorMessageResponse(errorCode.Value)); } Stream stream; @@ -198,7 +216,7 @@ namespace Tgstation.Server.Host.Transfer } catch (IOException ex) { - return Tuple.Create( + return Tuple.Create( null, new ErrorMessageResponse(ErrorCode.IOError) { @@ -208,8 +226,8 @@ namespace Tgstation.Server.Host.Transfer try { - logger.LogTrace("Ticket {ticket} downloading...", ticket.FileTicket); - return Tuple.Create(stream, null); + logger.LogTrace("Ticket {ticket} downloading...", ticket); + return Tuple.Create(stream, null); } catch { @@ -219,34 +237,27 @@ namespace Tgstation.Server.Host.Transfer } /// - public async ValueTask SetUploadStream(FileTicketResponse ticket, Stream stream, CancellationToken cancellationToken) + public async ValueTask SetUploadStream(FileTicketResponse ticketResponse, Stream stream, CancellationToken cancellationToken) { - ArgumentNullException.ThrowIfNull(ticket); + ArgumentNullException.ThrowIfNull(ticketResponse); + ObjectDisposedException.ThrowIf(disposed, this); - FileUploadProvider uploadProvider; + var ticket = ticketResponse.FileTicket ?? throw new InvalidOperationException("ticketResponse must have FileTicket!"); + FileUploadProvider? uploadProvider; lock (uploadTickets) { - if (!uploadTickets.TryGetValue(ticket.FileTicket, out uploadProvider)) + if (!uploadTickets.TryGetValue(ticket, out uploadProvider)) { - logger.LogTrace("Upload ticket {ticket} not found!", ticket.FileTicket); + logger.LogTrace("Upload ticket {ticket} not found!", ticket); return new ErrorMessageResponse(ErrorCode.ResourceNotPresent); } - uploadTickets.Remove(ticket.FileTicket); + uploadTickets.Remove(ticket); } return await uploadProvider.Completion(stream, cancellationToken); } - /// - /// Creates a new . - /// - /// A new . - FileTicketResponse CreateTicket() => new() - { - FileTicket = cryptographySuite.GetSecureString(), - }; - /// /// Queue an to run after . /// diff --git a/src/Tgstation.Server.Host/Transfer/IFileTransferStreamHandler.cs b/src/Tgstation.Server.Host/Transfer/IFileTransferStreamHandler.cs index f0ba7a396d..43ec027534 100644 --- a/src/Tgstation.Server.Host/Transfer/IFileTransferStreamHandler.cs +++ b/src/Tgstation.Server.Host/Transfer/IFileTransferStreamHandler.cs @@ -15,20 +15,20 @@ namespace Tgstation.Server.Host.Transfer public interface IFileTransferStreamHandler { /// - /// Sets the for a given associated with a pending upload. + /// Sets the for a given associated with a pending upload. /// - /// The . + /// The . /// The with uploaded data. /// The for the operation. /// A resulting in if the upload completed successfully, otherwise. - ValueTask SetUploadStream(FileTicketResponse ticket, Stream stream, CancellationToken cancellationToken); + ValueTask SetUploadStream(FileTicketResponse ticketResponse, Stream stream, CancellationToken cancellationToken); /// - /// Gets the the for a given associated with a pending download. + /// Gets the the for a given associated with a pending download. /// - /// The . + /// The . /// The for the operation. /// A resulting in a containing either a containing the data to download or an to return. - ValueTask> RetrieveDownloadStream(FileTicketResponse ticket, CancellationToken cancellationToken); + ValueTask> RetrieveDownloadStream(FileTicketResponse ticketResponse, CancellationToken cancellationToken); } } From 774315d3fd149e9b511892c8ec27a6eba330e194 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 23 Nov 2023 20:26:43 -0500 Subject: [PATCH 054/425] Nullify `FileUploadProvider` --- .../Transfer/FileUploadProvider.cs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/Tgstation.Server.Host/Transfer/FileUploadProvider.cs b/src/Tgstation.Server.Host/Transfer/FileUploadProvider.cs index 31a691b36a..db7965f545 100644 --- a/src/Tgstation.Server.Host/Transfer/FileUploadProvider.cs +++ b/src/Tgstation.Server.Host/Transfer/FileUploadProvider.cs @@ -9,8 +9,6 @@ using Tgstation.Server.Api.Models; using Tgstation.Server.Api.Models.Response; using Tgstation.Server.Host.IO; -#nullable disable - namespace Tgstation.Server.Host.Transfer { /// @@ -27,7 +25,7 @@ namespace Tgstation.Server.Host.Transfer /// /// The for the . /// - readonly TaskCompletionSource streamTcs; + readonly TaskCompletionSource streamTcs; /// /// The that completes in or when is called. @@ -42,7 +40,7 @@ namespace Tgstation.Server.Host.Transfer /// /// The that occurred while processing the upload if any. /// - ErrorMessageResponse errorMessage; + ErrorMessageResponse? errorMessage; /// /// Initializes a new instance of the class. @@ -54,7 +52,7 @@ namespace Tgstation.Server.Host.Transfer Ticket = ticket ?? throw new ArgumentNullException(nameof(ticket)); ticketExpiryCts = new CancellationTokenSource(); - streamTcs = new TaskCompletionSource(); + streamTcs = new TaskCompletionSource(); completionTcs = new TaskCompletionSource(); this.streamKind = streamKind; } @@ -68,7 +66,7 @@ namespace Tgstation.Server.Host.Transfer } /// - public async ValueTask GetResult(CancellationToken cancellationToken) + public async ValueTask GetResult(CancellationToken cancellationToken) { using (cancellationToken.Register(() => streamTcs.TrySetCanceled(cancellationToken))) using (ticketExpiryCts.Token.Register(() => streamTcs.TrySetResult(null))) @@ -90,14 +88,14 @@ namespace Tgstation.Server.Host.Transfer /// The containing uploaded data. /// The for the operation. /// A resulting in , otherwise. - public async ValueTask Completion(Stream stream, CancellationToken cancellationToken) + public async ValueTask Completion(Stream stream, CancellationToken cancellationToken) { ArgumentNullException.ThrowIfNull(stream); if (ticketExpiryCts.IsCancellationRequested) return new ErrorMessageResponse(ErrorCode.ResourceNotPresent); - Stream bufferedStream = null; + Stream? bufferedStream = null; try { switch (streamKind) From 5441e17880b30113cf403064cbdc363fe8967a45 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 23 Nov 2023 20:27:16 -0500 Subject: [PATCH 055/425] Nullify `IFileTransferStreamHandler` --- .../Transfer/IFileTransferStreamHandler.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Tgstation.Server.Host/Transfer/IFileTransferStreamHandler.cs b/src/Tgstation.Server.Host/Transfer/IFileTransferStreamHandler.cs index 43ec027534..45aafc7cd7 100644 --- a/src/Tgstation.Server.Host/Transfer/IFileTransferStreamHandler.cs +++ b/src/Tgstation.Server.Host/Transfer/IFileTransferStreamHandler.cs @@ -5,8 +5,6 @@ using System.Threading.Tasks; using Tgstation.Server.Api.Models.Response; -#nullable disable - namespace Tgstation.Server.Host.Transfer { /// @@ -21,7 +19,7 @@ namespace Tgstation.Server.Host.Transfer /// The with uploaded data. /// The for the operation. /// A resulting in if the upload completed successfully, otherwise. - ValueTask SetUploadStream(FileTicketResponse ticketResponse, Stream stream, CancellationToken cancellationToken); + ValueTask SetUploadStream(FileTicketResponse ticketResponse, Stream stream, CancellationToken cancellationToken); /// /// Gets the the for a given associated with a pending download. @@ -29,6 +27,6 @@ namespace Tgstation.Server.Host.Transfer /// The . /// The for the operation. /// A resulting in a containing either a containing the data to download or an to return. - ValueTask> RetrieveDownloadStream(FileTicketResponse ticketResponse, CancellationToken cancellationToken); + ValueTask> RetrieveDownloadStream(FileTicketResponse ticketResponse, CancellationToken cancellationToken); } } From a551699729352a73f7b8ab5fcdec08ee1c17aee4 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 23 Nov 2023 20:27:32 -0500 Subject: [PATCH 056/425] Nullify `IFileTransferTicketProvider` --- .../Transfer/IFileTransferTicketProvider.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Transfer/IFileTransferTicketProvider.cs b/src/Tgstation.Server.Host/Transfer/IFileTransferTicketProvider.cs index 98a2bfd913..1a13cb9f87 100644 --- a/src/Tgstation.Server.Host/Transfer/IFileTransferTicketProvider.cs +++ b/src/Tgstation.Server.Host/Transfer/IFileTransferTicketProvider.cs @@ -1,7 +1,5 @@ using Tgstation.Server.Api.Models.Response; -#nullable disable - namespace Tgstation.Server.Host.Transfer { /// From ba7ce116ec563a1c1ab62e20c32aaedec551cc81 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 23 Nov 2023 20:28:05 -0500 Subject: [PATCH 057/425] Nullify `IFileUploadTicket` --- src/Tgstation.Server.Host/Transfer/FileUploadProvider.cs | 2 +- src/Tgstation.Server.Host/Transfer/IFileUploadTicket.cs | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Tgstation.Server.Host/Transfer/FileUploadProvider.cs b/src/Tgstation.Server.Host/Transfer/FileUploadProvider.cs index db7965f545..23b37788fc 100644 --- a/src/Tgstation.Server.Host/Transfer/FileUploadProvider.cs +++ b/src/Tgstation.Server.Host/Transfer/FileUploadProvider.cs @@ -131,7 +131,7 @@ namespace Tgstation.Server.Host.Transfer } /// - public void SetError(ErrorCode errorCode, string additionalData) + public void SetError(ErrorCode errorCode, string? additionalData) { if (errorMessage != null) throw new InvalidOperationException("Error already set!"); diff --git a/src/Tgstation.Server.Host/Transfer/IFileUploadTicket.cs b/src/Tgstation.Server.Host/Transfer/IFileUploadTicket.cs index 260be9573f..43130810d3 100644 --- a/src/Tgstation.Server.Host/Transfer/IFileUploadTicket.cs +++ b/src/Tgstation.Server.Host/Transfer/IFileUploadTicket.cs @@ -2,8 +2,6 @@ using Tgstation.Server.Api.Models.Response; using Tgstation.Server.Host.IO; -#nullable disable - namespace Tgstation.Server.Host.Transfer { /// @@ -21,6 +19,6 @@ namespace Tgstation.Server.Host.Transfer /// /// The to set. /// Any additional information that can be provided about the error. - void SetError(ErrorCode errorCode, string additionalData); + void SetError(ErrorCode errorCode, string? additionalData); } } From a61c0711f09fc20aaaa4811c3abbe80a27d401a4 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 23 Nov 2023 20:28:27 -0500 Subject: [PATCH 058/425] Nullify `AssemblyInformationProvider` --- .../System/AssemblyInformationProvider.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Tgstation.Server.Host/System/AssemblyInformationProvider.cs b/src/Tgstation.Server.Host/System/AssemblyInformationProvider.cs index 4d072772e5..475eb49862 100644 --- a/src/Tgstation.Server.Host/System/AssemblyInformationProvider.cs +++ b/src/Tgstation.Server.Host/System/AssemblyInformationProvider.cs @@ -5,8 +5,6 @@ using System.Reflection; using Tgstation.Server.Common; using Tgstation.Server.Common.Extensions; -#nullable disable - namespace Tgstation.Server.Host.System { /// @@ -40,7 +38,7 @@ namespace Tgstation.Server.Host.System Assembly assembly = Assembly.GetExecutingAssembly(); Path = assembly.Location; AssemblyName = assembly.GetName(); - Version = AssemblyName.Version.Semver(); + Version = AssemblyName.Version!.Semver(); VersionString = String.Concat(VersionPrefix, "-v", Version); } } From 42a13bbe8f9664d2ef3999c71ac8414181e73cb2 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 23 Nov 2023 20:28:42 -0500 Subject: [PATCH 059/425] Nullify `IAssemblyInformationProvider` --- .../System/IAssemblyInformationProvider.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/System/IAssemblyInformationProvider.cs b/src/Tgstation.Server.Host/System/IAssemblyInformationProvider.cs index 7b092f8aea..184dd9f60a 100644 --- a/src/Tgstation.Server.Host/System/IAssemblyInformationProvider.cs +++ b/src/Tgstation.Server.Host/System/IAssemblyInformationProvider.cs @@ -2,8 +2,6 @@ using System.Net.Http.Headers; using System.Reflection; -#nullable disable - namespace Tgstation.Server.Host.System { /// From 4b1d9d0ee1fc25a2bad5efc4e2081f045fee2de4 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 23 Nov 2023 20:29:01 -0500 Subject: [PATCH 060/425] Nullify `IPlatformIdentifier` --- src/Tgstation.Server.Host/System/IPlatformIdentifier.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/System/IPlatformIdentifier.cs b/src/Tgstation.Server.Host/System/IPlatformIdentifier.cs index 104bb0dc32..805b93b97d 100644 --- a/src/Tgstation.Server.Host/System/IPlatformIdentifier.cs +++ b/src/Tgstation.Server.Host/System/IPlatformIdentifier.cs @@ -1,7 +1,5 @@ using System.Runtime.Versioning; -#nullable disable - namespace Tgstation.Server.Host.System { /// From 47cf9519033c57062dd89f3f51bf54b7b5bbe2e2 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 23 Nov 2023 20:29:36 -0500 Subject: [PATCH 061/425] Nullify `IPlatformIdentifier` --- src/Tgstation.Server.Host/System/IProcess.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/System/IProcess.cs b/src/Tgstation.Server.Host/System/IProcess.cs index 7b033f3e9d..8df102b2b2 100644 --- a/src/Tgstation.Server.Host/System/IProcess.cs +++ b/src/Tgstation.Server.Host/System/IProcess.cs @@ -2,8 +2,6 @@ using System.Threading; using System.Threading.Tasks; -#nullable disable - namespace Tgstation.Server.Host.System { /// From 643b6404fd500fd182d51a9d3345b8a2adb23081 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 23 Nov 2023 20:29:56 -0500 Subject: [PATCH 062/425] Nullify `IProcessBase` --- src/Tgstation.Server.Host/System/IProcessBase.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/System/IProcessBase.cs b/src/Tgstation.Server.Host/System/IProcessBase.cs index 91feee546e..8fc0bd4484 100644 --- a/src/Tgstation.Server.Host/System/IProcessBase.cs +++ b/src/Tgstation.Server.Host/System/IProcessBase.cs @@ -1,8 +1,6 @@ using System.Threading; using System.Threading.Tasks; -#nullable disable - namespace Tgstation.Server.Host.System { /// From 22d97588fa1448f09e394a3271ced359be65739d Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 23 Nov 2023 20:30:23 -0500 Subject: [PATCH 063/425] Nullify `IProcessExecutor` --- src/Tgstation.Server.Host/System/IProcessExecutor.cs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/Tgstation.Server.Host/System/IProcessExecutor.cs b/src/Tgstation.Server.Host/System/IProcessExecutor.cs index a0418aea0d..fe51ce451b 100644 --- a/src/Tgstation.Server.Host/System/IProcessExecutor.cs +++ b/src/Tgstation.Server.Host/System/IProcessExecutor.cs @@ -1,6 +1,4 @@ -#nullable disable - -namespace Tgstation.Server.Host.System +namespace Tgstation.Server.Host.System { /// /// For launching '. @@ -20,8 +18,8 @@ namespace Tgstation.Server.Host.System IProcess LaunchProcess( string fileName, string workingDirectory, - string arguments = null, - string fileRedirect = null, + string? arguments = null, + string? fileRedirect = null, bool readStandardHandles = false, bool noShellExecute = false); From b689d9d4c03bd4fb430b2382c7bacfe8ac231335 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 23 Nov 2023 20:30:41 -0500 Subject: [PATCH 064/425] Nullify `IProcessFeatures` --- src/Tgstation.Server.Host/System/IProcessFeatures.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/System/IProcessFeatures.cs b/src/Tgstation.Server.Host/System/IProcessFeatures.cs index 8d4a9258c6..abfaca6b7b 100644 --- a/src/Tgstation.Server.Host/System/IProcessFeatures.cs +++ b/src/Tgstation.Server.Host/System/IProcessFeatures.cs @@ -1,8 +1,6 @@ using System.Threading; using System.Threading.Tasks; -#nullable disable - namespace Tgstation.Server.Host.System { /// From acaa178cb11669a7897bb6e1a35eb96a41e8422c Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 23 Nov 2023 20:31:01 -0500 Subject: [PATCH 065/425] Nullify `NativeMethods` --- src/Tgstation.Server.Host/System/NativeMethods.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/System/NativeMethods.cs b/src/Tgstation.Server.Host/System/NativeMethods.cs index 11f465fb13..dc5046d133 100644 --- a/src/Tgstation.Server.Host/System/NativeMethods.cs +++ b/src/Tgstation.Server.Host/System/NativeMethods.cs @@ -2,8 +2,6 @@ using System.Runtime.InteropServices; using System.Text; -#nullable disable - namespace Tgstation.Server.Host.System { /// From 40f5b743036c11fb9a0b28343aa5a19d8257f6c9 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 23 Nov 2023 20:31:15 -0500 Subject: [PATCH 066/425] Nullify `PlatformIdentifier` --- src/Tgstation.Server.Host/System/PlatformIdentifier.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/System/PlatformIdentifier.cs b/src/Tgstation.Server.Host/System/PlatformIdentifier.cs index 6391932f1c..22931b97ce 100644 --- a/src/Tgstation.Server.Host/System/PlatformIdentifier.cs +++ b/src/Tgstation.Server.Host/System/PlatformIdentifier.cs @@ -1,8 +1,6 @@ using System.Runtime.InteropServices; using System.Runtime.Versioning; -#nullable disable - namespace Tgstation.Server.Host.System { /// From f647bb68b6f58f9bf07e56a9a2f38461258f4322 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 23 Nov 2023 20:31:47 -0500 Subject: [PATCH 067/425] Nullify `PosixProcessFeatures` --- src/Tgstation.Server.Host/System/PosixProcessFeatures.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/System/PosixProcessFeatures.cs b/src/Tgstation.Server.Host/System/PosixProcessFeatures.cs index c1999c4545..b45c845fa4 100644 --- a/src/Tgstation.Server.Host/System/PosixProcessFeatures.cs +++ b/src/Tgstation.Server.Host/System/PosixProcessFeatures.cs @@ -10,8 +10,6 @@ using Tgstation.Server.Api.Models; using Tgstation.Server.Host.IO; using Tgstation.Server.Host.Jobs; -#nullable disable - namespace Tgstation.Server.Host.System { /// From 0c7c97c8a5278f2a28563e4981a3785f3a3f1d27 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 23 Nov 2023 20:32:09 -0500 Subject: [PATCH 068/425] Nullify `PosixSignalHandler` --- src/Tgstation.Server.Host/System/PosixSignalHandler.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Tgstation.Server.Host/System/PosixSignalHandler.cs b/src/Tgstation.Server.Host/System/PosixSignalHandler.cs index 5342f68d39..eff4f6c7c2 100644 --- a/src/Tgstation.Server.Host/System/PosixSignalHandler.cs +++ b/src/Tgstation.Server.Host/System/PosixSignalHandler.cs @@ -10,8 +10,6 @@ using Mono.Unix.Native; using Tgstation.Server.Host.Core; using Tgstation.Server.Host.Utils; -#nullable disable - namespace Tgstation.Server.Host.System { /// @@ -47,7 +45,7 @@ namespace Tgstation.Server.Host.System /// /// The thread used to check the signal. See http://docs.go-mono.com/?link=T%3aMono.Unix.UnixSignal. /// - Task signalCheckerTask; + Task? signalCheckerTask; /// /// Initializes a new instance of the class. From 4144ed6c99b560ba2b1f9a2fd82e4def431f877c Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 23 Nov 2023 20:33:37 -0500 Subject: [PATCH 069/425] Nullify `Process` --- src/Tgstation.Server.Host/System/Process.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/System/Process.cs b/src/Tgstation.Server.Host/System/Process.cs index a505cee878..003f3b12e4 100644 --- a/src/Tgstation.Server.Host/System/Process.cs +++ b/src/Tgstation.Server.Host/System/Process.cs @@ -9,8 +9,6 @@ using Microsoft.Win32.SafeHandles; using Tgstation.Server.Host.IO; using Tgstation.Server.Host.Utils; -#nullable disable - namespace Tgstation.Server.Host.System { /// From 07ad701f57ead8349044796f45e2fe387d69984f Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 23 Nov 2023 20:37:42 -0500 Subject: [PATCH 070/425] Nullify `ProcessExecutor` --- src/Tgstation.Server.Host/System/IProcess.cs | 2 +- .../System/IProcessExecutor.cs | 6 ++-- .../System/PosixProcessFeatures.cs | 2 +- src/Tgstation.Server.Host/System/Process.cs | 8 ++--- .../System/ProcessExecutor.cs | 32 +++++++++---------- 5 files changed, 24 insertions(+), 26 deletions(-) diff --git a/src/Tgstation.Server.Host/System/IProcess.cs b/src/Tgstation.Server.Host/System/IProcess.cs index 8df102b2b2..f9f35e5c66 100644 --- a/src/Tgstation.Server.Host/System/IProcess.cs +++ b/src/Tgstation.Server.Host/System/IProcess.cs @@ -29,7 +29,7 @@ namespace Tgstation.Server.Host.System /// the result of this function must be ed before is called. /// May call internally if the process has exited. /// - ValueTask GetCombinedOutput(CancellationToken cancellationToken); + ValueTask GetCombinedOutput(CancellationToken cancellationToken); /// /// Asycnhronously terminates the process. diff --git a/src/Tgstation.Server.Host/System/IProcessExecutor.cs b/src/Tgstation.Server.Host/System/IProcessExecutor.cs index fe51ce451b..aae807eec2 100644 --- a/src/Tgstation.Server.Host/System/IProcessExecutor.cs +++ b/src/Tgstation.Server.Host/System/IProcessExecutor.cs @@ -18,7 +18,7 @@ IProcess LaunchProcess( string fileName, string workingDirectory, - string? arguments = null, + string arguments, string? fileRedirect = null, bool readStandardHandles = false, bool noShellExecute = false); @@ -34,13 +34,13 @@ /// /// The . /// The represented by on success, on failure. - IProcess GetProcess(int id); + IProcess? GetProcess(int id); /// /// Get a with a given . /// /// The name of the process executable without the extension. /// The represented by on success, on failure. - IProcess GetProcessByName(string name); + IProcess? GetProcessByName(string name); } } diff --git a/src/Tgstation.Server.Host/System/PosixProcessFeatures.cs b/src/Tgstation.Server.Host/System/PosixProcessFeatures.cs index b45c845fa4..8077577aaf 100644 --- a/src/Tgstation.Server.Host/System/PosixProcessFeatures.cs +++ b/src/Tgstation.Server.Host/System/PosixProcessFeatures.cs @@ -86,7 +86,7 @@ namespace Tgstation.Server.Host.System throw new JobException(ErrorCode.GameServerOffline, ex); } - string output; + string? output; int exitCode; await using (var gcoreProc = lazyLoadedProcessExecutor.Value.LaunchProcess( GCorePath, diff --git a/src/Tgstation.Server.Host/System/Process.cs b/src/Tgstation.Server.Host/System/Process.cs index 003f3b12e4..4b91aef6ac 100644 --- a/src/Tgstation.Server.Host/System/Process.cs +++ b/src/Tgstation.Server.Host/System/Process.cs @@ -57,7 +57,7 @@ namespace Tgstation.Server.Host.System /// /// The resulting in the process' standard output/error text. /// - readonly Task readTask; + readonly Task? readTask; /// /// If the was disposed. @@ -78,8 +78,8 @@ namespace Tgstation.Server.Host.System IProcessFeatures processFeatures, IAsyncDelayer asyncDelayer, global::System.Diagnostics.Process handle, - CancellationTokenSource readerCts, - Task readTask, + CancellationTokenSource? readerCts, + Task? readTask, ILogger logger, bool preExisting) { @@ -144,7 +144,7 @@ namespace Tgstation.Server.Host.System } /// - public async ValueTask GetCombinedOutput(CancellationToken cancellationToken) + public async ValueTask GetCombinedOutput(CancellationToken cancellationToken) { if (readTask == null) throw new InvalidOperationException("Output/Error stream reading was not enabled!"); diff --git a/src/Tgstation.Server.Host/System/ProcessExecutor.cs b/src/Tgstation.Server.Host/System/ProcessExecutor.cs index 94e4af31b7..fd411153f0 100644 --- a/src/Tgstation.Server.Host/System/ProcessExecutor.cs +++ b/src/Tgstation.Server.Host/System/ProcessExecutor.cs @@ -9,8 +9,6 @@ using Microsoft.Extensions.Logging; using Tgstation.Server.Host.IO; using Tgstation.Server.Host.Utils; -#nullable disable - namespace Tgstation.Server.Host.System { /// @@ -86,7 +84,7 @@ namespace Tgstation.Server.Host.System } /// - public IProcess GetProcess(int id) + public IProcess? GetProcess(int id) { logger.LogDebug("Attaching to process {pid}...", id); global::System.Diagnostics.Process handle; @@ -116,7 +114,7 @@ namespace Tgstation.Server.Host.System string fileName, string workingDirectory, string arguments, - string fileRedirect, + string? fileRedirect, bool readStandardHandles, bool noShellExecute) { @@ -143,11 +141,11 @@ namespace Tgstation.Server.Host.System handle.StartInfo.UseShellExecute = !noShellExecute; - Task readTask = null; - CancellationTokenSource disposeCts = null; + Task? readTask = null; + CancellationTokenSource? disposeCts = null; try { - TaskCompletionSource processStartTcs = null; + TaskCompletionSource? processStartTcs = null; if (readStandardHandles) { processStartTcs = new TaskCompletionSource(); @@ -203,11 +201,11 @@ namespace Tgstation.Server.Host.System } /// - public IProcess GetProcessByName(string name) + public IProcess? GetProcessByName(string name) { logger.LogTrace("GetProcessByName: {processName}...", name ?? throw new ArgumentNullException(nameof(name))); var procs = global::System.Diagnostics.Process.GetProcessesByName(name); - global::System.Diagnostics.Process handle = null; + global::System.Diagnostics.Process? handle = null; foreach (var proc in procs) if (handle == null) handle = proc; @@ -231,7 +229,7 @@ namespace Tgstation.Server.Host.System /// The optional path to redirect the streams to. /// The that triggers when the is disposed. /// A resulting in the program's output/error text if is , otherwise. - async Task ConsumeReaders(global::System.Diagnostics.Process handle, Task startTask, string fileRedirect, CancellationToken disposeToken) + async Task ConsumeReaders(global::System.Diagnostics.Process handle, Task startTask, string? fileRedirect, CancellationToken disposeToken) { await startTask; @@ -241,9 +239,9 @@ namespace Tgstation.Server.Host.System // once we obtain these handles we're responsible for them using var stdOutHandle = handle.StandardOutput; using var stdErrHandle = handle.StandardError; - Task outputReadTask = null, errorReadTask = null; + Task? outputReadTask = null, errorReadTask = null; bool outputOpen = true, errorOpen = true; - async Task GetNextLine() + async Task GetNextLine() { if (outputOpen && outputReadTask == null) outputReadTask = stdOutHandle.ReadLineAsync(disposeToken).AsTask(); @@ -251,7 +249,7 @@ namespace Tgstation.Server.Host.System if (errorOpen && errorReadTask == null) errorReadTask = stdErrHandle.ReadLineAsync(disposeToken).AsTask(); - var completedTask = await Task.WhenAny(outputReadTask ?? errorReadTask, errorReadTask ?? outputReadTask); + var completedTask = await Task.WhenAny(outputReadTask ?? errorReadTask!, errorReadTask ?? outputReadTask!); var line = await completedTask; if (completedTask == outputReadTask) { @@ -275,7 +273,7 @@ namespace Tgstation.Server.Host.System await using var fileStream = fileRedirect != null ? ioManager.CreateAsyncSequentialWriteStream(fileRedirect) : null; await using var writer = fileStream != null ? new StreamWriter(fileStream) : null; - string text; + string? text; var stringBuilder = fileStream == null ? new StringBuilder() : null; try { @@ -283,11 +281,11 @@ namespace Tgstation.Server.Host.System { if (fileStream != null) { - await writer.WriteLineAsync(text.AsMemory(), disposeToken); + await writer!.WriteLineAsync(text.AsMemory(), disposeToken); await writer.FlushAsync(disposeToken); } else - stringBuilder.AppendLine(text); + stringBuilder!.AppendLine(text); } logger.LogTrace("Finished read for PID {pid}", pid); @@ -296,7 +294,7 @@ namespace Tgstation.Server.Host.System { logger.LogWarning(ex, "PID {pid} stream reading interrupted!", pid); if (fileStream != null) - await writer.WriteLineAsync("-- Process detached, log truncated. This is likely due a to TGS restart --"); + await writer!.WriteLineAsync("-- Process detached, log truncated. This is likely due a to TGS restart --"); } return stringBuilder?.ToString(); From 52d8d04f5a31198be7b23c1dc2f5a3bc5add63d6 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 23 Nov 2023 20:43:08 -0500 Subject: [PATCH 071/425] Nullify `ProgramShutdownTokenSource` --- .../System/ProgramShutdownTokenSource.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Tgstation.Server.Host/System/ProgramShutdownTokenSource.cs b/src/Tgstation.Server.Host/System/ProgramShutdownTokenSource.cs index 0f0dfb13b1..0b9a77f7a6 100644 --- a/src/Tgstation.Server.Host/System/ProgramShutdownTokenSource.cs +++ b/src/Tgstation.Server.Host/System/ProgramShutdownTokenSource.cs @@ -1,8 +1,6 @@ using System; using System.Threading; -#nullable disable - namespace Tgstation.Server.Host.System { /// @@ -18,7 +16,7 @@ namespace Tgstation.Server.Host.System /// /// The for the . /// - CancellationTokenSource cancellationTokenSource; + CancellationTokenSource? cancellationTokenSource; /// /// Gets the . From a01173ebc73716845b8171df126aa315aeec8c60 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 23 Nov 2023 20:52:01 -0500 Subject: [PATCH 072/425] Nullify `SystemDManager` --- src/Tgstation.Server.Host/System/SystemDManager.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Tgstation.Server.Host/System/SystemDManager.cs b/src/Tgstation.Server.Host/System/SystemDManager.cs index 4e3b86972c..7b0542fcad 100644 --- a/src/Tgstation.Server.Host/System/SystemDManager.cs +++ b/src/Tgstation.Server.Host/System/SystemDManager.cs @@ -11,8 +11,6 @@ using Mono.Unix; using Tgstation.Server.Host.Components; using Tgstation.Server.Host.Core; -#nullable disable - namespace Tgstation.Server.Host.System { /// @@ -88,7 +86,7 @@ namespace Tgstation.Server.Host.System } /// - public ValueTask HandleRestart(Version updateVersion, bool handlerMayDelayShutdownWithExtremelyLongRunningTasks, CancellationToken cancellationToken) + public ValueTask HandleRestart(Version? updateVersion, bool handlerMayDelayShutdownWithExtremelyLongRunningTasks, CancellationToken cancellationToken) { // If this is set, we know a gracefule SHUTDOWN was requested restartInProgress = !handlerMayDelayShutdownWithExtremelyLongRunningTasks; From 5f066f880eeb9ba339ef364568e2232d9b450c40 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 23 Nov 2023 20:52:24 -0500 Subject: [PATCH 073/425] Nullify `WindowsFirewallHelper` --- src/Tgstation.Server.Host/System/WindowsFirewallHelper.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/System/WindowsFirewallHelper.cs b/src/Tgstation.Server.Host/System/WindowsFirewallHelper.cs index 7a5e82742f..74964a5569 100644 --- a/src/Tgstation.Server.Host/System/WindowsFirewallHelper.cs +++ b/src/Tgstation.Server.Host/System/WindowsFirewallHelper.cs @@ -4,8 +4,6 @@ using System.Threading.Tasks; using Microsoft.Extensions.Logging; -#nullable disable - namespace Tgstation.Server.Host.System { /// From 30a85d689c4b279c58563d23edd17be016e75c11 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 23 Nov 2023 20:53:02 -0500 Subject: [PATCH 074/425] Nullify `WindowsNetworkPromptReaper` --- src/Tgstation.Server.Host/System/NativeMethods.cs | 2 +- src/Tgstation.Server.Host/System/WindowsNetworkPromptReaper.cs | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Tgstation.Server.Host/System/NativeMethods.cs b/src/Tgstation.Server.Host/System/NativeMethods.cs index dc5046d133..234ba0661a 100644 --- a/src/Tgstation.Server.Host/System/NativeMethods.cs +++ b/src/Tgstation.Server.Host/System/NativeMethods.cs @@ -54,7 +54,7 @@ namespace Tgstation.Server.Host.System /// See https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-findwindoww. /// [DllImport("user32.dll", CharSet = CharSet.Unicode)] - public static extern IntPtr FindWindow(string lpClassName, string lpWindowName); + public static extern IntPtr FindWindow(string? lpClassName, string lpWindowName); /// /// See https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-sendmessage. diff --git a/src/Tgstation.Server.Host/System/WindowsNetworkPromptReaper.cs b/src/Tgstation.Server.Host/System/WindowsNetworkPromptReaper.cs index c30bbb0359..4892415571 100644 --- a/src/Tgstation.Server.Host/System/WindowsNetworkPromptReaper.cs +++ b/src/Tgstation.Server.Host/System/WindowsNetworkPromptReaper.cs @@ -13,8 +13,6 @@ using Microsoft.Extensions.Logging; using Tgstation.Server.Host.Utils; -#nullable disable - namespace Tgstation.Server.Host.System { /// From b28cc1a494dad12ac4e0ddc3cb46ab0dabe545cf Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 23 Nov 2023 20:54:16 -0500 Subject: [PATCH 075/425] Nullify `WindowsProcessFeatures` --- src/Tgstation.Server.Host/System/WindowsProcessFeatures.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/System/WindowsProcessFeatures.cs b/src/Tgstation.Server.Host/System/WindowsProcessFeatures.cs index c3a3b31d9b..41789aec8c 100644 --- a/src/Tgstation.Server.Host/System/WindowsProcessFeatures.cs +++ b/src/Tgstation.Server.Host/System/WindowsProcessFeatures.cs @@ -14,8 +14,6 @@ using Tgstation.Server.Api.Models; using Tgstation.Server.Host.IO; using Tgstation.Server.Host.Jobs; -#nullable disable - namespace Tgstation.Server.Host.System { /// From 378ce32f9728936a121d5030f2c753916a8925cf Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 23 Nov 2023 20:55:25 -0500 Subject: [PATCH 076/425] Nullify `IJobManager` --- src/Tgstation.Server.Host/Jobs/IJobManager.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Tgstation.Server.Host/Jobs/IJobManager.cs b/src/Tgstation.Server.Host/Jobs/IJobManager.cs index e8d0a83baf..58ad8eacd6 100644 --- a/src/Tgstation.Server.Host/Jobs/IJobManager.cs +++ b/src/Tgstation.Server.Host/Jobs/IJobManager.cs @@ -4,8 +4,6 @@ using System.Threading.Tasks; using Tgstation.Server.Api.Models.Response; using Tgstation.Server.Host.Models; -#nullable disable - namespace Tgstation.Server.Host.Jobs { /// @@ -36,7 +34,7 @@ namespace Tgstation.Server.Host.Jobs /// A that will cancel the . /// The for the operation. /// A representing the . Results in if the completed without errors, if errors occurred, or if the job isn't registered. - ValueTask WaitForJobCompletion(Job job, User canceller, CancellationToken jobCancellationToken, CancellationToken cancellationToken); + ValueTask WaitForJobCompletion(Job job, User? canceller, CancellationToken jobCancellationToken, CancellationToken cancellationToken); /// /// Cancels a give . @@ -46,6 +44,6 @@ namespace Tgstation.Server.Host.Jobs /// If the operation should wait until the job exits before completing. /// The for the operation. /// A resulting in the updated if it was cancelled, if it couldn't be found. - ValueTask CancelJob(Job job, User user, bool blocking, CancellationToken cancellationToken); + ValueTask CancelJob(Job job, User? user, bool blocking, CancellationToken cancellationToken); } } From 83c4ddccef8128ec407fd4dccf29d8e3616e22cd Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 23 Nov 2023 20:55:37 -0500 Subject: [PATCH 077/425] Nullify `IJobService` --- src/Tgstation.Server.Host/Jobs/IJobService.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Jobs/IJobService.cs b/src/Tgstation.Server.Host/Jobs/IJobService.cs index 847adff98c..e92ead5e6a 100644 --- a/src/Tgstation.Server.Host/Jobs/IJobService.cs +++ b/src/Tgstation.Server.Host/Jobs/IJobService.cs @@ -1,7 +1,5 @@ using Tgstation.Server.Host.Components; -#nullable disable - namespace Tgstation.Server.Host.Jobs { /// From 00886fd2ae65d3ef45656247b636d94c2f2c8acc Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 23 Nov 2023 20:55:58 -0500 Subject: [PATCH 078/425] Nullify `JobEntrypoint` --- src/Tgstation.Server.Host/Jobs/JobEntrypoint.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Jobs/JobEntrypoint.cs b/src/Tgstation.Server.Host/Jobs/JobEntrypoint.cs index 1a27215306..79e71b5048 100644 --- a/src/Tgstation.Server.Host/Jobs/JobEntrypoint.cs +++ b/src/Tgstation.Server.Host/Jobs/JobEntrypoint.cs @@ -5,8 +5,6 @@ using Tgstation.Server.Host.Components; using Tgstation.Server.Host.Database; using Tgstation.Server.Host.Models; -#nullable disable - namespace Tgstation.Server.Host.Jobs { /// From e570b733bf871bfff180339d58a8dad098577f80 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 23 Nov 2023 20:56:23 -0500 Subject: [PATCH 079/425] Nullify `JobException` --- src/Tgstation.Server.Host/Jobs/JobException.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Jobs/JobException.cs b/src/Tgstation.Server.Host/Jobs/JobException.cs index d29697252f..0eb62f2e29 100644 --- a/src/Tgstation.Server.Host/Jobs/JobException.cs +++ b/src/Tgstation.Server.Host/Jobs/JobException.cs @@ -2,8 +2,6 @@ using Tgstation.Server.Api.Models; -#nullable disable - namespace Tgstation.Server.Host.Jobs { /// From ae2932bba2d47ba62efcbb287422fbeed6503a67 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 23 Nov 2023 20:57:02 -0500 Subject: [PATCH 080/425] Nullify `JobHandler` --- src/Tgstation.Server.Host/Jobs/JobHandler.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Tgstation.Server.Host/Jobs/JobHandler.cs b/src/Tgstation.Server.Host/Jobs/JobHandler.cs index 3a290d48ce..04c3b84510 100644 --- a/src/Tgstation.Server.Host/Jobs/JobHandler.cs +++ b/src/Tgstation.Server.Host/Jobs/JobHandler.cs @@ -2,8 +2,6 @@ using System.Threading; using System.Threading.Tasks; -#nullable disable - namespace Tgstation.Server.Host.Jobs { /// @@ -24,7 +22,7 @@ namespace Tgstation.Server.Host.Jobs /// /// The stage of the job. /// - public string Stage { get; set; } + public string? Stage { get; set; } /// /// The for . @@ -39,7 +37,7 @@ namespace Tgstation.Server.Host.Jobs /// /// The being run. /// - Task task; + Task? task; /// /// Initializes a new instance of the class. From da0da4e6ebfbd8202ae05a380c877fb22e527470 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 23 Nov 2023 20:58:16 -0500 Subject: [PATCH 081/425] Nullify `JobProgressReporter` --- .../Jobs/JobProgressReporter.cs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/Tgstation.Server.Host/Jobs/JobProgressReporter.cs b/src/Tgstation.Server.Host/Jobs/JobProgressReporter.cs index 37b7ae03e2..753f8cf519 100644 --- a/src/Tgstation.Server.Host/Jobs/JobProgressReporter.cs +++ b/src/Tgstation.Server.Host/Jobs/JobProgressReporter.cs @@ -4,8 +4,6 @@ using Microsoft.Extensions.Logging; using Tgstation.Server.Host.Models; -#nullable disable - namespace Tgstation.Server.Host.Jobs { /// @@ -16,7 +14,7 @@ namespace Tgstation.Server.Host.Jobs /// /// The name of the current stage. /// - public string StageName + public string? StageName { get => stageName; set @@ -37,12 +35,12 @@ namespace Tgstation.Server.Host.Jobs /// /// Progress reporter callback taking a description of what the job is currently doing and the (optional) progress of the job on a scale from 0.0-1.0. /// - readonly Action callback; + readonly Action callback; /// /// Backing field for . /// - string stageName; + string? stageName; /// /// The last progress value pushed into the . @@ -60,7 +58,7 @@ namespace Tgstation.Server.Host.Jobs /// The value of . /// The value of . /// The value of . - public JobProgressReporter(ILogger logger, string stageName, Action callback) + public JobProgressReporter(ILogger logger, string? stageName, Action callback) { this.logger = logger ?? throw new ArgumentNullException(nameof(logger)); this.callback = callback ?? throw new ArgumentNullException(nameof(callback)); @@ -99,7 +97,7 @@ namespace Tgstation.Server.Host.Jobs /// The 0.0f-1.0f percentage of the current 's percentage should be given to the section. /// A new that is a subsection of this one. /// A should only have one active child at a time. - public JobProgressReporter CreateSection(string newStageName, double percentage) + public JobProgressReporter CreateSection(string? newStageName, double percentage) { if (percentage > 1 || percentage < 0) { From 280bbc836f561a4a16db03458cf9fa00c413635b Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 23 Nov 2023 21:06:55 -0500 Subject: [PATCH 082/425] Nullify `JobService` --- src/Tgstation.Server.Host/Jobs/IJobManager.cs | 2 +- src/Tgstation.Server.Host/Jobs/JobService.cs | 81 +++++++++---------- 2 files changed, 38 insertions(+), 45 deletions(-) diff --git a/src/Tgstation.Server.Host/Jobs/IJobManager.cs b/src/Tgstation.Server.Host/Jobs/IJobManager.cs index 58ad8eacd6..9f582b34ab 100644 --- a/src/Tgstation.Server.Host/Jobs/IJobManager.cs +++ b/src/Tgstation.Server.Host/Jobs/IJobManager.cs @@ -44,6 +44,6 @@ namespace Tgstation.Server.Host.Jobs /// If the operation should wait until the job exits before completing. /// The for the operation. /// A resulting in the updated if it was cancelled, if it couldn't be found. - ValueTask CancelJob(Job job, User? user, bool blocking, CancellationToken cancellationToken); + ValueTask CancelJob(Job job, User? user, bool blocking, CancellationToken cancellationToken); } } diff --git a/src/Tgstation.Server.Host/Jobs/JobService.cs b/src/Tgstation.Server.Host/Jobs/JobService.cs index e383bf1746..cf4ed22abd 100644 --- a/src/Tgstation.Server.Host/Jobs/JobService.cs +++ b/src/Tgstation.Server.Host/Jobs/JobService.cs @@ -21,8 +21,6 @@ using Tgstation.Server.Host.Models; using Tgstation.Server.Host.Utils; using Tgstation.Server.Host.Utils.SignalR; -#nullable disable - namespace Tgstation.Server.Host.Jobs { /// @@ -121,25 +119,19 @@ namespace Tgstation.Server.Host.Jobs ArgumentNullException.ThrowIfNull(job); ArgumentNullException.ThrowIfNull(operation); + if (job.StartedBy != null && job.StartedBy.Name == null) + throw new InvalidOperationException("StartedBy User associated with job does not have a Name!"); + job.StartedAt = DateTimeOffset.UtcNow; job.Cancelled = false; - if (job.StartedBy != null) - { - if (!job.StartedBy.Id.HasValue) - throw new InvalidOperationException("StartedBy User associated with job does not have an Id!"); - - if (job.StartedBy.Name == null) - throw new InvalidOperationException("StartedBy User associated with job does not have a Name!"); - } - var originalStartedBy = job.StartedBy; await databaseContextFactory.UseContext( async databaseContext => { job.Instance = new Models.Instance { - Id = job.Instance.Id.Value, + Id = job.Instance.Require(x => x.Id), }; databaseContext.Instances.Attach(job.Instance); @@ -149,14 +141,14 @@ namespace Tgstation.Server.Host.Jobs .GetTgsUser( dbUser => new User { - Id = dbUser.Id.Value, + Id = dbUser.Id!.Value, Name = dbUser.Name, }, cancellationToken); job.StartedBy = new User { - Id = originalStartedBy.Id.Value, + Id = originalStartedBy.Require(x => x.Id), }; databaseContext.Users.Attach(job.StartedBy); @@ -177,7 +169,7 @@ namespace Tgstation.Server.Host.Jobs bool jobShouldStart; lock (synchronizationLock) { - jobs.Add(job.Id.Value, jobHandler); + jobs.Add(job.Require(x => x.Id), jobHandler); jobShouldStart = !noMoreJobsShouldStart; } @@ -201,7 +193,7 @@ namespace Tgstation.Server.Host.Jobs .Jobs .AsQueryable() .Where(y => !y.StoppedAt.HasValue) - .Select(y => y.Id.Value) + .Select(y => y.Id!.Value) .ToListAsync(cancellationToken); if (badJobIds.Count > 0) { @@ -224,7 +216,7 @@ namespace Tgstation.Server.Host.Jobs /// public Task StopAsync(CancellationToken cancellationToken) { - List> joinTasks; + List> joinTasks; lock (addCancelLock) lock (synchronizationLock) { @@ -241,24 +233,25 @@ namespace Tgstation.Server.Host.Jobs } /// - public async ValueTask CancelJob(Job job, User user, bool blocking, CancellationToken cancellationToken) + public async ValueTask CancelJob(Job job, User? user, bool blocking, CancellationToken cancellationToken) { ArgumentNullException.ThrowIfNull(job); - JobHandler handler; + var jid = job.Require(x => x.Id); + JobHandler? handler; lock (addCancelLock) { lock (synchronizationLock) - if (!jobs.TryGetValue(job.Id.Value, out handler)) + if (!jobs.TryGetValue(jid, out handler)) return null; - logger.LogDebug("Cancelling job ID {jobId}...", job.Id.Value); + logger.LogDebug("Cancelling job ID {jobId}...", jid); handler.Cancel(); // this will ensure the db update is only done once } await databaseContextFactory.UseContext(async databaseContext => { - var updatedJob = new Job(job.Id.Value); + var updatedJob = new Job(jid); databaseContext.Jobs.Attach(updatedJob); var attachedUser = user == null ? await databaseContext @@ -266,12 +259,12 @@ namespace Tgstation.Server.Host.Jobs .GetTgsUser( dbUser => new User { - Id = dbUser.Id.Value, + Id = dbUser.Id!.Value, }, cancellationToken) : new User { - Id = user.Id.Value, + Id = user.Require(x => x.Id), }; databaseContext.Users.Attach(attachedUser); @@ -298,7 +291,7 @@ namespace Tgstation.Server.Host.Jobs ArgumentNullException.ThrowIfNull(apiResponse); lock (synchronizationLock) { - if (!jobs.TryGetValue(apiResponse.Id.Value, out var handler)) + if (!jobs.TryGetValue(apiResponse.Require(x => x.Id), out var handler)) return; apiResponse.Progress = handler.Progress; apiResponse.Stage = handler.Stage; @@ -306,18 +299,18 @@ namespace Tgstation.Server.Host.Jobs } /// - public async ValueTask WaitForJobCompletion(Job job, User canceller, CancellationToken jobCancellationToken, CancellationToken cancellationToken) + public async ValueTask WaitForJobCompletion(Job job, User? canceller, CancellationToken jobCancellationToken, CancellationToken cancellationToken) { ArgumentNullException.ThrowIfNull(job); if (!cancellationToken.CanBeCanceled) throw new ArgumentException("A cancellable CancellationToken should be provided!", nameof(cancellationToken)); - JobHandler handler; + JobHandler? handler; bool noMoreJobsShouldStart; lock (synchronizationLock) { - if (!jobs.TryGetValue(job.Id.Value, out handler)) + if (!jobs.TryGetValue(job.Require(x => x.Id), out handler)) return null; noMoreJobsShouldStart = this.noMoreJobsShouldStart; @@ -326,7 +319,7 @@ namespace Tgstation.Server.Host.Jobs if (noMoreJobsShouldStart && !handler.Started) await Extensions.TaskExtensions.InfiniteTask.WaitAsync(cancellationToken); - var cancelTask = ValueTask.FromResult(null); + var cancelTask = ValueTask.FromResult(null); bool result; using (jobCancellationToken.Register(() => cancelTask = CancelJob(job, canceller, true, cancellationToken))) result = await handler.Wait(cancellationToken); @@ -364,17 +357,18 @@ namespace Tgstation.Server.Host.Jobs async Task RunJob(Job job, JobEntrypoint operation, CancellationToken cancellationToken) #pragma warning restore CA1506 { - using (LogContext.PushProperty(SerilogContextHelper.JobIdContextProperty, job.Id)) + var jid = job.Require(x => x.Id); + using (LogContext.PushProperty(SerilogContextHelper.JobIdContextProperty, jid)) try { - void LogException(Exception ex) => logger.LogDebug(ex, "Job {jobId} exited with error!", job.Id); + void LogException(Exception ex) => logger.LogDebug(ex, "Job {jobId} exited with error!", jid); var hubUpdatesTask = Task.CompletedTask; var result = false; var firstLogHappened = false; var hubGroupName = JobsHub.HubGroupName(job); - Stopwatch stopwatch = null; + Stopwatch? stopwatch = null; void QueueHubUpdate(JobResponse update, bool final) { void NextUpdate(bool bypassRate) @@ -386,7 +380,7 @@ namespace Tgstation.Server.Host.Jobs if (!firstLogHappened) { - logger.LogTrace("Sending updates for job {id} to hub group {group}", update.Id.Value, hubGroupName); + logger.LogTrace("Sending updates for job {id} to hub group {group}", jid, hubGroupName); firstLogHappened = true; } @@ -397,7 +391,7 @@ namespace Tgstation.Server.Host.Jobs .ReceiveJobUpdate(update, CancellationToken.None); } - Stopwatch enteredLock = null; + Stopwatch? enteredLock = null; try { if (!bypassRate && stopwatch != null) @@ -418,19 +412,18 @@ namespace Tgstation.Server.Host.Jobs } } - var jobId = update.Id.Value; lock (hubUpdateActions) if (final) - hubUpdateActions.Remove(jobId); + hubUpdateActions.Remove(jid); else - hubUpdateActions[jobId] = () => NextUpdate(true); + hubUpdateActions[jid] = () => NextUpdate(true); NextUpdate(false); } try { - void UpdateProgress(string stage, double? progress) + void UpdateProgress(string? stage, double? progress) { if (progress.HasValue && (progress.Value < 0 || progress.Value > 1)) @@ -442,7 +435,7 @@ namespace Tgstation.Server.Host.Jobs int? newProgress = progress.HasValue ? (int)Math.Floor(progress.Value * 100) : null; lock (synchronizationLock) - if (jobs.TryGetValue(job.Id.Value, out var handler)) + if (jobs.TryGetValue(jid, out var handler)) { handler.Stage = stage; handler.Progress = newProgress; @@ -492,7 +485,7 @@ namespace Tgstation.Server.Host.Jobs { await databaseContextFactory.UseContext(async databaseContext => { - var attachedJob = new Job(job.Id.Value); + var attachedJob = new Job(jid); databaseContext.Jobs.Attach(attachedJob); attachedJob.StoppedAt = DateTimeOffset.UtcNow; @@ -517,7 +510,7 @@ namespace Tgstation.Server.Host.Jobs .Include(x => x.Instance) .Include(x => x.StartedBy) .Include(x => x.CancelledBy) - .Where(dbJob => dbJob.Id == job.Id.Value) + .Where(dbJob => dbJob.Id == jid) .FirstAsync(CancellationToken.None); QueueHubUpdate(finalJob.ToApi(), true); }); @@ -525,7 +518,7 @@ namespace Tgstation.Server.Host.Jobs catch { lock (hubUpdateActions) - hubUpdateActions.Remove(job.Id.Value); + hubUpdateActions.Remove(jid); throw; } @@ -545,8 +538,8 @@ namespace Tgstation.Server.Host.Jobs { lock (synchronizationLock) { - var handler = jobs[job.Id.Value]; - jobs.Remove(job.Id.Value); + var handler = jobs[jid]; + jobs.Remove(jid); handler.Dispose(); } } From e8984f3178d09269e3b8799696a6cae41aeb9c49 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 23 Nov 2023 21:07:33 -0500 Subject: [PATCH 083/425] Nullify `JobsHub` --- src/Tgstation.Server.Host/Jobs/JobsHub.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Tgstation.Server.Host/Jobs/JobsHub.cs b/src/Tgstation.Server.Host/Jobs/JobsHub.cs index 373fcc5af7..d11fdf7913 100644 --- a/src/Tgstation.Server.Host/Jobs/JobsHub.cs +++ b/src/Tgstation.Server.Host/Jobs/JobsHub.cs @@ -7,8 +7,6 @@ using Tgstation.Server.Host.Models; using Tgstation.Server.Host.Security; using Tgstation.Server.Host.Utils.SignalR; -#nullable disable - namespace Tgstation.Server.Host.Jobs { /// @@ -36,7 +34,7 @@ namespace Tgstation.Server.Host.Jobs if (job.Instance == null) throw new InvalidOperationException("job.Instance was null!"); - return HubGroupName(job.Instance.Id.Value); + return HubGroupName(job.Instance.Require(x => x.Id)); } /// From 9c21854532b572d8204a3939a38e23f979afdd50 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 23 Nov 2023 21:09:06 -0500 Subject: [PATCH 084/425] Nullify `JobsHubGroupMapper` --- .../Jobs/JobsHubGroupMapper.cs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/Tgstation.Server.Host/Jobs/JobsHubGroupMapper.cs b/src/Tgstation.Server.Host/Jobs/JobsHubGroupMapper.cs index 4fe5c71012..1342091caa 100644 --- a/src/Tgstation.Server.Host/Jobs/JobsHubGroupMapper.cs +++ b/src/Tgstation.Server.Host/Jobs/JobsHubGroupMapper.cs @@ -15,8 +15,6 @@ using Tgstation.Server.Host.Models; using Tgstation.Server.Host.Security; using Tgstation.Server.Host.Utils.SignalR; -#nullable disable - namespace Tgstation.Server.Host.Jobs { /// @@ -119,20 +117,24 @@ namespace Tgstation.Server.Host.Jobs { ArgumentNullException.ThrowIfNull(authenticationContext); - logger.LogTrace("MapConnectionGroups UID: {uid}", authenticationContext.User.Id.Value); + var pid = authenticationContext.PermissionSet.Require(x => x.Id); + logger.LogTrace( + "MapConnectionGroups UID: {uid} PID: {pid}", + authenticationContext.User.Require(x => x.Id), + pid); - List permedInstanceIds = null; + List? permedInstanceIds = null; await databaseContextFactory.UseContext( async databaseContext => permedInstanceIds = await databaseContext .InstancePermissionSets .AsQueryable() - .Where(ips => ips.PermissionSetId == authenticationContext.PermissionSet.Id.Value) + .Where(ips => ips.PermissionSetId == pid) .Select(ips => ips.InstanceId) .ToListAsync(cancellationToken)); await mappingFunc( - permedInstanceIds.Select( + permedInstanceIds!.Select( JobsHub.HubGroupName)); jobsHubUpdater.QueueActiveJobUpdates(); @@ -156,7 +158,7 @@ namespace Tgstation.Server.Host.Jobs var allInstanceIds = await databaseContext .Instances .Select( - instance => instance.Id.Value) + instance => instance.Id!.Value) .ToListAsync(cancellationToken); var permissionSetAccessibleInstanceIds = await databaseContext .InstancePermissionSets From 07a19988cfcc1c475cabdf19eb7fecd2c16afe27 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 23 Nov 2023 21:09:35 -0500 Subject: [PATCH 085/425] Nullify `DesignTimeDbContextFactoryHelpers` --- .../Database/Design/DesignTimeDbContextFactoryHelpers.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Tgstation.Server.Host/Database/Design/DesignTimeDbContextFactoryHelpers.cs b/src/Tgstation.Server.Host/Database/Design/DesignTimeDbContextFactoryHelpers.cs index b8527648bb..126dfbef4a 100644 --- a/src/Tgstation.Server.Host/Database/Design/DesignTimeDbContextFactoryHelpers.cs +++ b/src/Tgstation.Server.Host/Database/Design/DesignTimeDbContextFactoryHelpers.cs @@ -3,8 +3,6 @@ using Microsoft.Extensions.Options; using Tgstation.Server.Host.Configuration; -#nullable disable - namespace Tgstation.Server.Host.Database.Design { /// @@ -23,7 +21,7 @@ namespace Tgstation.Server.Host.Database.Design public static DbContextOptions CreateDatabaseContextOptions( DatabaseType databaseType, string connectionString, - string serverVersion = null) + string? serverVersion = null) where TDatabaseContext : DatabaseContext { var dbConfig = new DatabaseConfiguration From 5863410a67e5a275cbdf641aa01ea9bf6b73c185 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 23 Nov 2023 21:10:20 -0500 Subject: [PATCH 086/425] Nullify `IDesignTimeDbContextFactory`s --- .../Database/Design/MySqlDesignTimeDbContextFactory.cs | 2 -- .../Database/Design/PostgresSqlDesignTimeDbContextFactory.cs | 2 -- .../Database/Design/SqlServerDesignTimeDbContextFactory.cs | 2 -- .../Database/Design/SqliteDesignTimeDbContextFactory.cs | 2 -- 4 files changed, 8 deletions(-) diff --git a/src/Tgstation.Server.Host/Database/Design/MySqlDesignTimeDbContextFactory.cs b/src/Tgstation.Server.Host/Database/Design/MySqlDesignTimeDbContextFactory.cs index 86efd5568f..f67028efff 100644 --- a/src/Tgstation.Server.Host/Database/Design/MySqlDesignTimeDbContextFactory.cs +++ b/src/Tgstation.Server.Host/Database/Design/MySqlDesignTimeDbContextFactory.cs @@ -2,8 +2,6 @@ using Tgstation.Server.Host.Configuration; -#nullable disable - namespace Tgstation.Server.Host.Database.Design { /// diff --git a/src/Tgstation.Server.Host/Database/Design/PostgresSqlDesignTimeDbContextFactory.cs b/src/Tgstation.Server.Host/Database/Design/PostgresSqlDesignTimeDbContextFactory.cs index 11151e5e58..965eade13e 100644 --- a/src/Tgstation.Server.Host/Database/Design/PostgresSqlDesignTimeDbContextFactory.cs +++ b/src/Tgstation.Server.Host/Database/Design/PostgresSqlDesignTimeDbContextFactory.cs @@ -3,8 +3,6 @@ using Tgstation.Server.Common; using Tgstation.Server.Host.Configuration; -#nullable disable - namespace Tgstation.Server.Host.Database.Design { /// diff --git a/src/Tgstation.Server.Host/Database/Design/SqlServerDesignTimeDbContextFactory.cs b/src/Tgstation.Server.Host/Database/Design/SqlServerDesignTimeDbContextFactory.cs index ac0704df2a..9b5623725e 100644 --- a/src/Tgstation.Server.Host/Database/Design/SqlServerDesignTimeDbContextFactory.cs +++ b/src/Tgstation.Server.Host/Database/Design/SqlServerDesignTimeDbContextFactory.cs @@ -2,8 +2,6 @@ using Tgstation.Server.Host.Configuration; -#nullable disable - namespace Tgstation.Server.Host.Database.Design { /// diff --git a/src/Tgstation.Server.Host/Database/Design/SqliteDesignTimeDbContextFactory.cs b/src/Tgstation.Server.Host/Database/Design/SqliteDesignTimeDbContextFactory.cs index f4c36cb31f..924d8934f9 100644 --- a/src/Tgstation.Server.Host/Database/Design/SqliteDesignTimeDbContextFactory.cs +++ b/src/Tgstation.Server.Host/Database/Design/SqliteDesignTimeDbContextFactory.cs @@ -2,8 +2,6 @@ using Tgstation.Server.Host.Configuration; -#nullable disable - namespace Tgstation.Server.Host.Database.Design { /// From 1b68d408b5d8679e14159a74963a9bed07dee416 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 23 Nov 2023 21:12:54 -0500 Subject: [PATCH 087/425] Nullify migrations --- .../20230331220749_MSAddDreamDaemonLogOutput.Designer.cs | 2 -- .../Migrations/20230331220749_MSAddDreamDaemonLogOutput.cs | 2 -- .../20230331221032_PGAddDreamDaemonLogOutput.Designer.cs | 2 -- .../Migrations/20230331221032_PGAddDreamDaemonLogOutput.cs | 2 -- .../20230331221156_SLAddDreamDaemonLogOutput.Designer.cs | 2 -- .../Migrations/20230331221156_SLAddDreamDaemonLogOutput.cs | 2 -- .../20230401210715_MYAddDreamDaemonLogOutput.Designer.cs | 2 -- .../Migrations/20230401210715_MYAddDreamDaemonLogOutput.cs | 2 -- ...0230403050623_MSAddReattachInfoInitialCompileJob.Designer.cs | 2 -- .../20230403050623_MSAddReattachInfoInitialCompileJob.cs | 2 -- ...0230403050737_MYAddReattachInfoInitialCompileJob.Designer.cs | 2 -- .../20230403050737_MYAddReattachInfoInitialCompileJob.cs | 2 -- ...0230403050832_PGAddReattachInfoInitialCompileJob.Designer.cs | 2 -- .../20230403050832_PGAddReattachInfoInitialCompileJob.cs | 2 -- ...0230403050941_SLAddReattachInfoInitialCompileJob.Designer.cs | 2 -- .../20230403050941_SLAddReattachInfoInitialCompileJob.cs | 2 -- .../Migrations/20230520203236_MSAddSystemChannels.Designer.cs | 2 -- .../Database/Migrations/20230520203236_MSAddSystemChannels.cs | 2 -- .../Migrations/20230520203305_MYAddSystemChannels.Designer.cs | 2 -- .../Database/Migrations/20230520203305_MYAddSystemChannels.cs | 2 -- .../Migrations/20230520203332_PGAddSystemChannels.Designer.cs | 2 -- .../Database/Migrations/20230520203332_PGAddSystemChannels.cs | 2 -- .../Migrations/20230520203402_SLAddSystemChannels.Designer.cs | 2 -- .../Database/Migrations/20230520203402_SLAddSystemChannels.cs | 2 -- .../20230614053739_MSRenameHeartbeatsToHealthChecks.Designer.cs | 2 -- .../20230614053739_MSRenameHeartbeatsToHealthChecks.cs | 2 -- .../20230614053927_MYRenameHeartbeatsToHealthChecks.Designer.cs | 2 -- .../20230614053927_MYRenameHeartbeatsToHealthChecks.cs | 2 -- .../20230614054432_PGRenameHeartbeatsToHealthChecks.Designer.cs | 2 -- .../20230614054432_PGRenameHeartbeatsToHealthChecks.cs | 2 -- .../20230614054537_SLRenameHeartbeatsToHealthChecks.Designer.cs | 2 -- .../20230614054537_SLRenameHeartbeatsToHealthChecks.cs | 2 -- .../Migrations/20230622020600_MSAddMapThreads.Designer.cs | 2 -- .../Database/Migrations/20230622020600_MSAddMapThreads.cs | 2 -- .../Migrations/20230622020623_MYAddMapThreads.Designer.cs | 2 -- .../Database/Migrations/20230622020623_MYAddMapThreads.cs | 2 -- .../Migrations/20230622020647_PGAddMapThreads.Designer.cs | 2 -- .../Database/Migrations/20230622020647_PGAddMapThreads.cs | 2 -- .../Migrations/20230622020712_SLAddMapThreads.Designer.cs | 2 -- .../Database/Migrations/20230622020712_SLAddMapThreads.cs | 2 -- .../Migrations/20231105004801_MSAddJobCodes.Designer.cs | 2 -- .../Database/Migrations/20231105004801_MSAddJobCodes.cs | 2 -- .../Migrations/20231105004808_MYAddJobCodes.Designer.cs | 2 -- .../Database/Migrations/20231105004808_MYAddJobCodes.cs | 2 -- .../Migrations/20231105004814_PGAddJobCodes.Designer.cs | 2 -- .../Database/Migrations/20231105004814_PGAddJobCodes.cs | 2 -- .../Migrations/20231105004820_SLAddJobCodes.Designer.cs | 2 -- .../Database/Migrations/20231105004820_SLAddJobCodes.cs | 2 -- .../20231108004349_MSRenameByondColumnsToEngine.Designer.cs | 2 -- .../Migrations/20231108004349_MSRenameByondColumnsToEngine.cs | 2 -- .../20231108004356_MYRenameByondColumnsToEngine.Designer.cs | 2 -- .../Migrations/20231108004356_MYRenameByondColumnsToEngine.cs | 2 -- .../20231108004402_PGRenameByondColumnsToEngine.Designer.cs | 2 -- .../Migrations/20231108004402_PGRenameByondColumnsToEngine.cs | 2 -- .../20231108004409_SLRenameByondColumnsToEngine.Designer.cs | 2 -- .../Migrations/20231108004409_SLRenameByondColumnsToEngine.cs | 2 -- .../Database/Migrations/MySqlDatabaseContextModelSnapshot.cs | 2 -- .../Migrations/PostgresSqlDatabaseContextModelSnapshot.cs | 2 -- .../Migrations/SqlServerDatabaseContextModelSnapshot.cs | 2 -- .../Database/Migrations/SqliteDatabaseContextModelSnapshot.cs | 2 -- 60 files changed, 120 deletions(-) diff --git a/src/Tgstation.Server.Host/Database/Migrations/20230331220749_MSAddDreamDaemonLogOutput.Designer.cs b/src/Tgstation.Server.Host/Database/Migrations/20230331220749_MSAddDreamDaemonLogOutput.Designer.cs index 02be0acad1..8bc0ff72d4 100644 --- a/src/Tgstation.Server.Host/Database/Migrations/20230331220749_MSAddDreamDaemonLogOutput.Designer.cs +++ b/src/Tgstation.Server.Host/Database/Migrations/20230331220749_MSAddDreamDaemonLogOutput.Designer.cs @@ -5,8 +5,6 @@ using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; -#nullable disable - namespace Tgstation.Server.Host.Database.Migrations { [DbContext(typeof(SqlServerDatabaseContext))] diff --git a/src/Tgstation.Server.Host/Database/Migrations/20230331220749_MSAddDreamDaemonLogOutput.cs b/src/Tgstation.Server.Host/Database/Migrations/20230331220749_MSAddDreamDaemonLogOutput.cs index bc8e3d1880..b2d86c3ae7 100644 --- a/src/Tgstation.Server.Host/Database/Migrations/20230331220749_MSAddDreamDaemonLogOutput.cs +++ b/src/Tgstation.Server.Host/Database/Migrations/20230331220749_MSAddDreamDaemonLogOutput.cs @@ -2,8 +2,6 @@ using Microsoft.EntityFrameworkCore.Migrations; -#nullable disable - namespace Tgstation.Server.Host.Database.Migrations { /// diff --git a/src/Tgstation.Server.Host/Database/Migrations/20230331221032_PGAddDreamDaemonLogOutput.Designer.cs b/src/Tgstation.Server.Host/Database/Migrations/20230331221032_PGAddDreamDaemonLogOutput.Designer.cs index c1bb3e23c5..adca6dbfa7 100644 --- a/src/Tgstation.Server.Host/Database/Migrations/20230331221032_PGAddDreamDaemonLogOutput.Designer.cs +++ b/src/Tgstation.Server.Host/Database/Migrations/20230331221032_PGAddDreamDaemonLogOutput.Designer.cs @@ -5,8 +5,6 @@ using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; -#nullable disable - namespace Tgstation.Server.Host.Database.Migrations { [DbContext(typeof(PostgresSqlDatabaseContext))] diff --git a/src/Tgstation.Server.Host/Database/Migrations/20230331221032_PGAddDreamDaemonLogOutput.cs b/src/Tgstation.Server.Host/Database/Migrations/20230331221032_PGAddDreamDaemonLogOutput.cs index 1828f867bb..cded945a22 100644 --- a/src/Tgstation.Server.Host/Database/Migrations/20230331221032_PGAddDreamDaemonLogOutput.cs +++ b/src/Tgstation.Server.Host/Database/Migrations/20230331221032_PGAddDreamDaemonLogOutput.cs @@ -2,8 +2,6 @@ using Microsoft.EntityFrameworkCore.Migrations; -#nullable disable - namespace Tgstation.Server.Host.Database.Migrations { /// diff --git a/src/Tgstation.Server.Host/Database/Migrations/20230331221156_SLAddDreamDaemonLogOutput.Designer.cs b/src/Tgstation.Server.Host/Database/Migrations/20230331221156_SLAddDreamDaemonLogOutput.Designer.cs index 1e7c30621f..2610389f7e 100644 --- a/src/Tgstation.Server.Host/Database/Migrations/20230331221156_SLAddDreamDaemonLogOutput.Designer.cs +++ b/src/Tgstation.Server.Host/Database/Migrations/20230331221156_SLAddDreamDaemonLogOutput.Designer.cs @@ -5,8 +5,6 @@ using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; -#nullable disable - namespace Tgstation.Server.Host.Database.Migrations { [DbContext(typeof(SqliteDatabaseContext))] diff --git a/src/Tgstation.Server.Host/Database/Migrations/20230331221156_SLAddDreamDaemonLogOutput.cs b/src/Tgstation.Server.Host/Database/Migrations/20230331221156_SLAddDreamDaemonLogOutput.cs index 587dbf9aa2..f574ac0195 100644 --- a/src/Tgstation.Server.Host/Database/Migrations/20230331221156_SLAddDreamDaemonLogOutput.cs +++ b/src/Tgstation.Server.Host/Database/Migrations/20230331221156_SLAddDreamDaemonLogOutput.cs @@ -2,8 +2,6 @@ using Microsoft.EntityFrameworkCore.Migrations; -#nullable disable - namespace Tgstation.Server.Host.Database.Migrations { /// diff --git a/src/Tgstation.Server.Host/Database/Migrations/20230401210715_MYAddDreamDaemonLogOutput.Designer.cs b/src/Tgstation.Server.Host/Database/Migrations/20230401210715_MYAddDreamDaemonLogOutput.Designer.cs index 69acf576b1..aa0b1d70c1 100644 --- a/src/Tgstation.Server.Host/Database/Migrations/20230401210715_MYAddDreamDaemonLogOutput.Designer.cs +++ b/src/Tgstation.Server.Host/Database/Migrations/20230401210715_MYAddDreamDaemonLogOutput.Designer.cs @@ -5,8 +5,6 @@ using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; -#nullable disable - namespace Tgstation.Server.Host.Database.Migrations { [DbContext(typeof(MySqlDatabaseContext))] diff --git a/src/Tgstation.Server.Host/Database/Migrations/20230401210715_MYAddDreamDaemonLogOutput.cs b/src/Tgstation.Server.Host/Database/Migrations/20230401210715_MYAddDreamDaemonLogOutput.cs index 2b023f5fa2..18fc203d23 100644 --- a/src/Tgstation.Server.Host/Database/Migrations/20230401210715_MYAddDreamDaemonLogOutput.cs +++ b/src/Tgstation.Server.Host/Database/Migrations/20230401210715_MYAddDreamDaemonLogOutput.cs @@ -2,8 +2,6 @@ using Microsoft.EntityFrameworkCore.Migrations; -#nullable disable - namespace Tgstation.Server.Host.Database.Migrations { /// diff --git a/src/Tgstation.Server.Host/Database/Migrations/20230403050623_MSAddReattachInfoInitialCompileJob.Designer.cs b/src/Tgstation.Server.Host/Database/Migrations/20230403050623_MSAddReattachInfoInitialCompileJob.Designer.cs index f749992580..d1c93465d6 100644 --- a/src/Tgstation.Server.Host/Database/Migrations/20230403050623_MSAddReattachInfoInitialCompileJob.Designer.cs +++ b/src/Tgstation.Server.Host/Database/Migrations/20230403050623_MSAddReattachInfoInitialCompileJob.Designer.cs @@ -5,8 +5,6 @@ using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; -#nullable disable - namespace Tgstation.Server.Host.Database.Migrations { [DbContext(typeof(SqlServerDatabaseContext))] diff --git a/src/Tgstation.Server.Host/Database/Migrations/20230403050623_MSAddReattachInfoInitialCompileJob.cs b/src/Tgstation.Server.Host/Database/Migrations/20230403050623_MSAddReattachInfoInitialCompileJob.cs index 2c378335d7..2fa0030143 100644 --- a/src/Tgstation.Server.Host/Database/Migrations/20230403050623_MSAddReattachInfoInitialCompileJob.cs +++ b/src/Tgstation.Server.Host/Database/Migrations/20230403050623_MSAddReattachInfoInitialCompileJob.cs @@ -2,8 +2,6 @@ using Microsoft.EntityFrameworkCore.Migrations; -#nullable disable - namespace Tgstation.Server.Host.Database.Migrations { /// diff --git a/src/Tgstation.Server.Host/Database/Migrations/20230403050737_MYAddReattachInfoInitialCompileJob.Designer.cs b/src/Tgstation.Server.Host/Database/Migrations/20230403050737_MYAddReattachInfoInitialCompileJob.Designer.cs index a53708cfc0..e5a7f0400b 100644 --- a/src/Tgstation.Server.Host/Database/Migrations/20230403050737_MYAddReattachInfoInitialCompileJob.Designer.cs +++ b/src/Tgstation.Server.Host/Database/Migrations/20230403050737_MYAddReattachInfoInitialCompileJob.Designer.cs @@ -5,8 +5,6 @@ using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; -#nullable disable - namespace Tgstation.Server.Host.Database.Migrations { [DbContext(typeof(MySqlDatabaseContext))] diff --git a/src/Tgstation.Server.Host/Database/Migrations/20230403050737_MYAddReattachInfoInitialCompileJob.cs b/src/Tgstation.Server.Host/Database/Migrations/20230403050737_MYAddReattachInfoInitialCompileJob.cs index da962107e1..3dc01170b7 100644 --- a/src/Tgstation.Server.Host/Database/Migrations/20230403050737_MYAddReattachInfoInitialCompileJob.cs +++ b/src/Tgstation.Server.Host/Database/Migrations/20230403050737_MYAddReattachInfoInitialCompileJob.cs @@ -2,8 +2,6 @@ using Microsoft.EntityFrameworkCore.Migrations; -#nullable disable - namespace Tgstation.Server.Host.Database.Migrations { /// diff --git a/src/Tgstation.Server.Host/Database/Migrations/20230403050832_PGAddReattachInfoInitialCompileJob.Designer.cs b/src/Tgstation.Server.Host/Database/Migrations/20230403050832_PGAddReattachInfoInitialCompileJob.Designer.cs index 8e4962a1e0..3129b863f9 100644 --- a/src/Tgstation.Server.Host/Database/Migrations/20230403050832_PGAddReattachInfoInitialCompileJob.Designer.cs +++ b/src/Tgstation.Server.Host/Database/Migrations/20230403050832_PGAddReattachInfoInitialCompileJob.Designer.cs @@ -5,8 +5,6 @@ using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; -#nullable disable - namespace Tgstation.Server.Host.Database.Migrations { [DbContext(typeof(PostgresSqlDatabaseContext))] diff --git a/src/Tgstation.Server.Host/Database/Migrations/20230403050832_PGAddReattachInfoInitialCompileJob.cs b/src/Tgstation.Server.Host/Database/Migrations/20230403050832_PGAddReattachInfoInitialCompileJob.cs index 14d08913ec..bab6bbc9c1 100644 --- a/src/Tgstation.Server.Host/Database/Migrations/20230403050832_PGAddReattachInfoInitialCompileJob.cs +++ b/src/Tgstation.Server.Host/Database/Migrations/20230403050832_PGAddReattachInfoInitialCompileJob.cs @@ -2,8 +2,6 @@ using Microsoft.EntityFrameworkCore.Migrations; -#nullable disable - namespace Tgstation.Server.Host.Database.Migrations { /// diff --git a/src/Tgstation.Server.Host/Database/Migrations/20230403050941_SLAddReattachInfoInitialCompileJob.Designer.cs b/src/Tgstation.Server.Host/Database/Migrations/20230403050941_SLAddReattachInfoInitialCompileJob.Designer.cs index 8330e52cb1..3ac8984309 100644 --- a/src/Tgstation.Server.Host/Database/Migrations/20230403050941_SLAddReattachInfoInitialCompileJob.Designer.cs +++ b/src/Tgstation.Server.Host/Database/Migrations/20230403050941_SLAddReattachInfoInitialCompileJob.Designer.cs @@ -5,8 +5,6 @@ using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; -#nullable disable - namespace Tgstation.Server.Host.Database.Migrations { [DbContext(typeof(SqliteDatabaseContext))] diff --git a/src/Tgstation.Server.Host/Database/Migrations/20230403050941_SLAddReattachInfoInitialCompileJob.cs b/src/Tgstation.Server.Host/Database/Migrations/20230403050941_SLAddReattachInfoInitialCompileJob.cs index 630411174d..91f1ea6bb8 100644 --- a/src/Tgstation.Server.Host/Database/Migrations/20230403050941_SLAddReattachInfoInitialCompileJob.cs +++ b/src/Tgstation.Server.Host/Database/Migrations/20230403050941_SLAddReattachInfoInitialCompileJob.cs @@ -2,8 +2,6 @@ using Microsoft.EntityFrameworkCore.Migrations; -#nullable disable - namespace Tgstation.Server.Host.Database.Migrations { /// diff --git a/src/Tgstation.Server.Host/Database/Migrations/20230520203236_MSAddSystemChannels.Designer.cs b/src/Tgstation.Server.Host/Database/Migrations/20230520203236_MSAddSystemChannels.Designer.cs index 4fa9364f35..23b628d9c8 100644 --- a/src/Tgstation.Server.Host/Database/Migrations/20230520203236_MSAddSystemChannels.Designer.cs +++ b/src/Tgstation.Server.Host/Database/Migrations/20230520203236_MSAddSystemChannels.Designer.cs @@ -5,8 +5,6 @@ using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; -#nullable disable - namespace Tgstation.Server.Host.Database.Migrations { [DbContext(typeof(SqlServerDatabaseContext))] diff --git a/src/Tgstation.Server.Host/Database/Migrations/20230520203236_MSAddSystemChannels.cs b/src/Tgstation.Server.Host/Database/Migrations/20230520203236_MSAddSystemChannels.cs index 410d150c1e..3ab2299fe5 100644 --- a/src/Tgstation.Server.Host/Database/Migrations/20230520203236_MSAddSystemChannels.cs +++ b/src/Tgstation.Server.Host/Database/Migrations/20230520203236_MSAddSystemChannels.cs @@ -2,8 +2,6 @@ using Microsoft.EntityFrameworkCore.Migrations; -#nullable disable - namespace Tgstation.Server.Host.Database.Migrations { /// diff --git a/src/Tgstation.Server.Host/Database/Migrations/20230520203305_MYAddSystemChannels.Designer.cs b/src/Tgstation.Server.Host/Database/Migrations/20230520203305_MYAddSystemChannels.Designer.cs index 3f1e7b3249..2a7dbd32d8 100644 --- a/src/Tgstation.Server.Host/Database/Migrations/20230520203305_MYAddSystemChannels.Designer.cs +++ b/src/Tgstation.Server.Host/Database/Migrations/20230520203305_MYAddSystemChannels.Designer.cs @@ -5,8 +5,6 @@ using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; -#nullable disable - namespace Tgstation.Server.Host.Database.Migrations { [DbContext(typeof(MySqlDatabaseContext))] diff --git a/src/Tgstation.Server.Host/Database/Migrations/20230520203305_MYAddSystemChannels.cs b/src/Tgstation.Server.Host/Database/Migrations/20230520203305_MYAddSystemChannels.cs index ec249f3e44..691e439fdc 100644 --- a/src/Tgstation.Server.Host/Database/Migrations/20230520203305_MYAddSystemChannels.cs +++ b/src/Tgstation.Server.Host/Database/Migrations/20230520203305_MYAddSystemChannels.cs @@ -2,8 +2,6 @@ using Microsoft.EntityFrameworkCore.Migrations; -#nullable disable - namespace Tgstation.Server.Host.Database.Migrations { /// diff --git a/src/Tgstation.Server.Host/Database/Migrations/20230520203332_PGAddSystemChannels.Designer.cs b/src/Tgstation.Server.Host/Database/Migrations/20230520203332_PGAddSystemChannels.Designer.cs index 613cd8034e..cecc00d99f 100644 --- a/src/Tgstation.Server.Host/Database/Migrations/20230520203332_PGAddSystemChannels.Designer.cs +++ b/src/Tgstation.Server.Host/Database/Migrations/20230520203332_PGAddSystemChannels.Designer.cs @@ -5,8 +5,6 @@ using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; -#nullable disable - namespace Tgstation.Server.Host.Database.Migrations { [DbContext(typeof(PostgresSqlDatabaseContext))] diff --git a/src/Tgstation.Server.Host/Database/Migrations/20230520203332_PGAddSystemChannels.cs b/src/Tgstation.Server.Host/Database/Migrations/20230520203332_PGAddSystemChannels.cs index 60bf1c5229..17df0a48ef 100644 --- a/src/Tgstation.Server.Host/Database/Migrations/20230520203332_PGAddSystemChannels.cs +++ b/src/Tgstation.Server.Host/Database/Migrations/20230520203332_PGAddSystemChannels.cs @@ -2,8 +2,6 @@ using Microsoft.EntityFrameworkCore.Migrations; -#nullable disable - namespace Tgstation.Server.Host.Database.Migrations { /// diff --git a/src/Tgstation.Server.Host/Database/Migrations/20230520203402_SLAddSystemChannels.Designer.cs b/src/Tgstation.Server.Host/Database/Migrations/20230520203402_SLAddSystemChannels.Designer.cs index fbe9ae470e..2fbf158718 100644 --- a/src/Tgstation.Server.Host/Database/Migrations/20230520203402_SLAddSystemChannels.Designer.cs +++ b/src/Tgstation.Server.Host/Database/Migrations/20230520203402_SLAddSystemChannels.Designer.cs @@ -5,8 +5,6 @@ using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; -#nullable disable - namespace Tgstation.Server.Host.Database.Migrations { [DbContext(typeof(SqliteDatabaseContext))] diff --git a/src/Tgstation.Server.Host/Database/Migrations/20230520203402_SLAddSystemChannels.cs b/src/Tgstation.Server.Host/Database/Migrations/20230520203402_SLAddSystemChannels.cs index 4dc47740e8..95dc26a1b8 100644 --- a/src/Tgstation.Server.Host/Database/Migrations/20230520203402_SLAddSystemChannels.cs +++ b/src/Tgstation.Server.Host/Database/Migrations/20230520203402_SLAddSystemChannels.cs @@ -2,8 +2,6 @@ using Microsoft.EntityFrameworkCore.Migrations; -#nullable disable - namespace Tgstation.Server.Host.Database.Migrations { /// diff --git a/src/Tgstation.Server.Host/Database/Migrations/20230614053739_MSRenameHeartbeatsToHealthChecks.Designer.cs b/src/Tgstation.Server.Host/Database/Migrations/20230614053739_MSRenameHeartbeatsToHealthChecks.Designer.cs index 0b7c9281fb..af40476708 100644 --- a/src/Tgstation.Server.Host/Database/Migrations/20230614053739_MSRenameHeartbeatsToHealthChecks.Designer.cs +++ b/src/Tgstation.Server.Host/Database/Migrations/20230614053739_MSRenameHeartbeatsToHealthChecks.Designer.cs @@ -5,8 +5,6 @@ using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; -#nullable disable - namespace Tgstation.Server.Host.Database.Migrations { [DbContext(typeof(SqlServerDatabaseContext))] diff --git a/src/Tgstation.Server.Host/Database/Migrations/20230614053739_MSRenameHeartbeatsToHealthChecks.cs b/src/Tgstation.Server.Host/Database/Migrations/20230614053739_MSRenameHeartbeatsToHealthChecks.cs index 37dbc14816..20f53e2d0a 100644 --- a/src/Tgstation.Server.Host/Database/Migrations/20230614053739_MSRenameHeartbeatsToHealthChecks.cs +++ b/src/Tgstation.Server.Host/Database/Migrations/20230614053739_MSRenameHeartbeatsToHealthChecks.cs @@ -2,8 +2,6 @@ using Microsoft.EntityFrameworkCore.Migrations; -#nullable disable - namespace Tgstation.Server.Host.Database.Migrations { /// diff --git a/src/Tgstation.Server.Host/Database/Migrations/20230614053927_MYRenameHeartbeatsToHealthChecks.Designer.cs b/src/Tgstation.Server.Host/Database/Migrations/20230614053927_MYRenameHeartbeatsToHealthChecks.Designer.cs index 78f17b9159..ce9233fc4e 100644 --- a/src/Tgstation.Server.Host/Database/Migrations/20230614053927_MYRenameHeartbeatsToHealthChecks.Designer.cs +++ b/src/Tgstation.Server.Host/Database/Migrations/20230614053927_MYRenameHeartbeatsToHealthChecks.Designer.cs @@ -5,8 +5,6 @@ using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; -#nullable disable - namespace Tgstation.Server.Host.Database.Migrations { [DbContext(typeof(MySqlDatabaseContext))] diff --git a/src/Tgstation.Server.Host/Database/Migrations/20230614053927_MYRenameHeartbeatsToHealthChecks.cs b/src/Tgstation.Server.Host/Database/Migrations/20230614053927_MYRenameHeartbeatsToHealthChecks.cs index 37d18bf1fb..25fb3f21c8 100644 --- a/src/Tgstation.Server.Host/Database/Migrations/20230614053927_MYRenameHeartbeatsToHealthChecks.cs +++ b/src/Tgstation.Server.Host/Database/Migrations/20230614053927_MYRenameHeartbeatsToHealthChecks.cs @@ -2,8 +2,6 @@ using Microsoft.EntityFrameworkCore.Migrations; -#nullable disable - namespace Tgstation.Server.Host.Database.Migrations { /// diff --git a/src/Tgstation.Server.Host/Database/Migrations/20230614054432_PGRenameHeartbeatsToHealthChecks.Designer.cs b/src/Tgstation.Server.Host/Database/Migrations/20230614054432_PGRenameHeartbeatsToHealthChecks.Designer.cs index 650e56fe66..849210b585 100644 --- a/src/Tgstation.Server.Host/Database/Migrations/20230614054432_PGRenameHeartbeatsToHealthChecks.Designer.cs +++ b/src/Tgstation.Server.Host/Database/Migrations/20230614054432_PGRenameHeartbeatsToHealthChecks.Designer.cs @@ -5,8 +5,6 @@ using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; -#nullable disable - namespace Tgstation.Server.Host.Database.Migrations { [DbContext(typeof(PostgresSqlDatabaseContext))] diff --git a/src/Tgstation.Server.Host/Database/Migrations/20230614054432_PGRenameHeartbeatsToHealthChecks.cs b/src/Tgstation.Server.Host/Database/Migrations/20230614054432_PGRenameHeartbeatsToHealthChecks.cs index 5ccae3445b..75e99990d9 100644 --- a/src/Tgstation.Server.Host/Database/Migrations/20230614054432_PGRenameHeartbeatsToHealthChecks.cs +++ b/src/Tgstation.Server.Host/Database/Migrations/20230614054432_PGRenameHeartbeatsToHealthChecks.cs @@ -2,8 +2,6 @@ using Microsoft.EntityFrameworkCore.Migrations; -#nullable disable - namespace Tgstation.Server.Host.Database.Migrations { /// diff --git a/src/Tgstation.Server.Host/Database/Migrations/20230614054537_SLRenameHeartbeatsToHealthChecks.Designer.cs b/src/Tgstation.Server.Host/Database/Migrations/20230614054537_SLRenameHeartbeatsToHealthChecks.Designer.cs index 9180386ff1..9ffc8607f9 100644 --- a/src/Tgstation.Server.Host/Database/Migrations/20230614054537_SLRenameHeartbeatsToHealthChecks.Designer.cs +++ b/src/Tgstation.Server.Host/Database/Migrations/20230614054537_SLRenameHeartbeatsToHealthChecks.Designer.cs @@ -5,8 +5,6 @@ using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; -#nullable disable - namespace Tgstation.Server.Host.Database.Migrations { [DbContext(typeof(SqliteDatabaseContext))] diff --git a/src/Tgstation.Server.Host/Database/Migrations/20230614054537_SLRenameHeartbeatsToHealthChecks.cs b/src/Tgstation.Server.Host/Database/Migrations/20230614054537_SLRenameHeartbeatsToHealthChecks.cs index dc88c94012..8326dca934 100644 --- a/src/Tgstation.Server.Host/Database/Migrations/20230614054537_SLRenameHeartbeatsToHealthChecks.cs +++ b/src/Tgstation.Server.Host/Database/Migrations/20230614054537_SLRenameHeartbeatsToHealthChecks.cs @@ -2,8 +2,6 @@ using Microsoft.EntityFrameworkCore.Migrations; -#nullable disable - namespace Tgstation.Server.Host.Database.Migrations { /// diff --git a/src/Tgstation.Server.Host/Database/Migrations/20230622020600_MSAddMapThreads.Designer.cs b/src/Tgstation.Server.Host/Database/Migrations/20230622020600_MSAddMapThreads.Designer.cs index 09c3484802..8910b644ac 100644 --- a/src/Tgstation.Server.Host/Database/Migrations/20230622020600_MSAddMapThreads.Designer.cs +++ b/src/Tgstation.Server.Host/Database/Migrations/20230622020600_MSAddMapThreads.Designer.cs @@ -5,8 +5,6 @@ using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; -#nullable disable - namespace Tgstation.Server.Host.Database.Migrations { [DbContext(typeof(SqlServerDatabaseContext))] diff --git a/src/Tgstation.Server.Host/Database/Migrations/20230622020600_MSAddMapThreads.cs b/src/Tgstation.Server.Host/Database/Migrations/20230622020600_MSAddMapThreads.cs index dab10dc6af..2bfc981d34 100644 --- a/src/Tgstation.Server.Host/Database/Migrations/20230622020600_MSAddMapThreads.cs +++ b/src/Tgstation.Server.Host/Database/Migrations/20230622020600_MSAddMapThreads.cs @@ -2,8 +2,6 @@ using Microsoft.EntityFrameworkCore.Migrations; -#nullable disable - namespace Tgstation.Server.Host.Database.Migrations { /// diff --git a/src/Tgstation.Server.Host/Database/Migrations/20230622020623_MYAddMapThreads.Designer.cs b/src/Tgstation.Server.Host/Database/Migrations/20230622020623_MYAddMapThreads.Designer.cs index f7039334cf..b9fe9c7cdd 100644 --- a/src/Tgstation.Server.Host/Database/Migrations/20230622020623_MYAddMapThreads.Designer.cs +++ b/src/Tgstation.Server.Host/Database/Migrations/20230622020623_MYAddMapThreads.Designer.cs @@ -5,8 +5,6 @@ using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; -#nullable disable - namespace Tgstation.Server.Host.Database.Migrations { [DbContext(typeof(MySqlDatabaseContext))] diff --git a/src/Tgstation.Server.Host/Database/Migrations/20230622020623_MYAddMapThreads.cs b/src/Tgstation.Server.Host/Database/Migrations/20230622020623_MYAddMapThreads.cs index 1f83abc44d..aa52cc0d6b 100644 --- a/src/Tgstation.Server.Host/Database/Migrations/20230622020623_MYAddMapThreads.cs +++ b/src/Tgstation.Server.Host/Database/Migrations/20230622020623_MYAddMapThreads.cs @@ -2,8 +2,6 @@ using Microsoft.EntityFrameworkCore.Migrations; -#nullable disable - namespace Tgstation.Server.Host.Database.Migrations { /// diff --git a/src/Tgstation.Server.Host/Database/Migrations/20230622020647_PGAddMapThreads.Designer.cs b/src/Tgstation.Server.Host/Database/Migrations/20230622020647_PGAddMapThreads.Designer.cs index 6ef71f98ee..37c731af70 100644 --- a/src/Tgstation.Server.Host/Database/Migrations/20230622020647_PGAddMapThreads.Designer.cs +++ b/src/Tgstation.Server.Host/Database/Migrations/20230622020647_PGAddMapThreads.Designer.cs @@ -5,8 +5,6 @@ using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; -#nullable disable - namespace Tgstation.Server.Host.Database.Migrations { [DbContext(typeof(PostgresSqlDatabaseContext))] diff --git a/src/Tgstation.Server.Host/Database/Migrations/20230622020647_PGAddMapThreads.cs b/src/Tgstation.Server.Host/Database/Migrations/20230622020647_PGAddMapThreads.cs index 1ff154f448..1231427158 100644 --- a/src/Tgstation.Server.Host/Database/Migrations/20230622020647_PGAddMapThreads.cs +++ b/src/Tgstation.Server.Host/Database/Migrations/20230622020647_PGAddMapThreads.cs @@ -2,8 +2,6 @@ using Microsoft.EntityFrameworkCore.Migrations; -#nullable disable - namespace Tgstation.Server.Host.Database.Migrations { /// diff --git a/src/Tgstation.Server.Host/Database/Migrations/20230622020712_SLAddMapThreads.Designer.cs b/src/Tgstation.Server.Host/Database/Migrations/20230622020712_SLAddMapThreads.Designer.cs index 0db22004a6..23859c77be 100644 --- a/src/Tgstation.Server.Host/Database/Migrations/20230622020712_SLAddMapThreads.Designer.cs +++ b/src/Tgstation.Server.Host/Database/Migrations/20230622020712_SLAddMapThreads.Designer.cs @@ -5,8 +5,6 @@ using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; -#nullable disable - namespace Tgstation.Server.Host.Database.Migrations { [DbContext(typeof(SqliteDatabaseContext))] diff --git a/src/Tgstation.Server.Host/Database/Migrations/20230622020712_SLAddMapThreads.cs b/src/Tgstation.Server.Host/Database/Migrations/20230622020712_SLAddMapThreads.cs index 218c9d7d4b..8909a495d2 100644 --- a/src/Tgstation.Server.Host/Database/Migrations/20230622020712_SLAddMapThreads.cs +++ b/src/Tgstation.Server.Host/Database/Migrations/20230622020712_SLAddMapThreads.cs @@ -2,8 +2,6 @@ using Microsoft.EntityFrameworkCore.Migrations; -#nullable disable - namespace Tgstation.Server.Host.Database.Migrations { /// diff --git a/src/Tgstation.Server.Host/Database/Migrations/20231105004801_MSAddJobCodes.Designer.cs b/src/Tgstation.Server.Host/Database/Migrations/20231105004801_MSAddJobCodes.Designer.cs index 556f6d1009..3d2f9959ab 100644 --- a/src/Tgstation.Server.Host/Database/Migrations/20231105004801_MSAddJobCodes.Designer.cs +++ b/src/Tgstation.Server.Host/Database/Migrations/20231105004801_MSAddJobCodes.Designer.cs @@ -5,8 +5,6 @@ using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; -#nullable disable - namespace Tgstation.Server.Host.Database.Migrations { [DbContext(typeof(SqlServerDatabaseContext))] diff --git a/src/Tgstation.Server.Host/Database/Migrations/20231105004801_MSAddJobCodes.cs b/src/Tgstation.Server.Host/Database/Migrations/20231105004801_MSAddJobCodes.cs index 87636a060f..4a6606334a 100644 --- a/src/Tgstation.Server.Host/Database/Migrations/20231105004801_MSAddJobCodes.cs +++ b/src/Tgstation.Server.Host/Database/Migrations/20231105004801_MSAddJobCodes.cs @@ -2,8 +2,6 @@ using Microsoft.EntityFrameworkCore.Migrations; -#nullable disable - namespace Tgstation.Server.Host.Database.Migrations { /// diff --git a/src/Tgstation.Server.Host/Database/Migrations/20231105004808_MYAddJobCodes.Designer.cs b/src/Tgstation.Server.Host/Database/Migrations/20231105004808_MYAddJobCodes.Designer.cs index c5f5fb94dc..197b244173 100644 --- a/src/Tgstation.Server.Host/Database/Migrations/20231105004808_MYAddJobCodes.Designer.cs +++ b/src/Tgstation.Server.Host/Database/Migrations/20231105004808_MYAddJobCodes.Designer.cs @@ -5,8 +5,6 @@ using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; -#nullable disable - namespace Tgstation.Server.Host.Database.Migrations { [DbContext(typeof(MySqlDatabaseContext))] diff --git a/src/Tgstation.Server.Host/Database/Migrations/20231105004808_MYAddJobCodes.cs b/src/Tgstation.Server.Host/Database/Migrations/20231105004808_MYAddJobCodes.cs index 61eb53b6a5..4afb902183 100644 --- a/src/Tgstation.Server.Host/Database/Migrations/20231105004808_MYAddJobCodes.cs +++ b/src/Tgstation.Server.Host/Database/Migrations/20231105004808_MYAddJobCodes.cs @@ -2,8 +2,6 @@ using Microsoft.EntityFrameworkCore.Migrations; -#nullable disable - namespace Tgstation.Server.Host.Database.Migrations { /// diff --git a/src/Tgstation.Server.Host/Database/Migrations/20231105004814_PGAddJobCodes.Designer.cs b/src/Tgstation.Server.Host/Database/Migrations/20231105004814_PGAddJobCodes.Designer.cs index 6ad0149338..501367d6fc 100644 --- a/src/Tgstation.Server.Host/Database/Migrations/20231105004814_PGAddJobCodes.Designer.cs +++ b/src/Tgstation.Server.Host/Database/Migrations/20231105004814_PGAddJobCodes.Designer.cs @@ -5,8 +5,6 @@ using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; -#nullable disable - namespace Tgstation.Server.Host.Database.Migrations { [DbContext(typeof(PostgresSqlDatabaseContext))] diff --git a/src/Tgstation.Server.Host/Database/Migrations/20231105004814_PGAddJobCodes.cs b/src/Tgstation.Server.Host/Database/Migrations/20231105004814_PGAddJobCodes.cs index 5bd1b863f6..b11ba1b584 100644 --- a/src/Tgstation.Server.Host/Database/Migrations/20231105004814_PGAddJobCodes.cs +++ b/src/Tgstation.Server.Host/Database/Migrations/20231105004814_PGAddJobCodes.cs @@ -2,8 +2,6 @@ using Microsoft.EntityFrameworkCore.Migrations; -#nullable disable - namespace Tgstation.Server.Host.Database.Migrations { /// diff --git a/src/Tgstation.Server.Host/Database/Migrations/20231105004820_SLAddJobCodes.Designer.cs b/src/Tgstation.Server.Host/Database/Migrations/20231105004820_SLAddJobCodes.Designer.cs index 718743a339..7fb555cc8b 100644 --- a/src/Tgstation.Server.Host/Database/Migrations/20231105004820_SLAddJobCodes.Designer.cs +++ b/src/Tgstation.Server.Host/Database/Migrations/20231105004820_SLAddJobCodes.Designer.cs @@ -5,8 +5,6 @@ using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; -#nullable disable - namespace Tgstation.Server.Host.Database.Migrations { [DbContext(typeof(SqliteDatabaseContext))] diff --git a/src/Tgstation.Server.Host/Database/Migrations/20231105004820_SLAddJobCodes.cs b/src/Tgstation.Server.Host/Database/Migrations/20231105004820_SLAddJobCodes.cs index 76a2be02ee..77076a8361 100644 --- a/src/Tgstation.Server.Host/Database/Migrations/20231105004820_SLAddJobCodes.cs +++ b/src/Tgstation.Server.Host/Database/Migrations/20231105004820_SLAddJobCodes.cs @@ -2,8 +2,6 @@ using Microsoft.EntityFrameworkCore.Migrations; -#nullable disable - namespace Tgstation.Server.Host.Database.Migrations { /// diff --git a/src/Tgstation.Server.Host/Database/Migrations/20231108004349_MSRenameByondColumnsToEngine.Designer.cs b/src/Tgstation.Server.Host/Database/Migrations/20231108004349_MSRenameByondColumnsToEngine.Designer.cs index 65b94a6fc7..99cdc64c2e 100644 --- a/src/Tgstation.Server.Host/Database/Migrations/20231108004349_MSRenameByondColumnsToEngine.Designer.cs +++ b/src/Tgstation.Server.Host/Database/Migrations/20231108004349_MSRenameByondColumnsToEngine.Designer.cs @@ -5,8 +5,6 @@ using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; -#nullable disable - namespace Tgstation.Server.Host.Database.Migrations { [DbContext(typeof(SqlServerDatabaseContext))] diff --git a/src/Tgstation.Server.Host/Database/Migrations/20231108004349_MSRenameByondColumnsToEngine.cs b/src/Tgstation.Server.Host/Database/Migrations/20231108004349_MSRenameByondColumnsToEngine.cs index b142ab007b..cdf156ec28 100644 --- a/src/Tgstation.Server.Host/Database/Migrations/20231108004349_MSRenameByondColumnsToEngine.cs +++ b/src/Tgstation.Server.Host/Database/Migrations/20231108004349_MSRenameByondColumnsToEngine.cs @@ -2,8 +2,6 @@ using Microsoft.EntityFrameworkCore.Migrations; -#nullable disable - namespace Tgstation.Server.Host.Database.Migrations { /// diff --git a/src/Tgstation.Server.Host/Database/Migrations/20231108004356_MYRenameByondColumnsToEngine.Designer.cs b/src/Tgstation.Server.Host/Database/Migrations/20231108004356_MYRenameByondColumnsToEngine.Designer.cs index ff843c5a04..841a10d43d 100644 --- a/src/Tgstation.Server.Host/Database/Migrations/20231108004356_MYRenameByondColumnsToEngine.Designer.cs +++ b/src/Tgstation.Server.Host/Database/Migrations/20231108004356_MYRenameByondColumnsToEngine.Designer.cs @@ -5,8 +5,6 @@ using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; -#nullable disable - namespace Tgstation.Server.Host.Database.Migrations { [DbContext(typeof(MySqlDatabaseContext))] diff --git a/src/Tgstation.Server.Host/Database/Migrations/20231108004356_MYRenameByondColumnsToEngine.cs b/src/Tgstation.Server.Host/Database/Migrations/20231108004356_MYRenameByondColumnsToEngine.cs index 844b027d16..00a5d1fe1c 100644 --- a/src/Tgstation.Server.Host/Database/Migrations/20231108004356_MYRenameByondColumnsToEngine.cs +++ b/src/Tgstation.Server.Host/Database/Migrations/20231108004356_MYRenameByondColumnsToEngine.cs @@ -2,8 +2,6 @@ using Microsoft.EntityFrameworkCore.Migrations; -#nullable disable - namespace Tgstation.Server.Host.Database.Migrations { /// diff --git a/src/Tgstation.Server.Host/Database/Migrations/20231108004402_PGRenameByondColumnsToEngine.Designer.cs b/src/Tgstation.Server.Host/Database/Migrations/20231108004402_PGRenameByondColumnsToEngine.Designer.cs index 2689c8ae29..7f755e8876 100644 --- a/src/Tgstation.Server.Host/Database/Migrations/20231108004402_PGRenameByondColumnsToEngine.Designer.cs +++ b/src/Tgstation.Server.Host/Database/Migrations/20231108004402_PGRenameByondColumnsToEngine.Designer.cs @@ -5,8 +5,6 @@ using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; -#nullable disable - namespace Tgstation.Server.Host.Database.Migrations { [DbContext(typeof(PostgresSqlDatabaseContext))] diff --git a/src/Tgstation.Server.Host/Database/Migrations/20231108004402_PGRenameByondColumnsToEngine.cs b/src/Tgstation.Server.Host/Database/Migrations/20231108004402_PGRenameByondColumnsToEngine.cs index 32a4a0957e..4766b285e8 100644 --- a/src/Tgstation.Server.Host/Database/Migrations/20231108004402_PGRenameByondColumnsToEngine.cs +++ b/src/Tgstation.Server.Host/Database/Migrations/20231108004402_PGRenameByondColumnsToEngine.cs @@ -2,8 +2,6 @@ using Microsoft.EntityFrameworkCore.Migrations; -#nullable disable - namespace Tgstation.Server.Host.Database.Migrations { /// diff --git a/src/Tgstation.Server.Host/Database/Migrations/20231108004409_SLRenameByondColumnsToEngine.Designer.cs b/src/Tgstation.Server.Host/Database/Migrations/20231108004409_SLRenameByondColumnsToEngine.Designer.cs index f34889c73c..dae9036d07 100644 --- a/src/Tgstation.Server.Host/Database/Migrations/20231108004409_SLRenameByondColumnsToEngine.Designer.cs +++ b/src/Tgstation.Server.Host/Database/Migrations/20231108004409_SLRenameByondColumnsToEngine.Designer.cs @@ -5,8 +5,6 @@ using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Migrations; -#nullable disable - namespace Tgstation.Server.Host.Database.Migrations { [DbContext(typeof(SqliteDatabaseContext))] diff --git a/src/Tgstation.Server.Host/Database/Migrations/20231108004409_SLRenameByondColumnsToEngine.cs b/src/Tgstation.Server.Host/Database/Migrations/20231108004409_SLRenameByondColumnsToEngine.cs index 755fc8d06e..3b95c6433c 100644 --- a/src/Tgstation.Server.Host/Database/Migrations/20231108004409_SLRenameByondColumnsToEngine.cs +++ b/src/Tgstation.Server.Host/Database/Migrations/20231108004409_SLRenameByondColumnsToEngine.cs @@ -2,8 +2,6 @@ using Microsoft.EntityFrameworkCore.Migrations; -#nullable disable - namespace Tgstation.Server.Host.Database.Migrations { /// diff --git a/src/Tgstation.Server.Host/Database/Migrations/MySqlDatabaseContextModelSnapshot.cs b/src/Tgstation.Server.Host/Database/Migrations/MySqlDatabaseContextModelSnapshot.cs index 713ce53b72..e470e52b3c 100644 --- a/src/Tgstation.Server.Host/Database/Migrations/MySqlDatabaseContextModelSnapshot.cs +++ b/src/Tgstation.Server.Host/Database/Migrations/MySqlDatabaseContextModelSnapshot.cs @@ -4,8 +4,6 @@ using System; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; -#nullable disable - namespace Tgstation.Server.Host.Database.Migrations { [DbContext(typeof(MySqlDatabaseContext))] diff --git a/src/Tgstation.Server.Host/Database/Migrations/PostgresSqlDatabaseContextModelSnapshot.cs b/src/Tgstation.Server.Host/Database/Migrations/PostgresSqlDatabaseContextModelSnapshot.cs index 5e872a384a..96f60f6850 100644 --- a/src/Tgstation.Server.Host/Database/Migrations/PostgresSqlDatabaseContextModelSnapshot.cs +++ b/src/Tgstation.Server.Host/Database/Migrations/PostgresSqlDatabaseContextModelSnapshot.cs @@ -4,8 +4,6 @@ using System; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; -#nullable disable - namespace Tgstation.Server.Host.Database.Migrations { [DbContext(typeof(PostgresSqlDatabaseContext))] diff --git a/src/Tgstation.Server.Host/Database/Migrations/SqlServerDatabaseContextModelSnapshot.cs b/src/Tgstation.Server.Host/Database/Migrations/SqlServerDatabaseContextModelSnapshot.cs index cce9549902..30050cf789 100644 --- a/src/Tgstation.Server.Host/Database/Migrations/SqlServerDatabaseContextModelSnapshot.cs +++ b/src/Tgstation.Server.Host/Database/Migrations/SqlServerDatabaseContextModelSnapshot.cs @@ -4,8 +4,6 @@ using System; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; -#nullable disable - namespace Tgstation.Server.Host.Database.Migrations { [DbContext(typeof(SqlServerDatabaseContext))] diff --git a/src/Tgstation.Server.Host/Database/Migrations/SqliteDatabaseContextModelSnapshot.cs b/src/Tgstation.Server.Host/Database/Migrations/SqliteDatabaseContextModelSnapshot.cs index 3c0504bde5..3f4daecc39 100644 --- a/src/Tgstation.Server.Host/Database/Migrations/SqliteDatabaseContextModelSnapshot.cs +++ b/src/Tgstation.Server.Host/Database/Migrations/SqliteDatabaseContextModelSnapshot.cs @@ -4,8 +4,6 @@ using System; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; -#nullable disable - namespace Tgstation.Server.Host.Database.Migrations { [DbContext(typeof(SqliteDatabaseContext))] From 51fd04953efb76ae306b57abec087d4b5a89b3e4 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 23 Nov 2023 21:13:15 -0500 Subject: [PATCH 088/425] Nullify `DatabaseCollection` --- src/Tgstation.Server.Host/Database/DatabaseCollection.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Database/DatabaseCollection.cs b/src/Tgstation.Server.Host/Database/DatabaseCollection.cs index 831772335b..b2dafa719d 100644 --- a/src/Tgstation.Server.Host/Database/DatabaseCollection.cs +++ b/src/Tgstation.Server.Host/Database/DatabaseCollection.cs @@ -7,8 +7,6 @@ using System.Threading; using Microsoft.EntityFrameworkCore; -#nullable disable - namespace Tgstation.Server.Host.Database { /// From 6c50b3314761be5fe60ef026add2d4461a18ddbb Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 23 Nov 2023 21:13:27 -0500 Subject: [PATCH 089/425] Nullify `DatabaseConnectionFactory` --- src/Tgstation.Server.Host/Database/DatabaseConnectionFactory.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Database/DatabaseConnectionFactory.cs b/src/Tgstation.Server.Host/Database/DatabaseConnectionFactory.cs index 7cc0e2e5ed..b118f346db 100644 --- a/src/Tgstation.Server.Host/Database/DatabaseConnectionFactory.cs +++ b/src/Tgstation.Server.Host/Database/DatabaseConnectionFactory.cs @@ -10,8 +10,6 @@ using Npgsql; using Tgstation.Server.Host.Configuration; -#nullable disable - namespace Tgstation.Server.Host.Database { /// From bc80713a9520dd5bf45eb808c117e5feef931559 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 23 Nov 2023 21:14:17 -0500 Subject: [PATCH 090/425] Nullify `DatabaseContext` --- .../Database/DatabaseContext.cs | 34 +++++++++---------- 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/src/Tgstation.Server.Host/Database/DatabaseContext.cs b/src/Tgstation.Server.Host/Database/DatabaseContext.cs index 6b1ce65d23..a98fb1c180 100644 --- a/src/Tgstation.Server.Host/Database/DatabaseContext.cs +++ b/src/Tgstation.Server.Host/Database/DatabaseContext.cs @@ -15,8 +15,6 @@ using Tgstation.Server.Host.Configuration; using Tgstation.Server.Host.Database.Migrations; using Tgstation.Server.Host.Models; -#nullable disable - namespace Tgstation.Server.Host.Database { /// @@ -262,21 +260,21 @@ namespace Tgstation.Server.Host.Database protected DatabaseContext(DbContextOptions dbContextOptions) : base(dbContextOptions) { - usersCollection = new DatabaseCollection(Users); - instancesCollection = new DatabaseCollection(Instances); - instancePermissionSetsCollection = new DatabaseCollection(InstancePermissionSets); - compileJobsCollection = new DatabaseCollection(CompileJobs); - repositorySettingsCollection = new DatabaseCollection(RepositorySettings); - dreamMakerSettingsCollection = new DatabaseCollection(DreamMakerSettings); - dreamDaemonSettingsCollection = new DatabaseCollection(DreamDaemonSettings); - chatBotsCollection = new DatabaseCollection(ChatBots); - chatChannelsCollection = new DatabaseCollection(ChatChannels); - revisionInformationsCollection = new DatabaseCollection(RevisionInformations); - jobsCollection = new DatabaseCollection(Jobs); - reattachInformationsCollection = new DatabaseCollection(ReattachInformations); - oAuthConnections = new DatabaseCollection(OAuthConnections); - groups = new DatabaseCollection(Groups); - permissionSets = new DatabaseCollection(PermissionSets); + usersCollection = new DatabaseCollection(Users!); + instancesCollection = new DatabaseCollection(Instances!); + instancePermissionSetsCollection = new DatabaseCollection(InstancePermissionSets!); + compileJobsCollection = new DatabaseCollection(CompileJobs!); + repositorySettingsCollection = new DatabaseCollection(RepositorySettings!); + dreamMakerSettingsCollection = new DatabaseCollection(DreamMakerSettings!); + dreamDaemonSettingsCollection = new DatabaseCollection(DreamDaemonSettings!); + chatBotsCollection = new DatabaseCollection(ChatBots!); + chatChannelsCollection = new DatabaseCollection(ChatChannels!); + revisionInformationsCollection = new DatabaseCollection(RevisionInformations!); + jobsCollection = new DatabaseCollection(Jobs!); + reattachInformationsCollection = new DatabaseCollection(ReattachInformations!); + oAuthConnections = new DatabaseCollection(OAuthConnections!); + groups = new DatabaseCollection(Groups!); + permissionSets = new DatabaseCollection(PermissionSets!); } /// @@ -420,7 +418,7 @@ namespace Tgstation.Server.Host.Database throw new NotSupportedException("Cannot migrate below version 4.1.0!"); // Update this with new migrations as they are made - string targetMigration = null; + string? targetMigration = null; string BadDatabaseType() => throw new ArgumentException($"Invalid DatabaseType: {currentDatabaseType}", nameof(currentDatabaseType)); From f23d32f36c5519180152722901976f1ec828721b Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 23 Nov 2023 21:15:16 -0500 Subject: [PATCH 091/425] Nullify `DatabaseContextFactory` --- src/Tgstation.Server.Host/Database/DatabaseContextFactory.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Database/DatabaseContextFactory.cs b/src/Tgstation.Server.Host/Database/DatabaseContextFactory.cs index 854bc6ea65..b04e32858b 100644 --- a/src/Tgstation.Server.Host/Database/DatabaseContextFactory.cs +++ b/src/Tgstation.Server.Host/Database/DatabaseContextFactory.cs @@ -3,8 +3,6 @@ using System.Threading.Tasks; using Microsoft.Extensions.DependencyInjection; -#nullable disable - namespace Tgstation.Server.Host.Database { /// From e5b55f07aa45c94e0d0e6baef099334868561686 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 23 Nov 2023 21:18:26 -0500 Subject: [PATCH 092/425] Nullify `DatabaseSeeder` --- src/Tgstation.Server.Host/Database/DatabaseSeeder.cs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/Tgstation.Server.Host/Database/DatabaseSeeder.cs b/src/Tgstation.Server.Host/Database/DatabaseSeeder.cs index 51bf71bc6d..c88c7a5e0d 100644 --- a/src/Tgstation.Server.Host/Database/DatabaseSeeder.cs +++ b/src/Tgstation.Server.Host/Database/DatabaseSeeder.cs @@ -16,8 +16,6 @@ using Tgstation.Server.Host.System; using Z.EntityFramework.Plus; -#nullable disable - namespace Tgstation.Server.Host.Database { /// @@ -59,7 +57,7 @@ namespace Tgstation.Server.Host.Database /// The to add a system to. /// An existing , if any. /// The created system . - static User SeedSystemUser(IDatabaseContext databaseContext, User tgsUser = null) + static User SeedSystemUser(IDatabaseContext databaseContext, User? tgsUser = null) { bool alreadyExists = tgsUser != null; tgsUser ??= new User() @@ -233,7 +231,7 @@ namespace Tgstation.Server.Host.Database .AsQueryable() .ToListAsync(cancellationToken); foreach (var instance in allInstances) - instance.Path = instance.Path.Replace('\\', '/'); + instance.Path = instance.Path!.Replace('\\', '/'); } if (generalConfiguration.ByondTopicTimeout != 0) @@ -305,7 +303,7 @@ namespace Tgstation.Server.Host.Database /// The to use. /// The for the operation. /// A resulting in the admin or . If , must be called on . - async ValueTask GetAdminUser(IDatabaseContext databaseContext, CancellationToken cancellationToken) + async ValueTask GetAdminUser(IDatabaseContext databaseContext, CancellationToken cancellationToken) { var admin = await databaseContext .Users From d8e0e1f3e653f30379e4cddcc902981560ca1ec1 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 23 Nov 2023 21:18:45 -0500 Subject: [PATCH 093/425] Nullify `IDatabaseCollection` --- src/Tgstation.Server.Host/Database/IDatabaseCollection.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Database/IDatabaseCollection.cs b/src/Tgstation.Server.Host/Database/IDatabaseCollection.cs index 08df6330f9..a9e1fe0e03 100644 --- a/src/Tgstation.Server.Host/Database/IDatabaseCollection.cs +++ b/src/Tgstation.Server.Host/Database/IDatabaseCollection.cs @@ -1,8 +1,6 @@ using System.Collections.Generic; using System.Linq; -#nullable disable - namespace Tgstation.Server.Host.Database { /// From 34f8f2c63bc85286df5223972a04a4f4cc225c4d Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 23 Nov 2023 21:18:59 -0500 Subject: [PATCH 094/425] Nullify `IDatabaseConnectionFactory` --- .../Database/IDatabaseConnectionFactory.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Database/IDatabaseConnectionFactory.cs b/src/Tgstation.Server.Host/Database/IDatabaseConnectionFactory.cs index 7ce5ba0f5f..abea5f1702 100644 --- a/src/Tgstation.Server.Host/Database/IDatabaseConnectionFactory.cs +++ b/src/Tgstation.Server.Host/Database/IDatabaseConnectionFactory.cs @@ -2,8 +2,6 @@ using Tgstation.Server.Host.Configuration; -#nullable disable - namespace Tgstation.Server.Host.Database { /// From 46712f5f229d2f5fe46a8bbbf1a26ea411be883e Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 23 Nov 2023 21:19:16 -0500 Subject: [PATCH 095/425] Nullify `IDatabaseContext` --- src/Tgstation.Server.Host/Database/IDatabaseContext.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Database/IDatabaseContext.cs b/src/Tgstation.Server.Host/Database/IDatabaseContext.cs index dc276cf371..00b90298c6 100644 --- a/src/Tgstation.Server.Host/Database/IDatabaseContext.cs +++ b/src/Tgstation.Server.Host/Database/IDatabaseContext.cs @@ -8,8 +8,6 @@ using Microsoft.Extensions.Logging; using Tgstation.Server.Host.Configuration; using Tgstation.Server.Host.Models; -#nullable disable - namespace Tgstation.Server.Host.Database { /// From b6cc749dd9e0ed59f3756d59117dbd00b08cc8d3 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 23 Nov 2023 21:19:34 -0500 Subject: [PATCH 096/425] Nullift `IDatabaseContextFactory` --- src/Tgstation.Server.Host/Database/IDatabaseContextFactory.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Database/IDatabaseContextFactory.cs b/src/Tgstation.Server.Host/Database/IDatabaseContextFactory.cs index a51906ff40..4004c873c0 100644 --- a/src/Tgstation.Server.Host/Database/IDatabaseContextFactory.cs +++ b/src/Tgstation.Server.Host/Database/IDatabaseContextFactory.cs @@ -1,8 +1,6 @@ using System; using System.Threading.Tasks; -#nullable disable - namespace Tgstation.Server.Host.Database { /// From eb16e393c806337977d446cdbe2c25d5edf487d9 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 23 Nov 2023 21:19:51 -0500 Subject: [PATCH 097/425] Nullify `IDatabaseSeeder` --- src/Tgstation.Server.Host/Database/IDatabaseSeeder.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Database/IDatabaseSeeder.cs b/src/Tgstation.Server.Host/Database/IDatabaseSeeder.cs index 76c0761fb9..e888b0093a 100644 --- a/src/Tgstation.Server.Host/Database/IDatabaseSeeder.cs +++ b/src/Tgstation.Server.Host/Database/IDatabaseSeeder.cs @@ -2,8 +2,6 @@ using System.Threading; using System.Threading.Tasks; -#nullable disable - namespace Tgstation.Server.Host.Database { /// From 99a0e21be4dc0da87a6faf39c0c81250e7b446bf Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 23 Nov 2023 21:20:34 -0500 Subject: [PATCH 098/425] Nullify `DatabaseContext` overrides --- src/Tgstation.Server.Host/Database/MySqlDatabaseContext.cs | 2 -- .../Database/PostgresSqlDatabaseContext.cs | 2 -- src/Tgstation.Server.Host/Database/SqlServerDatabaseContext.cs | 2 -- src/Tgstation.Server.Host/Database/SqliteDatabaseContext.cs | 2 -- 4 files changed, 8 deletions(-) diff --git a/src/Tgstation.Server.Host/Database/MySqlDatabaseContext.cs b/src/Tgstation.Server.Host/Database/MySqlDatabaseContext.cs index 68112d5fb2..4bdcf9a066 100644 --- a/src/Tgstation.Server.Host/Database/MySqlDatabaseContext.cs +++ b/src/Tgstation.Server.Host/Database/MySqlDatabaseContext.cs @@ -8,8 +8,6 @@ using Tgstation.Server.Host.Configuration; using Tgstation.Server.Host.Extensions; using Tgstation.Server.Host.Models; -#nullable disable - namespace Tgstation.Server.Host.Database { /// diff --git a/src/Tgstation.Server.Host/Database/PostgresSqlDatabaseContext.cs b/src/Tgstation.Server.Host/Database/PostgresSqlDatabaseContext.cs index 952f515347..d9157ab41a 100644 --- a/src/Tgstation.Server.Host/Database/PostgresSqlDatabaseContext.cs +++ b/src/Tgstation.Server.Host/Database/PostgresSqlDatabaseContext.cs @@ -4,8 +4,6 @@ using Microsoft.EntityFrameworkCore; using Tgstation.Server.Host.Configuration; -#nullable disable - namespace Tgstation.Server.Host.Database { /// diff --git a/src/Tgstation.Server.Host/Database/SqlServerDatabaseContext.cs b/src/Tgstation.Server.Host/Database/SqlServerDatabaseContext.cs index 10e1f6d16f..3997e0a46b 100644 --- a/src/Tgstation.Server.Host/Database/SqlServerDatabaseContext.cs +++ b/src/Tgstation.Server.Host/Database/SqlServerDatabaseContext.cs @@ -4,8 +4,6 @@ using Microsoft.EntityFrameworkCore; using Tgstation.Server.Host.Configuration; -#nullable disable - namespace Tgstation.Server.Host.Database { /// diff --git a/src/Tgstation.Server.Host/Database/SqliteDatabaseContext.cs b/src/Tgstation.Server.Host/Database/SqliteDatabaseContext.cs index 1a35d2e769..98a58190d9 100644 --- a/src/Tgstation.Server.Host/Database/SqliteDatabaseContext.cs +++ b/src/Tgstation.Server.Host/Database/SqliteDatabaseContext.cs @@ -6,8 +6,6 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion; using Tgstation.Server.Host.Configuration; -#nullable disable - namespace Tgstation.Server.Host.Database { /// From cdee693be916dd03e7fcccffa5841d57cbb5a17d Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 23 Nov 2023 21:22:03 -0500 Subject: [PATCH 099/425] Nullify `BoolConverter` --- .../Extensions/Converters/BoolConverter.cs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/Tgstation.Server.Host/Extensions/Converters/BoolConverter.cs b/src/Tgstation.Server.Host/Extensions/Converters/BoolConverter.cs index 502980a212..7812072f4a 100644 --- a/src/Tgstation.Server.Host/Extensions/Converters/BoolConverter.cs +++ b/src/Tgstation.Server.Host/Extensions/Converters/BoolConverter.cs @@ -2,8 +2,6 @@ using Newtonsoft.Json; -#nullable disable - namespace Tgstation.Server.Host.Extensions.Converters { /// @@ -12,10 +10,18 @@ namespace Tgstation.Server.Host.Extensions.Converters sealed class BoolConverter : JsonConverter { /// - public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) => writer.WriteValue(((bool)value) ? 1 : 0); + public override void WriteJson(JsonWriter? writer, object? value, JsonSerializer serializer) + { + ArgumentNullException.ThrowIfNull(writer); + writer.WriteValue(((bool)value!) ? 1 : 0); + } /// - public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) => reader.Value.ToString() == "1"; + public override object? ReadJson(JsonReader? reader, Type? objectType, object? existingValue, JsonSerializer serializer) + { + ArgumentNullException.ThrowIfNull(reader); + return reader.Value!.ToString() == "1"; + } /// public override bool CanConvert(Type objectType) => objectType == typeof(bool); From 8f1dfe99c03882a2c7c32ffd5297bd42ed078792 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 23 Nov 2023 21:23:24 -0500 Subject: [PATCH 100/425] Nullify `VersionConverter` --- .../Extensions/Converters/VersionConverter.cs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/Tgstation.Server.Host/Extensions/Converters/VersionConverter.cs b/src/Tgstation.Server.Host/Extensions/Converters/VersionConverter.cs index e1bf992cab..48c593d72f 100644 --- a/src/Tgstation.Server.Host/Extensions/Converters/VersionConverter.cs +++ b/src/Tgstation.Server.Host/Extensions/Converters/VersionConverter.cs @@ -8,8 +8,6 @@ using YamlDotNet.Core; using YamlDotNet.Core.Events; using YamlDotNet.Serialization; -#nullable disable - namespace Tgstation.Server.Host.Extensions.Converters { /// @@ -23,7 +21,7 @@ namespace Tgstation.Server.Host.Extensions.Converters /// The to check. /// If the method should if validation fails. /// if is a , otherwise. - static bool CheckSupportsType(Type type, bool validate) + static bool CheckSupportsType(Type? type, bool validate) { ArgumentNullException.ThrowIfNull(type); @@ -35,7 +33,7 @@ namespace Tgstation.Server.Host.Extensions.Converters } /// - public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) + public override void WriteJson(JsonWriter? writer, object? value, JsonSerializer serializer) { ArgumentNullException.ThrowIfNull(writer); @@ -54,7 +52,7 @@ namespace Tgstation.Server.Host.Extensions.Converters } /// - public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) + public override object? ReadJson(JsonReader? reader, Type? objectType, object? existingValue, JsonSerializer serializer) { ArgumentNullException.ThrowIfNull(reader); @@ -67,7 +65,7 @@ namespace Tgstation.Server.Host.Extensions.Converters { try { - var v = global::System.Version.Parse((string)reader.Value); + var v = global::System.Version.Parse((string)reader.Value!); return v.Semver(); } catch (Exception ex) @@ -90,7 +88,7 @@ namespace Tgstation.Server.Host.Extensions.Converters public object ReadYaml(IParser parser, Type type) => throw new NotSupportedException("Deserialization not supported!"); // The default implementation is fine at handling this /// - public void WriteYaml(IEmitter emitter, object value, Type type) + public void WriteYaml(IEmitter? emitter, object? value, Type type) { ArgumentNullException.ThrowIfNull(emitter); From a9a82f0beeb3f03189aad0221678ea6f672dc0c2 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 23 Nov 2023 21:23:44 -0500 Subject: [PATCH 101/425] Nullify `ApplicationBuilderExtensions` --- .../Extensions/ApplicationBuilderExtensions.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Extensions/ApplicationBuilderExtensions.cs b/src/Tgstation.Server.Host/Extensions/ApplicationBuilderExtensions.cs index 1e69a743f0..637484f5bd 100644 --- a/src/Tgstation.Server.Host/Extensions/ApplicationBuilderExtensions.cs +++ b/src/Tgstation.Server.Host/Extensions/ApplicationBuilderExtensions.cs @@ -17,8 +17,6 @@ using Tgstation.Server.Host.Configuration; using Tgstation.Server.Host.System; using Tgstation.Server.Host.Utils; -#nullable disable - namespace Tgstation.Server.Host.Extensions { /// From a4e1b8ea7696dc96c3a6b34e45f5c1d6845400fd Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 23 Nov 2023 21:24:11 -0500 Subject: [PATCH 102/425] Nullify `ChatChannelExtensions` --- src/Tgstation.Server.Host/Extensions/ChatChannelExtensions.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Tgstation.Server.Host/Extensions/ChatChannelExtensions.cs b/src/Tgstation.Server.Host/Extensions/ChatChannelExtensions.cs index e4bb8948e3..3b77bd0b1f 100644 --- a/src/Tgstation.Server.Host/Extensions/ChatChannelExtensions.cs +++ b/src/Tgstation.Server.Host/Extensions/ChatChannelExtensions.cs @@ -4,8 +4,6 @@ using System.Linq; using Tgstation.Server.Host.Models; -#nullable disable - namespace Tgstation.Server.Host.Extensions { /// @@ -25,7 +23,7 @@ namespace Tgstation.Server.Host.Extensions /// /// The to retrieve information from. /// The IRC channel key stored in the if it exists, otherwise. - public static string GetIrcChannelKey(this ChatChannel chatChannel) + public static string? GetIrcChannelKey(this ChatChannel chatChannel) { var splits = GetIrcChannelSplits(chatChannel); if (splits.Count < 2) From 79b188a07f9ae9f3df44e2a304c0745f42b612f3 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 23 Nov 2023 21:24:30 -0500 Subject: [PATCH 103/425] Nullify `ControllerBaseExtensions` --- .../Extensions/ControllerBaseExtensions.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Extensions/ControllerBaseExtensions.cs b/src/Tgstation.Server.Host/Extensions/ControllerBaseExtensions.cs index 73f87308c7..9ab3b1cc87 100644 --- a/src/Tgstation.Server.Host/Extensions/ControllerBaseExtensions.cs +++ b/src/Tgstation.Server.Host/Extensions/ControllerBaseExtensions.cs @@ -6,8 +6,6 @@ using Microsoft.AspNetCore.Mvc; using Tgstation.Server.Api.Models; using Tgstation.Server.Api.Models.Response; -#nullable disable - namespace Tgstation.Server.Host.Extensions { /// From cd9f07b4970e87a565f8bb87f419891df73f74fe Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 23 Nov 2023 21:25:00 -0500 Subject: [PATCH 104/425] Nullify `DatabaseCollectionExtensions` --- .../Extensions/DatabaseCollectionExtensions.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Extensions/DatabaseCollectionExtensions.cs b/src/Tgstation.Server.Host/Extensions/DatabaseCollectionExtensions.cs index 40f005609c..ea50a7af17 100644 --- a/src/Tgstation.Server.Host/Extensions/DatabaseCollectionExtensions.cs +++ b/src/Tgstation.Server.Host/Extensions/DatabaseCollectionExtensions.cs @@ -9,8 +9,6 @@ using Microsoft.EntityFrameworkCore; using Tgstation.Server.Host.Database; using Tgstation.Server.Host.Models; -#nullable disable - namespace Tgstation.Server.Host.Extensions { /// From 6a53712175bdf90989613656eb918c951a9e3f2e Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 23 Nov 2023 21:25:19 -0500 Subject: [PATCH 105/425] Nullify `DateTimeOffsetExtensions` --- .../Extensions/DateTimeOffsetExtensions.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Extensions/DateTimeOffsetExtensions.cs b/src/Tgstation.Server.Host/Extensions/DateTimeOffsetExtensions.cs index 1d3a864cf9..44b0669314 100644 --- a/src/Tgstation.Server.Host/Extensions/DateTimeOffsetExtensions.cs +++ b/src/Tgstation.Server.Host/Extensions/DateTimeOffsetExtensions.cs @@ -1,8 +1,6 @@ using System; using System.Globalization; -#nullable disable - namespace Tgstation.Server.Host.Extensions { /// From 33e7d6c3afa89bc5103cfe6e0d4b02091bbe3b21 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 23 Nov 2023 21:26:10 -0500 Subject: [PATCH 106/425] Nullify `FileTransferStreamHandlerExtensions` --- .../Extensions/FileTransferStreamHandlerExtensions.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Tgstation.Server.Host/Extensions/FileTransferStreamHandlerExtensions.cs b/src/Tgstation.Server.Host/Extensions/FileTransferStreamHandlerExtensions.cs index 632bd0bd72..5bae10e79b 100644 --- a/src/Tgstation.Server.Host/Extensions/FileTransferStreamHandlerExtensions.cs +++ b/src/Tgstation.Server.Host/Extensions/FileTransferStreamHandlerExtensions.cs @@ -14,8 +14,6 @@ using Tgstation.Server.Api.Models.Response; using Tgstation.Server.Host.Controllers.Results; using Tgstation.Server.Host.Transfer; -#nullable disable - namespace Tgstation.Server.Host.Extensions { /// @@ -69,7 +67,9 @@ namespace Tgstation.Server.Host.Extensions } catch { - await stream.DisposeAsync(); + if (stream != null) + await stream.DisposeAsync(); + throw; } } From 5415d7c4abaae7d5d2e6808b6f9c43ca3856f6f6 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 23 Nov 2023 21:26:26 -0500 Subject: [PATCH 107/425] Nullify `GeneralConfigurationExtensions` --- .../Extensions/GeneralConfigurationExtensions.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Extensions/GeneralConfigurationExtensions.cs b/src/Tgstation.Server.Host/Extensions/GeneralConfigurationExtensions.cs index 5214ed0085..0a2a5fc8d8 100644 --- a/src/Tgstation.Server.Host/Extensions/GeneralConfigurationExtensions.cs +++ b/src/Tgstation.Server.Host/Extensions/GeneralConfigurationExtensions.cs @@ -2,8 +2,6 @@ using Tgstation.Server.Host.Configuration; -#nullable disable - namespace Tgstation.Server.Host.Extensions { /// From f2a12cbb8220098f58098214d40d76e716088923 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 23 Nov 2023 21:26:39 -0500 Subject: [PATCH 108/425] Nullify `HostBuilderExtensions` --- src/Tgstation.Server.Host/Extensions/HostBuilderExtensions.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Extensions/HostBuilderExtensions.cs b/src/Tgstation.Server.Host/Extensions/HostBuilderExtensions.cs index 160293e744..6bfc4cb528 100644 --- a/src/Tgstation.Server.Host/Extensions/HostBuilderExtensions.cs +++ b/src/Tgstation.Server.Host/Extensions/HostBuilderExtensions.cs @@ -6,8 +6,6 @@ using Tgstation.Server.Host.IO; using Tgstation.Server.Host.Setup; using Tgstation.Server.Host.System; -#nullable disable - namespace Tgstation.Server.Host.Extensions { /// From e4de050af6c86a947c1cdbe12b6e72bc874c77ea Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 23 Nov 2023 21:26:50 -0500 Subject: [PATCH 109/425] Nullify `ModelBuilderExtensions` --- src/Tgstation.Server.Host/Extensions/ModelBuilderExtensions.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Extensions/ModelBuilderExtensions.cs b/src/Tgstation.Server.Host/Extensions/ModelBuilderExtensions.cs index 8ecf17c600..f503f2c717 100644 --- a/src/Tgstation.Server.Host/Extensions/ModelBuilderExtensions.cs +++ b/src/Tgstation.Server.Host/Extensions/ModelBuilderExtensions.cs @@ -7,8 +7,6 @@ using Microsoft.EntityFrameworkCore; using Tgstation.Server.Api.Models; -#nullable disable - namespace Tgstation.Server.Host.Extensions { /// From 7abcce481900445d88e5674015ce81bc4e28cbdb Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 23 Nov 2023 21:27:38 -0500 Subject: [PATCH 110/425] Nullify `ModelBuilderExtensions` --- .../Extensions/ModelBuilderExtensions.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Extensions/ModelBuilderExtensions.cs b/src/Tgstation.Server.Host/Extensions/ModelBuilderExtensions.cs index f503f2c717..0db5100952 100644 --- a/src/Tgstation.Server.Host/Extensions/ModelBuilderExtensions.cs +++ b/src/Tgstation.Server.Host/Extensions/ModelBuilderExtensions.cs @@ -23,7 +23,7 @@ namespace Tgstation.Server.Host.Extensions /// . public static ModelBuilder MapMySqlTextField( this ModelBuilder modelBuilder, - Expression> expression) + Expression> expression) where TEntity : class { var property = modelBuilder @@ -47,7 +47,7 @@ namespace Tgstation.Server.Host.Extensions /// The entity. /// The accessing the relevant property. /// The pointed to by . - static PropertyInfo GetPropertyFromExpression(Expression> expression) + static PropertyInfo GetPropertyFromExpression(Expression> expression) { MemberExpression memberExpression; From f54eac33cae158e9cebd9b35e6c043734caffe2b Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 23 Nov 2023 21:28:06 -0500 Subject: [PATCH 111/425] Nullify `ResultExtensions` --- src/Tgstation.Server.Host/Extensions/ResultExtensions.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Tgstation.Server.Host/Extensions/ResultExtensions.cs b/src/Tgstation.Server.Host/Extensions/ResultExtensions.cs index 4f7d3bc4a4..f1157f2286 100644 --- a/src/Tgstation.Server.Host/Extensions/ResultExtensions.cs +++ b/src/Tgstation.Server.Host/Extensions/ResultExtensions.cs @@ -7,8 +7,6 @@ using Remora.Discord.API.Objects; using Remora.Rest.Results; using Remora.Results; -#nullable disable - namespace Tgstation.Server.Host.Extensions { /// @@ -118,7 +116,7 @@ namespace Tgstation.Server.Host.Extensions /// /// The of . /// The to mutate. - static void FormatErrorDetails(IEnumerable errorDetails, StringBuilder stringBuilder) + static void FormatErrorDetails(IEnumerable? errorDetails, StringBuilder stringBuilder) { if (errorDetails == null) return; From d23a4efca0fb85a785a2ed90d51c1491fa41ae1f Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 23 Nov 2023 21:31:17 -0500 Subject: [PATCH 112/425] Nullify `ServiceCollectionExtensions` --- .../Extensions/ServiceCollectionExtensions.cs | 28 +++++++++---------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/src/Tgstation.Server.Host/Extensions/ServiceCollectionExtensions.cs b/src/Tgstation.Server.Host/Extensions/ServiceCollectionExtensions.cs index f32d2a675d..cc7eb227a9 100644 --- a/src/Tgstation.Server.Host/Extensions/ServiceCollectionExtensions.cs +++ b/src/Tgstation.Server.Host/Extensions/ServiceCollectionExtensions.cs @@ -18,8 +18,6 @@ using Tgstation.Server.Host.Utils; using Tgstation.Server.Host.Utils.GitHub; using Tgstation.Server.Host.Utils.SignalR; -#nullable disable - namespace Tgstation.Server.Host.Extensions { /// @@ -30,22 +28,22 @@ namespace Tgstation.Server.Host.Extensions /// /// The implementation used in calls to . /// - static Type chatProviderFactoryType; + static Type? chatProviderFactoryType; /// /// The implementation used in calls to . /// - static Type gitHubServiceFactoryType; + static Type? gitHubServiceFactoryType; /// /// The implementation used in calls to . /// - static Type fileDownloaderType; + static Type? fileDownloaderType; /// /// A for an additional to use. /// - static ServiceDescriptor additionalLoggerProvider; + static ServiceDescriptor? additionalLoggerProvider; /// /// Initializes static members of the class. @@ -94,7 +92,7 @@ namespace Tgstation.Server.Host.Extensions { ArgumentNullException.ThrowIfNull(serviceCollection); - serviceCollection.AddSingleton(typeof(IFileDownloader), fileDownloaderType); + serviceCollection.AddSingleton(typeof(IFileDownloader), fileDownloaderType ?? throw new InvalidOperationException("fileDownloaderType not set!")); return serviceCollection; } @@ -109,7 +107,7 @@ namespace Tgstation.Server.Host.Extensions ArgumentNullException.ThrowIfNull(serviceCollection); serviceCollection.AddSingleton(); - serviceCollection.AddSingleton(typeof(IGitHubServiceFactory), gitHubServiceFactoryType); + serviceCollection.AddSingleton(typeof(IGitHubServiceFactory), gitHubServiceFactoryType ?? throw new InvalidOperationException("gitHubServiceFactoryType not set!")); return serviceCollection; } @@ -135,7 +133,7 @@ namespace Tgstation.Server.Host.Extensions { ArgumentNullException.ThrowIfNull(serviceCollection); - return serviceCollection.AddSingleton(typeof(IProviderFactory), chatProviderFactoryType); + return serviceCollection.AddSingleton(typeof(IProviderFactory), chatProviderFactoryType ?? throw new InvalidOperationException("chatProviderFactoryType not set!")); } /// @@ -160,7 +158,7 @@ namespace Tgstation.Server.Host.Extensions if (sectionField.FieldType != stringType) throw new InvalidOperationException(String.Format(CultureInfo.InvariantCulture, "{0} has invalid {1} field type, must be {2}!", configType, SectionFieldName, stringType)); - var sectionName = (string)sectionField.GetValue(null); + var sectionName = (string)sectionField.GetValue(null)!; return serviceCollection.Configure(configuration.GetSection(sectionName)); } @@ -178,10 +176,10 @@ namespace Tgstation.Server.Host.Extensions public static IServiceCollection SetupLogging( this IServiceCollection serviceCollection, Action configurationAction, - Action sinkConfigurationAction = null, - ElasticsearchSinkOptions elasticsearchSinkOptions = null, - InternalConfiguration internalConfiguration = null, - FileLoggingConfiguration fileLoggingConfiguration = null) + Action? sinkConfigurationAction = null, + ElasticsearchSinkOptions? elasticsearchSinkOptions = null, + InternalConfiguration? internalConfiguration = null, + FileLoggingConfiguration? fileLoggingConfiguration = null) { if (internalConfiguration != null) ArgumentNullException.ThrowIfNull(fileLoggingConfiguration); @@ -205,7 +203,7 @@ namespace Tgstation.Server.Host.Extensions + SerilogContextHelper.Template + "){NewLine} {Message:lj}{NewLine}{Exception}"; - if (!((internalConfiguration?.UsingSystemD ?? false) && !fileLoggingConfiguration.Disable)) + if (!((internalConfiguration?.UsingSystemD ?? false) && !(fileLoggingConfiguration?.Disable ?? false))) sinkConfiguration.Console(outputTemplate: template, formatProvider: CultureInfo.InvariantCulture); sinkConfigurationAction?.Invoke(sinkConfiguration); }); From 98b5fdcff53024425e6e8222b18ba9be53831793 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 23 Nov 2023 21:31:31 -0500 Subject: [PATCH 113/425] Nullify `SocketExtensions` --- src/Tgstation.Server.Host/Extensions/SocketExtensions.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Extensions/SocketExtensions.cs b/src/Tgstation.Server.Host/Extensions/SocketExtensions.cs index 1c74a95a50..6c1a695025 100644 --- a/src/Tgstation.Server.Host/Extensions/SocketExtensions.cs +++ b/src/Tgstation.Server.Host/Extensions/SocketExtensions.cs @@ -4,8 +4,6 @@ using System.Net.Sockets; using Tgstation.Server.Host.System; -#nullable disable - namespace Tgstation.Server.Host.Extensions { /// From 437d837ca41029fff5b83c89f5acfd8e47158aaa Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 23 Nov 2023 21:32:39 -0500 Subject: [PATCH 114/425] Nullify `TaskExtensions` --- src/Tgstation.Server.Host/Extensions/TaskExtensions.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Extensions/TaskExtensions.cs b/src/Tgstation.Server.Host/Extensions/TaskExtensions.cs index b2e5eaaf9e..55b6701dbb 100644 --- a/src/Tgstation.Server.Host/Extensions/TaskExtensions.cs +++ b/src/Tgstation.Server.Host/Extensions/TaskExtensions.cs @@ -1,7 +1,5 @@ using System.Threading.Tasks; -#nullable disable - namespace Tgstation.Server.Host.Extensions { /// From e3a7570574e6f3cda5995ad3d1b0c4d3d3b5083f Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 23 Nov 2023 21:33:14 -0500 Subject: [PATCH 115/425] Nullify `WebHostBuilderExtensions` --- .../Extensions/WebHostBuilderExtensions.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Extensions/WebHostBuilderExtensions.cs b/src/Tgstation.Server.Host/Extensions/WebHostBuilderExtensions.cs index c2f430e172..e6815cd7a0 100644 --- a/src/Tgstation.Server.Host/Extensions/WebHostBuilderExtensions.cs +++ b/src/Tgstation.Server.Host/Extensions/WebHostBuilderExtensions.cs @@ -13,8 +13,6 @@ using Tgstation.Server.Host.Security; using Tgstation.Server.Host.Setup; using Tgstation.Server.Host.System; -#nullable disable - namespace Tgstation.Server.Host.Extensions { /// From 800b772736562a77972f18751ba767d92ff680a8 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Fri, 24 Nov 2023 09:32:52 -0500 Subject: [PATCH 116/425] Nullify `AuthenticationContext` --- .../Security/AuthenticationContext.cs | 28 ++++++++++++------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/src/Tgstation.Server.Host/Security/AuthenticationContext.cs b/src/Tgstation.Server.Host/Security/AuthenticationContext.cs index b8719d5cc8..f0f4e5be03 100644 --- a/src/Tgstation.Server.Host/Security/AuthenticationContext.cs +++ b/src/Tgstation.Server.Host/Security/AuthenticationContext.cs @@ -4,8 +4,6 @@ using System.Linq; using Tgstation.Server.Api.Rights; using Tgstation.Server.Host.Models; -#nullable disable - namespace Tgstation.Server.Host.Security { /// @@ -15,16 +13,26 @@ namespace Tgstation.Server.Host.Security public bool Valid { get; private set; } /// - public User User { get; private set; } + public User User => user ?? throw new InvalidOperationException("AuthenticationContext is invalid!"); /// - public PermissionSet PermissionSet { get; private set; } + public PermissionSet PermissionSet => permissionSet ?? throw new InvalidOperationException("AuthenticationContext is invalid!"); /// - public InstancePermissionSet InstancePermissionSet { get; private set; } + public InstancePermissionSet? InstancePermissionSet { get; private set; } /// - public ISystemIdentity SystemIdentity { get; private set; } + public ISystemIdentity? SystemIdentity { get; private set; } + + /// + /// Backing field for . + /// + User? user; + + /// + /// Backing field for . + /// + PermissionSet? permissionSet; /// /// Initializes a new instance of the class. @@ -44,10 +52,10 @@ namespace Tgstation.Server.Host.Security /// The value of . public void Initialize(ISystemIdentity systemIdentity, User user, InstancePermissionSet instanceUser) { - User = user ?? throw new ArgumentNullException(nameof(user)); + this.user = user ?? throw new ArgumentNullException(nameof(user)); if (systemIdentity == null && User.SystemIdentifier != null) throw new ArgumentNullException(nameof(systemIdentity)); - PermissionSet = user.PermissionSet + permissionSet = user.PermissionSet ?? user.Group.PermissionSet ?? throw new ArgumentException("No PermissionSet provider", nameof(user)); InstancePermissionSet = instanceUser; @@ -74,9 +82,9 @@ namespace Tgstation.Server.Host.Security var nullableType = typeof(Nullable<>); var nullableRightsType = nullableType.MakeGenericType(rightsEnum); - var prop = typeToCheck.GetProperties().Where(x => x.PropertyType == nullableRightsType).First(); + var prop = typeToCheck.GetProperties().Where(x => x.PropertyType == nullableRightsType && x.CanRead).First(); - var right = prop.GetMethod.Invoke( + var right = prop.GetMethod!.Invoke( isInstance ? InstancePermissionSet : PermissionSet, From 754e4a4c3bbe385eef610472821114f7ea2bc22a Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Fri, 24 Nov 2023 09:33:29 -0500 Subject: [PATCH 117/425] Nullify `AuthenticationContextAuthorizationFilter` --- .../Security/AuthenticationContextAuthorizationFilter.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Security/AuthenticationContextAuthorizationFilter.cs b/src/Tgstation.Server.Host/Security/AuthenticationContextAuthorizationFilter.cs index a3191770e4..b009f599ad 100644 --- a/src/Tgstation.Server.Host/Security/AuthenticationContextAuthorizationFilter.cs +++ b/src/Tgstation.Server.Host/Security/AuthenticationContextAuthorizationFilter.cs @@ -5,7 +5,7 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Filters; using Microsoft.Extensions.Logging; -#nullable disable +using Tgstation.Server.Host.Models; namespace Tgstation.Server.Host.Security { @@ -45,7 +45,7 @@ namespace Tgstation.Server.Host.Security return; } - if (authenticationContext.User.Enabled.Value) + if (authenticationContext.User.Require(x => x.Enabled)) return; logger.LogTrace("authenticationContext is for a disabled user!"); From a982471e2408ece9560125484d64097af8c220d4 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Fri, 24 Nov 2023 09:33:59 -0500 Subject: [PATCH 118/425] Nullify `AuthenticationContextClaimsTransformation` --- .../Security/AuthenticationContextClaimsTransformation.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Tgstation.Server.Host/Security/AuthenticationContextClaimsTransformation.cs b/src/Tgstation.Server.Host/Security/AuthenticationContextClaimsTransformation.cs index 9cf5de9de7..c5b1fe0ce2 100644 --- a/src/Tgstation.Server.Host/Security/AuthenticationContextClaimsTransformation.cs +++ b/src/Tgstation.Server.Host/Security/AuthenticationContextClaimsTransformation.cs @@ -13,8 +13,6 @@ using Tgstation.Server.Api; using Tgstation.Server.Api.Rights; using Tgstation.Server.Host.Utils; -#nullable disable - namespace Tgstation.Server.Host.Security { /// @@ -30,7 +28,7 @@ namespace Tgstation.Server.Host.Security /// /// The for the . /// - readonly ApiHeaders apiHeaders; + readonly ApiHeaders? apiHeaders; /// /// Initializes a new instance of the class. From c269fbd57c76efb33d1fcb93eac06b327fb016ee Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Fri, 24 Nov 2023 09:35:04 -0500 Subject: [PATCH 119/425] Nullify `AuthenticationContextFactory` --- src/Tgstation.Server.Host/Security/AuthenticationContext.cs | 2 +- .../Security/AuthenticationContextFactory.cs | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/Tgstation.Server.Host/Security/AuthenticationContext.cs b/src/Tgstation.Server.Host/Security/AuthenticationContext.cs index f0f4e5be03..c40d122743 100644 --- a/src/Tgstation.Server.Host/Security/AuthenticationContext.cs +++ b/src/Tgstation.Server.Host/Security/AuthenticationContext.cs @@ -50,7 +50,7 @@ namespace Tgstation.Server.Host.Security /// The value of . /// The value of . /// The value of . - public void Initialize(ISystemIdentity systemIdentity, User user, InstancePermissionSet instanceUser) + public void Initialize(ISystemIdentity? systemIdentity, User user, InstancePermissionSet? instanceUser) { this.user = user ?? throw new ArgumentNullException(nameof(user)); if (systemIdentity == null && User.SystemIdentifier != null) diff --git a/src/Tgstation.Server.Host/Security/AuthenticationContextFactory.cs b/src/Tgstation.Server.Host/Security/AuthenticationContextFactory.cs index 3be3bc8061..8dca0248c7 100644 --- a/src/Tgstation.Server.Host/Security/AuthenticationContextFactory.cs +++ b/src/Tgstation.Server.Host/Security/AuthenticationContextFactory.cs @@ -11,8 +11,6 @@ using Tgstation.Server.Host.Configuration; using Tgstation.Server.Host.Database; using Tgstation.Server.Host.Models; -#nullable disable - namespace Tgstation.Server.Host.Security { /// @@ -99,7 +97,7 @@ namespace Tgstation.Server.Host.Security return currentAuthenticationContext; } - ISystemIdentity systemIdentity; + ISystemIdentity? systemIdentity; if (user.SystemIdentifier != null) systemIdentity = identityCache.LoadCachedIdentity(user); else @@ -116,7 +114,7 @@ namespace Tgstation.Server.Host.Security var userPermissionSet = user.PermissionSet ?? user.Group.PermissionSet; try { - InstancePermissionSet instancePermissionSet = null; + InstancePermissionSet? instancePermissionSet = null; if (instanceId.HasValue) { instancePermissionSet = await databaseContext.InstancePermissionSets From 760bc8b29a5c9e6ecf3dc31008b03ae709f81da7 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Fri, 24 Nov 2023 09:36:47 -0500 Subject: [PATCH 120/425] Nullify `AuthorizationContextHubFilter` --- .../Security/AuthorizationContextHubFilter.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Tgstation.Server.Host/Security/AuthorizationContextHubFilter.cs b/src/Tgstation.Server.Host/Security/AuthorizationContextHubFilter.cs index a64f3d4cdb..3eefac4f2e 100644 --- a/src/Tgstation.Server.Host/Security/AuthorizationContextHubFilter.cs +++ b/src/Tgstation.Server.Host/Security/AuthorizationContextHubFilter.cs @@ -5,7 +5,7 @@ using System.Threading.Tasks; using Microsoft.AspNetCore.SignalR; using Microsoft.Extensions.Logging; -#nullable disable +using Tgstation.Server.Host.Models; namespace Tgstation.Server.Host.Security { @@ -46,7 +46,7 @@ namespace Tgstation.Server.Host.Security } /// - public async ValueTask InvokeMethodAsync(HubInvocationContext invocationContext, Func> next) + public async ValueTask InvokeMethodAsync(HubInvocationContext invocationContext, Func> next) { ArgumentNullException.ThrowIfNull(invocationContext); if (ValidateAuthenticationContext(invocationContext.Hub)) @@ -64,7 +64,7 @@ namespace Tgstation.Server.Host.Security { if (!authenticationContext.Valid) logger.LogTrace("The token for connection {connectionId} is no longer authenticated! Aborting...", hub.Context.ConnectionId); - else if (!authenticationContext.User.Enabled.Value) + else if (!authenticationContext.User.Require(x => x.Enabled)) logger.LogTrace("The token for connection {connectionId} is no longer authorized! Aborting...", hub.Context.ConnectionId); else return true; @@ -75,8 +75,8 @@ namespace Tgstation.Server.Host.Security prop => prop.PropertyType.IsConstructedGenericType && prop.Name == nameof(hub.Clients)); var clients = typedClientsProperty.GetValue(hub); - var callerProperty = clients.GetType().GetProperty(nameof(hub.Clients.Caller)); - var caller = callerProperty.GetValue(clients); + var callerProperty = clients!.GetType().GetProperty(nameof(hub.Clients.Caller)); + var caller = callerProperty!.GetValue(clients); hub.Context.Abort(); return false; From fd03e349a54ba061772fe39f5380db629507846c Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Fri, 24 Nov 2023 09:49:35 -0500 Subject: [PATCH 121/425] Nullify `CryptographySuite` --- src/Tgstation.Server.Host/Security/CryptographySuite.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Security/CryptographySuite.cs b/src/Tgstation.Server.Host/Security/CryptographySuite.cs index 8d2f6eeca5..d98e61c303 100644 --- a/src/Tgstation.Server.Host/Security/CryptographySuite.cs +++ b/src/Tgstation.Server.Host/Security/CryptographySuite.cs @@ -6,8 +6,6 @@ using Microsoft.AspNetCore.Identity; using Tgstation.Server.Host.Models; -#nullable disable - namespace Tgstation.Server.Host.Security { /// From 74d53e04977884be273bf1c89cf63b0ef73fac4f Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Fri, 24 Nov 2023 09:50:11 -0500 Subject: [PATCH 122/425] Nullify `IAuthenticationContext` --- .../Security/IAuthenticationContext.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Tgstation.Server.Host/Security/IAuthenticationContext.cs b/src/Tgstation.Server.Host/Security/IAuthenticationContext.cs index 39da97b00e..8277a6601d 100644 --- a/src/Tgstation.Server.Host/Security/IAuthenticationContext.cs +++ b/src/Tgstation.Server.Host/Security/IAuthenticationContext.cs @@ -1,8 +1,6 @@ using Tgstation.Server.Api.Rights; using Tgstation.Server.Host.Models; -#nullable disable - namespace Tgstation.Server.Host.Security { /// @@ -28,7 +26,7 @@ namespace Tgstation.Server.Host.Security /// /// The 's effective if applicable. /// - InstancePermissionSet InstancePermissionSet { get; } + InstancePermissionSet? InstancePermissionSet { get; } /// /// Get the value of a given . @@ -40,6 +38,6 @@ namespace Tgstation.Server.Host.Security /// /// The of if applicable. /// - ISystemIdentity SystemIdentity { get; } + ISystemIdentity? SystemIdentity { get; } } } From ef750acbba22f6c4fce62cb3800f1e8641b4a079 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 25 Nov 2023 09:34:59 -0500 Subject: [PATCH 123/425] Nullify `IAuthenticationContextFactory` --- .../Security/IAuthenticationContextFactory.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Security/IAuthenticationContextFactory.cs b/src/Tgstation.Server.Host/Security/IAuthenticationContextFactory.cs index 945b4e09ad..cb70a50b18 100644 --- a/src/Tgstation.Server.Host/Security/IAuthenticationContextFactory.cs +++ b/src/Tgstation.Server.Host/Security/IAuthenticationContextFactory.cs @@ -2,8 +2,6 @@ using System.Threading; using System.Threading.Tasks; -#nullable disable - namespace Tgstation.Server.Host.Security { /// From 6046f0e635050266cc0b44d6abc4c56ea5c46dd2 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 25 Nov 2023 09:35:38 -0500 Subject: [PATCH 124/425] Nullify `ICryptographySuite` --- src/Tgstation.Server.Host/Security/ICryptographySuite.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Security/ICryptographySuite.cs b/src/Tgstation.Server.Host/Security/ICryptographySuite.cs index 955fdac6ae..257a78f4d1 100644 --- a/src/Tgstation.Server.Host/Security/ICryptographySuite.cs +++ b/src/Tgstation.Server.Host/Security/ICryptographySuite.cs @@ -1,7 +1,5 @@ using Tgstation.Server.Host.Models; -#nullable disable - namespace Tgstation.Server.Host.Security { /// From 616251e5a19276f9ef2c7e855962c3e72fca36dc Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 25 Nov 2023 09:37:42 -0500 Subject: [PATCH 125/425] Nullify `IdentityCache` --- .../Security/IdentityCache.cs | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/Tgstation.Server.Host/Security/IdentityCache.cs b/src/Tgstation.Server.Host/Security/IdentityCache.cs index 6c2a98b200..c42ffab3f6 100644 --- a/src/Tgstation.Server.Host/Security/IdentityCache.cs +++ b/src/Tgstation.Server.Host/Security/IdentityCache.cs @@ -7,8 +7,6 @@ using Microsoft.Extensions.Logging; using Tgstation.Server.Host.Models; using Tgstation.Server.Host.Utils; -#nullable disable - namespace Tgstation.Server.Host.Security { /// @@ -56,12 +54,14 @@ namespace Tgstation.Server.Host.Security ArgumentNullException.ThrowIfNull(user); ArgumentNullException.ThrowIfNull(systemIdentity); + var uid = user.Require(x => x.Id); + var sysId = systemIdentity.Uid; + lock (cachedIdentities) { - var uid = systemIdentity.Uid; - logger.LogDebug("Caching system identity {0} of user {1}", uid, user.Id); + logger.LogDebug("Caching system identity {sysId} of user {uid}", sysId, uid); - if (cachedIdentities.TryGetValue(user.Id.Value, out var identCache)) + if (cachedIdentities.TryGetValue(uid, out var identCache)) { logger.LogTrace("Expiring previously cached identity..."); identCache.Dispose(); // also clears it out @@ -72,12 +72,12 @@ namespace Tgstation.Server.Host.Security asyncDelayer, () => { - logger.LogDebug("Expiring system identity cache for user {0}", user.Id); + logger.LogDebug("Expiring system identity cache for user {uid}", uid); lock (cachedIdentities) - cachedIdentities.Remove(user.Id.Value); + cachedIdentities.Remove(uid); }, expiry); - cachedIdentities.Add(user.Id.Value, identCache); + cachedIdentities.Add(uid, identCache); } } @@ -85,9 +85,11 @@ namespace Tgstation.Server.Host.Security public ISystemIdentity LoadCachedIdentity(User user) { ArgumentNullException.ThrowIfNull(user); + var uid = user.Require(x => x.Id); lock (cachedIdentities) - if (cachedIdentities.TryGetValue(user.Id.Value, out var identity)) + if (cachedIdentities.TryGetValue(uid, out var identity)) return identity.SystemIdentity.Clone(); + throw new InvalidOperationException("Cached system identity has expired!"); } } From 2302c48ea1f42b9b72f640412202f213d148fee5 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 25 Nov 2023 09:39:57 -0500 Subject: [PATCH 126/425] Nullify `IdentityCacheObject` --- src/Tgstation.Server.Host/Security/IdentityCacheObject.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Security/IdentityCacheObject.cs b/src/Tgstation.Server.Host/Security/IdentityCacheObject.cs index d7125b877f..7cc10664e5 100644 --- a/src/Tgstation.Server.Host/Security/IdentityCacheObject.cs +++ b/src/Tgstation.Server.Host/Security/IdentityCacheObject.cs @@ -4,8 +4,6 @@ using System.Threading.Tasks; using Tgstation.Server.Host.Utils; -#nullable disable - namespace Tgstation.Server.Host.Security { /// From 4569c8cb201caabf89ef9a8db3fa51e226cd28d9 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 25 Nov 2023 09:42:06 -0500 Subject: [PATCH 127/425] Nullify `IIdentityCache` --- src/Tgstation.Server.Host/Security/IIdentityCache.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Tgstation.Server.Host/Security/IIdentityCache.cs b/src/Tgstation.Server.Host/Security/IIdentityCache.cs index 64fd3f39a9..75010f2c64 100644 --- a/src/Tgstation.Server.Host/Security/IIdentityCache.cs +++ b/src/Tgstation.Server.Host/Security/IIdentityCache.cs @@ -2,8 +2,6 @@ using Tgstation.Server.Host.Models; -#nullable disable - namespace Tgstation.Server.Host.Security { /// @@ -23,7 +21,7 @@ namespace Tgstation.Server.Host.Security /// Attempt to load a cached . /// /// The the belongs to. - /// The cached or if it doesn't exist or expired. + /// The cached . ISystemIdentity LoadCachedIdentity(User user); } } From 739d0778b766a51ffa59afa9a1f5c8c0f1d051ee Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 25 Nov 2023 09:53:19 -0500 Subject: [PATCH 128/425] Nullify `IPermissionsUpdateNotifyee` --- .../Security/IPermissionsUpdateNotifyee.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Security/IPermissionsUpdateNotifyee.cs b/src/Tgstation.Server.Host/Security/IPermissionsUpdateNotifyee.cs index dd313adc86..7a95f7f076 100644 --- a/src/Tgstation.Server.Host/Security/IPermissionsUpdateNotifyee.cs +++ b/src/Tgstation.Server.Host/Security/IPermissionsUpdateNotifyee.cs @@ -3,8 +3,6 @@ using System.Threading.Tasks; using Tgstation.Server.Host.Models; -#nullable disable - namespace Tgstation.Server.Host.Security { /// From 18a378f0e5192285796896ddf5f5547468c8311c Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 25 Nov 2023 12:31:42 -0500 Subject: [PATCH 129/425] Nullify `ISystemIdentity` --- src/Tgstation.Server.Host/Security/ISystemIdentity.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Security/ISystemIdentity.cs b/src/Tgstation.Server.Host/Security/ISystemIdentity.cs index e865b0345b..bd63d784de 100644 --- a/src/Tgstation.Server.Host/Security/ISystemIdentity.cs +++ b/src/Tgstation.Server.Host/Security/ISystemIdentity.cs @@ -2,8 +2,6 @@ using System.Threading; using System.Threading.Tasks; -#nullable disable - namespace Tgstation.Server.Host.Security { /// From b6b83ce5f0ff24db5c1d5a84a4dd95e4daeb8103 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 25 Nov 2023 12:33:14 -0500 Subject: [PATCH 130/425] Nullify `ISystemIdentityFactory` --- .../Security/ISystemIdentityFactory.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Tgstation.Server.Host/Security/ISystemIdentityFactory.cs b/src/Tgstation.Server.Host/Security/ISystemIdentityFactory.cs index de6e58d431..604ad60d8a 100644 --- a/src/Tgstation.Server.Host/Security/ISystemIdentityFactory.cs +++ b/src/Tgstation.Server.Host/Security/ISystemIdentityFactory.cs @@ -3,8 +3,6 @@ using System.Threading.Tasks; using Tgstation.Server.Host.Models; -#nullable disable - namespace Tgstation.Server.Host.Security { /// @@ -32,7 +30,7 @@ namespace Tgstation.Server.Host.Security /// The username of the user. /// The password of the user. /// The for the operation. - /// A resulting in a new based on the given credentials. - Task CreateSystemIdentity(string username, string password, CancellationToken cancellationToken); + /// A resulting in a new based on the given credentials on success, on failure. + Task CreateSystemIdentity(string username, string password, CancellationToken cancellationToken); } } From 17087376152b50337623d992df856b69c6a913ea Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 25 Nov 2023 12:33:57 -0500 Subject: [PATCH 131/425] Nullify `ITokenFactory` --- src/Tgstation.Server.Host/Security/ITokenFactory.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Security/ITokenFactory.cs b/src/Tgstation.Server.Host/Security/ITokenFactory.cs index 107965394c..bf9a70fab1 100644 --- a/src/Tgstation.Server.Host/Security/ITokenFactory.cs +++ b/src/Tgstation.Server.Host/Security/ITokenFactory.cs @@ -2,8 +2,6 @@ using Tgstation.Server.Api.Models.Response; -#nullable disable - namespace Tgstation.Server.Host.Security { /// From d8ae12ce110982b82e381e5d2e4afb063e8949d9 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 25 Nov 2023 12:52:14 -0500 Subject: [PATCH 132/425] Nullify `PosixSystemIdentity` --- src/Tgstation.Server.Host/Security/PosixSystemIdentity.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Security/PosixSystemIdentity.cs b/src/Tgstation.Server.Host/Security/PosixSystemIdentity.cs index 4f978e76d1..67f0e3ac83 100644 --- a/src/Tgstation.Server.Host/Security/PosixSystemIdentity.cs +++ b/src/Tgstation.Server.Host/Security/PosixSystemIdentity.cs @@ -2,8 +2,6 @@ using System.Threading; using System.Threading.Tasks; -#nullable disable - namespace Tgstation.Server.Host.Security { /// From bb76339461b0ff37d26e2fe98606511338134a2e Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 25 Nov 2023 12:54:27 -0500 Subject: [PATCH 133/425] Nullify `PosixSystemIdentityFactory` --- .../Security/PosixSystemIdentityFactory.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Tgstation.Server.Host/Security/PosixSystemIdentityFactory.cs b/src/Tgstation.Server.Host/Security/PosixSystemIdentityFactory.cs index 876cca613e..ae1cf2c036 100644 --- a/src/Tgstation.Server.Host/Security/PosixSystemIdentityFactory.cs +++ b/src/Tgstation.Server.Host/Security/PosixSystemIdentityFactory.cs @@ -4,8 +4,6 @@ using System.Threading.Tasks; using Tgstation.Server.Host.Models; -#nullable disable - namespace Tgstation.Server.Host.Security { /// @@ -21,6 +19,6 @@ namespace Tgstation.Server.Host.Security public Task CreateSystemIdentity(User user, CancellationToken cancellationToken) => throw new NotImplementedException(); /// - public Task CreateSystemIdentity(string username, string password, CancellationToken cancellationToken) => throw new NotImplementedException(); + public Task CreateSystemIdentity(string username, string password, CancellationToken cancellationToken) => throw new NotImplementedException(); } } From 9b05ce3b9caf811f09faa6b753ef6e22be265f83 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 25 Nov 2023 12:55:19 -0500 Subject: [PATCH 134/425] Nullify `TgsAuthorizeAttribute` --- src/Tgstation.Server.Host/Security/TgsAuthorizeAttribute.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Security/TgsAuthorizeAttribute.cs b/src/Tgstation.Server.Host/Security/TgsAuthorizeAttribute.cs index a80205bb6e..0fc4c11c1a 100644 --- a/src/Tgstation.Server.Host/Security/TgsAuthorizeAttribute.cs +++ b/src/Tgstation.Server.Host/Security/TgsAuthorizeAttribute.cs @@ -4,8 +4,6 @@ using Microsoft.AspNetCore.Authorization; using Tgstation.Server.Api.Rights; -#nullable disable - namespace Tgstation.Server.Host.Security { /// From e1b511386ddc2268232b5f946f7fdb09e154a8d1 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 25 Nov 2023 12:56:34 -0500 Subject: [PATCH 135/425] Nullfiy `TokenFactory` --- src/Tgstation.Server.Host/Security/TokenFactory.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Tgstation.Server.Host/Security/TokenFactory.cs b/src/Tgstation.Server.Host/Security/TokenFactory.cs index 3a17f2ac86..fcc5990c2f 100644 --- a/src/Tgstation.Server.Host/Security/TokenFactory.cs +++ b/src/Tgstation.Server.Host/Security/TokenFactory.cs @@ -10,10 +10,9 @@ using Microsoft.IdentityModel.Tokens; using Tgstation.Server.Api.Models.Response; using Tgstation.Server.Host.Configuration; +using Tgstation.Server.Host.Models; using Tgstation.Server.Host.System; -#nullable disable - namespace Tgstation.Server.Host.Security { /// @@ -84,10 +83,11 @@ namespace Tgstation.Server.Host.Security } /// - public TokenResponse CreateToken(Models.User user, bool oAuth) + public TokenResponse CreateToken(User user, bool oAuth) { ArgumentNullException.ThrowIfNull(user); + var uid = user.Require(x => x.Id); var now = DateTimeOffset.UtcNow; var nowUnix = now.ToUnixTimeSeconds(); @@ -115,7 +115,7 @@ namespace Tgstation.Server.Host.Security Enumerable.Empty(), new Dictionary { - { JwtRegisteredClaimNames.Sub, user.Id.Value.ToString(CultureInfo.InvariantCulture) }, + { JwtRegisteredClaimNames.Sub, uid.ToString(CultureInfo.InvariantCulture) }, }, notBefore.UtcDateTime, expiry.UtcDateTime, From 7b32abc0a24ffe3b0e59af34a1f560a5004715e4 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 25 Nov 2023 13:11:18 -0500 Subject: [PATCH 136/425] Nullify `WindowsSystemIdentity` --- .../Security/WindowsSystemIdentity.cs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/Tgstation.Server.Host/Security/WindowsSystemIdentity.cs b/src/Tgstation.Server.Host/Security/WindowsSystemIdentity.cs index f4ac20da19..e15b51557d 100644 --- a/src/Tgstation.Server.Host/Security/WindowsSystemIdentity.cs +++ b/src/Tgstation.Server.Host/Security/WindowsSystemIdentity.cs @@ -7,8 +7,6 @@ using System.Threading.Tasks; using Tgstation.Server.Host.IO; -#nullable disable - namespace Tgstation.Server.Host.Security { /// @@ -18,10 +16,10 @@ namespace Tgstation.Server.Host.Security sealed class WindowsSystemIdentity : ISystemIdentity { /// - public string Uid => (userPrincipal?.Sid ?? identity.User).ToString(); + public string Uid => (userPrincipal?.Sid ?? identity!.User!).ToString(); // we kno user isn't null because it can only be the case when anonymous (checked in this constructor) /// - public string Username => userPrincipal?.Name ?? identity.Name; + public string Username => userPrincipal?.Name ?? identity!.Name; /// public bool CanCreateSymlinks => canCreateSymlinks ?? throw new NotSupportedException(); @@ -29,12 +27,12 @@ namespace Tgstation.Server.Host.Security /// /// The for the . /// - readonly WindowsIdentity identity; + readonly WindowsIdentity? identity; /// /// The for the . /// - readonly UserPrincipal userPrincipal; + readonly UserPrincipal? userPrincipal; /// /// Backing field for . @@ -48,6 +46,9 @@ namespace Tgstation.Server.Host.Security public WindowsSystemIdentity(WindowsIdentity identity) { this.identity = identity ?? throw new ArgumentNullException(nameof(identity)); + if (identity.IsAnonymous) + throw new InvalidOperationException($"Cannot use anonymous {nameof(WindowsIdentity)} as a {nameof(WindowsSystemIdentity)}!"); + canCreateSymlinks = new WindowsPrincipal(identity).IsInRole(WindowsBuiltInRole.Administrator); } @@ -67,7 +68,7 @@ namespace Tgstation.Server.Host.Security identity.Dispose(); else { - var context = userPrincipal.Context; + var context = userPrincipal!.Context; userPrincipal.Dispose(); context.Dispose(); } From 19ad5e71d729fae8f7dcba80015a63d9d8d15377 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 25 Nov 2023 13:15:50 -0500 Subject: [PATCH 137/425] Nullify `WindowsSystemIdentityFactory` --- .../Security/ISystemIdentityFactory.cs | 2 +- .../Security/PosixSystemIdentityFactory.cs | 2 +- .../Security/WindowsSystemIdentityFactory.cs | 18 ++++++++---------- .../System/NativeMethods.cs | 2 +- 4 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/Tgstation.Server.Host/Security/ISystemIdentityFactory.cs b/src/Tgstation.Server.Host/Security/ISystemIdentityFactory.cs index 604ad60d8a..e2e245e38e 100644 --- a/src/Tgstation.Server.Host/Security/ISystemIdentityFactory.cs +++ b/src/Tgstation.Server.Host/Security/ISystemIdentityFactory.cs @@ -22,7 +22,7 @@ namespace Tgstation.Server.Host.Security /// The user to create a for. /// The for the operation. /// A resulting in a new based on the given or if the has no . - Task CreateSystemIdentity(User user, CancellationToken cancellationToken); + Task CreateSystemIdentity(User user, CancellationToken cancellationToken); /// /// Create a for a given username and password. diff --git a/src/Tgstation.Server.Host/Security/PosixSystemIdentityFactory.cs b/src/Tgstation.Server.Host/Security/PosixSystemIdentityFactory.cs index ae1cf2c036..062a42747f 100644 --- a/src/Tgstation.Server.Host/Security/PosixSystemIdentityFactory.cs +++ b/src/Tgstation.Server.Host/Security/PosixSystemIdentityFactory.cs @@ -16,7 +16,7 @@ namespace Tgstation.Server.Host.Security public ISystemIdentity GetCurrent() => new PosixSystemIdentity(); /// - public Task CreateSystemIdentity(User user, CancellationToken cancellationToken) => throw new NotImplementedException(); + public Task CreateSystemIdentity(User user, CancellationToken cancellationToken) => throw new NotImplementedException(); /// public Task CreateSystemIdentity(string username, string password, CancellationToken cancellationToken) => throw new NotImplementedException(); diff --git a/src/Tgstation.Server.Host/Security/WindowsSystemIdentityFactory.cs b/src/Tgstation.Server.Host/Security/WindowsSystemIdentityFactory.cs index 56b0435651..ca47a87192 100644 --- a/src/Tgstation.Server.Host/Security/WindowsSystemIdentityFactory.cs +++ b/src/Tgstation.Server.Host/Security/WindowsSystemIdentityFactory.cs @@ -1,4 +1,5 @@ using System; +using System.Diagnostics.CodeAnalysis; using System.DirectoryServices.AccountManagement; using System.Runtime.Versioning; using System.Security.Principal; @@ -12,8 +13,6 @@ using Tgstation.Server.Host.IO; using Tgstation.Server.Host.Models; using Tgstation.Server.Host.System; -#nullable disable - namespace Tgstation.Server.Host.Security { /// @@ -33,7 +32,7 @@ namespace Tgstation.Server.Host.Security /// The input . /// The output username. /// The output domain name. May be . - static void GetUserAndDomainName(string input, out string username, out string domainName) + static void GetUserAndDomainName(string input, out string username, out string? domainName) { var splits = input.Split('\\'); username = splits.Length > 1 ? splits[1] : splits[0]; @@ -53,7 +52,7 @@ namespace Tgstation.Server.Host.Security public ISystemIdentity GetCurrent() => new WindowsSystemIdentity(WindowsIdentity.GetCurrent()); /// - public Task CreateSystemIdentity(User user, CancellationToken cancellationToken) => Task.Factory.StartNew( + public Task CreateSystemIdentity(User user, CancellationToken cancellationToken) => Task.Factory.StartNew( () => { ArgumentNullException.ThrowIfNull(user); @@ -61,13 +60,12 @@ namespace Tgstation.Server.Host.Security if (user.SystemIdentifier == null) throw new InvalidOperationException("User's SystemIdentifier must not be null!"); - PrincipalContext pc = null; - UserPrincipal principal = null; - + PrincipalContext? pc = null; GetUserAndDomainName(user.SystemIdentifier, out _, out var domainName); - bool TryGetPrincipalFromContextType(ContextType contextType) + bool TryGetPrincipalFromContextType(ContextType contextType, [NotNullWhen(true)] out UserPrincipal? principal) { + principal = null; try { pc = domainName != null @@ -100,7 +98,7 @@ namespace Tgstation.Server.Host.Security return principal != null; } - if (!TryGetPrincipalFromContextType(ContextType.Machine) && !TryGetPrincipalFromContextType(ContextType.Domain)) + if (!TryGetPrincipalFromContextType(ContextType.Machine, out var principal) && !TryGetPrincipalFromContextType(ContextType.Domain, out principal)) return null; return (ISystemIdentity)new WindowsSystemIdentity(principal); }, @@ -109,7 +107,7 @@ namespace Tgstation.Server.Host.Security TaskScheduler.Current); /// - public Task CreateSystemIdentity(string username, string password, CancellationToken cancellationToken) => Task.Factory.StartNew( + public Task CreateSystemIdentity(string username, string password, CancellationToken cancellationToken) => Task.Factory.StartNew( () => { ArgumentNullException.ThrowIfNull(username); diff --git a/src/Tgstation.Server.Host/System/NativeMethods.cs b/src/Tgstation.Server.Host/System/NativeMethods.cs index 234ba0661a..ffba29cc9c 100644 --- a/src/Tgstation.Server.Host/System/NativeMethods.cs +++ b/src/Tgstation.Server.Host/System/NativeMethods.cs @@ -83,7 +83,7 @@ namespace Tgstation.Server.Host.System /// See https://msdn.microsoft.com/en-us/library/windows/desktop/aa378184(v=vs.85).aspx. /// [DllImport("advapi32.dll", SetLastError = true, CharSet = CharSet.Unicode)] - public static extern bool LogonUser(string lpszUsername, string lpszDomain, string lpszPassword, int dwLogonType, int dwLogonProvider, out IntPtr phToken); + public static extern bool LogonUser(string lpszUsername, string? lpszDomain, string lpszPassword, int dwLogonType, int dwLogonProvider, out IntPtr phToken); /// /// See https://docs.microsoft.com/en-us/windows/desktop/api/winbase/nf-winbase-createsymboliclinkw. From dbf049dc0d57bb7b4385c17f9a1c5b1f2e5553d2 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 25 Nov 2023 13:18:55 -0500 Subject: [PATCH 138/425] Nullify `ISwarmOperations` --- src/Tgstation.Server.Host/Swarm/ISwarmOperations.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Swarm/ISwarmOperations.cs b/src/Tgstation.Server.Host/Swarm/ISwarmOperations.cs index 8d3e198006..dd9c01b783 100644 --- a/src/Tgstation.Server.Host/Swarm/ISwarmOperations.cs +++ b/src/Tgstation.Server.Host/Swarm/ISwarmOperations.cs @@ -5,8 +5,6 @@ using System.Threading.Tasks; using Tgstation.Server.Api.Models.Response; -#nullable disable - namespace Tgstation.Server.Host.Swarm { /// From 0da3a49667beaba83cd2704d78758f5775486294 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 25 Nov 2023 13:21:40 -0500 Subject: [PATCH 139/425] Nullify `ISwarmService` --- src/Tgstation.Server.Host/Swarm/ISwarmService.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Swarm/ISwarmService.cs b/src/Tgstation.Server.Host/Swarm/ISwarmService.cs index c9e29bd052..9b86389540 100644 --- a/src/Tgstation.Server.Host/Swarm/ISwarmService.cs +++ b/src/Tgstation.Server.Host/Swarm/ISwarmService.cs @@ -6,8 +6,6 @@ using System.Threading.Tasks; using Tgstation.Server.Api.Models.Response; using Tgstation.Server.Host.IO; -#nullable disable - namespace Tgstation.Server.Host.Swarm { /// From e6f69f16bf691323098aa25443ea445f5514d26a Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 25 Nov 2023 13:21:52 -0500 Subject: [PATCH 140/425] Nullify `ISwarmServiceController` --- src/Tgstation.Server.Host/Swarm/ISwarmServiceController.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Swarm/ISwarmServiceController.cs b/src/Tgstation.Server.Host/Swarm/ISwarmServiceController.cs index 9f875ce05b..34babd945b 100644 --- a/src/Tgstation.Server.Host/Swarm/ISwarmServiceController.cs +++ b/src/Tgstation.Server.Host/Swarm/ISwarmServiceController.cs @@ -1,8 +1,6 @@ using System.Threading; using System.Threading.Tasks; -#nullable disable - namespace Tgstation.Server.Host.Swarm { /// From e22a6092ba95928ee1c7b846ffd014262bf91b04 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 25 Nov 2023 13:22:05 -0500 Subject: [PATCH 141/425] Nullify `ISwarmUpdateAborter` --- src/Tgstation.Server.Host/Swarm/ISwarmUpdateAborter.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Swarm/ISwarmUpdateAborter.cs b/src/Tgstation.Server.Host/Swarm/ISwarmUpdateAborter.cs index 6cd79b9956..8d69505f27 100644 --- a/src/Tgstation.Server.Host/Swarm/ISwarmUpdateAborter.cs +++ b/src/Tgstation.Server.Host/Swarm/ISwarmUpdateAborter.cs @@ -1,7 +1,5 @@ using System.Threading.Tasks; -#nullable disable - namespace Tgstation.Server.Host.Swarm { /// From 499860051d50680bdc48cc9774a2e1e0d215ade8 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 25 Nov 2023 13:22:18 -0500 Subject: [PATCH 142/425] Nullify `SwarmConstants` --- src/Tgstation.Server.Host/Swarm/SwarmConstants.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Swarm/SwarmConstants.cs b/src/Tgstation.Server.Host/Swarm/SwarmConstants.cs index ec61a982bb..988c60243e 100644 --- a/src/Tgstation.Server.Host/Swarm/SwarmConstants.cs +++ b/src/Tgstation.Server.Host/Swarm/SwarmConstants.cs @@ -4,8 +4,6 @@ using Newtonsoft.Json.Serialization; using Tgstation.Server.Api; using Tgstation.Server.Host.Extensions.Converters; -#nullable disable - namespace Tgstation.Server.Host.Swarm { /// From 0d7f3a353cf778c8e70061efa28a226c5576e93d Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 25 Nov 2023 13:24:27 -0500 Subject: [PATCH 143/425] Nullify `SwarmServersUpdateRequest` --- src/Tgstation.Server.Host/Swarm/SwarmServersUpdateRequest.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Tgstation.Server.Host/Swarm/SwarmServersUpdateRequest.cs b/src/Tgstation.Server.Host/Swarm/SwarmServersUpdateRequest.cs index 2b3cdeaa23..06fb6260bb 100644 --- a/src/Tgstation.Server.Host/Swarm/SwarmServersUpdateRequest.cs +++ b/src/Tgstation.Server.Host/Swarm/SwarmServersUpdateRequest.cs @@ -3,8 +3,6 @@ using System.ComponentModel.DataAnnotations; using Tgstation.Server.Api.Models.Response; -#nullable disable - namespace Tgstation.Server.Host.Swarm { /// @@ -16,6 +14,6 @@ namespace Tgstation.Server.Host.Swarm /// The of updated s. /// [Required] - public ICollection SwarmServers { get; set; } + public ICollection? SwarmServers { get; set; } } } From af0f05d8bff10819bfbe5b08d1148fc16a460d5e Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 25 Nov 2023 15:05:03 -0500 Subject: [PATCH 144/425] Nullify `SwarmService` Had to use many forgiveness operators here, but I've validated them in their current state --- .../Swarm/ISwarmService.cs | 2 +- .../Swarm/SwarmService.cs | 119 ++++++++++-------- .../Swarm/SwarmUpdateOperation.cs | 2 +- 3 files changed, 70 insertions(+), 53 deletions(-) diff --git a/src/Tgstation.Server.Host/Swarm/ISwarmService.cs b/src/Tgstation.Server.Host/Swarm/ISwarmService.cs index 9b86389540..8e827eb131 100644 --- a/src/Tgstation.Server.Host/Swarm/ISwarmService.cs +++ b/src/Tgstation.Server.Host/Swarm/ISwarmService.cs @@ -38,6 +38,6 @@ namespace Tgstation.Server.Host.Swarm /// Gets the list of s in the swarm, including the current one. /// /// A of s in the swarm. If the server is not part of a swarm, will be returned. - ICollection GetSwarmServers(); + ICollection? GetSwarmServers(); } } diff --git a/src/Tgstation.Server.Host/Swarm/SwarmService.cs b/src/Tgstation.Server.Host/Swarm/SwarmService.cs index d081050754..7850f9e5e5 100644 --- a/src/Tgstation.Server.Host/Swarm/SwarmService.cs +++ b/src/Tgstation.Server.Host/Swarm/SwarmService.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Net; using System.Net.Http; @@ -26,8 +27,6 @@ using Tgstation.Server.Host.System; using Tgstation.Server.Host.Transfer; using Tgstation.Server.Host.Utils; -#nullable disable - namespace Tgstation.Server.Host.Swarm { /// @@ -51,6 +50,7 @@ namespace Tgstation.Server.Host.Swarm /// /// If the swarm system is enabled. /// + [MemberNotNullWhen(true, nameof(serverHealthCheckTask), nameof(forceHealthCheckTcs), nameof(serverHealthCheckCancellationTokenSource), nameof(swarmServers))] bool SwarmMode => swarmConfiguration.PrivateKey != null; /// @@ -101,17 +101,17 @@ namespace Tgstation.Server.Host.Swarm /// /// The for . /// - readonly CancellationTokenSource serverHealthCheckCancellationTokenSource; + readonly CancellationTokenSource? serverHealthCheckCancellationTokenSource; /// /// of connected s. /// - readonly List swarmServers; + readonly List? swarmServers; /// /// of s to registration s and when they were created. /// - readonly Dictionary registrationIdsAndTimes; + readonly Dictionary? registrationIdsAndTimes; /// /// If the current server is the swarm controller. @@ -121,17 +121,17 @@ namespace Tgstation.Server.Host.Swarm /// /// A that is currently in progress. /// - volatile SwarmUpdateOperation updateOperation; + volatile SwarmUpdateOperation? updateOperation; /// /// A that is used to force a health check. /// - volatile TaskCompletionSource forceHealthCheckTcs; + volatile TaskCompletionSource? forceHealthCheckTcs; /// /// The for the . /// - Task serverHealthCheckTask; + Task? serverHealthCheckTask; /// /// The registration provided by the swarm controller. @@ -185,18 +185,17 @@ namespace Tgstation.Server.Host.Swarm { if (swarmConfiguration.Address == null) throw new InvalidOperationException("Swarm configuration missing Address!"); + if (String.IsNullOrWhiteSpace(swarmConfiguration.Identifier)) throw new InvalidOperationException("Swarm configuration missing Identifier!"); - } - swarmController = !SwarmMode || swarmConfiguration.ControllerAddress == null; - if (SwarmMode) - { - serverHealthCheckCancellationTokenSource = new CancellationTokenSource(); - forceHealthCheckTcs = new TaskCompletionSource(); + swarmController = swarmConfiguration.ControllerAddress == null; if (swarmController) registrationIdsAndTimes = new(); + serverHealthCheckCancellationTokenSource = new CancellationTokenSource(); + forceHealthCheckTcs = new TaskCompletionSource(); + swarmServers = new List { new SwarmServerResponse @@ -208,6 +207,8 @@ namespace Tgstation.Server.Host.Swarm }, }; } + else + swarmController = true; } /// @@ -348,7 +349,7 @@ namespace Tgstation.Server.Host.Swarm } /// - public ICollection GetSwarmServers() + public ICollection? GetSwarmServers() { if (!SwarmMode) return null; @@ -426,7 +427,7 @@ namespace Tgstation.Server.Host.Swarm { logger.LogTrace("Begin Shutdown"); - async ValueTask SendUnregistrationRequest(SwarmServerResponse swarmServer) + async ValueTask SendUnregistrationRequest(SwarmServerResponse? swarmServer) { using var httpClient = httpClientFactory.CreateClient(); using var request = PrepareSwarmRequest( @@ -445,13 +446,13 @@ namespace Tgstation.Server.Host.Swarm logger.LogWarning( ex, "Error unregistering {nodeType}!", - swarmController + swarmServer != null ? $"node {swarmServer.Identifier}" : "from controller"); } } - if (serverHealthCheckTask != null) + if (SwarmMode && serverHealthCheckTask != null) { serverHealthCheckCancellationTokenSource.Cancel(); await serverHealthCheckTask; @@ -491,7 +492,7 @@ namespace Tgstation.Server.Host.Swarm .Select(SendUnregistrationRequest) .ToList()); swarmServers.RemoveRange(1, swarmServers.Count - 1); - registrationIdsAndTimes.Clear(); + registrationIdsAndTimes!.Clear(); } await task; @@ -506,6 +507,9 @@ namespace Tgstation.Server.Host.Swarm { ArgumentNullException.ThrowIfNull(swarmServers); + if (!SwarmMode) + throw new InvalidOperationException("Swarm mode not enabled!"); + if (swarmController) throw new InvalidOperationException("Cannot UpdateSwarmServersList on swarm controller!"); @@ -520,9 +524,12 @@ namespace Tgstation.Server.Host.Swarm /// public bool ValidateRegistration(Guid registrationId) { + if (!SwarmMode) + throw new InvalidOperationException("Swarm mode not enabled!"); + if (swarmController) lock (swarmServers) - return registrationIdsAndTimes.Values.Any(x => x.RegistrationId == registrationId); + return registrationIdsAndTimes!.Values.Any(x => x.RegistrationId == registrationId); if (registrationId != controllerRegistration) return false; @@ -542,6 +549,9 @@ namespace Tgstation.Server.Host.Swarm if (node.Address == null) throw new ArgumentException("Node missing Address!", nameof(node)); + if (!SwarmMode) + throw new InvalidOperationException("Swarm mode not enabled!"); + if (!swarmController) throw new InvalidOperationException("Cannot RegisterNode on swarm node!"); @@ -549,6 +559,7 @@ namespace Tgstation.Server.Host.Swarm await AbortUpdate(); + var registrationIdsAndTimes = this.registrationIdsAndTimes!; lock (swarmServers) { if (registrationIdsAndTimes.Any(x => x.Value.RegistrationId == registrationId)) @@ -642,6 +653,9 @@ namespace Tgstation.Server.Host.Swarm /// public async ValueTask UnregisterNode(Guid registrationId, CancellationToken cancellationToken) { + if (!SwarmMode) + throw new InvalidOperationException("Swarm mode not enabled!"); + logger.LogTrace("UnregisterNode {registrationId}", registrationId); await AbortUpdate(); @@ -663,7 +677,7 @@ namespace Tgstation.Server.Host.Swarm lock (swarmServers) { swarmServers.RemoveAll(x => x.Identifier == nodeIdentifier); - registrationIdsAndTimes.Remove(nodeIdentifier); + registrationIdsAndTimes!.Remove(nodeIdentifier); } MarkServersDirty(); @@ -710,7 +724,7 @@ namespace Tgstation.Server.Host.Swarm Address = swarmConfiguration.ControllerAddress, }); - lock (swarmServers) + lock (swarmServers!) return ValueTaskExtensions.WhenAll( swarmServers .Where(x => !x.Controller) @@ -760,7 +774,7 @@ namespace Tgstation.Server.Host.Swarm /// The . Must always have populated. If is , it must be fully populated. /// The for the operation. /// A resulting in the . - async ValueTask PrepareUpdateImpl(ISeekableFileStreamProvider initiatorProvider, SwarmUpdateRequest updateRequest, CancellationToken cancellationToken) + async ValueTask PrepareUpdateImpl(ISeekableFileStreamProvider? initiatorProvider, SwarmUpdateRequest updateRequest, CancellationToken cancellationToken) { if (!SwarmMode) { @@ -777,7 +791,7 @@ namespace Tgstation.Server.Host.Swarm SwarmUpdateOperation localUpdateOperation; try { - SwarmServerResponse sourceNode = null; + SwarmServerResponse? sourceNode = null; List currentNodes; lock (swarmServers) { @@ -814,7 +828,7 @@ namespace Tgstation.Server.Host.Swarm if (!swarmController && initiator) { - var downloadTickets = await CreateDownloadTickets(initiatorProvider, currentNodes, cancellationToken); + var downloadTickets = await CreateDownloadTickets(initiatorProvider!, currentNodes, cancellationToken); // condition of initiator logger.LogInformation("Forwarding update request to swarm controller..."); using var httpClient = httpClientFactory.CreateClient(); @@ -854,7 +868,7 @@ namespace Tgstation.Server.Host.Swarm return SwarmPrepareResult.Failure; } - if (!updateRequest.DownloadTickets.TryGetValue(swarmConfiguration.Identifier, out var ticket)) + if (!updateRequest.DownloadTickets.TryGetValue(swarmConfiguration.Identifier!, out var ticket)) { logger.Log( swarmController @@ -924,7 +938,7 @@ namespace Tgstation.Server.Host.Swarm /// The for the operation. /// A resulting in the . async ValueTask ControllerDistributedPrepareUpdate( - ISeekableFileStreamProvider initiatorProvider, + ISeekableFileStreamProvider? initiatorProvider, SwarmUpdateRequest updateRequest, SwarmUpdateOperation currentUpdateOperation, CancellationToken cancellationToken) @@ -967,7 +981,7 @@ namespace Tgstation.Server.Host.Swarm } var downloadTicketDictionary = weAreInitiator - ? await CreateDownloadTickets(initiatorProvider, currentUpdateOperation.InvolvedServers, cancellationToken) + ? await CreateDownloadTickets(initiatorProvider!, currentUpdateOperation.InvolvedServers, cancellationToken) : updateRequest.DownloadTickets; var sourceNode = weAreInitiator @@ -984,18 +998,19 @@ namespace Tgstation.Server.Host.Swarm .Select(node => { // only send the necessary ticket to each node from the controller - Dictionary localTicketDictionary; - if (!downloadTicketDictionary.TryGetValue(node.Identifier, out var ticket) - && node.Identifier != sourceNode) + Dictionary localTicketDictionary; + var nodeId = node.Identifier!; + if (!downloadTicketDictionary.TryGetValue(nodeId, out var ticket) + && nodeId != sourceNode) { - logger.LogError("Missing download ticket for node {missingNodeId}!", node.Identifier); + logger.LogError("Missing download ticket for node {missingNodeId}!", nodeId); anyFailed = true; return null; } else - localTicketDictionary = new Dictionary + localTicketDictionary = new Dictionary { - { node.Identifier, ticket }, + { nodeId, ticket }, }; var request = new SwarmUpdateRequest @@ -1015,7 +1030,7 @@ namespace Tgstation.Server.Host.Swarm var tasks = updateRequests .Select(async tuple => { - var node = tuple.Item1; + var node = tuple!.Item1; var body = tuple.Item2; using var request = PrepareSwarmRequest( @@ -1088,7 +1103,7 @@ namespace Tgstation.Server.Host.Swarm var downloadTickets = new Dictionary(serversRequiringTickets.Count); foreach (var node in serversRequiringTickets) downloadTickets.Add( - node.Identifier, + node.Identifier!, transferService.CreateDownload(downloadProvider)); await streamRetrievalTask; @@ -1105,9 +1120,10 @@ namespace Tgstation.Server.Host.Swarm using var httpClient = httpClientFactory.CreateClient(); List currentSwarmServers; - lock (swarmServers) + lock (swarmServers!) currentSwarmServers = swarmServers.ToList(); + var registrationIdsAndTimes = this.registrationIdsAndTimes!; async ValueTask HealthRequestForServer(SwarmServerResponse swarmServer) { using var request = PrepareSwarmRequest( @@ -1133,14 +1149,14 @@ namespace Tgstation.Server.Host.Swarm lock (swarmServers) { swarmServers.Remove(swarmServer); - registrationIdsAndTimes.Remove(swarmServer.Identifier); + registrationIdsAndTimes.Remove(swarmServer.Identifier!); } } await ValueTaskExtensions.WhenAll( currentSwarmServers .Where(node => !node.Controller - && registrationIdsAndTimes.TryGetValue(node.Identifier, out var registrationAndTime) + && registrationIdsAndTimes.TryGetValue(node.Identifier!, out var registrationAndTime) && registrationAndTime.RegisteredAt.AddMinutes(SwarmConstants.ControllerHealthCheckIntervalMinutes) < DateTimeOffset.UtcNow) .Select(HealthRequestForServer)); @@ -1169,7 +1185,7 @@ namespace Tgstation.Server.Host.Swarm bool TriggerHealthCheck() { var currentTcs = Interlocked.Exchange(ref forceHealthCheckTcs, new TaskCompletionSource()); - return currentTcs.TrySetResult(); + return currentTcs!.TrySetResult(); } /// @@ -1299,7 +1315,7 @@ namespace Tgstation.Server.Host.Swarm async ValueTask SendUpdatedServerListToNodes(CancellationToken cancellationToken) { List currentSwarmServers; - lock (swarmServers) + lock (swarmServers!) { serversDirty = false; currentSwarmServers = swarmServers.ToList(); @@ -1337,7 +1353,7 @@ namespace Tgstation.Server.Host.Swarm lock (swarmServers) { swarmServers.Remove(swarmServer); - registrationIdsAndTimes.Remove(swarmServer.Identifier); + registrationIdsAndTimes!.Remove(swarmServer.Identifier!); } } } @@ -1352,17 +1368,17 @@ namespace Tgstation.Server.Host.Swarm /// /// Prepares a for swarm communication. /// - /// The the message is for, if null will be sent to swarm controller. + /// The the message is for. Must have and set. If , will be sent to swarm controller. /// The . /// The route on to use. /// The body if any. /// An optional override to the . /// A new . HttpRequestMessage PrepareSwarmRequest( - SwarmServerResponse swarmServer, + SwarmServerResponse? swarmServer, HttpMethod httpMethod, string route, - object body, + object? body, Guid? registrationIdOverride = null) { swarmServer ??= new SwarmServerResponse @@ -1375,7 +1391,7 @@ namespace Tgstation.Server.Host.Swarm "{method} {route} to swarm server {nodeIdOrAddress}", httpMethod, fullRoute, - swarmServer.Identifier ?? swarmServer.Address.ToString()); + swarmServer.Identifier ?? swarmServer.Address!.ToString()); var request = new HttpRequestMessage( httpMethod, @@ -1390,8 +1406,8 @@ namespace Tgstation.Server.Host.Swarm request.Headers.Add(SwarmConstants.RegistrationIdHeader, registrationIdOverride.Value.ToString()); else if (swarmController) { - lock (swarmServers) - if (registrationIdsAndTimes.TryGetValue(swarmServer.Identifier, out var registrationIdAndTime)) + lock (swarmServers!) + if (registrationIdsAndTimes!.TryGetValue(swarmServer.Identifier!, out var registrationIdAndTime)) request.Headers.Add(SwarmConstants.RegistrationIdHeader, registrationIdAndTime.RegistrationId.ToString()); } else if (controllerRegistration.HasValue) @@ -1422,7 +1438,7 @@ namespace Tgstation.Server.Host.Swarm logger.LogTrace("Starting HealthCheckLoop..."); try { - var nextForceHealthCheckTask = forceHealthCheckTcs.Task; + var nextForceHealthCheckTask = forceHealthCheckTcs!.Task; while (!cancellationToken.IsCancellationRequested) { TimeSpan delay; @@ -1500,13 +1516,14 @@ namespace Tgstation.Server.Host.Swarm /// /// The registration . /// The registered or if it does not exist. - string NodeIdentifierFromRegistration(Guid registrationId) + string? NodeIdentifierFromRegistration(Guid registrationId) { if (!swarmController) throw new InvalidOperationException("NodeIdentifierFromRegistration on node!"); - lock (swarmServers) + lock (swarmServers!) { + var registrationIdsAndTimes = this.registrationIdsAndTimes!; var exists = registrationIdsAndTimes.Any(x => x.Value.RegistrationId == registrationId); if (!exists) { diff --git a/src/Tgstation.Server.Host/Swarm/SwarmUpdateOperation.cs b/src/Tgstation.Server.Host/Swarm/SwarmUpdateOperation.cs index 3ebe8576e2..56d7496a26 100644 --- a/src/Tgstation.Server.Host/Swarm/SwarmUpdateOperation.cs +++ b/src/Tgstation.Server.Host/Swarm/SwarmUpdateOperation.cs @@ -60,7 +60,7 @@ namespace Tgstation.Server.Host.Swarm /// Initializes a new instance of the class. /// /// The value of . - /// An of the controller's current nodes as s. + /// An of the controller's current nodes as s. Must have and set. /// This is the variant for use by the controller. public SwarmUpdateOperation(Version targetVersion, IEnumerable currentNodes) : this(targetVersion) From 1e21ef20b8a161dfbd0f2cf861b3eba213c65c46 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 25 Nov 2023 15:05:56 -0500 Subject: [PATCH 145/425] Nullify `SwarmUpdateOperation` --- src/Tgstation.Server.Host/Swarm/SwarmUpdateOperation.cs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/Tgstation.Server.Host/Swarm/SwarmUpdateOperation.cs b/src/Tgstation.Server.Host/Swarm/SwarmUpdateOperation.cs index 56d7496a26..67d65686ca 100644 --- a/src/Tgstation.Server.Host/Swarm/SwarmUpdateOperation.cs +++ b/src/Tgstation.Server.Host/Swarm/SwarmUpdateOperation.cs @@ -6,8 +6,6 @@ using System.Threading.Tasks; using Tgstation.Server.Api.Models.Internal; using Tgstation.Server.Api.Models.Response; -#nullable disable - namespace Tgstation.Server.Host.Swarm { /// @@ -33,7 +31,7 @@ namespace Tgstation.Server.Host.Swarm /// /// Backing field for . /// - readonly IReadOnlyList initialInvolvedServers; + readonly IReadOnlyList? initialInvolvedServers; /// /// The backing for . @@ -43,7 +41,7 @@ namespace Tgstation.Server.Host.Swarm /// /// of that need to send a ready-commit to the controller before the commit can happen. /// - readonly HashSet nodesThatNeedToBeReadyToCommit; + readonly HashSet? nodesThatNeedToBeReadyToCommit; /// /// Initializes a new instance of the class. @@ -68,7 +66,7 @@ namespace Tgstation.Server.Host.Swarm initialInvolvedServers = currentNodes?.ToList() ?? throw new ArgumentNullException(nameof(currentNodes)); nodesThatNeedToBeReadyToCommit = initialInvolvedServers .Where(node => !node.Controller) - .Select(node => node.Identifier) + .Select(node => node.Identifier!) .ToHashSet(); } From bd20e37d3d4b9018f8878ea74f657dbb58805c9b Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 25 Nov 2023 15:32:15 -0500 Subject: [PATCH 146/425] Nullify `SwarmUpdateRequest` --- .../Swarm/SwarmService.cs | 23 ++++++++++++------- .../Swarm/SwarmUpdateRequest.cs | 8 +++---- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/src/Tgstation.Server.Host/Swarm/SwarmService.cs b/src/Tgstation.Server.Host/Swarm/SwarmService.cs index 7850f9e5e5..cd0e855151 100644 --- a/src/Tgstation.Server.Host/Swarm/SwarmService.cs +++ b/src/Tgstation.Server.Host/Swarm/SwarmService.cs @@ -776,14 +776,14 @@ namespace Tgstation.Server.Host.Swarm /// A resulting in the . async ValueTask PrepareUpdateImpl(ISeekableFileStreamProvider? initiatorProvider, SwarmUpdateRequest updateRequest, CancellationToken cancellationToken) { + var version = updateRequest.UpdateVersion!; if (!SwarmMode) { // we still need an active update operation for the TargetVersion - updateOperation = new SwarmUpdateOperation(updateRequest.UpdateVersion); + updateOperation = new SwarmUpdateOperation(version); return SwarmPrepareResult.SuccessProviderNotRequired; } - var version = updateRequest.UpdateVersion; var initiator = initiatorProvider != null; logger.LogTrace("PrepareUpdateImpl {version}...", version); @@ -868,6 +868,12 @@ namespace Tgstation.Server.Host.Swarm return SwarmPrepareResult.Failure; } + if (updateRequest.DownloadTickets == null) + { + logger.LogError("Missing download tickets in update request!"); + return SwarmPrepareResult.Failure; + } + if (!updateRequest.DownloadTickets.TryGetValue(swarmConfiguration.Identifier!, out var ticket)) { logger.Log( @@ -970,7 +976,7 @@ namespace Tgstation.Server.Host.Swarm } // The initiator node obviously doesn't create a ticket for itself - else if (!weAreInitiator && updateRequest.DownloadTickets.Count != currentUpdateOperation.InvolvedServers.Count - 1) + else if (!weAreInitiator && updateRequest.DownloadTickets!.Count != currentUpdateOperation.InvolvedServers.Count - 1) { logger.LogWarning( "Aborting update, {receivedTickets} download tickets were provided but there are {nodesToUpdate} nodes in the swarm that require the package!", @@ -982,7 +988,7 @@ namespace Tgstation.Server.Host.Swarm var downloadTicketDictionary = weAreInitiator ? await CreateDownloadTickets(initiatorProvider!, currentUpdateOperation.InvolvedServers, cancellationToken) - : updateRequest.DownloadTickets; + : updateRequest.DownloadTickets!; var sourceNode = weAreInitiator ? swarmConfiguration.Identifier @@ -998,17 +1004,18 @@ namespace Tgstation.Server.Host.Swarm .Select(node => { // only send the necessary ticket to each node from the controller - Dictionary localTicketDictionary; + Dictionary? localTicketDictionary; var nodeId = node.Identifier!; - if (!downloadTicketDictionary.TryGetValue(nodeId, out var ticket) - && nodeId != sourceNode) + if (nodeId == sourceNode) + localTicketDictionary = null; + else if (!downloadTicketDictionary.TryGetValue(nodeId, out var ticket)) { logger.LogError("Missing download ticket for node {missingNodeId}!", nodeId); anyFailed = true; return null; } else - localTicketDictionary = new Dictionary + localTicketDictionary = new Dictionary { { nodeId, ticket }, }; diff --git a/src/Tgstation.Server.Host/Swarm/SwarmUpdateRequest.cs b/src/Tgstation.Server.Host/Swarm/SwarmUpdateRequest.cs index a0d7b0fe5c..958a8f5afb 100644 --- a/src/Tgstation.Server.Host/Swarm/SwarmUpdateRequest.cs +++ b/src/Tgstation.Server.Host/Swarm/SwarmUpdateRequest.cs @@ -4,8 +4,6 @@ using System.ComponentModel.DataAnnotations; using Tgstation.Server.Api.Models.Response; -#nullable disable - namespace Tgstation.Server.Host.Swarm { /// @@ -17,17 +15,17 @@ namespace Tgstation.Server.Host.Swarm /// The TGS to update to. /// [Required] - public Version UpdateVersion { get; init; } + public Version? UpdateVersion { get; init; } /// /// The of the node to download the update package from. /// [Required] - public string SourceNode { get; init; } + public string? SourceNode { get; init; } /// /// The map of s to s for retrieving the update package from the initiating server. /// - public Dictionary DownloadTickets { get; init; } + public Dictionary? DownloadTickets { get; init; } } } From ffcea66b248f3143d3ee7a331b278553bab1b963 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 25 Nov 2023 16:01:15 -0500 Subject: [PATCH 147/425] Nullify `DiscordOAuthValidator` --- .../Security/OAuth/DiscordOAuthValidator.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Security/OAuth/DiscordOAuthValidator.cs b/src/Tgstation.Server.Host/Security/OAuth/DiscordOAuthValidator.cs index 166ff85f27..3195ec9dcf 100644 --- a/src/Tgstation.Server.Host/Security/OAuth/DiscordOAuthValidator.cs +++ b/src/Tgstation.Server.Host/Security/OAuth/DiscordOAuthValidator.cs @@ -6,8 +6,6 @@ using Tgstation.Server.Api.Models; using Tgstation.Server.Common.Http; using Tgstation.Server.Host.Configuration; -#nullable disable - namespace Tgstation.Server.Host.Security.OAuth { /// From 2f78ebf147dafc800e9558f09e7a786603ad81e6 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 25 Nov 2023 16:02:39 -0500 Subject: [PATCH 148/425] Nullify `GenericOAuthValidator` --- .../Security/OAuth/GenericOAuthValidator.cs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/Tgstation.Server.Host/Security/OAuth/GenericOAuthValidator.cs b/src/Tgstation.Server.Host/Security/OAuth/GenericOAuthValidator.cs index 0885546d11..5963023b0f 100644 --- a/src/Tgstation.Server.Host/Security/OAuth/GenericOAuthValidator.cs +++ b/src/Tgstation.Server.Host/Security/OAuth/GenericOAuthValidator.cs @@ -16,8 +16,6 @@ using Tgstation.Server.Api.Models; using Tgstation.Server.Common.Http; using Tgstation.Server.Host.Configuration; -#nullable disable - namespace Tgstation.Server.Host.Security.OAuth { /// @@ -82,11 +80,11 @@ namespace Tgstation.Server.Host.Security.OAuth } /// - public async ValueTask ValidateResponseCode(string code, CancellationToken cancellationToken) + public async ValueTask ValidateResponseCode(string code, CancellationToken cancellationToken) { using var httpClient = CreateHttpClient(); - string tokenResponsePayload = null; - string userInformationPayload = null; + string? tokenResponsePayload = null; + string? userInformationPayload = null; try { Logger.LogTrace("Validating response code..."); @@ -99,7 +97,7 @@ namespace Tgstation.Server.Host.Security.OAuth tokenRequestPayload, SerializerSettings()); - var tokenRequestDictionary = JsonConvert.DeserializeObject>(tokenRequestJson); + var tokenRequestDictionary = JsonConvert.DeserializeObject>(tokenRequestJson)!; tokenRequest.Content = new FormUrlEncodedContent(tokenRequestDictionary); using var tokenResponse = await httpClient.SendAsync(tokenRequest, HttpCompletionOption.ResponseHeadersRead, cancellationToken); From e895f796f501ce1182af852f28ab70554780322d Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 25 Nov 2023 16:03:03 -0500 Subject: [PATCH 149/425] Nullify `GitHubOAuthValidator` --- .../Security/OAuth/GitHubOAuthValidator.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Tgstation.Server.Host/Security/OAuth/GitHubOAuthValidator.cs b/src/Tgstation.Server.Host/Security/OAuth/GitHubOAuthValidator.cs index d6ed38808b..3f3180f9da 100644 --- a/src/Tgstation.Server.Host/Security/OAuth/GitHubOAuthValidator.cs +++ b/src/Tgstation.Server.Host/Security/OAuth/GitHubOAuthValidator.cs @@ -10,8 +10,6 @@ using Tgstation.Server.Api.Models; using Tgstation.Server.Host.Configuration; using Tgstation.Server.Host.Utils.GitHub; -#nullable disable - namespace Tgstation.Server.Host.Security.OAuth { /// @@ -54,7 +52,7 @@ namespace Tgstation.Server.Host.Security.OAuth } /// - public async ValueTask ValidateResponseCode(string code, CancellationToken cancellationToken) + public async ValueTask ValidateResponseCode(string code, CancellationToken cancellationToken) { ArgumentNullException.ThrowIfNull(code); From 870e0b565293bd9cd4e167801b3fba5caee7e788 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 25 Nov 2023 16:03:22 -0500 Subject: [PATCH 150/425] Nullify `InvisionCommunityOAuthValidator` --- .../Security/OAuth/InvisionCommunityOAuthValidator.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Tgstation.Server.Host/Security/OAuth/InvisionCommunityOAuthValidator.cs b/src/Tgstation.Server.Host/Security/OAuth/InvisionCommunityOAuthValidator.cs index 14382d5838..0e912bd368 100644 --- a/src/Tgstation.Server.Host/Security/OAuth/InvisionCommunityOAuthValidator.cs +++ b/src/Tgstation.Server.Host/Security/OAuth/InvisionCommunityOAuthValidator.cs @@ -6,15 +6,13 @@ using Tgstation.Server.Api.Models; using Tgstation.Server.Common.Http; using Tgstation.Server.Host.Configuration; -#nullable disable - namespace Tgstation.Server.Host.Security.OAuth { /// /// OAuth validator for Invision Community (selfhosted). /// sealed class InvisionCommunityOAuthValidator : GenericOAuthValidator - { + { /// public override OAuthProvider Provider => OAuthProvider.InvisionCommunity; From 991b4075803f65063d7c0bb1114f116ceb23ede4 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 25 Nov 2023 16:03:57 -0500 Subject: [PATCH 151/425] Nullify `IOAuthProviders` --- src/Tgstation.Server.Host/Security/OAuth/IOAuthProviders.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Tgstation.Server.Host/Security/OAuth/IOAuthProviders.cs b/src/Tgstation.Server.Host/Security/OAuth/IOAuthProviders.cs index c7e9a06274..2da6651c04 100644 --- a/src/Tgstation.Server.Host/Security/OAuth/IOAuthProviders.cs +++ b/src/Tgstation.Server.Host/Security/OAuth/IOAuthProviders.cs @@ -2,8 +2,6 @@ using Tgstation.Server.Api.Models; -#nullable disable - namespace Tgstation.Server.Host.Security.OAuth { /// @@ -16,7 +14,7 @@ namespace Tgstation.Server.Host.Security.OAuth /// /// The to get the validator for. /// The for . - IOAuthValidator GetValidator(OAuthProvider oAuthProvider); + IOAuthValidator? GetValidator(OAuthProvider oAuthProvider); /// /// Gets a of the provider client IDs. From 47c729fdf4f8987d2789ed54aeec2022719cb786 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 25 Nov 2023 16:04:17 -0500 Subject: [PATCH 152/425] Nullify `IOAuthValidator` --- src/Tgstation.Server.Host/Security/OAuth/IOAuthValidator.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Tgstation.Server.Host/Security/OAuth/IOAuthValidator.cs b/src/Tgstation.Server.Host/Security/OAuth/IOAuthValidator.cs index 402fb5efe7..472a7ff091 100644 --- a/src/Tgstation.Server.Host/Security/OAuth/IOAuthValidator.cs +++ b/src/Tgstation.Server.Host/Security/OAuth/IOAuthValidator.cs @@ -3,8 +3,6 @@ using System.Threading.Tasks; using Tgstation.Server.Api.Models; -#nullable disable - namespace Tgstation.Server.Host.Security.OAuth { /// @@ -29,6 +27,6 @@ namespace Tgstation.Server.Host.Security.OAuth /// The OAuth response string from web application. /// The for the operation. /// A resulting in if authentication failed, if a rate limit occurred, and the validated otherwise. - ValueTask ValidateResponseCode(string code, CancellationToken cancellationToken); + ValueTask ValidateResponseCode(string code, CancellationToken cancellationToken); } } From 302c458e745311dc470a24332f3f0a59e6b490dd Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 25 Nov 2023 16:04:39 -0500 Subject: [PATCH 153/425] Nullify `KeycloakOAuthValidator` --- .../Security/OAuth/KeycloakOAuthValidator.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Security/OAuth/KeycloakOAuthValidator.cs b/src/Tgstation.Server.Host/Security/OAuth/KeycloakOAuthValidator.cs index 1152398d6a..f4e61b4b5c 100644 --- a/src/Tgstation.Server.Host/Security/OAuth/KeycloakOAuthValidator.cs +++ b/src/Tgstation.Server.Host/Security/OAuth/KeycloakOAuthValidator.cs @@ -6,8 +6,6 @@ using Tgstation.Server.Api.Models; using Tgstation.Server.Common.Http; using Tgstation.Server.Host.Configuration; -#nullable disable - namespace Tgstation.Server.Host.Security.OAuth { /// From d781370bc7844d4d437ccb81c66a2c02fc8123f0 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 25 Nov 2023 16:05:02 -0500 Subject: [PATCH 154/425] Nullify `OAuthProviders` --- src/Tgstation.Server.Host/Security/OAuth/OAuthProviders.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Tgstation.Server.Host/Security/OAuth/OAuthProviders.cs b/src/Tgstation.Server.Host/Security/OAuth/OAuthProviders.cs index 7e0e1a308c..9d28ab1c82 100644 --- a/src/Tgstation.Server.Host/Security/OAuth/OAuthProviders.cs +++ b/src/Tgstation.Server.Host/Security/OAuth/OAuthProviders.cs @@ -10,8 +10,6 @@ using Tgstation.Server.Common.Http; using Tgstation.Server.Host.Configuration; using Tgstation.Server.Host.Utils.GitHub; -#nullable disable - namespace Tgstation.Server.Host.Security.OAuth { /// @@ -82,7 +80,7 @@ namespace Tgstation.Server.Host.Security.OAuth } /// - public IOAuthValidator GetValidator(OAuthProvider oAuthProvider) => validators.FirstOrDefault(x => x.Provider == oAuthProvider); + public IOAuthValidator? GetValidator(OAuthProvider oAuthProvider) => validators.FirstOrDefault(x => x.Provider == oAuthProvider); /// public Dictionary ProviderInfos() From 5dbba020e54bf9cb0df655750cd4fa7008d82962 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 25 Nov 2023 16:05:32 -0500 Subject: [PATCH 155/425] Nullify `OAuthTokenRequest` --- src/Tgstation.Server.Host/Security/OAuth/OAuthTokenRequest.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Tgstation.Server.Host/Security/OAuth/OAuthTokenRequest.cs b/src/Tgstation.Server.Host/Security/OAuth/OAuthTokenRequest.cs index 2c7721f4af..a3955ceaff 100644 --- a/src/Tgstation.Server.Host/Security/OAuth/OAuthTokenRequest.cs +++ b/src/Tgstation.Server.Host/Security/OAuth/OAuthTokenRequest.cs @@ -2,8 +2,6 @@ using Tgstation.Server.Host.Configuration; -#nullable disable - namespace Tgstation.Server.Host.Security.OAuth { /// @@ -24,7 +22,7 @@ namespace Tgstation.Server.Host.Security.OAuth /// /// The OAuth redirect URI. /// - public Uri RedirectUri { get; } + public Uri? RedirectUri { get; } /// /// The OAuth grant type. From 7cc0d477fb7f5154fad2a24e44dd75416c578317 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 25 Nov 2023 16:05:43 -0500 Subject: [PATCH 156/425] Nullify `TGForumsOAuthValidator` --- .../Security/OAuth/TGForumsOAuthValidator.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Security/OAuth/TGForumsOAuthValidator.cs b/src/Tgstation.Server.Host/Security/OAuth/TGForumsOAuthValidator.cs index 36b213b6d9..c81a54ec73 100644 --- a/src/Tgstation.Server.Host/Security/OAuth/TGForumsOAuthValidator.cs +++ b/src/Tgstation.Server.Host/Security/OAuth/TGForumsOAuthValidator.cs @@ -6,8 +6,6 @@ using Tgstation.Server.Api.Models; using Tgstation.Server.Common.Http; using Tgstation.Server.Host.Configuration; -#nullable disable - namespace Tgstation.Server.Host.Security.OAuth { /// From dc1040e4225e5bd63c5901c47ed0db3382ec7f2c Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 25 Nov 2023 16:06:13 -0500 Subject: [PATCH 157/425] Nullify `IPostSetupServices` --- src/Tgstation.Server.Host/Setup/IPostSetupServices.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Setup/IPostSetupServices.cs b/src/Tgstation.Server.Host/Setup/IPostSetupServices.cs index aaa785f413..21264d9277 100644 --- a/src/Tgstation.Server.Host/Setup/IPostSetupServices.cs +++ b/src/Tgstation.Server.Host/Setup/IPostSetupServices.cs @@ -1,8 +1,6 @@ using Tgstation.Server.Host.Configuration; using Tgstation.Server.Host.System; -#nullable disable - namespace Tgstation.Server.Host.Setup { /// From c479b0b31db012fbf50506cfa04f64235f9f840c Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 25 Nov 2023 16:06:35 -0500 Subject: [PATCH 158/425] Nullify `IPostSetupServices` --- .../Setup/IPostSetupServices{TLoggerType}.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Setup/IPostSetupServices{TLoggerType}.cs b/src/Tgstation.Server.Host/Setup/IPostSetupServices{TLoggerType}.cs index 25024af43d..f36d9526e7 100644 --- a/src/Tgstation.Server.Host/Setup/IPostSetupServices{TLoggerType}.cs +++ b/src/Tgstation.Server.Host/Setup/IPostSetupServices{TLoggerType}.cs @@ -1,7 +1,5 @@ using Microsoft.Extensions.Logging; -#nullable disable - namespace Tgstation.Server.Host.Setup { /// From 65f26d7d312ab874479b96641dd69ff4a7a90a17 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 25 Nov 2023 16:07:10 -0500 Subject: [PATCH 159/425] Nullify `PostSetupServices` --- src/Tgstation.Server.Host/Setup/PostSetupServices.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Setup/PostSetupServices.cs b/src/Tgstation.Server.Host/Setup/PostSetupServices.cs index 4fce4e6075..c1ace340ec 100644 --- a/src/Tgstation.Server.Host/Setup/PostSetupServices.cs +++ b/src/Tgstation.Server.Host/Setup/PostSetupServices.cs @@ -6,8 +6,6 @@ using Microsoft.Extensions.Options; using Tgstation.Server.Host.Configuration; using Tgstation.Server.Host.System; -#nullable disable - namespace Tgstation.Server.Host.Setup { /// From f33c46c0207ae697440ca318c1e044e5652a4fa4 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 25 Nov 2023 16:07:27 -0500 Subject: [PATCH 160/425] Nullify `SetupApplication` --- src/Tgstation.Server.Host/Setup/SetupApplication.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Setup/SetupApplication.cs b/src/Tgstation.Server.Host/Setup/SetupApplication.cs index ca4b64be58..56c590ce7d 100644 --- a/src/Tgstation.Server.Host/Setup/SetupApplication.cs +++ b/src/Tgstation.Server.Host/Setup/SetupApplication.cs @@ -12,8 +12,6 @@ using Tgstation.Server.Host.IO; using Tgstation.Server.Host.System; using Tgstation.Server.Host.Utils; -#nullable disable - namespace Tgstation.Server.Host.Setup { /// From d619571871d1d8a1f3287320b76fda8cd8b0ecfb Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 25 Nov 2023 16:11:03 -0500 Subject: [PATCH 161/425] Nullify `SetupWizard` --- .../Setup/SetupWizard.cs | 35 ++++++++++--------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/src/Tgstation.Server.Host/Setup/SetupWizard.cs b/src/Tgstation.Server.Host/Setup/SetupWizard.cs index d4611f4465..c164b9d333 100644 --- a/src/Tgstation.Server.Host/Setup/SetupWizard.cs +++ b/src/Tgstation.Server.Host/Setup/SetupWizard.cs @@ -31,8 +31,6 @@ using Tgstation.Server.Host.Utils; using YamlDotNet.Serialization; -#nullable disable - namespace Tgstation.Server.Host.Setup { /// @@ -222,9 +220,12 @@ namespace Tgstation.Server.Host.Setup await console.WriteAsync($"Checking {databaseConfiguration.DatabaseType} version...", true, cancellationToken); using var command = testConnection.CreateCommand(); command.CommandText = "SELECT VERSION()"; - var fullVersion = (string)await command.ExecuteScalarAsync(cancellationToken); + var fullVersion = (string?)await command.ExecuteScalarAsync(cancellationToken); await console.WriteAsync(String.Format(CultureInfo.InvariantCulture, "Found {0}", fullVersion), true, cancellationToken); + if (fullVersion == null) + throw new InvalidOperationException($"\"{command.CommandText}\" returned null!"); + if (databaseConfiguration.DatabaseType == DatabaseType.PostgresSql) { var splits = fullVersion.Split(' '); @@ -293,7 +294,7 @@ namespace Tgstation.Server.Host.Setup /// The path to the potential SQLite database file. /// The for the operation. /// A resulting in the SQLite database path to store in the configuration. - async ValueTask ValidateNonExistantSqliteDBName(string databaseName, CancellationToken cancellationToken) + async ValueTask ValidateNonExistantSqliteDBName(string databaseName, CancellationToken cancellationToken) { var dbPathIsRooted = Path.IsPathRooted(databaseName); var resolvedPath = ioManager.ResolvePath( @@ -408,12 +409,12 @@ namespace Tgstation.Server.Host.Setup DatabaseType = await PromptDatabaseType(firstTime, cancellationToken), }; - string serverAddress = null; + string? serverAddress = null; ushort? serverPort = null; var definitelyLocalMariaDB = firstTime && internalConfiguration.MariaDBSetup; var isSqliteDB = databaseConfiguration.DatabaseType == DatabaseType.Sqlite; - IPHostEntry serverAddressEntry = null; + IPHostEntry? serverAddressEntry = null; if (!isSqliteDB) do { @@ -470,7 +471,7 @@ namespace Tgstation.Server.Host.Setup await console.WriteAsync(null, true, cancellationToken); await console.WriteAsync($"Enter the database {(isSqliteDB ? "file path" : "name")} ({(definitelyLocalMariaDB ? "leave blank for \"tgs\")" : "Can be from previous installation. Otherwise, should not exist")}): ", false, cancellationToken); - string databaseName; + string? databaseName; bool dbExists = false; do { @@ -512,8 +513,8 @@ namespace Tgstation.Server.Host.Setup await console.WriteAsync(null, true, cancellationToken); - string username = null; - string password = null; + string? username = null; + string? password = null; if (!isSqliteDB) if (!useWinAuth) { @@ -885,7 +886,7 @@ namespace Tgstation.Server.Host.Setup /// /// The for the operation. /// A resulting in the new . - async ValueTask ConfigureSwarm(CancellationToken cancellationToken) + async ValueTask ConfigureSwarm(CancellationToken cancellationToken) { var enable = await PromptYesNo("Enable swarm mode?", false, cancellationToken); if (!enable) @@ -902,7 +903,7 @@ namespace Tgstation.Server.Host.Setup async ValueTask ParseAddress(string question) { var first = true; - Uri address; + Uri? address; do { if (first) @@ -933,7 +934,7 @@ namespace Tgstation.Server.Host.Setup while (String.IsNullOrWhiteSpace(privateKey)); var controller = await PromptYesNo("Is this server the swarm's controller? (y/n): ", null, cancellationToken); - Uri controllerAddress = null; + Uri? controllerAddress = null; if (!controller) controllerAddress = await ParseAddress("Enter the swarm controller's HTTP(S) address: "); @@ -965,15 +966,15 @@ namespace Tgstation.Server.Host.Setup ushort? hostingPort, DatabaseConfiguration databaseConfiguration, GeneralConfiguration newGeneralConfiguration, - FileLoggingConfiguration fileLoggingConfiguration, - ElasticsearchConfiguration elasticsearchConfiguration, + FileLoggingConfiguration? fileLoggingConfiguration, + ElasticsearchConfiguration? elasticsearchConfiguration, ControlPanelConfiguration controlPanelConfiguration, - SwarmConfiguration swarmConfiguration, + SwarmConfiguration? swarmConfiguration, CancellationToken cancellationToken) { newGeneralConfiguration.ApiPort = hostingPort ?? GeneralConfiguration.DefaultApiPort; newGeneralConfiguration.ConfigVersion = GeneralConfiguration.CurrentConfigVersion; - var map = new Dictionary() + var map = new Dictionary() { { DatabaseConfiguration.Section, databaseConfiguration }, { GeneralConfiguration.Section, newGeneralConfiguration }, @@ -1097,7 +1098,7 @@ namespace Tgstation.Server.Host.Setup } Task finalTask = Task.CompletedTask; - string originalConsoleTitle = null; + string? originalConsoleTitle = null; void SetConsoleTitle() { if (originalConsoleTitle != null) From 2b69e9078fde5d52e4585b7e20ce63a8c38ffb9a Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 25 Nov 2023 16:11:27 -0500 Subject: [PATCH 162/425] Nullify `IServer` --- src/Tgstation.Server.Host/IServer.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/IServer.cs b/src/Tgstation.Server.Host/IServer.cs index 105b14f773..e13364831f 100644 --- a/src/Tgstation.Server.Host/IServer.cs +++ b/src/Tgstation.Server.Host/IServer.cs @@ -1,8 +1,6 @@ using System.Threading; using System.Threading.Tasks; -#nullable disable - namespace Tgstation.Server.Host { /// From 03cfae1796810709e8dee67c2063c81ad61ce6f8 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 25 Nov 2023 16:12:29 -0500 Subject: [PATCH 163/425] Nullify `MasterVersionsAttribute` --- .../Properties/MasterVersionsAttribute.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Tgstation.Server.Host/Properties/MasterVersionsAttribute.cs b/src/Tgstation.Server.Host/Properties/MasterVersionsAttribute.cs index 042b679202..d77bcd349b 100644 --- a/src/Tgstation.Server.Host/Properties/MasterVersionsAttribute.cs +++ b/src/Tgstation.Server.Host/Properties/MasterVersionsAttribute.cs @@ -1,8 +1,6 @@ using System; using System.Reflection; -#nullable disable - namespace Tgstation.Server.Host.Properties { /// @@ -16,7 +14,7 @@ namespace Tgstation.Server.Host.Properties /// public static MasterVersionsAttribute Instance => Assembly .GetExecutingAssembly() - .GetCustomAttribute(); + .GetCustomAttribute()!; /// /// The of the version built. From 48313dc7b8a0b920447894916e6548c9dddb55ef Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 25 Nov 2023 16:12:54 -0500 Subject: [PATCH 164/425] Nullify `LimitedStreamResult` --- .../Controllers/Results/LimitedStreamResult.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Controllers/Results/LimitedStreamResult.cs b/src/Tgstation.Server.Host/Controllers/Results/LimitedStreamResult.cs index 10b0e08909..998f5779c5 100644 --- a/src/Tgstation.Server.Host/Controllers/Results/LimitedStreamResult.cs +++ b/src/Tgstation.Server.Host/Controllers/Results/LimitedStreamResult.cs @@ -10,8 +10,6 @@ using Microsoft.Extensions.DependencyInjection; using Tgstation.Server.Host.IO; -#nullable disable - namespace Tgstation.Server.Host.Controllers.Results { /// From 53bcad8fa5428ed8534f327e7aa4d39ac280e381 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 25 Nov 2023 16:15:19 -0500 Subject: [PATCH 165/425] Nullify `LimitedStreamResultExecutor` --- .../Controllers/Results/LimitedStreamResultExecutor.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Tgstation.Server.Host/Controllers/Results/LimitedStreamResultExecutor.cs b/src/Tgstation.Server.Host/Controllers/Results/LimitedStreamResultExecutor.cs index 2a7bc72279..c3d3b7d372 100644 --- a/src/Tgstation.Server.Host/Controllers/Results/LimitedStreamResultExecutor.cs +++ b/src/Tgstation.Server.Host/Controllers/Results/LimitedStreamResultExecutor.cs @@ -7,8 +7,6 @@ using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.Infrastructure; using Microsoft.Extensions.Logging; -#nullable disable - namespace Tgstation.Server.Host.Controllers.Results { /// @@ -55,7 +53,7 @@ namespace Tgstation.Server.Host.Controllers.Results } else { - stream.Seek(range.From.Value, SeekOrigin.Begin); + stream.Seek(range.From ?? 0, SeekOrigin.Begin); await StreamCopyOperation.CopyToAsync( stream, outputStream, From 54beb2dbc62d79f0175465acc124ce3031bc8e3a Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 25 Nov 2023 16:17:09 -0500 Subject: [PATCH 166/425] Nullify `PaginatableResult` --- .../Controllers/Results/PaginatableResult.cs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/Tgstation.Server.Host/Controllers/Results/PaginatableResult.cs b/src/Tgstation.Server.Host/Controllers/Results/PaginatableResult.cs index 7be3c27aa1..5d4f80d023 100644 --- a/src/Tgstation.Server.Host/Controllers/Results/PaginatableResult.cs +++ b/src/Tgstation.Server.Host/Controllers/Results/PaginatableResult.cs @@ -1,10 +1,9 @@ using System; +using System.Diagnostics.CodeAnalysis; using System.Linq; using Microsoft.AspNetCore.Mvc; -#nullable disable - namespace Tgstation.Server.Host.Controllers.Results { /// @@ -13,15 +12,22 @@ namespace Tgstation.Server.Host.Controllers.Results /// The of model intended to be returned. public sealed class PaginatableResult { + /// + /// Whether or not the is valid. + /// + [MemberNotNullWhen(true, nameof(Results))] + [MemberNotNullWhen(false, nameof(EarlyOut))] + public bool Valid => EarlyOut == null; + /// /// The results. /// - public IOrderedQueryable Results { get; } + public IOrderedQueryable? Results { get; } /// /// An to return immediately. /// - public IActionResult EarlyOut { get; } + public IActionResult? EarlyOut { get; } /// /// Initializes a new instance of the class. From 1d8959ddcd88f20b5ce8f03f75c36a3052aa8a79 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 25 Nov 2023 16:18:37 -0500 Subject: [PATCH 167/425] Nullify `AdministrationController` --- .../Models/Response/ServerUpdateResponse.cs | 2 +- .../Controllers/AdministrationController.cs | 14 ++++++-------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/Tgstation.Server.Api/Models/Response/ServerUpdateResponse.cs b/src/Tgstation.Server.Api/Models/Response/ServerUpdateResponse.cs index 3578e6cd0a..48c9b99e6a 100644 --- a/src/Tgstation.Server.Api/Models/Response/ServerUpdateResponse.cs +++ b/src/Tgstation.Server.Api/Models/Response/ServerUpdateResponse.cs @@ -20,7 +20,7 @@ namespace Tgstation.Server.Api.Models.Response /// The value of . /// The optional value of . [JsonConstructor] - public ServerUpdateResponse(Version newVersion, string fileTicket) + public ServerUpdateResponse(Version newVersion, string? fileTicket) { NewVersion = newVersion ?? throw new ArgumentNullException(nameof(newVersion)); FileTicket = fileTicket; diff --git a/src/Tgstation.Server.Host/Controllers/AdministrationController.cs b/src/Tgstation.Server.Host/Controllers/AdministrationController.cs index f90a842a5c..2ccc4f4c8b 100644 --- a/src/Tgstation.Server.Host/Controllers/AdministrationController.cs +++ b/src/Tgstation.Server.Host/Controllers/AdministrationController.cs @@ -29,8 +29,6 @@ using Tgstation.Server.Host.Transfer; using Tgstation.Server.Host.Utils; using Tgstation.Server.Host.Utils.GitHub; -#nullable disable - namespace Tgstation.Server.Host.Controllers { /// @@ -146,8 +144,8 @@ namespace Tgstation.Server.Host.Controllers { try { - Version greatestVersion = null; - Uri repoUrl = null; + Version? greatestVersion = null; + Uri? repoUrl = null; try { var gitHubService = gitHubServiceFactory.CreateService(); @@ -215,10 +213,10 @@ namespace Tgstation.Server.Host.Controllers var attemptingUpload = model.UploadZip == true; if (attemptingUpload) { - if (!AuthenticationContext.PermissionSet.AdministrationRights.Value.HasFlag(AdministrationRights.UploadVersion)) + if (!AuthenticationContext.PermissionSet.AdministrationRights!.Value.HasFlag(AdministrationRights.UploadVersion)) return Forbid(); } - else if (!AuthenticationContext.PermissionSet.AdministrationRights.Value.HasFlag(AdministrationRights.ChangeVersion)) + else if (!AuthenticationContext.PermissionSet.AdministrationRights!.Value.HasFlag(AdministrationRights.ChangeVersion)) return Forbid(); if (model.NewVersion == null) @@ -379,7 +377,7 @@ namespace Tgstation.Server.Host.Controllers /// A resulting in the of the request. async ValueTask AttemptInitiateUpdate(Version newVersion, bool attemptingUpload, CancellationToken cancellationToken) { - IFileUploadTicket uploadTicket = attemptingUpload + IFileUploadTicket? uploadTicket = attemptingUpload ? fileTransferService.CreateUpload(FileUploadStreamKind.None) : null; @@ -393,7 +391,7 @@ namespace Tgstation.Server.Host.Controllers catch { if (attemptingUpload) - await uploadTicket.DisposeAsync(); + await uploadTicket!.DisposeAsync(); throw; } From c63352e04cbcbb7287214f802b94c29aba10cdab Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 25 Nov 2023 16:21:43 -0500 Subject: [PATCH 168/425] Nullify `ApiController` --- .../Controllers/ApiController.cs | 24 +++++++++---------- .../Extensions/ControllerBaseExtensions.cs | 2 +- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/src/Tgstation.Server.Host/Controllers/ApiController.cs b/src/Tgstation.Server.Host/Controllers/ApiController.cs index 561bde364b..ea8c4c3209 100644 --- a/src/Tgstation.Server.Host/Controllers/ApiController.cs +++ b/src/Tgstation.Server.Host/Controllers/ApiController.cs @@ -28,8 +28,6 @@ using Tgstation.Server.Host.Models; using Tgstation.Server.Host.Security; using Tgstation.Server.Host.Utils; -#nullable disable - namespace Tgstation.Server.Host.Controllers { /// @@ -50,7 +48,7 @@ namespace Tgstation.Server.Host.Controllers /// /// The for the operation. /// - protected ApiHeaders ApiHeaders => ApiHeadersProvider.ApiHeaders; + protected ApiHeaders? ApiHeaders => ApiHeadersProvider.ApiHeaders; /// /// The containing value of . @@ -75,7 +73,7 @@ namespace Tgstation.Server.Host.Controllers /// /// The for the operation. /// - protected Models.Instance Instance { get; } + protected Models.Instance? Instance { get; } /// /// If are required. @@ -102,13 +100,13 @@ namespace Tgstation.Server.Host.Controllers ApiHeadersProvider = apiHeadersProvider ?? throw new ArgumentNullException(nameof(apiHeadersProvider)); Logger = logger ?? throw new ArgumentNullException(nameof(logger)); - Instance = AuthenticationContext?.InstancePermissionSet?.Instance; + Instance = AuthenticationContext.InstancePermissionSet?.Instance; this.requireHeaders = requireHeaders; } /// #pragma warning disable CA1506 // TODO: Decomplexify - protected override async ValueTask HookExecuteAction(Func executeAction, CancellationToken cancellationToken) + protected override async ValueTask HookExecuteAction(Func executeAction, CancellationToken cancellationToken) { ArgumentNullException.ThrowIfNull(executeAction); @@ -116,7 +114,7 @@ namespace Tgstation.Server.Host.Controllers if (ApiHeaders == null) { if (requireHeaders) - return HeadersIssue(ApiHeadersProvider.HeadersException); + return HeadersIssue(ApiHeadersProvider.HeadersException!); } var errorCase = await ValidateRequest(cancellationToken); @@ -126,7 +124,7 @@ namespace Tgstation.Server.Host.Controllers if (ModelState?.IsValid == false) { var errorMessages = ModelState - .SelectMany(x => x.Value.Errors) + .SelectMany(x => x.Value!.Errors) .Select(x => x.ErrorMessage) // We use RequiredAttributes purely for preventing properties from becoming nullable in the databases @@ -240,8 +238,8 @@ namespace Tgstation.Server.Host.Controllers /// /// The for the operation. /// A resulting in an appropriate on validation failure, otherwise. - protected virtual ValueTask ValidateRequest(CancellationToken cancellationToken) - => ValueTask.FromResult(null); + protected virtual ValueTask ValidateRequest(CancellationToken cancellationToken) + => ValueTask.FromResult(null); /// /// Response for missing/Invalid headers. @@ -276,7 +274,7 @@ namespace Tgstation.Server.Host.Controllers /// A resulting in the for the operation. protected ValueTask Paginated( Func>> queryGenerator, - Func resultTransformer, + Func? resultTransformer, int? pageQuery, int? pageSizeQuery, CancellationToken cancellationToken) => PaginatedImpl( @@ -324,7 +322,7 @@ namespace Tgstation.Server.Host.Controllers /// A resulting in the for the operation. async ValueTask PaginatedImpl( Func>> queryGenerator, - Func resultTransformer, + Func? resultTransformer, int? pageQuery, int? pageSizeQuery, CancellationToken cancellationToken) @@ -344,7 +342,7 @@ namespace Tgstation.Server.Host.Controllers var page = pageQuery ?? 1; var paginationResult = await queryGenerator(); - if (paginationResult.EarlyOut != null) + if (!paginationResult.Valid) return paginationResult.EarlyOut; var queriedResults = paginationResult diff --git a/src/Tgstation.Server.Host/Extensions/ControllerBaseExtensions.cs b/src/Tgstation.Server.Host/Extensions/ControllerBaseExtensions.cs index 9ab3b1cc87..f74a30913c 100644 --- a/src/Tgstation.Server.Host/Extensions/ControllerBaseExtensions.cs +++ b/src/Tgstation.Server.Host/Extensions/ControllerBaseExtensions.cs @@ -28,7 +28,7 @@ namespace Tgstation.Server.Host.Extensions /// The . /// The accompanying payload. /// A with the given . - public static ObjectResult StatusCode(this ControllerBase controller, HttpStatusCode statusCode, object errorMessage) + public static ObjectResult StatusCode(this ControllerBase controller, HttpStatusCode statusCode, object? errorMessage) => controller?.StatusCode((int)statusCode, errorMessage) ?? throw new ArgumentNullException(nameof(controller)); } } From 92c4e653e429a5d6b66fb2fa01e003eeefeabdcb Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 25 Nov 2023 16:22:38 -0500 Subject: [PATCH 169/425] Nullify `ApiControllerBase` --- src/Tgstation.Server.Host/Controllers/ApiControllerBase.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Tgstation.Server.Host/Controllers/ApiControllerBase.cs b/src/Tgstation.Server.Host/Controllers/ApiControllerBase.cs index 8e313397f1..748dd81096 100644 --- a/src/Tgstation.Server.Host/Controllers/ApiControllerBase.cs +++ b/src/Tgstation.Server.Host/Controllers/ApiControllerBase.cs @@ -8,8 +8,6 @@ using Microsoft.AspNetCore.Mvc.Filters; using Microsoft.Extensions.Primitives; using Microsoft.Net.Http.Headers; -#nullable disable - namespace Tgstation.Server.Host.Controllers { /// @@ -39,7 +37,7 @@ namespace Tgstation.Server.Host.Controllers /// A that should be invoked and its response awaited to continue normal execution of the request. Should NOT be called if this method returns a non- value. /// The for the operation. /// A resulting in an that, if not , is executed. - protected virtual async ValueTask HookExecuteAction(Func executeAction, CancellationToken cancellationToken) + protected virtual async ValueTask HookExecuteAction(Func executeAction, CancellationToken cancellationToken) { ArgumentNullException.ThrowIfNull(executeAction); From d41f143cf8fd3798ac68c91bcf713eb08f7498be Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 25 Nov 2023 16:25:12 -0500 Subject: [PATCH 170/425] Nullify `ApiRootController` --- .../Controllers/ApiRootController.cs | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/Tgstation.Server.Host/Controllers/ApiRootController.cs b/src/Tgstation.Server.Host/Controllers/ApiRootController.cs index 5480c689d2..334eba85a4 100644 --- a/src/Tgstation.Server.Host/Controllers/ApiRootController.cs +++ b/src/Tgstation.Server.Host/Controllers/ApiRootController.cs @@ -27,8 +27,6 @@ using Tgstation.Server.Host.Swarm; using Tgstation.Server.Host.System; using Tgstation.Server.Host.Utils; -#nullable disable - namespace Tgstation.Server.Host.Controllers { /// @@ -215,7 +213,7 @@ namespace Tgstation.Server.Host.Controllers if (ApiHeaders == null) { Response.Headers.Add(HeaderNames.WWWAuthenticate, new StringValues($"basic realm=\"Create TGS {ApiHeaders.BearerAuthenticationScheme} token\"")); - return HeadersIssue(ApiHeadersProvider.HeadersException); + return HeadersIssue(ApiHeadersProvider.HeadersException!); } if (ApiHeaders.IsTokenAuthentication) @@ -223,12 +221,12 @@ namespace Tgstation.Server.Host.Controllers var oAuthLogin = ApiHeaders.OAuthProvider.HasValue; - ISystemIdentity systemIdentity = null; + ISystemIdentity? systemIdentity = null; if (!oAuthLogin) try { // trust the system over the database because a user's name can change while still having the same SID - systemIdentity = await systemIdentityFactory.CreateSystemIdentity(ApiHeaders.Username, ApiHeaders.Password, cancellationToken); + systemIdentity = await systemIdentityFactory.CreateSystemIdentity(ApiHeaders.Username!, ApiHeaders.Password!, cancellationToken); } catch (NotImplementedException) { @@ -241,8 +239,8 @@ namespace Tgstation.Server.Host.Controllers IQueryable query = DatabaseContext.Users.AsQueryable(); if (oAuthLogin) { - var oAuthProvider = ApiHeaders.OAuthProvider.Value; - string externalUserId; + var oAuthProvider = ApiHeaders.OAuthProvider!.Value; + string? externalUserId; try { var validator = oAuthProviders @@ -313,7 +311,7 @@ namespace Tgstation.Server.Host.Controllers if (!usingSystemIdentity) { // DB User password check and update - if (!isLikelyDbUser || !cryptographySuite.CheckUserPassword(user, ApiHeaders.Password)) + if (!isLikelyDbUser || !cryptographySuite.CheckUserPassword(user, ApiHeaders.Password!)) return Unauthorized(); if (user.PasswordHash != originalHash) { @@ -329,7 +327,7 @@ namespace Tgstation.Server.Host.Controllers } else { - var usernameMismatch = systemIdentity.Username != user.Name; + var usernameMismatch = systemIdentity!.Username != user.Name; if (isLikelyDbUser || usernameMismatch) { DatabaseContext.Users.Attach(user); @@ -354,7 +352,7 @@ namespace Tgstation.Server.Host.Controllers } // Now that the bookeeping is done, tell them to fuck off if necessary - if (!user.Enabled.Value) + if (!user.Enabled!.Value) { Logger.LogTrace("Not logging in disabled user {userId}.", user.Id); return Forbid(); @@ -367,7 +365,7 @@ namespace Tgstation.Server.Host.Controllers var identExpiry = token.ParseJwt().ValidTo; identExpiry += tokenFactory.ValidationParameters.ClockSkew; identExpiry += TimeSpan.FromSeconds(15); - identityCache.CacheSystemIdentity(user, systemIdentity, identExpiry); + identityCache.CacheSystemIdentity(user, systemIdentity!, identExpiry); } Logger.LogDebug("Successfully logged in user {userId}!", user.Id); From 1c3b12f9694334bc14cdf878bc603b58049a62ec Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 25 Nov 2023 16:27:59 -0500 Subject: [PATCH 171/425] Nullify `BridgeController` --- .../Controllers/BridgeController.cs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/Tgstation.Server.Host/Controllers/BridgeController.cs b/src/Tgstation.Server.Host/Controllers/BridgeController.cs index 96c44f5085..4b1a1fac3e 100644 --- a/src/Tgstation.Server.Host/Controllers/BridgeController.cs +++ b/src/Tgstation.Server.Host/Controllers/BridgeController.cs @@ -18,8 +18,6 @@ using Tgstation.Server.Host.Components.Interop; using Tgstation.Server.Host.Components.Interop.Bridge; using Tgstation.Server.Host.Utils; -#nullable disable - namespace Tgstation.Server.Host.Controllers { /// @@ -91,7 +89,7 @@ namespace Tgstation.Server.Host.Controllers { // Nothing to see here var remoteIP = Request.HttpContext.Connection.RemoteIpAddress; - if (!IPAddress.IsLoopback(remoteIP)) + if (remoteIP == null || !IPAddress.IsLoopback(remoteIP)) { logger.LogTrace("Rejecting remote bridge request from {remoteIP}", remoteIP); return Forbid(); @@ -99,7 +97,7 @@ namespace Tgstation.Server.Host.Controllers using (LogContext.PushProperty(SerilogContextHelper.BridgeRequestIterationContextProperty, Interlocked.Increment(ref requestsProcessed))) { - BridgeParameters request; + BridgeParameters? request; try { request = JsonConvert.DeserializeObject(data, DMApiConstants.SerializerSettings); @@ -111,6 +109,13 @@ namespace Tgstation.Server.Host.Controllers return BadRequest(); } + if (request == null) + { + if (LogContent) + logger.LogWarning("Error deserializing bridge request: {badJson}", data); + return BadRequest(); + } + if (LogContent) logger.LogTrace("Bridge Request: {json}", data); From 6a8b48ad68fcb9944e9b020bd256779df30ca341 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 25 Nov 2023 16:33:15 -0500 Subject: [PATCH 172/425] Nullify `ChatController` --- .../Controllers/ChatController.cs | 23 +++++++++---------- .../Controllers/InstanceRequiredController.cs | 5 ++++ 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/Tgstation.Server.Host/Controllers/ChatController.cs b/src/Tgstation.Server.Host/Controllers/ChatController.cs index 551d03d943..fc411b460a 100644 --- a/src/Tgstation.Server.Host/Controllers/ChatController.cs +++ b/src/Tgstation.Server.Host/Controllers/ChatController.cs @@ -25,9 +25,8 @@ using Tgstation.Server.Host.Extensions; using Tgstation.Server.Host.Models; using Tgstation.Server.Host.Security; using Tgstation.Server.Host.Utils; -using Z.EntityFramework.Plus; -#nullable disable +using Z.EntityFramework.Plus; namespace Tgstation.Server.Host.Controllers { @@ -120,7 +119,7 @@ namespace Tgstation.Server.Host.Controllers .Where(x => x.InstanceId == Instance.Id) .CountAsync(cancellationToken); - if (countOfExistingBotsInInstance >= Instance.ChatBotLimit.Value) + if (countOfExistingBotsInInstance >= Instance.ChatBotLimit!.Value) return Conflict(new ErrorMessageResponse(ErrorCode.ChatBotMax)); model.Enabled ??= false; @@ -132,8 +131,8 @@ namespace Tgstation.Server.Host.Controllers Name = model.Name, ConnectionString = model.ConnectionString, Enabled = model.Enabled, - Channels = model.Channels?.Select(x => ConvertApiChatChannel(x, model.Provider.Value)).ToList() ?? new List(), // important that this isn't null - InstanceId = Instance.Id.Value, + Channels = model.Channels?.Select(x => ConvertApiChatChannel(x, model.Provider!.Value)).ToList() ?? new List(), // important that this isn't null + InstanceId = Instance.Id!.Value, Provider = model.Provider, ReconnectionInterval = model.ReconnectionInterval, ChannelLimit = model.ChannelLimit, @@ -151,7 +150,7 @@ namespace Tgstation.Server.Host.Controllers await instance.Chat.ChangeSettings(dbModel, cancellationToken); if (dbModel.Channels.Count > 0) - await instance.Chat.ChangeChannels(dbModel.Id.Value, dbModel.Channels, cancellationToken); + await instance.Chat.ChangeChannels(dbModel.Id!.Value, dbModel.Channels, cancellationToken); } catch { @@ -160,7 +159,7 @@ namespace Tgstation.Server.Host.Controllers // DCTx2: Operations must always run await DatabaseContext.Save(default); - await instance.Chat.DeleteConnection(dbModel.Id.Value, default); + await instance.Chat.DeleteConnection(dbModel.Id!.Value, default); throw; } @@ -297,7 +296,7 @@ namespace Tgstation.Server.Host.Controllers if (current == default) return this.Gone(); - if ((model.Channels?.Count ?? current.Channels.Count) > (model.ChannelLimit ?? current.ChannelLimit.Value)) + if ((model.Channels?.Count ?? current.Channels.Count) > (model.ChannelLimit ?? current.ChannelLimit!.Value)) { // 400 or 409 depends on if the client sent both var errorMessage = new ErrorMessageResponse(ErrorCode.ChatBotMaxChannels); @@ -343,7 +342,7 @@ namespace Tgstation.Server.Host.Controllers DatabaseContext.ChatChannels.RemoveRange(current.Channels); if (hasChannels) { - var dbChannels = model.Channels.Select(x => ConvertApiChatChannel(x, model.Provider ?? current.Provider.Value)).ToList(); + var dbChannels = model.Channels!.Select(x => ConvertApiChatChannel(x, model.Provider ?? current.Provider!.Value)).ToList(); DatabaseContext.ChatChannels.AddRange(dbChannels); current.Channels = dbChannels; } @@ -360,8 +359,8 @@ namespace Tgstation.Server.Host.Controllers if (anySettingsModified) await chat.ChangeSettings(current, cancellationToken); // have to rebuild the thing first - if ((model.Channels != null || anySettingsModified) && current.Enabled.Value) - await chat.ChangeChannels(current.Id.Value, current.Channels, cancellationToken); + if ((model.Channels != null || anySettingsModified) && current.Enabled!.Value) + await chat.ChangeChannels(current.Id!.Value, current.Channels, cancellationToken); return null; }); @@ -384,7 +383,7 @@ namespace Tgstation.Server.Host.Controllers /// The to validate. /// If the is being created. /// An to respond with or . - IActionResult StandardModelChecks(ChatBotApiBase model, bool forCreation) + IActionResult? StandardModelChecks(ChatBotApiBase model, bool forCreation) { if (model.ReconnectionInterval == 0) throw new InvalidOperationException("RecconnectionInterval cannot be zero!"); diff --git a/src/Tgstation.Server.Host/Controllers/InstanceRequiredController.cs b/src/Tgstation.Server.Host/Controllers/InstanceRequiredController.cs index 6ee1fe4963..68dec10504 100644 --- a/src/Tgstation.Server.Host/Controllers/InstanceRequiredController.cs +++ b/src/Tgstation.Server.Host/Controllers/InstanceRequiredController.cs @@ -14,6 +14,11 @@ namespace Tgstation.Server.Host.Controllers /// public abstract class InstanceRequiredController : ComponentInterfacingController { + /// + /// The . + /// + protected new Models.Instance Instance => base.Instance!; + /// /// Initializes a new instance of the class. /// From f4ff59ce1faf70a14bc06413e14d75938b8d74cb Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 25 Nov 2023 16:36:35 -0500 Subject: [PATCH 173/425] Nullify `ComponentInterfacingController` --- .../Controllers/ChatController.cs | 6 ++--- .../ComponentInterfacingController.cs | 25 +++++++++++++------ 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/src/Tgstation.Server.Host/Controllers/ChatController.cs b/src/Tgstation.Server.Host/Controllers/ChatController.cs index fc411b460a..6b35f19d28 100644 --- a/src/Tgstation.Server.Host/Controllers/ChatController.cs +++ b/src/Tgstation.Server.Host/Controllers/ChatController.cs @@ -141,7 +141,7 @@ namespace Tgstation.Server.Host.Controllers DatabaseContext.ChatBots.Add(dbModel); await DatabaseContext.Save(cancellationToken); - return await WithComponentInstance( + return await WithComponentInstanceNullable( async instance => { try @@ -180,7 +180,7 @@ namespace Tgstation.Server.Host.Controllers [TgsAuthorize(ChatBotRights.Delete)] [ProducesResponseType(204)] public async ValueTask Delete(long id, CancellationToken cancellationToken) - => await WithComponentInstance( + => await WithComponentInstanceNullable( async instance => { await Task.WhenAll( @@ -352,7 +352,7 @@ namespace Tgstation.Server.Host.Controllers await DatabaseContext.Save(cancellationToken); - earlyOut = await WithComponentInstance( + earlyOut = await WithComponentInstanceNullable( async instance => { var chat = instance.Chat; diff --git a/src/Tgstation.Server.Host/Controllers/ComponentInterfacingController.cs b/src/Tgstation.Server.Host/Controllers/ComponentInterfacingController.cs index c830a45d17..108390890f 100644 --- a/src/Tgstation.Server.Host/Controllers/ComponentInterfacingController.cs +++ b/src/Tgstation.Server.Host/Controllers/ComponentInterfacingController.cs @@ -10,11 +10,10 @@ using Tgstation.Server.Api.Models; using Tgstation.Server.Api.Models.Response; using Tgstation.Server.Host.Components; using Tgstation.Server.Host.Database; +using Tgstation.Server.Host.Models; using Tgstation.Server.Host.Security; using Tgstation.Server.Host.Utils; -#nullable disable - namespace Tgstation.Server.Host.Controllers { /// @@ -65,18 +64,18 @@ namespace Tgstation.Server.Host.Controllers } /// - protected override async ValueTask ValidateRequest(CancellationToken cancellationToken) + protected override async ValueTask ValidateRequest(CancellationToken cancellationToken) { if (!useInstanceRequestHeader) return null; - if (!ApiHeaders.InstanceId.HasValue) + if (!ApiHeaders!.InstanceId.HasValue) return BadRequest(new ErrorMessageResponse(ErrorCode.InstanceHeaderRequired)); if (AuthenticationContext.InstancePermissionSet == null) return Forbid(); - if (ValidateInstanceOnlineStatus(Instance)) + if (ValidateInstanceOnlineStatus(Instance!)) await DatabaseContext.Save(cancellationToken); using var instanceReferenceCheck = instanceManager.GetInstanceReference(Instance); @@ -99,7 +98,7 @@ namespace Tgstation.Server.Host.Controllers using (var instanceReferenceCheck = instanceManager.GetInstanceReference(metadata)) online = instanceReferenceCheck != null; - if (metadata.Online.Value == online) + if (metadata.Require(x => x.Online) == online) return false; const string OfflineWord = "offline"; @@ -122,11 +121,11 @@ namespace Tgstation.Server.Host.Controllers /// The to grab. If , will be used. /// A resulting in the that should be returned. /// The context of should be as small as possible so as to avoid race conditions. This function can return a if the requested instance was offline. - protected async ValueTask WithComponentInstance(Func> action, Models.Instance instance = null) + protected async ValueTask WithComponentInstanceNullable(Func> action, Models.Instance? instance = null) { ArgumentNullException.ThrowIfNull(action); - instance ??= Instance; + instance ??= Instance ?? throw new InvalidOperationException("ComponentInterfacingController has no Instance!"); using var instanceReference = instanceManager.GetInstanceReference(instance); using (LogContext.PushProperty(SerilogContextHelper.InstanceReferenceContextProperty, instanceReference.Uid)) @@ -136,5 +135,15 @@ namespace Tgstation.Server.Host.Controllers return await action(instanceReference); } } + + /// + /// Run a given with the relevant . + /// + /// A accepting the and returning a with the . + /// The to grab. If , will be used. + /// A resulting in the that should be returned. + /// The context of should be as small as possible so as to avoid race conditions. This function can return a if the requested instance was offline. + protected async ValueTask WithComponentInstance(Func> action, Models.Instance? instance = null) + => (await WithComponentInstanceNullable(async core => await action(core), instance))!; } } From 38728291fc44af97e2d835d2060988ad5f04718a Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 25 Nov 2023 16:47:02 -0500 Subject: [PATCH 174/425] Nullify `ConfigurationController` --- .../Controllers/ConfigurationController.cs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/Tgstation.Server.Host/Controllers/ConfigurationController.cs b/src/Tgstation.Server.Host/Controllers/ConfigurationController.cs index 2b95796ef7..1df1fbc907 100644 --- a/src/Tgstation.Server.Host/Controllers/ConfigurationController.cs +++ b/src/Tgstation.Server.Host/Controllers/ConfigurationController.cs @@ -19,8 +19,6 @@ using Tgstation.Server.Host.Models; using Tgstation.Server.Host.Security; using Tgstation.Server.Host.Utils; -#nullable disable - namespace Tgstation.Server.Host.Controllers { /// @@ -75,7 +73,7 @@ namespace Tgstation.Server.Host.Controllers public async ValueTask Update([FromBody] ConfigurationFileRequest model, CancellationToken cancellationToken) { ArgumentNullException.ThrowIfNull(model); - if (ForbidDueToModeConflicts(model.Path, out var systemIdentity)) + if (ForbidDueToModeConflicts(model.Path!, out var systemIdentity)) return Forbid(); try @@ -166,7 +164,7 @@ namespace Tgstation.Server.Host.Controllers [ProducesResponseType(typeof(ErrorMessageResponse), 409)] [ProducesResponseType(typeof(ErrorMessageResponse), 410)] public ValueTask Directory( - string directoryPath, + string? directoryPath, [FromQuery] int? page, [FromQuery] int? pageSize, CancellationToken cancellationToken) @@ -340,7 +338,7 @@ namespace Tgstation.Server.Host.Controllers /// The path to validate if any. /// The to use when calling into . /// if a should be returned, otherwise. - bool ForbidDueToModeConflicts(string path, out ISystemIdentity systemIdentityToUse) + bool ForbidDueToModeConflicts(string? path, out ISystemIdentity? systemIdentityToUse) { if (Instance.ConfigurationType == ConfigurationType.Disallowed || (Instance.ConfigurationType == ConfigurationType.SystemIdentityWrite && AuthenticationContext.SystemIdentity == null) From 13563cff64c15a26f77a5c242391fbd260e5089c Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 25 Nov 2023 16:47:21 -0500 Subject: [PATCH 175/425] Nullify `ControlPanelController` --- src/Tgstation.Server.Host/Controllers/ControlPanelController.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Controllers/ControlPanelController.cs b/src/Tgstation.Server.Host/Controllers/ControlPanelController.cs index 1d2d1274b8..08d8f74dad 100644 --- a/src/Tgstation.Server.Host/Controllers/ControlPanelController.cs +++ b/src/Tgstation.Server.Host/Controllers/ControlPanelController.cs @@ -16,8 +16,6 @@ using Microsoft.Net.Http.Headers; using Tgstation.Server.Api; using Tgstation.Server.Host.Configuration; -#nullable disable - namespace Tgstation.Server.Host.Controllers { /// From be29aa0a8e55286d489160dc1c8d03b2e81184d0 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 14 Dec 2023 17:42:35 -0500 Subject: [PATCH 176/425] Nullify `ChannelMapping` --- .../Components/Chat/ChannelMapping.cs | 13 +++++++++++-- .../Components/Chat/ChatManager.cs | 8 +++----- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Chat/ChannelMapping.cs b/src/Tgstation.Server.Host/Components/Chat/ChannelMapping.cs index 8773e402a9..19581b09bb 100644 --- a/src/Tgstation.Server.Host/Components/Chat/ChannelMapping.cs +++ b/src/Tgstation.Server.Host/Components/Chat/ChannelMapping.cs @@ -1,4 +1,4 @@ -#nullable disable +using System; namespace Tgstation.Server.Host.Components.Chat { @@ -40,6 +40,15 @@ namespace Tgstation.Server.Host.Components.Chat /// /// The with the mapped Id. /// - public ChannelRepresentation Channel { get; set; } + public ChannelRepresentation Channel { get; } + + /// + /// Initializes a new instance of the class. + /// + /// The value of . + public ChannelMapping(ChannelRepresentation channel) + { + Channel = channel ?? throw new ArgumentNullException(nameof(channel)); + } } } diff --git a/src/Tgstation.Server.Host/Components/Chat/ChatManager.cs b/src/Tgstation.Server.Host/Components/Chat/ChatManager.cs index 409c6555c2..44e6625691 100644 --- a/src/Tgstation.Server.Host/Components/Chat/ChatManager.cs +++ b/src/Tgstation.Server.Host/Components/Chat/ChatManager.cs @@ -71,7 +71,7 @@ namespace Tgstation.Server.Host.Components.Chat readonly Dictionary providers; /// - /// Map of s used to guard concurrent access to , keyed by . + /// Map of s used to guard concurrent access to , keyed by . /// readonly ConcurrentDictionary changeChannelSemaphores; @@ -236,7 +236,7 @@ namespace Tgstation.Server.Host.Components.Chat var newMappings = results.SelectMany( kvp => kvp.Value.Select( - channelRepresentation => new ChannelMapping + channelRepresentation => new ChannelMapping(channelRepresentation) { IsWatchdogChannel = kvp.Key.IsWatchdogChannel == true, IsUpdatesChannel = kvp.Key.IsUpdatesChannel == true, @@ -244,7 +244,6 @@ namespace Tgstation.Server.Host.Components.Chat IsSystemChannel = kvp.Key.IsSystemChannel == true, ProviderChannelId = channelRepresentation.RealId, ProviderId = connectionId, - Channel = channelRepresentation, })); ulong baseId; @@ -767,11 +766,10 @@ namespace Tgstation.Server.Host.Components.Chat message.User.Channel.ConnectionName, message.User.FriendlyName, newId); - mappedChannels.Add(newId, new ChannelMapping + mappedChannels.Add(newId, new ChannelMapping(message.User.Channel) { ProviderChannelId = message.User.Channel.RealId, ProviderId = providerId, - Channel = message.User.Channel, }); logger.LogTrace( From f775a0563b16e5432e4af3b27689f6e4ab86df64 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sun, 17 Dec 2023 10:33:48 -0500 Subject: [PATCH 177/425] Nullify `ChannelRepresentation` --- .../Components/Chat/ChannelRepresentation.cs | 22 +++++++++++++---- .../Chat/Providers/DiscordProvider.cs | 24 +++++++++---------- .../Components/Chat/Providers/IrcProvider.cs | 15 ++++-------- .../Live/DummyChatProvider.cs | 13 ++++------ .../Live/Instance/WatchdogTest.cs | 4 +--- 5 files changed, 40 insertions(+), 38 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Chat/ChannelRepresentation.cs b/src/Tgstation.Server.Host/Components/Chat/ChannelRepresentation.cs index aed43e0817..b7bed776d6 100644 --- a/src/Tgstation.Server.Host/Components/Chat/ChannelRepresentation.cs +++ b/src/Tgstation.Server.Host/Components/Chat/ChannelRepresentation.cs @@ -3,8 +3,6 @@ using System.Globalization; using Newtonsoft.Json; -#nullable disable - namespace Tgstation.Server.Host.Components.Chat { /// @@ -32,12 +30,12 @@ namespace Tgstation.Server.Host.Components.Chat /// /// The user friendly name of the . /// - public string FriendlyName { get; set; } + public string FriendlyName { get; } /// /// The name of the connection the belongs to. /// - public string ConnectionName { get; set; } + public string ConnectionName { get; } /// /// If this is considered a channel for admin commands. @@ -52,11 +50,25 @@ namespace Tgstation.Server.Host.Components.Chat /// /// For user use. /// - public string Tag { get; set; } + public string? Tag { get; set; } /// /// If this channel supports embeds. /// public bool EmbedsSupported { get; set; } + + /// + /// Initializes a new instance of the class. + /// + /// The value of . + /// The value of . + /// The value of /. + public ChannelRepresentation(string connectionName, string friendlyName, ulong id) + { + ConnectionName = connectionName ?? throw new ArgumentNullException(nameof(connectionName)); + FriendlyName = friendlyName ?? throw new ArgumentNullException(nameof(friendlyName)); + Id = null!; + RealId = id; + } } } diff --git a/src/Tgstation.Server.Host/Components/Chat/Providers/DiscordProvider.cs b/src/Tgstation.Server.Host/Components/Chat/Providers/DiscordProvider.cs index 3ee853f36c..3b3b4699d3 100644 --- a/src/Tgstation.Server.Host/Components/Chat/Providers/DiscordProvider.cs +++ b/src/Tgstation.Server.Host/Components/Chat/Providers/DiscordProvider.cs @@ -541,12 +541,12 @@ namespace Tgstation.Server.Host.Components.Chat.Providers User = new ChatUser { RealId = messageCreateEvent.Author.ID.Value, - Channel = new ChannelRepresentation + Channel = new ChannelRepresentation( + pm ? messageCreateEvent.Author.Username : guildName, + channelResponse.Entity.Name.Value, + messageCreateEvent.ChannelID.Value) { - RealId = messageCreateEvent.ChannelID.Value, IsPrivateChannel = pm, - ConnectionName = pm ? messageCreateEvent.Author.Username : guildName, - FriendlyName = channelResponse.Entity.Name.Value, EmbedsSupported = true, // isAdmin and Tag populated by manager @@ -721,12 +721,12 @@ namespace Tgstation.Server.Host.Components.Chat.Providers var connectionName = guildsResponse.Entity.Name; - var channelModel = new ChannelRepresentation + var channelModel = new ChannelRepresentation( + guildsResponse.Entity.Name, + discordChannelResponse.Entity.Name.Value, + channelId) { - RealId = channelId, IsAdminChannel = channelFromDB.IsAdminChannel == true, - ConnectionName = guildsResponse.Entity.Name, - FriendlyName = discordChannelResponse.Entity.Name.Value, IsPrivateChannel = false, Tag = channelFromDB.Tag, EmbedsSupported = true, @@ -776,13 +776,13 @@ namespace Tgstation.Server.Host.Components.Chat.Providers // Add catch-all channel unmappedTasks.Add(Task.FromResult( - new ChannelRepresentation + new ChannelRepresentation( + "(Unknown Discord Guilds)", + "(Unknown Discord Channels)", + 0) { IsAdminChannel = channelIdZeroModel.IsAdminChannel.Value, - ConnectionName = "(Unknown Discord Guilds)", EmbedsSupported = true, - FriendlyName = "(Unknown Discord Channels)", - RealId = 0, Tag = channelIdZeroModel.Tag, })); diff --git a/src/Tgstation.Server.Host/Components/Chat/Providers/IrcProvider.cs b/src/Tgstation.Server.Host/Components/Chat/Providers/IrcProvider.cs index b870536fb7..2db2f30376 100644 --- a/src/Tgstation.Server.Host/Components/Chat/Providers/IrcProvider.cs +++ b/src/Tgstation.Server.Host/Components/Chat/Providers/IrcProvider.cs @@ -353,14 +353,11 @@ namespace Tgstation.Server.Host.Components.Chat.Providers dbChannel, new List { - new() + new(address, channelIdMap[id.Value], id.Value) { - RealId = id.Value, - IsAdminChannel = dbChannel.IsAdminChannel == true, - ConnectionName = address, - FriendlyName = channelIdMap[id.Value], - IsPrivateChannel = false, Tag = dbChannel.Tag, + IsAdminChannel = dbChannel.IsAdminChannel == true, + IsPrivateChannel = false, EmbedsSupported = false, }, }); @@ -532,16 +529,14 @@ namespace Tgstation.Server.Host.Components.Chat.Providers channelId = isPrivate ? userId : MapAndGetChannelId(channelIdMap); } + var channelFriendlyName = isPrivate ? String.Format(CultureInfo.InvariantCulture, "PM: {0}", channelName) : channelName; var message = new Message { Content = e.Data.Message, User = new ChatUser { - Channel = new ChannelRepresentation + Channel = new ChannelRepresentation(address, channelFriendlyName, channelId) { - ConnectionName = address, - FriendlyName = isPrivate ? String.Format(CultureInfo.InvariantCulture, "PM: {0}", channelName) : channelName, - RealId = channelId, IsPrivateChannel = isPrivate, EmbedsSupported = false, diff --git a/tests/Tgstation.Server.Tests/Live/DummyChatProvider.cs b/tests/Tgstation.Server.Tests/Live/DummyChatProvider.cs index 2edb4686ed..7aa9d531d6 100644 --- a/tests/Tgstation.Server.Tests/Live/DummyChatProvider.cs +++ b/tests/Tgstation.Server.Tests/Live/DummyChatProvider.cs @@ -188,14 +188,14 @@ namespace Tgstation.Server.Tests.Live else channelId = (ulong)channel.IrcChannel.GetHashCode(); - var entry = new ChannelRepresentation + var entry = new ChannelRepresentation( + $"Connection_{channelId}", + $"(Friendly) Channel_ID_{channelId}", + channelId) { IsAdminChannel = channel.IsAdminChannel.Value, - ConnectionName = $"Connection_{channelId}", EmbedsSupported = ChatBot.Provider.Value != Api.Models.ChatProvider.Irc, - FriendlyName = $"(Friendly) Channel_ID_{channelId}", IsPrivateChannel = false, - RealId = channelId, Tag = channel.Tag, }; @@ -253,12 +253,9 @@ namespace Tgstation.Server.Tests.Live } while (knownChannels.ContainsKey(channelId)); - channel = new ChannelRepresentation + channel = new ChannelRepresentation($"{username}_Connection", $"{username}_Channel", channelId) { - RealId = channelId, IsPrivateChannel = true, - ConnectionName = $"{username}_Connection", - FriendlyName = $"{username}_Channel", EmbedsSupported = ChatBot.Provider.Value != Api.Models.ChatProvider.Irc, // isAdmin and Tag populated by manager diff --git a/tests/Tgstation.Server.Tests/Live/Instance/WatchdogTest.cs b/tests/Tgstation.Server.Tests/Live/Instance/WatchdogTest.cs index bcde5714ff..fda9c94cce 100644 --- a/tests/Tgstation.Server.Tests/Live/Instance/WatchdogTest.cs +++ b/tests/Tgstation.Server.Tests/Live/Instance/WatchdogTest.cs @@ -983,12 +983,10 @@ namespace Tgstation.Server.Tests.Live.Instance { var mockChatUser = new ChatUser { - Channel = new ChannelRepresentation + Channel = new ChannelRepresentation("test_connection", "Test Connection", 0) { IsAdminChannel = true, - ConnectionName = "test_connection", EmbedsSupported = true, - FriendlyName = "Test Connection", Id = "test_channel_id", IsPrivateChannel = false, }, From 360490189f73d158f5ac4a79690be4d482a6fa64 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sun, 17 Dec 2023 14:41:18 -0500 Subject: [PATCH 178/425] Nullify `ChatManagerFactory` --- .../Components/Chat/ChatManagerFactory.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Chat/ChatManagerFactory.cs b/src/Tgstation.Server.Host/Components/Chat/ChatManagerFactory.cs index 7e9c09eb42..a1697a9711 100644 --- a/src/Tgstation.Server.Host/Components/Chat/ChatManagerFactory.cs +++ b/src/Tgstation.Server.Host/Components/Chat/ChatManagerFactory.cs @@ -7,8 +7,7 @@ using Microsoft.Extensions.Logging; using Tgstation.Server.Host.Components.Chat.Commands; using Tgstation.Server.Host.Components.Chat.Providers; using Tgstation.Server.Host.Core; - -#nullable disable +using Tgstation.Server.Host.Models; namespace Tgstation.Server.Host.Components.Chat { @@ -56,6 +55,6 @@ namespace Tgstation.Server.Host.Components.Chat serverControl, loggerFactory, loggerFactory.CreateLogger(), - initialChatBots.Where(x => x.Enabled.Value)); + initialChatBots.Where(x => x.Require(y => y.Enabled))); } } From 4ba1f591c689a7739ec3c4c59a161549aa9c2934 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sun, 17 Dec 2023 14:42:31 -0500 Subject: [PATCH 179/425] Nullify `ChatTrackingContext` --- .../Components/Chat/ChatTrackingContext.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Chat/ChatTrackingContext.cs b/src/Tgstation.Server.Host/Components/Chat/ChatTrackingContext.cs index bf6ab315ed..1378714e24 100644 --- a/src/Tgstation.Server.Host/Components/Chat/ChatTrackingContext.cs +++ b/src/Tgstation.Server.Host/Components/Chat/ChatTrackingContext.cs @@ -8,8 +8,6 @@ using Microsoft.Extensions.Logging; using Tgstation.Server.Host.Components.Chat.Commands; -#nullable disable - namespace Tgstation.Server.Host.Components.Chat { /// @@ -75,12 +73,12 @@ namespace Tgstation.Server.Host.Components.Chat /// /// The if any. /// - IChannelSink channelSink; + IChannelSink? channelSink; /// /// The to run when d. /// - Action onDispose; + Action? onDispose; /// /// Backing field for . From f36349fb6fd6c541a84dc20fbf28d17323a504d3 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sun, 17 Dec 2023 14:43:16 -0500 Subject: [PATCH 180/425] Nullify `CommandFactory` --- .../Components/Chat/Commands/CommandFactory.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Chat/Commands/CommandFactory.cs b/src/Tgstation.Server.Host/Components/Chat/Commands/CommandFactory.cs index 28eecb2628..a575ec9c87 100644 --- a/src/Tgstation.Server.Host/Components/Chat/Commands/CommandFactory.cs +++ b/src/Tgstation.Server.Host/Components/Chat/Commands/CommandFactory.cs @@ -8,8 +8,6 @@ using Tgstation.Server.Host.Components.Watchdog; using Tgstation.Server.Host.Database; using Tgstation.Server.Host.System; -#nullable disable - namespace Tgstation.Server.Host.Components.Chat.Commands { /// @@ -48,7 +46,7 @@ namespace Tgstation.Server.Host.Components.Chat.Commands /// /// The for the . /// - IWatchdog watchdog; + IWatchdog? watchdog; /// /// Initializes a new instance of the class. From b1810e5a678e923284d51525556ee49cb2a721a4 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sun, 17 Dec 2023 14:49:37 -0500 Subject: [PATCH 181/425] Nullify `CustomCommand` --- .../Components/Chat/Commands/CustomCommand.cs | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Chat/Commands/CustomCommand.cs b/src/Tgstation.Server.Host/Components/Chat/Commands/CustomCommand.cs index b11d22d5ef..9492e925d7 100644 --- a/src/Tgstation.Server.Host/Components/Chat/Commands/CustomCommand.cs +++ b/src/Tgstation.Server.Host/Components/Chat/Commands/CustomCommand.cs @@ -4,8 +4,6 @@ using System.Threading.Tasks; using Tgstation.Server.Host.Components.Interop; -#nullable disable - namespace Tgstation.Server.Host.Components.Chat.Commands { /// @@ -14,18 +12,31 @@ namespace Tgstation.Server.Host.Components.Chat.Commands public sealed class CustomCommand : ICommand { /// - public string Name { get; set; } + public string Name { get; } /// - public string HelpText { get; set; } + public string HelpText { get; } /// - public bool AdminOnly { get; set; } + public bool AdminOnly { get; } /// /// The for the . /// - ICustomCommandHandler handler; + ICustomCommandHandler? handler; + + /// + /// Initializes a new instance of the class. + /// + /// The value of . + /// The value of . + /// The value of . + public CustomCommand(string name, string helpText, bool adminOnly) + { + Name = name ?? throw new ArgumentNullException(nameof(name)); + HelpText = helpText ?? throw new ArgumentNullException(nameof(helpText)); + AdminOnly = adminOnly; + } /// /// Set a new . From 83e0c2046a5b24119b04393387bdcd3260f45c94 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sun, 17 Dec 2023 15:00:03 -0500 Subject: [PATCH 182/425] Improved `EngineVersion` parsing --- .../Models/EngineVersion.cs | 19 ++++++++++++++++++- .../Models/Internal/TestEngineVersion.cs | 8 ++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/Tgstation.Server.Api/Models/EngineVersion.cs b/src/Tgstation.Server.Api/Models/EngineVersion.cs index d4681faa60..adaa90bcbf 100644 --- a/src/Tgstation.Server.Api/Models/EngineVersion.cs +++ b/src/Tgstation.Server.Api/Models/EngineVersion.cs @@ -38,7 +38,7 @@ namespace Tgstation.Server.Api.Models public int? CustomIteration { get; set; } /// - /// Parses a stringified . + /// Attempts to parse a stringified . /// /// The input . /// The output . @@ -110,6 +110,23 @@ namespace Tgstation.Server.Api.Models return true; } + /// + /// Parses a stringified . + /// + /// The input . + /// The output . + /// If the is not a valid stringified . + public static EngineVersion Parse(string input) + { + if (input == null) + throw new ArgumentNullException(nameof(input)); + + if (TryParse(input, out var engineVersion)) + return engineVersion!; + + throw new InvalidOperationException($"Invalid engine version: {input}"); + } + /// /// Initializes a new instance of the class. /// diff --git a/tests/Tgstation.Server.Api.Tests/Models/Internal/TestEngineVersion.cs b/tests/Tgstation.Server.Api.Tests/Models/Internal/TestEngineVersion.cs index a426927b01..f13f09f3ff 100644 --- a/tests/Tgstation.Server.Api.Tests/Models/Internal/TestEngineVersion.cs +++ b/tests/Tgstation.Server.Api.Tests/Models/Internal/TestEngineVersion.cs @@ -11,28 +11,36 @@ namespace Tgstation.Server.Api.Models.Internal.Tests public void TestParsing() { Assert.IsTrue(EngineVersion.TryParse("OpenDream-6894ba0702c1764d333eb52aa0cc211d62e2cb1c-1", out var version)); + Assert.IsNotNull(version); Assert.AreEqual(EngineType.OpenDream, version.Engine); Assert.AreEqual("6894ba0702c1764d333eb52aa0cc211d62e2cb1c", version.SourceSHA); Assert.IsNull(version.Version); Assert.AreEqual(1, version.CustomIteration); Assert.IsTrue(EngineVersion.TryParse("OpenDream-6894ba0702c1764d333eb52aa0cc211d62e2cb1c", out version)); + Assert.IsNotNull(version); Assert.AreEqual(EngineType.OpenDream, version.Engine); Assert.AreEqual("6894ba0702c1764d333eb52aa0cc211d62e2cb1c", version.SourceSHA); Assert.IsNull(version.Version); Assert.IsFalse(version.CustomIteration.HasValue); Assert.IsTrue(EngineVersion.TryParse("515.1616", out version)); + Assert.IsNotNull(version); Assert.AreEqual(EngineType.Byond, version.Engine); Assert.AreEqual(new Version(515, 1616), version.Version); Assert.IsNull(version.SourceSHA); Assert.IsFalse(version.CustomIteration.HasValue); Assert.IsTrue(EngineVersion.TryParse("515.1616.12", out version)); + Assert.IsNotNull(version); Assert.AreEqual(EngineType.Byond, version.Engine); Assert.AreEqual(new Version(515, 1616), version.Version); Assert.IsNull(version.SourceSHA); Assert.AreEqual(12, version.CustomIteration); + + Assert.IsFalse(EngineVersion.TryParse("x", out version)); + Assert.IsNull(version); + Assert.ThrowsException(() => EngineVersion.Parse("x")); } } } From 1d815498fc21087b0979bf9ec0258dd69a848f3b Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sun, 17 Dec 2023 15:01:16 -0500 Subject: [PATCH 183/425] Nullify `EngineCommand` --- .../Components/Chat/Commands/EngineCommand.cs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Chat/Commands/EngineCommand.cs b/src/Tgstation.Server.Host/Components/Chat/Commands/EngineCommand.cs index 75a6e79e54..21789bb258 100644 --- a/src/Tgstation.Server.Host/Components/Chat/Commands/EngineCommand.cs +++ b/src/Tgstation.Server.Host/Components/Chat/Commands/EngineCommand.cs @@ -8,8 +8,6 @@ using Tgstation.Server.Host.Components.Engine; using Tgstation.Server.Host.Components.Interop; using Tgstation.Server.Host.Components.Watchdog; -#nullable disable - namespace Tgstation.Server.Host.Components.Chat.Commands { /// @@ -69,8 +67,7 @@ namespace Tgstation.Server.Host.Components.Chat.Commands Text = "None!", }); - if (!EngineVersion.TryParse(watchdog.ActiveCompileJob.EngineVersion, out engineVersion)) - throw new InvalidOperationException($"Invalid engine version: {watchdog.ActiveCompileJob.EngineVersion}"); + engineVersion = EngineVersion.Parse(watchdog.ActiveCompileJob.EngineVersion); } string text; @@ -78,10 +75,10 @@ namespace Tgstation.Server.Host.Components.Chat.Commands text = "None!"; else { - text = engineVersion.Engine.Value switch + text = engineVersion.Engine!.Value switch { EngineType.OpenDream => $"OpenDream: {engineVersion.SourceSHA}", - EngineType.Byond => $"BYOND {engineVersion.Version.Major}.{engineVersion.Version.Minor}", + EngineType.Byond => $"BYOND {engineVersion.Version!.Major}.{engineVersion.Version.Minor}", _ => throw new InvalidOperationException($"Invalid EngineType: {engineVersion.Engine.Value}"), }; From b4831b63f6b4fe76b5a6207d615664d9c5c7cea8 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sun, 17 Dec 2023 19:43:57 -0500 Subject: [PATCH 184/425] Nullify `ICommand` --- src/Tgstation.Server.Host/Components/Chat/Commands/ICommand.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Chat/Commands/ICommand.cs b/src/Tgstation.Server.Host/Components/Chat/Commands/ICommand.cs index c5d4e3ef3e..766f29b6c0 100644 --- a/src/Tgstation.Server.Host/Components/Chat/Commands/ICommand.cs +++ b/src/Tgstation.Server.Host/Components/Chat/Commands/ICommand.cs @@ -3,8 +3,6 @@ using System.Threading.Tasks; using Tgstation.Server.Host.Components.Interop; -#nullable disable - namespace Tgstation.Server.Host.Components.Chat.Commands { /// From de637293f0f0e7a06c257fbf226f2126bb63333b Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sun, 17 Dec 2023 19:44:09 -0500 Subject: [PATCH 185/425] Nullify `ICommandFactory` --- .../Components/Chat/Commands/ICommandFactory.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Chat/Commands/ICommandFactory.cs b/src/Tgstation.Server.Host/Components/Chat/Commands/ICommandFactory.cs index 1cc91c7ada..c3ffa50d74 100644 --- a/src/Tgstation.Server.Host/Components/Chat/Commands/ICommandFactory.cs +++ b/src/Tgstation.Server.Host/Components/Chat/Commands/ICommandFactory.cs @@ -1,7 +1,5 @@ using System.Collections.Generic; -#nullable disable - namespace Tgstation.Server.Host.Components.Chat.Commands { /// From 06b8dc9599497e9d35bc303b5bfc499aa05a7c35 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sun, 17 Dec 2023 19:45:07 -0500 Subject: [PATCH 186/425] Nullify `KekCommand` --- .../Components/Chat/Commands/KekCommand.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Chat/Commands/KekCommand.cs b/src/Tgstation.Server.Host/Components/Chat/Commands/KekCommand.cs index f5ef18e1d9..a41278ae0a 100644 --- a/src/Tgstation.Server.Host/Components/Chat/Commands/KekCommand.cs +++ b/src/Tgstation.Server.Host/Components/Chat/Commands/KekCommand.cs @@ -3,8 +3,6 @@ using System.Threading.Tasks; using Tgstation.Server.Host.Components.Interop; -#nullable disable - namespace Tgstation.Server.Host.Components.Chat.Commands { /// From 54b6dc2423023a398f8ee00fccf1c17a2f0bfb01 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sun, 17 Dec 2023 19:47:31 -0500 Subject: [PATCH 187/425] Nullify `PullRequestsCommand` --- .../Components/Chat/Commands/PullRequestsCommand.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Chat/Commands/PullRequestsCommand.cs b/src/Tgstation.Server.Host/Components/Chat/Commands/PullRequestsCommand.cs index 990b5bdc11..c4022d95d7 100644 --- a/src/Tgstation.Server.Host/Components/Chat/Commands/PullRequestsCommand.cs +++ b/src/Tgstation.Server.Host/Components/Chat/Commands/PullRequestsCommand.cs @@ -13,8 +13,6 @@ using Tgstation.Server.Host.Components.Repository; using Tgstation.Server.Host.Components.Watchdog; using Tgstation.Server.Host.Database; -#nullable disable - namespace Tgstation.Server.Host.Components.Chat.Commands { /// @@ -83,7 +81,7 @@ namespace Tgstation.Server.Host.Components.Chat.Commands #pragma warning disable CA1506 public async ValueTask Invoke(string arguments, ChatUser user, CancellationToken cancellationToken) { - IEnumerable results = null; + IEnumerable results; var splits = arguments.Split(' '); var hasRepo = splits.Any(x => x.Equals("--repo", StringComparison.OrdinalIgnoreCase)); var hasStaged = splits.Any(x => x.Equals("--staged", StringComparison.OrdinalIgnoreCase)); @@ -114,6 +112,7 @@ namespace Tgstation.Server.Host.Components.Chat.Commands head = repo.Head; } + results = null!; await databaseContextFactory.UseContext( async db => results = await db .RevisionInformations @@ -155,7 +154,7 @@ namespace Tgstation.Server.Host.Components.Chat.Commands : String.Join( ", ", results.Select( - x => $"#{x.Number} at {x.TargetCommitSha[..7]}")), + x => $"#{x.Number} at {x.TargetCommitSha![..7]}")), }; } #pragma warning restore CA1506 From 8ef36dc4e3612de7ba09e5b54db2fc7c1ce0dfc0 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sun, 17 Dec 2023 19:48:18 -0500 Subject: [PATCH 188/425] Nullify `RevisionCommand` --- .../Components/Chat/Commands/RevisionCommand.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Chat/Commands/RevisionCommand.cs b/src/Tgstation.Server.Host/Components/Chat/Commands/RevisionCommand.cs index 60c12f9fc3..39ed128d59 100644 --- a/src/Tgstation.Server.Host/Components/Chat/Commands/RevisionCommand.cs +++ b/src/Tgstation.Server.Host/Components/Chat/Commands/RevisionCommand.cs @@ -9,8 +9,6 @@ using Tgstation.Server.Host.Components.Interop; using Tgstation.Server.Host.Components.Repository; using Tgstation.Server.Host.Components.Watchdog; -#nullable disable - namespace Tgstation.Server.Host.Components.Chat.Commands { /// @@ -77,7 +75,7 @@ namespace Tgstation.Server.Host.Components.Chat.Commands { Text = "Server offline!", }; - result = watchdog.ActiveCompileJob?.RevisionInformation.OriginCommitSha; + result = watchdog.ActiveCompileJob?.RevisionInformation.OriginCommitSha!; } return new MessageContent From 1f1c7914d70687fdf9e7b3ccfe580e6610d6944b Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sun, 17 Dec 2023 20:58:09 -0500 Subject: [PATCH 189/425] Fix a race condition with starting the server and bridge requests --- src/Tgstation.Server.Host/Components/InstanceManager.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/InstanceManager.cs b/src/Tgstation.Server.Host/Components/InstanceManager.cs index bf2b5dbba0..8f76162753 100644 --- a/src/Tgstation.Server.Host/Components/InstanceManager.cs +++ b/src/Tgstation.Server.Host/Components/InstanceManager.cs @@ -611,10 +611,11 @@ namespace Tgstation.Server.Host.Components await Task.WhenAll(instanceOnliningTasks); - jobService.Activate(this); - logger.LogInformation("Server ready!"); readyTcs.SetResult(); + + // this needs to happen after the HTTP API opens with readyTcs otherwise it can race and cause failed bridge requests with 503's + jobService.Activate(this); } catch (OperationCanceledException ex) { From 3ab14c99a65b8a44655dd38c49fd1dbd6b2d1c09 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sun, 17 Dec 2023 21:38:54 -0500 Subject: [PATCH 190/425] Nullify `IChannelSink` --- src/Tgstation.Server.Host/Components/Chat/IChannelSink.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Chat/IChannelSink.cs b/src/Tgstation.Server.Host/Components/Chat/IChannelSink.cs index 78dbee1d73..e9e366902e 100644 --- a/src/Tgstation.Server.Host/Components/Chat/IChannelSink.cs +++ b/src/Tgstation.Server.Host/Components/Chat/IChannelSink.cs @@ -2,8 +2,6 @@ using System.Threading; using System.Threading.Tasks; -#nullable disable - namespace Tgstation.Server.Host.Components.Chat { /// From cef33be32c7ffd4f623d7c6b4d81c15fe43bdaaa Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sun, 17 Dec 2023 21:40:08 -0500 Subject: [PATCH 191/425] Nullify `VersionCommand` --- .../Components/Chat/Commands/VersionCommand.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Chat/Commands/VersionCommand.cs b/src/Tgstation.Server.Host/Components/Chat/Commands/VersionCommand.cs index 5857f6fea7..60e7f9e9a1 100644 --- a/src/Tgstation.Server.Host/Components/Chat/Commands/VersionCommand.cs +++ b/src/Tgstation.Server.Host/Components/Chat/Commands/VersionCommand.cs @@ -5,8 +5,6 @@ using System.Threading.Tasks; using Tgstation.Server.Host.Components.Interop; using Tgstation.Server.Host.System; -#nullable disable - namespace Tgstation.Server.Host.Components.Chat.Commands { /// From 3c7cf0360f4b84bd03d3eb9ce0e0685058343fb3 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sun, 17 Dec 2023 21:43:19 -0500 Subject: [PATCH 192/425] Cleanup a `ValueTask` message --- .../Components/InstanceManager.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/InstanceManager.cs b/src/Tgstation.Server.Host/Components/InstanceManager.cs index 8f76162753..af7a3d7c81 100644 --- a/src/Tgstation.Server.Host/Components/InstanceManager.cs +++ b/src/Tgstation.Server.Host/Components/InstanceManager.cs @@ -353,7 +353,7 @@ namespace Tgstation.Server.Host.Components await container.OnZeroReferences.WaitAsync(cancellationToken); // we are the one responsible for cancelling his jobs - var tasks = new List>(); + ValueTask groupedTask = default; await databaseContextFactory.UseContext( async db => { @@ -363,11 +363,13 @@ namespace Tgstation.Server.Host.Components .Where(x => x.Instance.Id == metadata.Id && !x.StoppedAt.HasValue) .Select(x => new Models.Job(x.Id.Value)) .ToListAsync(cancellationToken); - foreach (var job in jobs) - tasks.Add(jobService.CancelJob(job, user, true, cancellationToken)); + + groupedTask = ValueTaskExtensions.WhenAll( + jobs.Select(job => jobService.CancelJob(job, user, true, cancellationToken)), + jobs.Count); }); - await ValueTaskExtensions.WhenAll(tasks); + await groupedTask; } catch { From 8c34cf83d987dee341327c3d29ad128d258a1782 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sun, 17 Dec 2023 21:44:45 -0500 Subject: [PATCH 193/425] Nullify `DiscordMessage` --- .../Components/Chat/Providers/DiscordMessage.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Chat/Providers/DiscordMessage.cs b/src/Tgstation.Server.Host/Components/Chat/Providers/DiscordMessage.cs index 4d55e31d85..b0b3fbb56e 100644 --- a/src/Tgstation.Server.Host/Components/Chat/Providers/DiscordMessage.cs +++ b/src/Tgstation.Server.Host/Components/Chat/Providers/DiscordMessage.cs @@ -1,8 +1,6 @@ using Remora.Discord.API.Abstractions.Objects; using Remora.Rest.Core; -#nullable disable - namespace Tgstation.Server.Host.Components.Chat.Providers { /// From ee16007c64a21c69cd674a4f1fd09c61fc47e11a Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sun, 17 Dec 2023 21:47:38 -0500 Subject: [PATCH 194/425] Cleanup some collection initializations --- .../Components/Chat/Providers/DiscordProvider.cs | 6 +++--- src/Tgstation.Server.Host/Core/Application.cs | 3 +-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Chat/Providers/DiscordProvider.cs b/src/Tgstation.Server.Host/Components/Chat/Providers/DiscordProvider.cs index 3b3b4699d3..20432e68d0 100644 --- a/src/Tgstation.Server.Host/Components/Chat/Providers/DiscordProvider.cs +++ b/src/Tgstation.Server.Host/Components/Chat/Providers/DiscordProvider.cs @@ -60,13 +60,13 @@ namespace Tgstation.Server.Host.Components.Chat.Providers /// /// The s supported by the for mapping. /// - static readonly ChannelType[] SupportedGuildChannelTypes = new[] - { + static readonly ChannelType[] SupportedGuildChannelTypes = + [ ChannelType.GuildText, ChannelType.GuildAnnouncement, ChannelType.PrivateThread, ChannelType.PublicThread, - }; + ]; /// /// The for the . diff --git a/src/Tgstation.Server.Host/Core/Application.cs b/src/Tgstation.Server.Host/Core/Application.cs index 03e14ed6a2..202b098d7c 100644 --- a/src/Tgstation.Server.Host/Core/Application.cs +++ b/src/Tgstation.Server.Host/Core/Application.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Globalization; -using System.Linq; using System.Threading.Tasks; using Cyberboss.AspNetCore.AsyncInitializer; @@ -546,7 +545,7 @@ namespace Tgstation.Server.Host.Core else if (controlPanelConfiguration.AllowedOrigins?.Count > 0) { logger.LogTrace("Access-Control-Allow-Origin: {allowedOrigins}", String.Join(',', controlPanelConfiguration.AllowedOrigins)); - corsBuilder = builder => builder.WithOrigins(controlPanelConfiguration.AllowedOrigins.ToArray()); + corsBuilder = builder => builder.WithOrigins([.. controlPanelConfiguration.AllowedOrigins]); } var originalBuilder = corsBuilder; From b225cbcf9e49d1d1b987bae10c92ec13f86f43b0 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sun, 17 Dec 2023 21:47:57 -0500 Subject: [PATCH 195/425] Nullify `IDiscordResponders` --- .../Components/Chat/Providers/IDiscordResponders.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Chat/Providers/IDiscordResponders.cs b/src/Tgstation.Server.Host/Components/Chat/Providers/IDiscordResponders.cs index 3ca8ec9d42..d0c320fa9e 100644 --- a/src/Tgstation.Server.Host/Components/Chat/Providers/IDiscordResponders.cs +++ b/src/Tgstation.Server.Host/Components/Chat/Providers/IDiscordResponders.cs @@ -1,8 +1,6 @@ using Remora.Discord.API.Abstractions.Gateway.Events; using Remora.Discord.Gateway.Responders; -#nullable disable - namespace Tgstation.Server.Host.Components.Chat.Providers { /// From a574487235e8c16c7779cd0eba6a113e80ed3d53 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sun, 17 Dec 2023 21:49:53 -0500 Subject: [PATCH 196/425] Nullify `IProvider` --- .../Components/Chat/Providers/IProvider.cs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Chat/Providers/IProvider.cs b/src/Tgstation.Server.Host/Components/Chat/Providers/IProvider.cs index 0fc6beeb29..01b0d29a5e 100644 --- a/src/Tgstation.Server.Host/Components/Chat/Providers/IProvider.cs +++ b/src/Tgstation.Server.Host/Components/Chat/Providers/IProvider.cs @@ -7,8 +7,6 @@ using Tgstation.Server.Api.Models.Internal; using Tgstation.Server.Host.Components.Interop; using Tgstation.Server.Host.Models; -#nullable disable - namespace Tgstation.Server.Host.Components.Chat.Providers { /// @@ -47,7 +45,7 @@ namespace Tgstation.Server.Host.Components.Chat.Providers /// The for the operation. /// A resulting in the next available or if the needed to reconnect. /// Note that private messages will come in the form of s not returned in . - Task NextMessage(CancellationToken cancellationToken); + Task NextMessage(CancellationToken cancellationToken); /// /// Gracefully disconnects the provider. Permanently stops the reconnection timer. @@ -67,12 +65,12 @@ namespace Tgstation.Server.Host.Components.Chat.Providers /// /// Send a message to the . /// - /// The to reply to. + /// The optional to reply to. /// The . /// The to send to. /// The for the operation. /// A representing the running operation. - ValueTask SendMessage(Message replyTo, MessageContent message, ulong channelId, CancellationToken cancellationToken); + ValueTask SendMessage(Message? replyTo, MessageContent message, ulong channelId, CancellationToken cancellationToken); /// /// Set the interval at which the provider starts jobs to try to reconnect. @@ -98,8 +96,8 @@ namespace Tgstation.Server.Host.Components.Chat.Providers Models.RevisionInformation revisionInformation, Api.Models.EngineVersion engineVersion, DateTimeOffset? estimatedCompletionTime, - string gitHubOwner, - string gitHubRepo, + string? gitHubOwner, + string? gitHubRepo, ulong channelId, bool localCommitPushed, CancellationToken cancellationToken); From c88d837d693aee9d51bb059b92ea00d91a14bf37 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sun, 17 Dec 2023 21:50:08 -0500 Subject: [PATCH 197/425] Nullify `IProviderFactory` --- .../Components/Chat/Providers/IProviderFactory.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Chat/Providers/IProviderFactory.cs b/src/Tgstation.Server.Host/Components/Chat/Providers/IProviderFactory.cs index fea864ea71..d79e0bb7d5 100644 --- a/src/Tgstation.Server.Host/Components/Chat/Providers/IProviderFactory.cs +++ b/src/Tgstation.Server.Host/Components/Chat/Providers/IProviderFactory.cs @@ -1,7 +1,5 @@ using Tgstation.Server.Host.Models; -#nullable disable - namespace Tgstation.Server.Host.Components.Chat.Providers { /// From 81ef6191d5b270dbd0742c2daf6f2756bd94d4a9 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sun, 17 Dec 2023 21:55:36 -0500 Subject: [PATCH 198/425] Nullify `Message` --- .../Components/Chat/Providers/DiscordMessage.cs | 14 ++++++++++++++ .../Chat/Providers/DiscordProvider.cs | 10 ++++------ .../Components/Chat/Providers/IrcProvider.cs | 8 +++----- .../Components/Chat/Providers/Message.cs | 17 ++++++++++++++--- .../Live/DummyChatProvider.cs | 7 +------ 5 files changed, 36 insertions(+), 20 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Chat/Providers/DiscordMessage.cs b/src/Tgstation.Server.Host/Components/Chat/Providers/DiscordMessage.cs index b0b3fbb56e..565d78d654 100644 --- a/src/Tgstation.Server.Host/Components/Chat/Providers/DiscordMessage.cs +++ b/src/Tgstation.Server.Host/Components/Chat/Providers/DiscordMessage.cs @@ -12,5 +12,19 @@ namespace Tgstation.Server.Host.Components.Chat.Providers /// The of the source . /// public Optional MessageReference { get; set; } + + /// + /// Initializes a new instance of the class. + /// + /// The value of . + /// The value of . + /// The value of . + public DiscordMessage(ChatUser user, string content, Optional messageReference) + : base( + user, + content) + { + MessageReference = messageReference; + } } } diff --git a/src/Tgstation.Server.Host/Components/Chat/Providers/DiscordProvider.cs b/src/Tgstation.Server.Host/Components/Chat/Providers/DiscordProvider.cs index 20432e68d0..3a89c2245c 100644 --- a/src/Tgstation.Server.Host/Components/Chat/Providers/DiscordProvider.cs +++ b/src/Tgstation.Server.Host/Components/Chat/Providers/DiscordProvider.cs @@ -534,11 +534,8 @@ namespace Tgstation.Server.Host.Components.Chat.Providers messageGuildResponse.LogFormat()); } - var result = new DiscordMessage - { - MessageReference = messageReference, - Content = content, - User = new ChatUser + var result = new DiscordMessage( + new ChatUser { RealId = messageCreateEvent.Author.ID.Value, Channel = new ChannelRepresentation( @@ -554,7 +551,8 @@ namespace Tgstation.Server.Host.Components.Chat.Providers FriendlyName = messageCreateEvent.Author.Username, Mention = NormalizeMentions($"<@{messageCreateEvent.Author.ID}>"), }, - }; + content, + messageReference); EnqueueMessage(result); return Result.FromSuccess(); diff --git a/src/Tgstation.Server.Host/Components/Chat/Providers/IrcProvider.cs b/src/Tgstation.Server.Host/Components/Chat/Providers/IrcProvider.cs index 2db2f30376..70665bf695 100644 --- a/src/Tgstation.Server.Host/Components/Chat/Providers/IrcProvider.cs +++ b/src/Tgstation.Server.Host/Components/Chat/Providers/IrcProvider.cs @@ -530,10 +530,8 @@ namespace Tgstation.Server.Host.Components.Chat.Providers } var channelFriendlyName = isPrivate ? String.Format(CultureInfo.InvariantCulture, "PM: {0}", channelName) : channelName; - var message = new Message - { - Content = e.Data.Message, - User = new ChatUser + var message = new Message( + new ChatUser { Channel = new ChannelRepresentation(address, channelFriendlyName, channelId) { @@ -546,7 +544,7 @@ namespace Tgstation.Server.Host.Components.Chat.Providers RealId = userId, Mention = username, }, - }; + e.Data.Message); EnqueueMessage(message); } diff --git a/src/Tgstation.Server.Host/Components/Chat/Providers/Message.cs b/src/Tgstation.Server.Host/Components/Chat/Providers/Message.cs index f410514b80..c9084657fc 100644 --- a/src/Tgstation.Server.Host/Components/Chat/Providers/Message.cs +++ b/src/Tgstation.Server.Host/Components/Chat/Providers/Message.cs @@ -1,4 +1,4 @@ -#nullable disable +using System; namespace Tgstation.Server.Host.Components.Chat.Providers { @@ -10,11 +10,22 @@ namespace Tgstation.Server.Host.Components.Chat.Providers /// /// The text of the message. /// - public string Content { get; set; } + public string Content { get; } /// /// The who sent the . /// - public ChatUser User { get; set; } + public ChatUser User { get; } + + /// + /// Initializes a new instance of the class. + /// + /// The value of . + /// The value of . + public Message(ChatUser user, string content) + { + User = user ?? throw new ArgumentNullException(nameof(user)); + Content = content ?? throw new ArgumentNullException(nameof(content)); + } } } diff --git a/tests/Tgstation.Server.Tests/Live/DummyChatProvider.cs b/tests/Tgstation.Server.Tests/Live/DummyChatProvider.cs index 160af5010c..8997c22841 100644 --- a/tests/Tgstation.Server.Tests/Live/DummyChatProvider.cs +++ b/tests/Tgstation.Server.Tests/Live/DummyChatProvider.cs @@ -315,13 +315,8 @@ namespace Tgstation.Server.Tests.Live else content = $"{content} embeds_test"; // NEVER send the response_overload_test, it causes so much havoc in CI and we test it manually - EnqueueMessage(new Message - { - Content = content, - User = sender, - }); + EnqueueMessage(new Message(sender, content)); } - } catch (OperationCanceledException) { From eb2e34fb0b545c928c4639f95836b00f51dde5d5 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sun, 17 Dec 2023 21:58:46 -0500 Subject: [PATCH 199/425] Nullify `Provider` --- .../Components/Chat/Providers/Provider.cs | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Chat/Providers/Provider.cs b/src/Tgstation.Server.Host/Components/Chat/Providers/Provider.cs index 1a036d7ffd..da4deecd11 100644 --- a/src/Tgstation.Server.Host/Components/Chat/Providers/Provider.cs +++ b/src/Tgstation.Server.Host/Components/Chat/Providers/Provider.cs @@ -11,8 +11,6 @@ using Tgstation.Server.Host.Jobs; using Tgstation.Server.Host.Models; using Tgstation.Server.Host.Utils; -#nullable disable - namespace Tgstation.Server.Host.Components.Chat.Providers { /// @@ -44,7 +42,7 @@ namespace Tgstation.Server.Host.Components.Chat.Providers /// /// of received s. /// - readonly Queue messageQueue; + readonly Queue messageQueue; /// /// The backing for . @@ -64,12 +62,12 @@ namespace Tgstation.Server.Host.Components.Chat.Providers /// /// The auto reconnect . /// - Task reconnectTask; + Task? reconnectTask; /// /// for . /// - CancellationTokenSource reconnectCts; + CancellationTokenSource? reconnectCts; /// /// Get the prefix for messages about deployments. @@ -98,7 +96,7 @@ namespace Tgstation.Server.Host.Components.Chat.Providers Logger = logger ?? throw new ArgumentNullException(nameof(logger)); ChatBot = chatBot ?? throw new ArgumentNullException(nameof(chatBot)); - messageQueue = new Queue(); + messageQueue = new Queue(); nextMessage = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); initialConnectionTcs = new TaskCompletionSource(); reconnectTaskLock = new object(); @@ -159,7 +157,7 @@ namespace Tgstation.Server.Host.Components.Chat.Providers } /// - public async Task NextMessage(CancellationToken cancellationToken) + public async Task NextMessage(CancellationToken cancellationToken) { while (true) { @@ -193,15 +191,15 @@ namespace Tgstation.Server.Host.Components.Chat.Providers } /// - public abstract ValueTask SendMessage(Message replyTo, MessageContent message, ulong channelId, CancellationToken cancellationToken); + public abstract ValueTask SendMessage(Message? replyTo, MessageContent message, ulong channelId, CancellationToken cancellationToken); /// public abstract ValueTask>>> SendUpdateMessage( RevisionInformation revisionInformation, Api.Models.EngineVersion engineVersion, DateTimeOffset? estimatedCompletionTime, - string gitHubOwner, - string gitHubRepo, + string? gitHubOwner, + string? gitHubRepo, ulong channelId, bool localCommitPushed, CancellationToken cancellationToken); @@ -234,7 +232,7 @@ namespace Tgstation.Server.Host.Components.Chat.Providers /// Queues a for . /// /// The to queue. A value of indicates the channel mappings are out of date. - protected void EnqueueMessage(Message message) + protected void EnqueueMessage(Message? message) { if (message == null) Logger.LogTrace("Requesting channel remap..."); @@ -259,7 +257,7 @@ namespace Tgstation.Server.Host.Components.Chat.Providers reconnectCts.Cancel(); reconnectCts.Dispose(); reconnectCts = null; - var reconnectTask = this.reconnectTask; + var reconnectTask = this.reconnectTask!; this.reconnectTask = null; return reconnectTask; } From 85207f6ce8f741bcd6b523865497b44f52537c05 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sun, 17 Dec 2023 21:59:06 -0500 Subject: [PATCH 200/425] Nullify `ProviderFactory` --- .../Components/Chat/Providers/ProviderFactory.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Chat/Providers/ProviderFactory.cs b/src/Tgstation.Server.Host/Components/Chat/Providers/ProviderFactory.cs index 9519abcc1c..ed3608b92d 100644 --- a/src/Tgstation.Server.Host/Components/Chat/Providers/ProviderFactory.cs +++ b/src/Tgstation.Server.Host/Components/Chat/Providers/ProviderFactory.cs @@ -10,8 +10,6 @@ using Tgstation.Server.Host.Jobs; using Tgstation.Server.Host.System; using Tgstation.Server.Host.Utils; -#nullable disable - namespace Tgstation.Server.Host.Components.Chat.Providers { /// From de1872cd7f4cf1b69cb05ef11519b49f4bf704bf Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sun, 17 Dec 2023 22:22:23 -0500 Subject: [PATCH 201/425] Nullify `ChatManager` --- .../Components/Chat/ChatManager.cs | 74 +++++++++---------- 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Chat/ChatManager.cs b/src/Tgstation.Server.Host/Components/Chat/ChatManager.cs index 44e6625691..b6000a7619 100644 --- a/src/Tgstation.Server.Host/Components/Chat/ChatManager.cs +++ b/src/Tgstation.Server.Host/Components/Chat/ChatManager.cs @@ -21,8 +21,6 @@ using Tgstation.Server.Host.Components.Interop; using Tgstation.Server.Host.Core; using Tgstation.Server.Host.Utils; -#nullable disable - namespace Tgstation.Server.Host.Components.Chat { /// @@ -103,17 +101,17 @@ namespace Tgstation.Server.Host.Components.Chat /// /// The for the . /// - ICustomCommandHandler customCommandHandler; + ICustomCommandHandler? customCommandHandler; /// /// The that monitors incoming chat messages. /// - Task chatHandler; + Task? chatHandler; /// /// A that represents the s initial connection. /// - Task initialProviderConnectionsTask; + Task? initialProviderConnectionsTask; /// /// A that represents all sent messages. @@ -256,7 +254,7 @@ namespace Tgstation.Server.Host.Components.Chat lock (mappedChannels) { lock (providers) - if (!providers.TryGetValue(connectionId, out IProvider verify) || verify != provider) // aborted again + if (!providers.TryGetValue(connectionId, out var verify) || verify != provider) // aborted again return; foreach (var newMapping in newMappings) { @@ -270,7 +268,7 @@ namespace Tgstation.Server.Host.Components.Chat // we only want to update contexts if everything at startup has connected once already // otherwise we could send an incomplete channel set to the DMAPI, which will then spout all its queued messages into it instead of all relevant chatbots // The watchdog can call this if it needs to after starting up - if (initialProviderConnectionsTask.IsCompleted) + if (initialProviderConnectionsTask!.IsCompleted) await UpdateTrackingContexts(cancellationToken); } finally @@ -288,23 +286,25 @@ namespace Tgstation.Server.Host.Components.Chat logger.LogTrace("ChangeSettings..."); Task disconnectTask; - IProvider provider = null; + IProvider? provider = null; + var newSettingsId = Models.ModelExtensions.Require(newSettings, x => x.Id); + var newSettingsEnabled = Models.ModelExtensions.Require(newSettings, x => x.Enabled); lock (providers) { // raw settings changes forces a rebuild of the provider - if (providers.ContainsKey(newSettings.Id.Value)) - disconnectTask = DeleteConnection(newSettings.Id.Value, cancellationToken); + if (providers.ContainsKey(newSettingsId)) + disconnectTask = DeleteConnection(newSettingsId, cancellationToken); else disconnectTask = Task.CompletedTask; - if (newSettings.Enabled.Value) + if (newSettingsEnabled) { provider = providerFactory.CreateProvider(newSettings); - providers.Add(newSettings.Id.Value, provider); + providers.Add(newSettingsId, provider); } } lock (mappedChannels) - foreach (var oldMappedChannelId in mappedChannels.Where(x => x.Value.ProviderId == newSettings.Id).Select(x => x.Key).ToList()) + foreach (var oldMappedChannelId in mappedChannels.Where(x => x.Value.ProviderId == newSettingsId).Select(x => x.Key).ToList()) mappedChannels.Remove(oldMappedChannelId); await disconnectTask; @@ -318,8 +318,8 @@ namespace Tgstation.Server.Host.Components.Chat } var reconnectionUpdateTask = provider?.SetReconnectInterval( - newSettings.ReconnectionInterval.Value, - newSettings.Enabled.Value) + Models.ModelExtensions.Require(newSettings, x => x.ReconnectionInterval), + newSettingsEnabled) ?? Task.CompletedTask; lock (activeChatBots) { @@ -358,7 +358,7 @@ namespace Tgstation.Server.Host.Components.Chat message = String.Format(CultureInfo.InvariantCulture, "WD: {0}", message); - if (!initialProviderConnectionsTask.IsCompleted) + if (!initialProviderConnectionsTask!.IsCompleted) logger.LogTrace("Waiting for initial provider connections before sending watchdog message..."); // Reimplementing QueueMessage @@ -397,11 +397,11 @@ namespace Tgstation.Server.Host.Components.Chat wdChannels.Select( async x => { - ChannelMapping channelMapping; + ChannelMapping? channelMapping; lock (mappedChannels) if (!mappedChannels.TryGetValue(x, out channelMapping)) return; - IProvider provider; + IProvider? provider; lock (providers) if (!providers.TryGetValue(channelMapping.ProviderId, out provider)) return; @@ -432,7 +432,7 @@ namespace Tgstation.Server.Host.Components.Chat AddMessageTask(task); Task callbackTask; - Func finalUpdateAction = null; + Func? finalUpdateAction = null; async Task CallbackTask(string errorMessage, string dreamMakerOutput) { await task; @@ -458,7 +458,7 @@ namespace Tgstation.Server.Host.Components.Chat return; } - AddMessageTask(finalUpdateAction(active)); + AddMessageTask(finalUpdateAction!(active)); } return (errorMessage, dreamMakerOutput) => @@ -496,7 +496,7 @@ namespace Tgstation.Server.Host.Components.Chat if (customCommandHandler == null) throw new InvalidOperationException("RegisterCommandHandler() hasn't been called!"); - IChatTrackingContext context = null; + IChatTrackingContext context = null!; lock (mappedChannels) context = new ChatTrackingContext( customCommandHandler, @@ -525,7 +525,7 @@ namespace Tgstation.Server.Host.Components.Chat await channelSink.UpdateChannels(channels, cancellationToken); } - var waitingForInitialConnection = !initialProviderConnectionsTask.IsCompleted; + var waitingForInitialConnection = !initialProviderConnectionsTask!.IsCompleted; if (waitingForInitialConnection) { logger.LogTrace("Waiting for initial chat bot connections before updating tracking contexts..."); @@ -563,7 +563,7 @@ namespace Tgstation.Server.Host.Components.Chat ? semaphore : null) using (hasSemaphore - ? await SemaphoreSlimContext.Lock(semaphore, cancellationToken) + ? await SemaphoreSlimContext.Lock(semaphore!, cancellationToken) : null) { var provider = await RemoveProviderChannels(connectionId, true, cancellationToken); @@ -590,7 +590,7 @@ namespace Tgstation.Server.Host.Components.Chat } /// - public ValueTask HandleRestart(Version updateVersion, bool handlerMayDelayShutdownWithExtremelyLongRunningTasks, CancellationToken cancellationToken) + public ValueTask HandleRestart(Version? updateVersion, bool handlerMayDelayShutdownWithExtremelyLongRunningTasks, CancellationToken cancellationToken) { var message = updateVersion == null ? $"TGS: {(handlerMayDelayShutdownWithExtremelyLongRunningTasks ? "Graceful shutdown" : "Going down")}..." @@ -619,10 +619,10 @@ namespace Tgstation.Server.Host.Components.Chat /// If the provider should be removed from and should be update. /// The for the operation. /// A resulting in the being removed if it exists, otherwise. - async ValueTask RemoveProviderChannels(long connectionId, bool removeProvider, CancellationToken cancellationToken) + async ValueTask RemoveProviderChannels(long connectionId, bool removeProvider, CancellationToken cancellationToken) { logger.LogTrace("RemoveProviderChannels {connectionId}...", connectionId); - IProvider provider; + IProvider? provider; lock (providers) { if (!providers.TryGetValue(connectionId, out provider)) @@ -664,7 +664,7 @@ namespace Tgstation.Server.Host.Components.Chat async ValueTask RemapProvider(IProvider provider, CancellationToken cancellationToken) { logger.LogTrace("Remapping channels for provider reconnection..."); - IEnumerable channelsToMap; + IEnumerable? channelsToMap; long providerId; lock (providers) providerId = providers.Where(x => x.Value == provider).Select(x => x.Key).First(); @@ -685,7 +685,7 @@ namespace Tgstation.Server.Host.Components.Chat /// The for the operation. /// A representing the running operation. #pragma warning disable CA1502 - async ValueTask ProcessMessage(IProvider provider, Message message, bool recursed, CancellationToken cancellationToken) + async ValueTask ProcessMessage(IProvider provider, Message? message, bool recursed, CancellationToken cancellationToken) #pragma warning restore CA1502 { if (!provider.Connected) @@ -843,16 +843,16 @@ namespace Tgstation.Server.Host.Components.Chat splits.RemoveAt(0); var arguments = String.Join(" ", splits); - Tuple GetCommand() + Tuple? GetCommand() { if (!builtinCommands.TryGetValue(command, out var handler)) return trackingContexts .Where(trackingContext => trackingContext.Active) - .SelectMany(trackingContext => trackingContext.CustomCommands.Select(customCommand => Tuple.Create(customCommand, trackingContext))) + .SelectMany(trackingContext => trackingContext.CustomCommands.Select(customCommand => Tuple.Create(customCommand, trackingContext))) .Where(tuple => tuple.Item1.Name.Equals(command, StringComparison.OrdinalIgnoreCase)) .FirstOrDefault(); - return Tuple.Create(handler, null); + return Tuple.Create(handler, null); } const string UnknownCommandMessage = "TGS: Unknown command! Type '?' or 'help' for available commands."; @@ -935,11 +935,11 @@ namespace Tgstation.Server.Host.Components.Chat async Task MonitorMessages(CancellationToken cancellationToken) { logger.LogTrace("Starting processing loop..."); - var messageTasks = new Dictionary>(); + var messageTasks = new Dictionary>(); ValueTask activeProcessingTask = ValueTask.CompletedTask; try { - Task updatedTask = null; + Task? updatedTask = null; while (!cancellationToken.IsCancellationRequested) { if (updatedTask?.IsCompleted != false) @@ -1025,7 +1025,7 @@ namespace Tgstation.Server.Host.Components.Chat /// The to send. /// The for the operation. /// A representing the running operation. - ValueTask SendMessage(IEnumerable channelIds, Message replyTo, MessageContent message, CancellationToken cancellationToken) + ValueTask SendMessage(IEnumerable channelIds, Message? replyTo, MessageContent message, CancellationToken cancellationToken) { var channelIdsList = channelIds.ToList(); @@ -1041,11 +1041,11 @@ namespace Tgstation.Server.Host.Components.Chat return ValueTaskExtensions.WhenAll( channelIdsList.Select(x => { - ChannelMapping channelMapping; + ChannelMapping? channelMapping; lock (mappedChannels) if (!mappedChannels.TryGetValue(x, out channelMapping)) return ValueTask.CompletedTask; - IProvider provider; + IProvider? provider; lock (providers) if (!providers.TryGetValue(channelMapping.ProviderId, out provider)) return ValueTask.CompletedTask; @@ -1102,7 +1102,7 @@ namespace Tgstation.Server.Host.Components.Chat { var cancellationToken = handlerCts.Token; if (waitForConnections) - await initialProviderConnectionsTask.WaitAsync(cancellationToken); + await initialProviderConnectionsTask!.WaitAsync(cancellationToken); await SendMessage( channelIdsFactory(), From 8ee927486e8f45565eb950440b1b9b248c352627 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Mon, 18 Dec 2023 13:21:59 -0500 Subject: [PATCH 202/425] Nullify `DiscordProvider` Also partially fixes case of non-github owner/names --- .../Chat/Providers/DiscordProvider.cs | 96 ++++++++++--------- 1 file changed, 53 insertions(+), 43 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Chat/Providers/DiscordProvider.cs b/src/Tgstation.Server.Host/Components/Chat/Providers/DiscordProvider.cs index 3a89c2245c..958aa54b26 100644 --- a/src/Tgstation.Server.Host/Components/Chat/Providers/DiscordProvider.cs +++ b/src/Tgstation.Server.Host/Components/Chat/Providers/DiscordProvider.cs @@ -33,8 +33,6 @@ using Tgstation.Server.Host.Models; using Tgstation.Server.Host.System; using Tgstation.Server.Host.Utils; -#nullable disable - namespace Tgstation.Server.Host.Components.Chat.Providers { /// @@ -106,17 +104,17 @@ namespace Tgstation.Server.Host.Components.Chat.Providers /// /// The for the . /// - CancellationTokenSource gatewayCts; + CancellationTokenSource? gatewayCts; /// /// The for the initial gateway connection event. /// - TaskCompletionSource gatewayReadyTcs; + TaskCompletionSource? gatewayReadyTcs; /// /// The representing the lifetime of the client. /// - Task gatewayTask; + Task? gatewayTask; /// /// The bot's . @@ -159,8 +157,8 @@ namespace Tgstation.Server.Host.Components.Chat.Providers mappedChannels = new List(); connectDisconnectLock = new object(); - var csb = new DiscordConnectionStringBuilder(chatBot.ConnectionString); - var botToken = csb.BotToken; + var csb = new DiscordConnectionStringBuilder(chatBot.ConnectionString!); + var botToken = csb.BotToken!; outputDisplayType = csb.DMOutputDisplay; deploymentBranding = csb.DeploymentBranding; @@ -196,7 +194,7 @@ namespace Tgstation.Server.Host.Components.Chat.Providers } /// - public override async ValueTask SendMessage(Message replyTo, MessageContent message, ulong channelId, CancellationToken cancellationToken) + public override async ValueTask SendMessage(Message? replyTo, MessageContent message, ulong channelId, CancellationToken cancellationToken) { ArgumentNullException.ThrowIfNull(message); @@ -291,21 +289,19 @@ namespace Tgstation.Server.Host.Components.Chat.Providers Models.RevisionInformation revisionInformation, EngineVersion engineVersion, DateTimeOffset? estimatedCompletionTime, - string gitHubOwner, - string gitHubRepo, + string? gitHubOwner, + string? gitHubRepo, ulong channelId, bool localCommitPushed, CancellationToken cancellationToken) { ArgumentNullException.ThrowIfNull(revisionInformation); ArgumentNullException.ThrowIfNull(engineVersion); - ArgumentNullException.ThrowIfNull(gitHubOwner); - ArgumentNullException.ThrowIfNull(gitHubRepo); localCommitPushed |= revisionInformation.CommitSha == revisionInformation.OriginCommitSha; var fields = BuildUpdateEmbedFields(revisionInformation, engineVersion, gitHubOwner, gitHubRepo, localCommitPushed); - var author = new EmbedAuthor(assemblyInformationProvider.VersionPrefix) + Optional author = new EmbedAuthor(assemblyInformationProvider.VersionPrefix) { Url = "https://github.com/tgstation/tgstation-server", IconUrl = "https://cdn.discordapp.com/attachments/1114451486374637629/1151650846019432448/tgs.png", @@ -325,7 +321,7 @@ namespace Tgstation.Server.Host.Components.Chat.Providers Logger.LogTrace("Attempting to post deploy embed to channel {channelId}...", channelId); var channelsClient = serviceProvider.GetRequiredService(); - var prefix = GetEngineCompilerPrefix(engineVersion.Engine.Value); + var prefix = GetEngineCompilerPrefix(engineVersion.Engine!.Value); var messageResponse = await channelsClient.CreateMessageAsync( new Snowflake(channelId), $"{prefix}: Deployment in progress...", @@ -388,7 +384,7 @@ namespace Tgstation.Server.Host.Components.Chat.Providers var updatedMessageText = errorMessage == null ? $"{prefix}: Deployment pending reboot..." : $"{prefix}: Deployment failed!"; - IMessage updatedMessage = null; + IMessage? updatedMessage = null; async ValueTask CreateUpdatedMessage() { var createUpdatedMessageResponse = await channelsClient.CreateMessageAsync( @@ -540,7 +536,7 @@ namespace Tgstation.Server.Host.Components.Chat.Providers RealId = messageCreateEvent.Author.ID.Value, Channel = new ChannelRepresentation( pm ? messageCreateEvent.Author.Username : guildName, - channelResponse.Entity.Name.Value, + channelResponse.Entity.Name.Value!, messageCreateEvent.ChannelID.Value) { IsPrivateChannel = pm, @@ -635,8 +631,8 @@ namespace Tgstation.Server.Host.Components.Chat.Providers CancellationTokenSource localGatewayCts; lock (connectDisconnectLock) { - localGatewayTask = gatewayTask; - localGatewayCts = gatewayCts; + localGatewayTask = gatewayTask!; + localGatewayCts = gatewayCts!; gatewayTask = null; gatewayCts = null; if (localGatewayTask == null) @@ -662,7 +658,7 @@ namespace Tgstation.Server.Host.Components.Chat.Providers var guildsClient = serviceProvider.GetRequiredService(); var guildTasks = new ConcurrentDictionary>>(); - async ValueTask>> GetModelChannelFromDBChannel(Models.ChatChannel channelFromDB) + async ValueTask>?> GetModelChannelFromDBChannel(Models.ChatChannel channelFromDB) { if (!channelFromDB.DiscordChannelId.HasValue) throw new InvalidOperationException("ChatChannel missing DiscordChannelId!"); @@ -721,7 +717,7 @@ namespace Tgstation.Server.Host.Components.Chat.Providers var channelModel = new ChannelRepresentation( guildsResponse.Entity.Name, - discordChannelResponse.Entity.Name.Value, + discordChannelResponse.Entity.Name.Value!, channelId) { IsAdminChannel = channelFromDB.IsAdminChannel == true, @@ -742,8 +738,9 @@ namespace Tgstation.Server.Host.Components.Chat.Providers var channelTuples = await ValueTaskExtensions.WhenAll(tasks.ToList()); - var enumerator = channelTuples + var list = channelTuples .Where(x => x != null) + .Cast>>() // NRT my beloathed .ToList(); var channelIdZeroModel = channels.FirstOrDefault(x => x.DiscordChannelId == 0); @@ -752,7 +749,7 @@ namespace Tgstation.Server.Host.Components.Chat.Providers Logger.LogInformation("Mapping ALL additional accessible text channels"); var allAccessibleChannels = await GetAllAccessibleTextChannels(cancellationToken); var unmappedTextChannels = allAccessibleChannels - .Where(x => !tasks.Any(task => task.Result != null && new Snowflake(task.Result.Item1.DiscordChannelId.Value) == x.ID)); + .Where(x => !tasks.Any(task => task.Result != null && new Snowflake(task.Result.Item1.DiscordChannelId!.Value) == x.ID)); async ValueTask>> CreateMappingsForUnmappedChannels() { @@ -773,13 +770,13 @@ namespace Tgstation.Server.Host.Components.Chat.Providers .ToList(); // Add catch-all channel - unmappedTasks.Add(Task.FromResult( + unmappedTasks.Add(Task.FromResult( new ChannelRepresentation( "(Unknown Discord Guilds)", "(Unknown Discord Channels)", 0) { - IsAdminChannel = channelIdZeroModel.IsAdminChannel.Value, + IsAdminChannel = channelIdZeroModel.IsAdminChannel!.Value, EmbedsSupported = true, Tag = channelIdZeroModel.Tag, })); @@ -787,18 +784,22 @@ namespace Tgstation.Server.Host.Components.Chat.Providers await Task.WhenAll(unmappedTasks); return Tuple.Create>( channelIdZeroModel, - unmappedTasks.Select(x => x.Result).Where(x => x != null).ToList()); + unmappedTasks + .Select(x => x.Result) + .Where(x => x != null) + .Cast() // NRT my beloathed + .ToList()); } var task = CreateMappingsForUnmappedChannels(); var tuple = await task; - enumerator.Add(tuple); + list.Add(tuple); } lock (mappedChannels) { mappedChannels.Clear(); - mappedChannels.AddRange(enumerator.SelectMany(x => x.Item2).Select(x => x.RealId)); + mappedChannels.AddRange(list.SelectMany(x => x.Item2).Select(x => x.RealId)); } if (remapRequired) @@ -807,7 +808,7 @@ namespace Tgstation.Server.Host.Components.Chat.Providers EnqueueMessage(null); } - return new Dictionary>(enumerator.Select(x => new KeyValuePair>(x.Item1, x.Item2))); + return new Dictionary>(list.Select(x => new KeyValuePair>(x.Item1, x.Item2))); } /// @@ -881,46 +882,55 @@ namespace Tgstation.Server.Host.Components.Chat.Providers List BuildUpdateEmbedFields( Models.RevisionInformation revisionInformation, EngineVersion engineVersion, - string gitHubOwner, - string gitHubRepo, + string? gitHubOwner, + string? gitHubRepo, bool localCommitPushed) { bool gitHub = gitHubOwner != null && gitHubRepo != null; - var engineField = engineVersion.Engine.Value switch + var engineField = engineVersion.Engine!.Value switch { EngineType.Byond => new EmbedField( "BYOND Version", - $"{engineVersion.Version.Major}.{engineVersion.Version.Minor}{(engineVersion.CustomIteration.HasValue ? $".{engineVersion.CustomIteration.Value}" : String.Empty)}", + $"{engineVersion.Version!.Major}.{engineVersion.Version.Minor}{(engineVersion.CustomIteration.HasValue ? $".{engineVersion.CustomIteration.Value}" : String.Empty)}", true), EngineType.OpenDream => new EmbedField( "OpenDream Version", - $"[{engineVersion.SourceSHA[..7]}]({generalConfiguration.OpenDreamGitUrl}/commit/{engineVersion.SourceSHA})", + $"[{engineVersion.SourceSHA![..7]}]({generalConfiguration.OpenDreamGitUrl}/commit/{engineVersion.SourceSHA})", true), _ => throw new InvalidOperationException($"Invaild EngineType: {engineVersion.Engine.Value}"), }; + var revisionSha = revisionInformation.CommitSha!; + var revisionOriginSha = revisionInformation.OriginCommitSha!; var fields = new List { engineField, + }; + + if (gitHubOwner == null || gitHubRepo == null) + return fields; + + fields.Add( new EmbedField( "Local Commit", localCommitPushed && gitHub - ? $"[{revisionInformation.CommitSha[..7]}](https://github.com/{gitHubOwner}/{gitHubRepo}/commit/{revisionInformation.CommitSha})" - : revisionInformation.CommitSha[..7], - true), + ? $"[{revisionSha[..7]}](https://github.com/{gitHubOwner}/{gitHubRepo}/commit/{revisionSha})" + : revisionSha[..7], + true)); + + fields.Add( new EmbedField( "Branch Commit", gitHub - ? $"[{revisionInformation.OriginCommitSha[..7]}](https://github.com/{gitHubOwner}/{gitHubRepo}/commit/{revisionInformation.OriginCommitSha})" - : revisionInformation.OriginCommitSha[..7], - true), - }; + ? $"[{revisionOriginSha[..7]}](https://github.com/{gitHubOwner}/{gitHubRepo}/commit/{revisionOriginSha})" + : revisionOriginSha[..7], + true)); fields.AddRange((revisionInformation.ActiveTestMerges ?? Enumerable.Empty()) .Select(x => x.TestMerge) .Select(x => new EmbedField( $"#{x.Number}", - $"[{x.TitleAtMerge}]({x.Url}) by _[@{x.Author}](https://github.com/{x.Author})_{Environment.NewLine}Commit: [{x.TargetCommitSha[..7]}](https://github.com/{gitHubOwner}/{gitHubRepo}/commit/{x.TargetCommitSha}){(String.IsNullOrWhiteSpace(x.Comment) ? String.Empty : $"{Environment.NewLine}_**{x.Comment}**_")}", + $"[{x.TitleAtMerge}]({x.Url}) by _[@{x.Author}](https://github.com/{x.Author})_{Environment.NewLine}Commit: [{x.TargetCommitSha![..7]}](https://github.com/{gitHubOwner}/{gitHubRepo}/commit/{x.TargetCommitSha}){(String.IsNullOrWhiteSpace(x.Comment) ? String.Empty : $"{Environment.NewLine}_**{x.Comment}**_")}", false))); return fields; @@ -955,7 +965,7 @@ namespace Tgstation.Server.Host.Components.Chat.Providers embed.Author = null; } - List fields = null; + List? fields = null; if (embed.Fields != null) { fields = new List(); @@ -1037,7 +1047,7 @@ namespace Tgstation.Server.Host.Components.Chat.Providers Description = embed.Description ?? default(Optional), Fields = fields ?? default(Optional>), Footer = embed.Footer != null - ? new EmbedFooter(embed.Footer.Text) + ? (Optional)new EmbedFooter(embed.Footer.Text) { IconUrl = embed.Footer.IconUrl ?? default(Optional), ProxyIconUrl = embed.Footer.ProxyIconUrl ?? default(Optional), From 6d03d2ec57e615d8a743346f5b781e7569088e36 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Mon, 18 Dec 2023 13:23:15 -0500 Subject: [PATCH 203/425] Nullify `DiscordForwardingResponder` --- .../Components/Chat/Providers/DiscordForwardingResponder.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Chat/Providers/DiscordForwardingResponder.cs b/src/Tgstation.Server.Host/Components/Chat/Providers/DiscordForwardingResponder.cs index 878ac1bc4c..85444cb499 100644 --- a/src/Tgstation.Server.Host/Components/Chat/Providers/DiscordForwardingResponder.cs +++ b/src/Tgstation.Server.Host/Components/Chat/Providers/DiscordForwardingResponder.cs @@ -6,8 +6,6 @@ using Remora.Discord.API.Abstractions.Gateway.Events; using Remora.Discord.Gateway.Responders; using Remora.Results; -#nullable disable - namespace Tgstation.Server.Host.Components.Chat.Providers { /// From d5d5eabc5aad48ab93f5dd7f6564c7a39bc1513d Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Mon, 18 Dec 2023 13:44:34 -0500 Subject: [PATCH 204/425] Nullify `IrcProvider` --- .../Components/Chat/Providers/IrcProvider.cs | 51 +++++++++---------- 1 file changed, 25 insertions(+), 26 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Chat/Providers/IrcProvider.cs b/src/Tgstation.Server.Host/Components/Chat/Providers/IrcProvider.cs index 70665bf695..5207cc380d 100644 --- a/src/Tgstation.Server.Host/Components/Chat/Providers/IrcProvider.cs +++ b/src/Tgstation.Server.Host/Components/Chat/Providers/IrcProvider.cs @@ -19,8 +19,6 @@ using Tgstation.Server.Host.Jobs; using Tgstation.Server.Host.System; using Tgstation.Server.Host.Utils; -#nullable disable - namespace Tgstation.Server.Host.Components.Chat.Providers { /// @@ -77,23 +75,23 @@ namespace Tgstation.Server.Host.Components.Chat.Providers /// /// Map of s to channel names. /// - readonly Dictionary channelIdMap; + readonly Dictionary channelIdMap; /// /// Map of s to query users. /// readonly Dictionary queryChannelIdMap; + /// + /// The used for . + /// + Task? listenTask; + /// /// Id counter for . /// ulong channelIdCounter; - /// - /// The used for . - /// - Task listenTask; - /// /// If we are disconnecting. /// @@ -121,11 +119,11 @@ namespace Tgstation.Server.Host.Components.Chat.Providers if (builder == null || !builder.Valid || builder is not IrcConnectionStringBuilder ircBuilder) throw new InvalidOperationException("Invalid ChatConnectionStringBuilder!"); - address = ircBuilder.Address; - port = ircBuilder.Port.Value; - nickname = ircBuilder.Nickname; + address = ircBuilder.Address!; + port = ircBuilder.Port!.Value; + nickname = ircBuilder.Nickname!; - password = ircBuilder.Password; + password = ircBuilder.Password!; passwordType = ircBuilder.PasswordType; client = new IrcFeatures @@ -140,7 +138,7 @@ namespace Tgstation.Server.Host.Components.Chat.Providers ActiveChannelSyncing = true, AutoNickHandling = true, CtcpVersion = assemblyInformationProvider.VersionString, - UseSsl = ircBuilder.UseSsl.Value, + UseSsl = ircBuilder.UseSsl!.Value, }; if (ircBuilder.UseSsl.Value) client.ValidateServerCertificate = true; // dunno if it defaults to that or what @@ -151,7 +149,7 @@ namespace Tgstation.Server.Host.Components.Chat.Providers /*client.OnReadLine += (sender, e) => Logger.LogTrace("READ: {line}", e.Line); client.OnWriteLine += (sender, e) => Logger.LogTrace("WRITE: {line}", e.Line);*/ - channelIdMap = new Dictionary(); + channelIdMap = new Dictionary(); queryChannelIdMap = new Dictionary(); channelIdCounter = 1; } @@ -166,7 +164,7 @@ namespace Tgstation.Server.Host.Components.Chat.Providers } /// - public override async ValueTask SendMessage(Message replyTo, MessageContent message, ulong channelId, CancellationToken cancellationToken) + public override async ValueTask SendMessage(Message? replyTo, MessageContent message, ulong channelId, CancellationToken cancellationToken) { ArgumentNullException.ThrowIfNull(message); @@ -224,8 +222,8 @@ namespace Tgstation.Server.Host.Components.Chat.Providers Models.RevisionInformation revisionInformation, EngineVersion engineVersion, DateTimeOffset? estimatedCompletionTime, - string gitHubOwner, - string gitHubRepo, + string? gitHubOwner, + string? gitHubRepo, ulong channelId, bool localCommitPushed, CancellationToken cancellationToken) @@ -235,7 +233,7 @@ namespace Tgstation.Server.Host.Components.Chat.Providers ArgumentNullException.ThrowIfNull(gitHubOwner); ArgumentNullException.ThrowIfNull(gitHubRepo); - var commitInsert = revisionInformation.CommitSha[..7]; + var commitInsert = revisionInformation.CommitSha![..7]; string remoteCommitInsert; if (revisionInformation.CommitSha == revisionInformation.OriginCommitSha) { @@ -243,7 +241,7 @@ namespace Tgstation.Server.Host.Components.Chat.Providers remoteCommitInsert = String.Empty; } else - remoteCommitInsert = String.Format(CultureInfo.InvariantCulture, ". Remote commit: ^{0}", revisionInformation.OriginCommitSha[..7]); + remoteCommitInsert = String.Format(CultureInfo.InvariantCulture, ". Remote commit: ^{0}", revisionInformation.OriginCommitSha![..7]); var testmergeInsert = (revisionInformation.ActiveTestMerges?.Count ?? 0) == 0 ? String.Empty @@ -253,17 +251,17 @@ namespace Tgstation.Server.Host.Components.Chat.Providers String.Join( ", ", revisionInformation - .ActiveTestMerges + .ActiveTestMerges! .Select(x => x.TestMerge) .Select(x => { - var result = String.Format(CultureInfo.InvariantCulture, "#{0} at {1}", x.Number, x.TargetCommitSha[..7]); + var result = String.Format(CultureInfo.InvariantCulture, "#{0} at {1}", x.Number, x.TargetCommitSha![..7]); if (x.Comment != null) result += String.Format(CultureInfo.InvariantCulture, " ({0})", x.Comment); return result; }))); - var prefix = GetEngineCompilerPrefix(engineVersion.Engine.Value); + var prefix = GetEngineCompilerPrefix(engineVersion.Engine!.Value); await SendMessage( null, new MessageContent @@ -353,7 +351,7 @@ namespace Tgstation.Server.Host.Components.Chat.Providers dbChannel, new List { - new(address, channelIdMap[id.Value], id.Value) + new(address, channelName, id!.Value) { Tag = dbChannel.Tag, IsAdminChannel = dbChannel.IsAdminChannel == true, @@ -502,7 +500,7 @@ namespace Tgstation.Server.Host.Components.Chat.Providers var username = e.Data.Nick; var channelName = isPrivate ? username : e.Data.Channel; - ulong MapAndGetChannelId(Dictionary dicToCheck) + ulong MapAndGetChannelId(Dictionary dicToCheck) { ulong? resultId = null; if (!dicToCheck.Any(x => @@ -519,13 +517,14 @@ namespace Tgstation.Server.Host.Components.Chat.Providers channelIdMap.Add(resultId.Value, null); } - return resultId.Value; + return resultId!.Value; } ulong userId, channelId; lock (client) { - userId = MapAndGetChannelId(queryChannelIdMap); + userId = MapAndGetChannelId(new Dictionary(queryChannelIdMap + .Cast>())); // NRT my beloathed channelId = isPrivate ? userId : MapAndGetChannelId(channelIdMap); } From bd80c592babdf26a028140a8ed9366a24bcc2f2a Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Mon, 18 Dec 2023 13:51:28 -0500 Subject: [PATCH 205/425] Update to `Byond.TopicSender` v8.0.1 --- src/Tgstation.Server.Host/Tgstation.Server.Host.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Tgstation.Server.Host/Tgstation.Server.Host.csproj b/src/Tgstation.Server.Host/Tgstation.Server.Host.csproj index b9b2690ae2..6bb958fb74 100644 --- a/src/Tgstation.Server.Host/Tgstation.Server.Host.csproj +++ b/src/Tgstation.Server.Host/Tgstation.Server.Host.csproj @@ -64,7 +64,7 @@ - + From 9ab553fe175d6e0fcfdf6a7e57681864f36dd730 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Mon, 18 Dec 2023 14:07:48 -0500 Subject: [PATCH 206/425] Nullify `BufferedFileStreamProvider` --- src/Tgstation.Server.Host/IO/BufferedFileStreamProvider.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Tgstation.Server.Host/IO/BufferedFileStreamProvider.cs b/src/Tgstation.Server.Host/IO/BufferedFileStreamProvider.cs index e4a8fcd139..d1310029df 100644 --- a/src/Tgstation.Server.Host/IO/BufferedFileStreamProvider.cs +++ b/src/Tgstation.Server.Host/IO/BufferedFileStreamProvider.cs @@ -5,8 +5,6 @@ using System.Threading.Tasks; using Tgstation.Server.Host.Utils; -#nullable disable - namespace Tgstation.Server.Host.IO { /// @@ -30,7 +28,7 @@ namespace Tgstation.Server.Host.IO /// /// The backing . /// - volatile MemoryStream buffer; + volatile MemoryStream? buffer; /// /// If has been populated. @@ -60,7 +58,7 @@ namespace Tgstation.Server.Host.IO /// public async ValueTask DisposeAsync() { - MemoryStream localBuffer; + MemoryStream? localBuffer; lock (semaphore) { localBuffer = buffer; From 49809d690cd422d22cba6ca13dd08cf2114bb51d Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Mon, 18 Dec 2023 14:13:51 -0500 Subject: [PATCH 207/425] Nullify `IConsole` and `Console` --- .../Components/InstanceManager.cs | 4 ++-- src/Tgstation.Server.Host/IO/Console.cs | 24 ++++++++++--------- src/Tgstation.Server.Host/IO/IConsole.cs | 12 ++++++---- .../Setup/SetupWizard.cs | 4 ++-- 4 files changed, 25 insertions(+), 19 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/InstanceManager.cs b/src/Tgstation.Server.Host/Components/InstanceManager.cs index af7a3d7c81..50da066c52 100644 --- a/src/Tgstation.Server.Host/Components/InstanceManager.cs +++ b/src/Tgstation.Server.Host/Components/InstanceManager.cs @@ -489,7 +489,7 @@ namespace Tgstation.Server.Host.Components finally { if (originalConsoleTitle != null) - console.Title = originalConsoleTitle; + console.SetTitle(originalConsoleTitle); } } catch (Exception ex) @@ -569,7 +569,7 @@ namespace Tgstation.Server.Host.Components try { logger.LogInformation("{versionString}", assemblyInformationProvider.VersionString); - console.Title = assemblyInformationProvider.VersionString; + console.SetTitle(assemblyInformationProvider.VersionString); CheckSystemCompatibility(); diff --git a/src/Tgstation.Server.Host/IO/Console.cs b/src/Tgstation.Server.Host/IO/Console.cs index ae6efa4ed7..6a94540bb0 100644 --- a/src/Tgstation.Server.Host/IO/Console.cs +++ b/src/Tgstation.Server.Host/IO/Console.cs @@ -5,8 +5,6 @@ using System.Threading.Tasks; using Tgstation.Server.Host.System; -#nullable disable - namespace Tgstation.Server.Host.IO { /// @@ -15,13 +13,9 @@ namespace Tgstation.Server.Host.IO sealed class Console : IConsole, IDisposable { /// - public string Title - { - get => platformIdentifier.IsWindows - ? global::System.Console.Title - : null; - set => global::System.Console.Title = value; - } + public string? Title => platformIdentifier.IsWindows + ? global::System.Console.Title + : null; /// public bool Available => Environment.UserInteractive; @@ -91,7 +85,8 @@ namespace Tgstation.Server.Host.IO // TODO: Make this better: https://stackoverflow.com/questions/9479573/how-to-interrupt-console-readline CheckAvailable(); if (!usePasswordChar) - return global::System.Console.ReadLine(); + return global::System.Console.ReadLine() + ?? throw new InvalidOperationException("Console input has been closed!"); var passwordBuilder = new StringBuilder(); do @@ -126,7 +121,7 @@ namespace Tgstation.Server.Host.IO .WaitAsync(cancellationToken); /// - public Task WriteAsync(string text, bool newLine, CancellationToken cancellationToken) => Task.Factory.StartNew( + public Task WriteAsync(string? text, bool newLine, CancellationToken cancellationToken) => Task.Factory.StartNew( () => { CheckAvailable(); @@ -145,6 +140,13 @@ namespace Tgstation.Server.Host.IO DefaultIOManager.BlockingTaskCreationOptions, TaskScheduler.Current); + /// + public void SetTitle(string newTitle) + { + ArgumentNullException.ThrowIfNull(newTitle); + global::System.Console.Title = newTitle; + } + /// /// Assert that the is available, throwing an otherwise. /// diff --git a/src/Tgstation.Server.Host/IO/IConsole.cs b/src/Tgstation.Server.Host/IO/IConsole.cs index cc71295c55..ee1e948891 100644 --- a/src/Tgstation.Server.Host/IO/IConsole.cs +++ b/src/Tgstation.Server.Host/IO/IConsole.cs @@ -1,8 +1,6 @@ using System.Threading; using System.Threading.Tasks; -#nullable disable - namespace Tgstation.Server.Host.IO { /// @@ -13,7 +11,7 @@ namespace Tgstation.Server.Host.IO /// /// Gets or sets the window's title. Can return if getting the console title is not supported. /// - string Title { get; set; } + string? Title { get; } /// /// If the is visible to the user. @@ -32,7 +30,7 @@ namespace Tgstation.Server.Host.IO /// If there should be a new line after the . /// The for the operation. /// A representing the running operation. - Task WriteAsync(string text, bool newLine, CancellationToken cancellationToken); + Task WriteAsync(string? text, bool newLine, CancellationToken cancellationToken); /// /// Wait for a key press on the . @@ -48,5 +46,11 @@ namespace Tgstation.Server.Host.IO /// The for the operation. /// A resulting in the read by the . Task ReadLineAsync(bool usePasswordChar, CancellationToken cancellationToken); + + /// + /// Sets a console window. + /// + /// The new . + void SetTitle(string newTitle); } } diff --git a/src/Tgstation.Server.Host/Setup/SetupWizard.cs b/src/Tgstation.Server.Host/Setup/SetupWizard.cs index ba82f4bc18..c8007f16b5 100644 --- a/src/Tgstation.Server.Host/Setup/SetupWizard.cs +++ b/src/Tgstation.Server.Host/Setup/SetupWizard.cs @@ -1107,7 +1107,7 @@ namespace Tgstation.Server.Host.Setup return; originalConsoleTitle = console.Title; - console.Title = $"{assemblyInformationProvider.VersionString} Setup Wizard"; + console.SetTitle($"{assemblyInformationProvider.VersionString} Setup Wizard"); } // Link passed cancellationToken with cancel key press @@ -1197,7 +1197,7 @@ namespace Tgstation.Server.Host.Setup { await finalTask; if (originalConsoleTitle != null) - console.Title = originalConsoleTitle; + console.SetTitle(originalConsoleTitle); } } } From ca94ce577e0efa937d3430bec841c5fb592cf9e5 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Mon, 18 Dec 2023 14:18:01 -0500 Subject: [PATCH 208/425] Nullify `IIOManager` --- .../Configuration/InternalConfiguration.cs | 2 +- src/Tgstation.Server.Host/IO/IIOManager.cs | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Tgstation.Server.Host/Configuration/InternalConfiguration.cs b/src/Tgstation.Server.Host/Configuration/InternalConfiguration.cs index 832041deba..58f2ad4720 100644 --- a/src/Tgstation.Server.Host/Configuration/InternalConfiguration.cs +++ b/src/Tgstation.Server.Host/Configuration/InternalConfiguration.cs @@ -28,7 +28,7 @@ /// /// The base path for the app settings configuration files. /// - public string? AppSettingsBasePath { get; set; } + public string AppSettingsBasePath { get; set; } = "UNINITIALIZED"; // this is set in a hacky way in ServerFactory /// /// Coerce the to select . diff --git a/src/Tgstation.Server.Host/IO/IIOManager.cs b/src/Tgstation.Server.Host/IO/IIOManager.cs index b66bd6f0fa..ec43f1d23f 100644 --- a/src/Tgstation.Server.Host/IO/IIOManager.cs +++ b/src/Tgstation.Server.Host/IO/IIOManager.cs @@ -4,8 +4,6 @@ using System.IO; using System.Threading; using System.Threading.Tasks; -#nullable disable - namespace Tgstation.Server.Host.IO { /// @@ -59,7 +57,7 @@ namespace Tgstation.Server.Host.IO /// A representing the running operation. ValueTask CopyDirectory( IEnumerable ignore, - Func postCopyCallback, + Func? postCopyCallback, string src, string dest, int? taskThrottle, From 16ed57cbb532416c75e573c1259ed8e6bd638a3a Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Mon, 18 Dec 2023 14:19:19 -0500 Subject: [PATCH 209/425] Nullify `DefaultIOManager` --- .../IO/DefaultIOManager.cs | 17 ++++++++--------- src/Tgstation.Server.Host/IO/IIOManager.cs | 1 + .../System/ProcessExecutor.cs | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/Tgstation.Server.Host/IO/DefaultIOManager.cs b/src/Tgstation.Server.Host/IO/DefaultIOManager.cs index 321271faf9..89231a6a49 100644 --- a/src/Tgstation.Server.Host/IO/DefaultIOManager.cs +++ b/src/Tgstation.Server.Host/IO/DefaultIOManager.cs @@ -8,8 +8,6 @@ using System.Threading.Tasks; using Tgstation.Server.Host.Utils; -#nullable disable - namespace Tgstation.Server.Host.IO { /// @@ -72,7 +70,7 @@ namespace Tgstation.Server.Host.IO /// public async ValueTask CopyDirectory( IEnumerable ignore, - Func postCopyCallback, + Func? postCopyCallback, string src, string dest, int? taskThrottle, @@ -142,7 +140,8 @@ namespace Tgstation.Server.Host.IO public Task DirectoryExists(string path, CancellationToken cancellationToken) => Task.Factory.StartNew(() => Directory.Exists(ResolvePath(path)), cancellationToken, BlockingTaskCreationOptions, TaskScheduler.Current); /// - public string GetDirectoryName(string path) => Path.GetDirectoryName(path ?? throw new ArgumentNullException(nameof(path))); + public string GetDirectoryName(string path) => Path.GetDirectoryName(path ?? throw new ArgumentNullException(nameof(path))) + ?? throw new InvalidOperationException($"Null was returned. Path ({path}) must be rooted. This is not supported!"); /// public string GetFileName(string path) => Path.GetFileName(path ?? throw new ArgumentNullException(nameof(path))); @@ -338,7 +337,7 @@ namespace Tgstation.Server.Host.IO /// /// The source directory path. /// The destination directory path. - /// Files and folders to ignore at the root level. + /// Optional files and folders to ignore at the root level. /// The optional callback called for each source/dest file pair post copy. /// Optional used to limit degree of parallelism. /// The for the operation. @@ -346,13 +345,13 @@ namespace Tgstation.Server.Host.IO IEnumerable CopyDirectoryImpl( string src, string dest, - IEnumerable ignore, - Func postCopyCallback, - SemaphoreSlim semaphore, + IEnumerable? ignore, + Func? postCopyCallback, + SemaphoreSlim? semaphore, CancellationToken cancellationToken) { var dir = new DirectoryInfo(src); - Task subdirCreationTask = null; + Task? subdirCreationTask = null; foreach (var subDirectory in dir.EnumerateDirectories()) { if (ignore != null && ignore.Contains(subDirectory.Name)) diff --git a/src/Tgstation.Server.Host/IO/IIOManager.cs b/src/Tgstation.Server.Host/IO/IIOManager.cs index ec43f1d23f..ed4a90fb52 100644 --- a/src/Tgstation.Server.Host/IO/IIOManager.cs +++ b/src/Tgstation.Server.Host/IO/IIOManager.cs @@ -133,6 +133,7 @@ namespace Tgstation.Server.Host.IO /// /// A path to check. /// The directory portion of the given . + /// If is rooted. string GetDirectoryName(string path); /// diff --git a/src/Tgstation.Server.Host/System/ProcessExecutor.cs b/src/Tgstation.Server.Host/System/ProcessExecutor.cs index a0a787e53b..7820ca11b3 100644 --- a/src/Tgstation.Server.Host/System/ProcessExecutor.cs +++ b/src/Tgstation.Server.Host/System/ProcessExecutor.cs @@ -229,7 +229,7 @@ namespace Tgstation.Server.Host.System handle.StartInfo.RedirectStandardError = true; bool writingToFile; - await using var fileStream = (writingToFile = fileRedirect != null) ? ioManager.CreateAsyncSequentialWriteStream(fileRedirect) : null; + await using var fileStream = (writingToFile = fileRedirect != null) ? ioManager.CreateAsyncSequentialWriteStream(fileRedirect!) : null; await using var fileWriter = fileStream != null ? new StreamWriter(fileStream) : null; var stringBuilder = fileStream == null ? new StringBuilder() : null; From ef2fca7b4d0c47a66b8e3fea85c6a5ae9f923763 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Mon, 18 Dec 2023 14:22:09 -0500 Subject: [PATCH 210/425] Nullify `IFileDownloader` --- src/Tgstation.Server.Host/IO/IFileDownloader.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Tgstation.Server.Host/IO/IFileDownloader.cs b/src/Tgstation.Server.Host/IO/IFileDownloader.cs index 6cc9baad86..446700e55f 100644 --- a/src/Tgstation.Server.Host/IO/IFileDownloader.cs +++ b/src/Tgstation.Server.Host/IO/IFileDownloader.cs @@ -1,7 +1,5 @@ using System; -#nullable disable - namespace Tgstation.Server.Host.IO { /// @@ -15,6 +13,6 @@ namespace Tgstation.Server.Host.IO /// The URL to download. /// Optional to use as the "Bearer" value in the optional "Authorization" header for the request. /// A new for the downloaded file. - IFileStreamProvider DownloadFile(Uri url, string bearerToken); + IFileStreamProvider DownloadFile(Uri url, string? bearerToken); } } From 671cbfcb934bc2a36d59d5a8bc4bcc86233f26ff Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Mon, 18 Dec 2023 14:22:56 -0500 Subject: [PATCH 211/425] Nullify `FileDownloader` --- src/Tgstation.Server.Host/IO/FileDownloader.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Tgstation.Server.Host/IO/FileDownloader.cs b/src/Tgstation.Server.Host/IO/FileDownloader.cs index 1b133e9647..30efdb6718 100644 --- a/src/Tgstation.Server.Host/IO/FileDownloader.cs +++ b/src/Tgstation.Server.Host/IO/FileDownloader.cs @@ -7,8 +7,6 @@ using Microsoft.Extensions.Logging; using Tgstation.Server.Api; using Tgstation.Server.Common.Http; -#nullable disable - namespace Tgstation.Server.Host.IO { /// @@ -36,7 +34,7 @@ namespace Tgstation.Server.Host.IO } /// - public IFileStreamProvider DownloadFile(Uri url, string bearerToken) + public IFileStreamProvider DownloadFile(Uri url, string? bearerToken) { ArgumentNullException.ThrowIfNull(url); From 0bae4338bb1666d293ad80631e29a00a89ff4025 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Mon, 18 Dec 2023 14:32:01 -0500 Subject: [PATCH 212/425] Nullify `IFilesystemLinkFactory` --- src/Tgstation.Server.Host/IO/IFilesystemLinkFactory.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/IO/IFilesystemLinkFactory.cs b/src/Tgstation.Server.Host/IO/IFilesystemLinkFactory.cs index 36ea58a9df..3cf0622801 100644 --- a/src/Tgstation.Server.Host/IO/IFilesystemLinkFactory.cs +++ b/src/Tgstation.Server.Host/IO/IFilesystemLinkFactory.cs @@ -1,8 +1,6 @@ using System.Threading; using System.Threading.Tasks; -#nullable disable - namespace Tgstation.Server.Host.IO { /// From 645377f469bfef6db02dba2aba91518c65ccd36a Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Mon, 18 Dec 2023 14:31:28 -0500 Subject: [PATCH 213/425] Nullify `IFileStreamProvider` and revisit `IFileUploadTicket` Only the latter can have a nullable return value. --- .../IO/IFileStreamProvider.cs | 4 +--- .../Transfer/FileUploadProvider.cs | 21 ++++++++++++------- .../Transfer/IFileUploadTicket.cs | 14 ++++++++++++- 3 files changed, 27 insertions(+), 12 deletions(-) diff --git a/src/Tgstation.Server.Host/IO/IFileStreamProvider.cs b/src/Tgstation.Server.Host/IO/IFileStreamProvider.cs index 47a2caca10..6b1670194d 100644 --- a/src/Tgstation.Server.Host/IO/IFileStreamProvider.cs +++ b/src/Tgstation.Server.Host/IO/IFileStreamProvider.cs @@ -3,8 +3,6 @@ using System.IO; using System.Threading; using System.Threading.Tasks; -#nullable disable - namespace Tgstation.Server.Host.IO { /// @@ -16,7 +14,7 @@ namespace Tgstation.Server.Host.IO /// Gets the provided . May be called multiple times, though cancelling any may cause all calls to be cancelled. All calls yield the same reference. /// /// The for the operation. - /// A resulting in the provided on success, if it could not be provided. + /// A resulting in the provided . /// The resulting is owned by the and is short lived unless otherwise specified. It should be buffered if it needs use outside the lifetime of the . ValueTask GetResult(CancellationToken cancellationToken); } diff --git a/src/Tgstation.Server.Host/Transfer/FileUploadProvider.cs b/src/Tgstation.Server.Host/Transfer/FileUploadProvider.cs index 23b37788fc..0dd709dcc8 100644 --- a/src/Tgstation.Server.Host/Transfer/FileUploadProvider.cs +++ b/src/Tgstation.Server.Host/Transfer/FileUploadProvider.cs @@ -65,14 +65,6 @@ namespace Tgstation.Server.Host.Transfer return ValueTask.CompletedTask; } - /// - public async ValueTask GetResult(CancellationToken cancellationToken) - { - using (cancellationToken.Register(() => streamTcs.TrySetCanceled(cancellationToken))) - using (ticketExpiryCts.Token.Register(() => streamTcs.TrySetResult(null))) - return await streamTcs.Task; - } - /// /// Expire the . /// @@ -142,5 +134,18 @@ namespace Tgstation.Server.Host.Transfer }; completionTcs.TrySetResult(); } + + /// + public async ValueTask GetResult(CancellationToken cancellationToken) + => await ((IFileUploadTicket)this).GetResult(cancellationToken) + ?? throw new InvalidOperationException("Upload ticket expired!"); + + /// + async ValueTask IFileUploadTicket.GetResult(CancellationToken cancellationToken) + { + using (cancellationToken.Register(() => streamTcs.TrySetCanceled(cancellationToken))) + using (ticketExpiryCts.Token.Register(() => streamTcs.TrySetResult(null))) + return await streamTcs.Task; + } } } diff --git a/src/Tgstation.Server.Host/Transfer/IFileUploadTicket.cs b/src/Tgstation.Server.Host/Transfer/IFileUploadTicket.cs index 43130810d3..7e1eabf813 100644 --- a/src/Tgstation.Server.Host/Transfer/IFileUploadTicket.cs +++ b/src/Tgstation.Server.Host/Transfer/IFileUploadTicket.cs @@ -1,4 +1,8 @@ -using Tgstation.Server.Api.Models; +using System.IO; +using System.Threading; +using System.Threading.Tasks; + +using Tgstation.Server.Api.Models; using Tgstation.Server.Api.Models.Response; using Tgstation.Server.Host.IO; @@ -20,5 +24,13 @@ namespace Tgstation.Server.Host.Transfer /// The to set. /// Any additional information that can be provided about the error. void SetError(ErrorCode errorCode, string? additionalData); + + /// + /// Gets the provided . May be called multiple times, though cancelling any may cause all calls to be cancelled. All calls yield the same reference. + /// + /// The for the operation. + /// A resulting in the provided on success, if the upload expired. + /// The resulting is owned by the and is short lived unless otherwise specified. It should be buffered if it needs use outside the lifetime of the . + new ValueTask GetResult(CancellationToken cancellationToken); } } From 4511f1a60c0e7c00652658419249ab3595ddc320 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Mon, 18 Dec 2023 14:48:05 -0500 Subject: [PATCH 214/425] Nullify `ISeekableFileStreamProvider` --- src/Tgstation.Server.Host/IO/ISeekableFileStreamProvider.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Tgstation.Server.Host/IO/ISeekableFileStreamProvider.cs b/src/Tgstation.Server.Host/IO/ISeekableFileStreamProvider.cs index f34e28745d..42cfc86953 100644 --- a/src/Tgstation.Server.Host/IO/ISeekableFileStreamProvider.cs +++ b/src/Tgstation.Server.Host/IO/ISeekableFileStreamProvider.cs @@ -2,8 +2,6 @@ using System.Threading; using System.Threading.Tasks; -#nullable disable - namespace Tgstation.Server.Host.IO { /// @@ -20,7 +18,7 @@ namespace Tgstation.Server.Host.IO /// Gets the provided . May be called multiple times, though cancelling any may cause all calls to be cancelled. /// /// The for the operation. - /// A resulting in the provided on success, if it could not be provided. + /// A resulting in the provided on success. ValueTask GetOwnedResult(CancellationToken cancellationToken); } } From 1f5834dd7cc6618f9943ac1afa8696fc005e9b0c Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Mon, 18 Dec 2023 14:49:11 -0500 Subject: [PATCH 215/425] Remove an unused parameter --- .../Components/Engine/ByondInstallerBase.cs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Engine/ByondInstallerBase.cs b/src/Tgstation.Server.Host/Components/Engine/ByondInstallerBase.cs index 082eeaf349..7aef964b9c 100644 --- a/src/Tgstation.Server.Host/Components/Engine/ByondInstallerBase.cs +++ b/src/Tgstation.Server.Host/Components/Engine/ByondInstallerBase.cs @@ -200,7 +200,7 @@ namespace Tgstation.Server.Host.Components.Engine { CheckVersionValidity(version); - var url = await GetDownloadZipUrl(version, cancellationToken); + var url = GetDownloadZipUrl(version); Logger.LogTrace("Downloading {engineType} version {version} from {url}...", TargetEngineType, version, url); await using var download = fileDownloader.DownloadFile(url, null); @@ -233,13 +233,12 @@ namespace Tgstation.Server.Host.Components.Engine /// Create a pointing to the location of the download for a given . /// /// The to create a for. - /// The for the operation. - /// A resulting in a new pointing to the version download location. - ValueTask GetDownloadZipUrl(EngineVersion version, CancellationToken cancellationToken) + /// A pointing to the version download location. + Uri GetDownloadZipUrl(EngineVersion version) { CheckVersionValidity(version); var url = String.Format(CultureInfo.InvariantCulture, ByondRevisionsUrlTemplate, version.Version.Major, version.Version.Minor); - return ValueTask.FromResult(new Uri(url)); + return new Uri(url); } } } From c262f09bd595255ccc7a29efd317e5c69a525194 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Mon, 18 Dec 2023 14:49:25 -0500 Subject: [PATCH 216/425] Nullify `PosixFilesystemLinkFactory` --- src/Tgstation.Server.Host/IO/PosixFilesystemLinkFactory.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/IO/PosixFilesystemLinkFactory.cs b/src/Tgstation.Server.Host/IO/PosixFilesystemLinkFactory.cs index b5355d9aad..b80af9e122 100644 --- a/src/Tgstation.Server.Host/IO/PosixFilesystemLinkFactory.cs +++ b/src/Tgstation.Server.Host/IO/PosixFilesystemLinkFactory.cs @@ -5,8 +5,6 @@ using System.Threading.Tasks; using Mono.Unix; -#nullable disable - namespace Tgstation.Server.Host.IO { /// From 9ff89df72086dc4814fa989665dcd931e9330017 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Mon, 18 Dec 2023 14:49:43 -0500 Subject: [PATCH 217/425] Nullify `PosixPostWriteHandler` --- src/Tgstation.Server.Host/IO/PosixPostWriteHandler.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/IO/PosixPostWriteHandler.cs b/src/Tgstation.Server.Host/IO/PosixPostWriteHandler.cs index ec441813b1..a0f4f5a4c8 100644 --- a/src/Tgstation.Server.Host/IO/PosixPostWriteHandler.cs +++ b/src/Tgstation.Server.Host/IO/PosixPostWriteHandler.cs @@ -4,8 +4,6 @@ using Microsoft.Extensions.Logging; using Mono.Unix; using Mono.Unix.Native; -#nullable disable - namespace Tgstation.Server.Host.IO { /// From 1b263ca750fc1af6959386edd1633f4b3e8d5a60 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Mon, 18 Dec 2023 14:50:29 -0500 Subject: [PATCH 218/425] Nullify `RequestFileStreamProvider` --- src/Tgstation.Server.Host/IO/RequestFileStreamProvider.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Tgstation.Server.Host/IO/RequestFileStreamProvider.cs b/src/Tgstation.Server.Host/IO/RequestFileStreamProvider.cs index ef4ddb0d14..12461e4e7f 100644 --- a/src/Tgstation.Server.Host/IO/RequestFileStreamProvider.cs +++ b/src/Tgstation.Server.Host/IO/RequestFileStreamProvider.cs @@ -6,8 +6,6 @@ using System.Threading.Tasks; using Tgstation.Server.Common.Http; -#nullable disable - namespace Tgstation.Server.Host.IO { /// @@ -33,7 +31,7 @@ namespace Tgstation.Server.Host.IO /// /// The resulting in the downloaded . /// - Task downloadTask; + Task? downloadTask; /// /// If has been called. @@ -56,7 +54,7 @@ namespace Tgstation.Server.Host.IO /// public async ValueTask DisposeAsync() { - Task localDownloadTask; + Task? localDownloadTask; lock (downloadCts) { if (disposed) From 72ff717ec87457c07a042438224d593bc1d6bf58 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Mon, 18 Dec 2023 14:50:43 -0500 Subject: [PATCH 219/425] Nullify `ResolvingIOManager` --- src/Tgstation.Server.Host/IO/ResolvingIOManager.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/IO/ResolvingIOManager.cs b/src/Tgstation.Server.Host/IO/ResolvingIOManager.cs index 665a5b6bc4..3b86b92c36 100644 --- a/src/Tgstation.Server.Host/IO/ResolvingIOManager.cs +++ b/src/Tgstation.Server.Host/IO/ResolvingIOManager.cs @@ -1,8 +1,6 @@ using System; using System.IO; -#nullable disable - namespace Tgstation.Server.Host.IO { /// From bd2b6b5d5f823f6e1490da1574ee43e339535830 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Mon, 18 Dec 2023 14:48:32 -0500 Subject: [PATCH 220/425] Nullify `ISynchronousIOManager` --- src/Tgstation.Server.Host/IO/ISynchronousIOManager.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Tgstation.Server.Host/IO/ISynchronousIOManager.cs b/src/Tgstation.Server.Host/IO/ISynchronousIOManager.cs index df87b894c6..16e0ea370e 100644 --- a/src/Tgstation.Server.Host/IO/ISynchronousIOManager.cs +++ b/src/Tgstation.Server.Host/IO/ISynchronousIOManager.cs @@ -2,8 +2,6 @@ using System.IO; using System.Threading; -#nullable disable - namespace Tgstation.Server.Host.IO { /// @@ -57,7 +55,7 @@ namespace Tgstation.Server.Host.IO /// The function only succeeds if this parameter matches the SHA-1 hash of the contents of the current file. Contains the SHA1 of the file on disk once the function returns. /// The for the operation. /// on success, if the operation failed due to not matching the file's contents. - bool WriteFileChecked(string path, Stream data, ref string sha1InOut, CancellationToken cancellationToken); + bool WriteFileChecked(string path, Stream data, ref string? sha1InOut, CancellationToken cancellationToken); /// /// Checks if a given is a directory. From ac357e935ad7b4df26af9d1ff663a81c778667a7 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Mon, 18 Dec 2023 14:52:56 -0500 Subject: [PATCH 221/425] Nullify `SynchronousIOManager` --- src/Tgstation.Server.Host/IO/SynchronousIOManager.cs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/Tgstation.Server.Host/IO/SynchronousIOManager.cs b/src/Tgstation.Server.Host/IO/SynchronousIOManager.cs index 590cbfbb6f..4dbf3d833b 100644 --- a/src/Tgstation.Server.Host/IO/SynchronousIOManager.cs +++ b/src/Tgstation.Server.Host/IO/SynchronousIOManager.cs @@ -6,8 +6,6 @@ using System.Linq; using System.Security.Cryptography; using System.Threading; -#nullable disable - namespace Tgstation.Server.Host.IO { /// @@ -74,14 +72,13 @@ namespace Tgstation.Server.Host.IO } /// - public bool WriteFileChecked(string path, Stream data, ref string sha1InOut, CancellationToken cancellationToken) + public bool WriteFileChecked(string path, Stream data, ref string? sha1InOut, CancellationToken cancellationToken) { ArgumentNullException.ThrowIfNull(path); ArgumentNullException.ThrowIfNull(data); cancellationToken.ThrowIfCancellationRequested(); - var directory = Path.GetDirectoryName(path); - + var directory = Path.GetDirectoryName(path) ?? throw new ArgumentException("path cannot be rooted!", nameof(path)); Directory.CreateDirectory(directory); var newFile = !File.Exists(path); @@ -99,7 +96,7 @@ namespace Tgstation.Server.Host.IO // suppressed due to only using for consistency checks using (var sha1 = SHA1.Create()) { - string GetSha1(Stream dataToHash) + string? GetSha1(Stream dataToHash) { if (dataToHash == null) return null; From 330217cbe3a09171ef95a77455e1ac6ae5890b31 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Mon, 18 Dec 2023 14:54:24 -0500 Subject: [PATCH 222/425] Nullify `WindowsFilesystemLinkFactory` --- src/Tgstation.Server.Host/IO/WindowsFilesystemLinkFactory.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Tgstation.Server.Host/IO/WindowsFilesystemLinkFactory.cs b/src/Tgstation.Server.Host/IO/WindowsFilesystemLinkFactory.cs index 5a410ab3d7..6636838ab4 100644 --- a/src/Tgstation.Server.Host/IO/WindowsFilesystemLinkFactory.cs +++ b/src/Tgstation.Server.Host/IO/WindowsFilesystemLinkFactory.cs @@ -4,9 +4,8 @@ using System.Threading; using System.Threading.Tasks; using BetterWin32Errors; -using Tgstation.Server.Host.System; -#nullable disable +using Tgstation.Server.Host.System; namespace Tgstation.Server.Host.IO { From ae505a207c2a0dea57ce20c2011cff1b9152a4b2 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Mon, 18 Dec 2023 14:54:45 -0500 Subject: [PATCH 223/425] Nullify `WindowsPostWriteHandler` --- src/Tgstation.Server.Host/IO/WindowsPostWriteHandler.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/IO/WindowsPostWriteHandler.cs b/src/Tgstation.Server.Host/IO/WindowsPostWriteHandler.cs index a2b6b0d4ae..2a94e42a2f 100644 --- a/src/Tgstation.Server.Host/IO/WindowsPostWriteHandler.cs +++ b/src/Tgstation.Server.Host/IO/WindowsPostWriteHandler.cs @@ -1,7 +1,5 @@ using System; -#nullable disable - namespace Tgstation.Server.Host.IO { /// From 960f2e4561917e3b1bc2102a5bfdaa3298d9adb0 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Mon, 18 Dec 2023 15:05:13 -0500 Subject: [PATCH 224/425] Nullify `SwarmRegistrationRequest` --- .../Swarm/SwarmRegistrationRequest.cs | 13 ++++++++++--- src/Tgstation.Server.Host/Swarm/SwarmService.cs | 3 +-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/Tgstation.Server.Host/Swarm/SwarmRegistrationRequest.cs b/src/Tgstation.Server.Host/Swarm/SwarmRegistrationRequest.cs index 93f5ed92db..229d4d28d2 100644 --- a/src/Tgstation.Server.Host/Swarm/SwarmRegistrationRequest.cs +++ b/src/Tgstation.Server.Host/Swarm/SwarmRegistrationRequest.cs @@ -3,8 +3,6 @@ using System.ComponentModel.DataAnnotations; using Tgstation.Server.Api.Models.Internal; -#nullable disable - namespace Tgstation.Server.Host.Swarm { /// @@ -16,6 +14,15 @@ namespace Tgstation.Server.Host.Swarm /// The TGS of the sending server. /// [Required] - public Version ServerVersion { get; set; } + public Version ServerVersion { get; } + + /// + /// Initializes a new instance of the class. + /// + /// The value of . + public SwarmRegistrationRequest(Version serverVersion) + { + ServerVersion = serverVersion ?? throw new ArgumentNullException(nameof(serverVersion)); + } } } diff --git a/src/Tgstation.Server.Host/Swarm/SwarmService.cs b/src/Tgstation.Server.Host/Swarm/SwarmService.cs index cd0e855151..0ff0131c72 100644 --- a/src/Tgstation.Server.Host/Swarm/SwarmService.cs +++ b/src/Tgstation.Server.Host/Swarm/SwarmService.cs @@ -1267,9 +1267,8 @@ namespace Tgstation.Server.Host.Swarm null, HttpMethod.Post, SwarmConstants.RegisterRoute, - new SwarmRegistrationRequest + new SwarmRegistrationRequest(assemblyInformationProvider.Version) { - ServerVersion = assemblyInformationProvider.Version, Identifier = swarmConfiguration.Identifier, Address = swarmConfiguration.Address, PublicAddress = swarmConfiguration.PublicAddress, From c9b236da67ba5ee4701c6ced919cafabc3db71eb Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Mon, 18 Dec 2023 15:11:40 -0500 Subject: [PATCH 225/425] Nullify `ChatBot` --- .../Components/Chat/ChatManager.cs | 3 +-- .../Controllers/ChatController.cs | 10 +++---- src/Tgstation.Server.Host/Models/ChatBot.cs | 26 +++++++++++++++---- .../Chat/Providers/TestDiscordProvider.cs | 1 + .../Chat/Providers/TestIrcProvider.cs | 1 + 5 files changed, 29 insertions(+), 12 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Chat/ChatManager.cs b/src/Tgstation.Server.Host/Components/Chat/ChatManager.cs index b6000a7619..b0586d81a9 100644 --- a/src/Tgstation.Server.Host/Components/Chat/ChatManager.cs +++ b/src/Tgstation.Server.Host/Components/Chat/ChatManager.cs @@ -327,7 +327,7 @@ namespace Tgstation.Server.Host.Components.Chat if (originalChatBot != null) activeChatBots.Remove(originalChatBot); - activeChatBots.Add(new Models.ChatBot + activeChatBots.Add(new Models.ChatBot(newSettings.Channels) { Id = newSettings.Id, ConnectionString = newSettings.ConnectionString, @@ -335,7 +335,6 @@ namespace Tgstation.Server.Host.Components.Chat Name = newSettings.Name, ReconnectionInterval = newSettings.ReconnectionInterval, Provider = newSettings.Provider, - Channels = newSettings.Channels, }); } diff --git a/src/Tgstation.Server.Host/Controllers/ChatController.cs b/src/Tgstation.Server.Host/Controllers/ChatController.cs index 6b35f19d28..6bae07a444 100644 --- a/src/Tgstation.Server.Host/Controllers/ChatController.cs +++ b/src/Tgstation.Server.Host/Controllers/ChatController.cs @@ -126,12 +126,12 @@ namespace Tgstation.Server.Host.Controllers model.ReconnectionInterval ??= 1; // try to update das db first - var dbModel = new ChatBot + var newChannels = model.Channels?.Select(x => ConvertApiChatChannel(x, model.Provider!.Value)).ToList() ?? new List(); // important that this isn't null + var dbModel = new ChatBot(newChannels) { Name = model.Name, ConnectionString = model.ConnectionString, Enabled = model.Enabled, - Channels = model.Channels?.Select(x => ConvertApiChatChannel(x, model.Provider!.Value)).ToList() ?? new List(), // important that this isn't null InstanceId = Instance.Id!.Value, Provider = model.Provider, ReconnectionInterval = model.ReconnectionInterval, @@ -296,7 +296,7 @@ namespace Tgstation.Server.Host.Controllers if (current == default) return this.Gone(); - if ((model.Channels?.Count ?? current.Channels.Count) > (model.ChannelLimit ?? current.ChannelLimit!.Value)) + if ((model.Channels?.Count ?? current.Channels!.Count) > (model.ChannelLimit ?? current.ChannelLimit!.Value)) { // 400 or 409 depends on if the client sent both var errorMessage = new ErrorMessageResponse(ErrorCode.ChatBotMaxChannels); @@ -339,7 +339,7 @@ namespace Tgstation.Server.Host.Controllers var hasChannels = model.Channels != null; if (hasChannels || (model.Provider.HasValue && model.Provider != oldProvider)) { - DatabaseContext.ChatChannels.RemoveRange(current.Channels); + DatabaseContext.ChatChannels.RemoveRange(current.Channels!); if (hasChannels) { var dbChannels = model.Channels!.Select(x => ConvertApiChatChannel(x, model.Provider ?? current.Provider!.Value)).ToList(); @@ -347,7 +347,7 @@ namespace Tgstation.Server.Host.Controllers current.Channels = dbChannels; } else - current.Channels.Clear(); + current.Channels!.Clear(); } await DatabaseContext.Save(cancellationToken); diff --git a/src/Tgstation.Server.Host/Models/ChatBot.cs b/src/Tgstation.Server.Host/Models/ChatBot.cs index 8b5fe59f7d..fb31ff5032 100644 --- a/src/Tgstation.Server.Host/Models/ChatBot.cs +++ b/src/Tgstation.Server.Host/Models/ChatBot.cs @@ -1,11 +1,10 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Linq; using Tgstation.Server.Api.Models.Response; -#nullable disable - namespace Tgstation.Server.Host.Models { /// @@ -25,17 +24,34 @@ namespace Tgstation.Server.Host.Models /// The parent . /// [Required] - public Instance Instance { get; set; } + public Instance? Instance { get; set; } /// /// See . /// public ICollection Channels { get; set; } + /// + /// Initializes a new instance of the class. + /// + public ChatBot() + : this(new List()) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// The value of . + public ChatBot(ICollection channels) + { + Channels = channels ?? throw new ArgumentNullException(nameof(channels)); + } + /// public ChatBotResponse ToApi() => new ChatBotResponse { - Channels = Channels.Select(x => x.ToApi(Provider.Value)).ToList(), + Channels = Channels.Select(x => x.ToApi(this.Require(x => x.Provider))).ToList(), ConnectionString = ConnectionString, Enabled = Enabled, Provider = Provider, diff --git a/tests/Tgstation.Server.Host.Tests/Components/Chat/Providers/TestDiscordProvider.cs b/tests/Tgstation.Server.Host.Tests/Components/Chat/Providers/TestDiscordProvider.cs index b21b19f0ae..61d61a19a3 100644 --- a/tests/Tgstation.Server.Host.Tests/Components/Chat/Providers/TestDiscordProvider.cs +++ b/tests/Tgstation.Server.Host.Tests/Components/Chat/Providers/TestDiscordProvider.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.Reflection; using System.Threading; using System.Threading.Tasks; diff --git a/tests/Tgstation.Server.Host.Tests/Components/Chat/Providers/TestIrcProvider.cs b/tests/Tgstation.Server.Host.Tests/Components/Chat/Providers/TestIrcProvider.cs index 9e8565955e..60021ea019 100644 --- a/tests/Tgstation.Server.Host.Tests/Components/Chat/Providers/TestIrcProvider.cs +++ b/tests/Tgstation.Server.Host.Tests/Components/Chat/Providers/TestIrcProvider.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.Reflection; using System.Threading; using System.Threading.Tasks; From f6083fcf6608bf72c7459b85e4ed8e1d9cc584ed Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Mon, 18 Dec 2023 15:15:31 -0500 Subject: [PATCH 226/425] Clean up a method signature --- src/Tgstation.Server.Host/Controllers/ChatController.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Tgstation.Server.Host/Controllers/ChatController.cs b/src/Tgstation.Server.Host/Controllers/ChatController.cs index 6bae07a444..9ea7f4f5a7 100644 --- a/src/Tgstation.Server.Host/Controllers/ChatController.cs +++ b/src/Tgstation.Server.Host/Controllers/ChatController.cs @@ -281,7 +281,7 @@ namespace Tgstation.Server.Host.Controllers { ArgumentNullException.ThrowIfNull(model); - var earlyOut = StandardModelChecks(model, false); + IActionResult? earlyOut = StandardModelChecks(model, false); if (earlyOut != null) return earlyOut; @@ -382,8 +382,8 @@ namespace Tgstation.Server.Host.Controllers /// /// The to validate. /// If the is being created. - /// An to respond with or . - IActionResult? StandardModelChecks(ChatBotApiBase model, bool forCreation) + /// An to respond with or . + BadRequestObjectResult? StandardModelChecks(ChatBotApiBase model, bool forCreation) { if (model.ReconnectionInterval == 0) throw new InvalidOperationException("RecconnectionInterval cannot be zero!"); From 9a69af5a861ada4db937cc06eed7ee2b5babe696 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Mon, 18 Dec 2023 15:17:23 -0500 Subject: [PATCH 227/425] Nullify `ChatChannel` --- src/Tgstation.Server.Host/Models/ChatChannel.cs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/Tgstation.Server.Host/Models/ChatChannel.cs b/src/Tgstation.Server.Host/Models/ChatChannel.cs index 85823089cf..9263d2f9a6 100644 --- a/src/Tgstation.Server.Host/Models/ChatChannel.cs +++ b/src/Tgstation.Server.Host/Models/ChatChannel.cs @@ -4,8 +4,6 @@ using System.Globalization; using Tgstation.Server.Api.Models; using Tgstation.Server.Api.Models.Internal; -#nullable disable - namespace Tgstation.Server.Host.Models { /// @@ -25,7 +23,7 @@ namespace Tgstation.Server.Host.Models /// The IRC channel name. /// [StringLength(Limits.MaximumIndexableStringLength, MinimumLength = 1)] - public string IrcChannel { get; set; } + public string? IrcChannel { get; set; } /// /// The Discord channel snowflake. @@ -35,16 +33,16 @@ namespace Tgstation.Server.Host.Models /// /// The . /// - public ChatBot ChatSettings { get; set; } + public ChatBot? ChatSettings { get; set; } /// /// Convert to a . /// /// The channel's . /// The converted . - public Api.Models.ChatChannel ToApi(ChatProvider chatProvider) => new Api.Models.ChatChannel + public Api.Models.ChatChannel ToApi(ChatProvider chatProvider) => new() { - ChannelData = chatProvider == ChatProvider.Discord ? DiscordChannelId.Value.ToString(CultureInfo.InvariantCulture) : IrcChannel, + ChannelData = chatProvider == ChatProvider.Discord ? DiscordChannelId!.Value.ToString(CultureInfo.InvariantCulture) : IrcChannel, IsAdminChannel = IsAdminChannel, IsWatchdogChannel = IsWatchdogChannel, IsUpdatesChannel = IsUpdatesChannel, From 082990927a680bafeb491a866585b627ced048f6 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Mon, 18 Dec 2023 15:30:06 -0500 Subject: [PATCH 228/425] Nullify `CompileJob` --- .../Components/Deployment/DreamMaker.cs | 14 ++--- .../Models/CompileJob.cs | 51 +++++++++++++++++-- 2 files changed, 54 insertions(+), 11 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Deployment/DreamMaker.cs b/src/Tgstation.Server.Host/Components/Deployment/DreamMaker.cs index 5d99463637..a36068a825 100644 --- a/src/Tgstation.Server.Host/Components/Deployment/DreamMaker.cs +++ b/src/Tgstation.Server.Host/Components/Deployment/DreamMaker.cs @@ -317,6 +317,7 @@ namespace Tgstation.Server.Host.Components.Deployment && repositorySettings.AccessUser != null; using (repo) compileJob = await Compile( + job, revInfo, dreamMakerSettings, ddSettings, @@ -447,6 +448,7 @@ namespace Tgstation.Server.Host.Components.Deployment /// /// Run the compile implementation. /// + /// The currently running . /// The . /// The . /// The . @@ -458,6 +460,7 @@ namespace Tgstation.Server.Host.Components.Deployment /// The for the operation. /// A resulting in the completed . async ValueTask Compile( + Models.Job job, Models.RevisionInformation revisionInformation, Api.Models.Internal.DreamMakerSettings dreamMakerSettings, DreamDaemonLaunchParameters launchParameters, @@ -485,19 +488,16 @@ namespace Tgstation.Server.Host.Components.Deployment repository.RemoteRepositoryName, localCommitExistsOnRemote); - var job = new Models.CompileJob + var compileJob = new Models.CompileJob(job, revisionInformation, engineLock.Version.ToString(), repository.Origin.ToString()) { DirectoryName = Guid.NewGuid(), DmeName = dreamMakerSettings.ProjectName, - RevisionInformation = revisionInformation, - EngineVersion = engineLock.Version.ToString(), - RepositoryOrigin = repository.Origin.ToString(), }; progressReporter.StageName = "Creating remote deployment notification"; await remoteDeploymentManager.StartDeployment( repository, - job, + compileJob, cancellationToken); logger.LogTrace("Deployment will timeout at {timeoutTime}", DateTimeOffset.UtcNow + dreamMakerSettings.Timeout.Value); @@ -510,7 +510,7 @@ namespace Tgstation.Server.Host.Components.Deployment { await RunCompileJob( progressReporter, - job, + compileJob, dreamMakerSettings, launchParameters, engineLock, @@ -524,7 +524,7 @@ namespace Tgstation.Server.Host.Components.Deployment } } - return job; + return compileJob; } catch (OperationCanceledException) { diff --git a/src/Tgstation.Server.Host/Models/CompileJob.cs b/src/Tgstation.Server.Host/Models/CompileJob.cs index 5883302c59..ea729e9217 100644 --- a/src/Tgstation.Server.Host/Models/CompileJob.cs +++ b/src/Tgstation.Server.Host/Models/CompileJob.cs @@ -4,8 +4,6 @@ using System.ComponentModel.DataAnnotations; using Tgstation.Server.Api.Models; using Tgstation.Server.Api.Models.Response; -#nullable disable - namespace Tgstation.Server.Host.Models { /// @@ -65,14 +63,14 @@ namespace Tgstation.Server.Host.Models public int? GitHubDeploymentId { get; set; } /// - public override Version DMApiVersion + public override Version? DMApiVersion { get { if (!DMApiMajorVersion.HasValue) return null; - return new Version(DMApiMajorVersion.Value, DMApiMinorVersion.Value, DMApiPatchVersion.Value); + return new Version(DMApiMajorVersion.Value, DMApiMinorVersion!.Value, DMApiPatchVersion!.Value); } set @@ -83,6 +81,51 @@ namespace Tgstation.Server.Host.Models } } + /// + /// Initializes a new instance of the class. + /// + [Obsolete("For use by EFCore only", true)] + public CompileJob() + : this(null!, null!, null!, null!, false) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// The value of . + /// The value of . + /// The value of . + /// The value of . + public CompileJob(Job job, RevisionInformation revisionInformation, string engineVersion, string repositoryOrigin) + : this(job, revisionInformation, engineVersion, repositoryOrigin, true) + { + } + + /// + /// Initializes a new instance of the class. + /// + /// The value of . + /// The value of . + /// The value of . + /// The value of . + /// If , , and should be checked for nulls. + CompileJob(Job job, RevisionInformation revisionInformation, string engineVersion, string repositoryOrigin, bool nullChecks) + { + if (nullChecks) + { + ArgumentNullException.ThrowIfNull(job); + ArgumentNullException.ThrowIfNull(revisionInformation); + ArgumentNullException.ThrowIfNull(engineVersion); + ArgumentNullException.ThrowIfNull(repositoryOrigin); + } + + Job = job; + RevisionInformation = revisionInformation; + EngineVersion = engineVersion; + RepositoryOrigin = repositoryOrigin; + } + /// public CompileJobResponse ToApi() => new() { From dd23015f4a431df9e8a140c1ecb3c643cd1ad45b Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Mon, 18 Dec 2023 15:57:57 -0500 Subject: [PATCH 229/425] Slightly increase the health check timeout --- tests/Tgstation.Server.Tests/Live/Instance/WatchdogTest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Tgstation.Server.Tests/Live/Instance/WatchdogTest.cs b/tests/Tgstation.Server.Tests/Live/Instance/WatchdogTest.cs index d182e542a3..0df8a9755c 100644 --- a/tests/Tgstation.Server.Tests/Live/Instance/WatchdogTest.cs +++ b/tests/Tgstation.Server.Tests/Live/Instance/WatchdogTest.cs @@ -771,7 +771,7 @@ namespace Tgstation.Server.Tests.Live.Instance .GetProcess(ddProc.Id); // Ensure it's responding to health checks - await Task.WhenAny(Task.Delay(6000, cancellationToken), ourProcessHandler.Lifetime); + await Task.WhenAny(Task.Delay(7000, cancellationToken), ourProcessHandler.Lifetime); Assert.IsFalse(ddProc.HasExited); // check DD agrees From d169c2162471513bd7745f918076cd698265e2c0 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Mon, 18 Dec 2023 16:23:45 -0500 Subject: [PATCH 230/425] Nullify `DreamDaemonSettings` --- src/Tgstation.Server.Host/Models/DreamDaemonSettings.cs | 4 +--- src/Tgstation.Server.Host/Utils/PortAllocator.cs | 4 ++-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/Tgstation.Server.Host/Models/DreamDaemonSettings.cs b/src/Tgstation.Server.Host/Models/DreamDaemonSettings.cs index c58642fd95..0da7f22079 100644 --- a/src/Tgstation.Server.Host/Models/DreamDaemonSettings.cs +++ b/src/Tgstation.Server.Host/Models/DreamDaemonSettings.cs @@ -1,7 +1,5 @@ using System.ComponentModel.DataAnnotations; -#nullable disable - namespace Tgstation.Server.Host.Models { /// @@ -21,6 +19,6 @@ namespace Tgstation.Server.Host.Models /// The parent . /// [Required] - public Instance Instance { get; set; } + public Instance? Instance { get; set; } } } diff --git a/src/Tgstation.Server.Host/Utils/PortAllocator.cs b/src/Tgstation.Server.Host/Utils/PortAllocator.cs index 310cfbfe3d..1aa096ab0b 100644 --- a/src/Tgstation.Server.Host/Utils/PortAllocator.cs +++ b/src/Tgstation.Server.Host/Utils/PortAllocator.cs @@ -74,14 +74,14 @@ namespace Tgstation.Server.Host.Utils var ddPorts = await databaseContext .DreamDaemonSettings .AsQueryable() - .Where(x => x.Instance.SwarmIdentifer == swarmConfiguration.Identifier) + .Where(x => x.Instance!.SwarmIdentifer == swarmConfiguration.Identifier) .Select(x => x.Port) .ToListAsync(cancellationToken); var dmPorts = await databaseContext .DreamMakerSettings .AsQueryable() - .Where(x => x.Instance.SwarmIdentifer == swarmConfiguration.Identifier) + .Where(x => x.Instance!.SwarmIdentifer == swarmConfiguration.Identifier) .Select(x => x.ApiValidationPort) .ToListAsync(cancellationToken); From 2f9531ed9f5b3e68411d75ae5a2f96b7302fa1cc Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Mon, 18 Dec 2023 16:24:09 -0500 Subject: [PATCH 231/425] Nullify `DreamMakerSettings` --- src/Tgstation.Server.Host/Models/DreamMakerSettings.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Tgstation.Server.Host/Models/DreamMakerSettings.cs b/src/Tgstation.Server.Host/Models/DreamMakerSettings.cs index 88bfe61344..4cc7998e41 100644 --- a/src/Tgstation.Server.Host/Models/DreamMakerSettings.cs +++ b/src/Tgstation.Server.Host/Models/DreamMakerSettings.cs @@ -2,8 +2,6 @@ using Tgstation.Server.Api.Models.Response; -#nullable disable - namespace Tgstation.Server.Host.Models { /// @@ -23,7 +21,7 @@ namespace Tgstation.Server.Host.Models /// The parent . /// [Required] - public Instance Instance { get; set; } + public Instance? Instance { get; set; } /// public DreamMakerResponse ToApi() => new DreamMakerResponse From aee739cfb0c6cc779d9eda5ed46a96f04e0f55ee Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Mon, 18 Dec 2023 16:26:18 -0500 Subject: [PATCH 232/425] Cleanup another ValueTask message --- .../Components/Deployment/DreamMaker.cs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Deployment/DreamMaker.cs b/src/Tgstation.Server.Host/Components/Deployment/DreamMaker.cs index a36068a825..255c07dd54 100644 --- a/src/Tgstation.Server.Host/Components/Deployment/DreamMaker.cs +++ b/src/Tgstation.Server.Host/Components/Deployment/DreamMaker.cs @@ -967,13 +967,16 @@ namespace Tgstation.Server.Host.Components.Deployment } } - // DCT: None available + var dirCleanTask = CleanDir(); + + var failRemoteDeployTask = remoteDeploymentManager.FailDeployment( + job, + FormatExceptionForUsers(exception), + CancellationToken.None); // DCT: None available + return ValueTaskExtensions.WhenAll( - CleanDir(), - remoteDeploymentManager.FailDeployment( - job, - FormatExceptionForUsers(exception), - CancellationToken.None)); + dirCleanTask, + failRemoteDeployTask); } } } From 4a7d675cb3bff57c6a68da16568a0452d63f0593 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Mon, 18 Dec 2023 16:29:35 -0500 Subject: [PATCH 233/425] Nullify `Instance` --- src/Tgstation.Server.Host/Models/Instance.cs | 21 ++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/Tgstation.Server.Host/Models/Instance.cs b/src/Tgstation.Server.Host/Models/Instance.cs index d098b60e70..a96470e9fa 100644 --- a/src/Tgstation.Server.Host/Models/Instance.cs +++ b/src/Tgstation.Server.Host/Models/Instance.cs @@ -2,8 +2,6 @@ using Tgstation.Server.Api.Models.Response; -#nullable disable - namespace Tgstation.Server.Host.Models { /// @@ -19,22 +17,22 @@ namespace Tgstation.Server.Host.Models /// /// The for the . /// - public DreamMakerSettings DreamMakerSettings { get; set; } + public DreamMakerSettings? DreamMakerSettings { get; set; } /// /// The for the . /// - public DreamDaemonSettings DreamDaemonSettings { get; set; } + public DreamDaemonSettings? DreamDaemonSettings { get; set; } /// /// The for the . /// - public RepositorySettings RepositorySettings { get; set; } + public RepositorySettings? RepositorySettings { get; set; } /// /// The of the the server in the swarm this instance belongs to. /// - public string SwarmIdentifer { get; set; } + public string? SwarmIdentifer { get; set; } /// /// The s in the . @@ -56,6 +54,17 @@ namespace Tgstation.Server.Host.Models /// public ICollection Jobs { get; set; } + /// + /// Initializes a new instance of the class. + /// + public Instance() + { + InstancePermissionSets = new List(); + ChatSettings = new List(); + RevisionInformations = new List(); + Jobs = new List(); + } + /// public InstanceResponse ToApi() => new() { From 9ea0b7bed93e4d2ccf5a87cf9fd8ce2509986001 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Mon, 18 Dec 2023 16:30:53 -0500 Subject: [PATCH 234/425] Simplify some `new()` expressions --- src/Tgstation.Server.Host/Models/ChatBot.cs | 2 +- src/Tgstation.Server.Host/Models/DreamMakerSettings.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Models/ChatBot.cs b/src/Tgstation.Server.Host/Models/ChatBot.cs index fb31ff5032..caf1f0c645 100644 --- a/src/Tgstation.Server.Host/Models/ChatBot.cs +++ b/src/Tgstation.Server.Host/Models/ChatBot.cs @@ -49,7 +49,7 @@ namespace Tgstation.Server.Host.Models } /// - public ChatBotResponse ToApi() => new ChatBotResponse + public ChatBotResponse ToApi() => new() { Channels = Channels.Select(x => x.ToApi(this.Require(x => x.Provider))).ToList(), ConnectionString = ConnectionString, diff --git a/src/Tgstation.Server.Host/Models/DreamMakerSettings.cs b/src/Tgstation.Server.Host/Models/DreamMakerSettings.cs index 4cc7998e41..72f5a99f29 100644 --- a/src/Tgstation.Server.Host/Models/DreamMakerSettings.cs +++ b/src/Tgstation.Server.Host/Models/DreamMakerSettings.cs @@ -24,7 +24,7 @@ namespace Tgstation.Server.Host.Models public Instance? Instance { get; set; } /// - public DreamMakerResponse ToApi() => new DreamMakerResponse + public DreamMakerResponse ToApi() => new() { ProjectName = ProjectName, ApiValidationPort = ApiValidationPort, From 3a6047702f6bc1534fad80f43e22539f4404e4c7 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Mon, 18 Dec 2023 19:31:29 -0500 Subject: [PATCH 235/425] Nullify `InstancePermissionSet` --- src/Tgstation.Server.Host/Jobs/JobsHubGroupMapper.cs | 2 +- src/Tgstation.Server.Host/Models/InstancePermissionSet.cs | 8 +++----- .../Security/AuthenticationContextFactory.cs | 2 +- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/Tgstation.Server.Host/Jobs/JobsHubGroupMapper.cs b/src/Tgstation.Server.Host/Jobs/JobsHubGroupMapper.cs index 1342091caa..6264c185d7 100644 --- a/src/Tgstation.Server.Host/Jobs/JobsHubGroupMapper.cs +++ b/src/Tgstation.Server.Host/Jobs/JobsHubGroupMapper.cs @@ -67,7 +67,7 @@ namespace Tgstation.Server.Host.Jobs public ValueTask InstancePermissionSetCreated(InstancePermissionSet instancePermissionSet, CancellationToken cancellationToken) { ArgumentNullException.ThrowIfNull(instancePermissionSet); - var permissionSetId = instancePermissionSet.PermissionSet.Id ?? instancePermissionSet.PermissionSetId; + var permissionSetId = instancePermissionSet.PermissionSetId; logger.LogTrace("InstancePermissionSetCreated"); return RefreshHubGroups( diff --git a/src/Tgstation.Server.Host/Models/InstancePermissionSet.cs b/src/Tgstation.Server.Host/Models/InstancePermissionSet.cs index 01bc99ae42..8db1f17fba 100644 --- a/src/Tgstation.Server.Host/Models/InstancePermissionSet.cs +++ b/src/Tgstation.Server.Host/Models/InstancePermissionSet.cs @@ -2,8 +2,6 @@ using Tgstation.Server.Api.Models.Response; -#nullable disable - namespace Tgstation.Server.Host.Models { /// @@ -23,16 +21,16 @@ namespace Tgstation.Server.Host.Models /// The the belongs to. /// [Required] - public Instance Instance { get; set; } + public Instance? Instance { get; set; } /// /// The the belongs to. /// [Required] - public PermissionSet PermissionSet { get; set; } + public PermissionSet? PermissionSet { get; set; } /// - public InstancePermissionSetResponse ToApi() => new InstancePermissionSetResponse + public InstancePermissionSetResponse ToApi() => new() { EngineRights = EngineRights, ChatBotRights = ChatBotRights, diff --git a/src/Tgstation.Server.Host/Security/AuthenticationContextFactory.cs b/src/Tgstation.Server.Host/Security/AuthenticationContextFactory.cs index 8dca0248c7..7fa7b2802f 100644 --- a/src/Tgstation.Server.Host/Security/AuthenticationContextFactory.cs +++ b/src/Tgstation.Server.Host/Security/AuthenticationContextFactory.cs @@ -119,7 +119,7 @@ namespace Tgstation.Server.Host.Security { instancePermissionSet = await databaseContext.InstancePermissionSets .AsQueryable() - .Where(x => x.PermissionSetId == userPermissionSet.Id && x.InstanceId == instanceId && x.Instance.SwarmIdentifer == swarmConfiguration.Identifier) + .Where(x => x.PermissionSetId == userPermissionSet.Id && x.InstanceId == instanceId && x.Instance!.SwarmIdentifer == swarmConfiguration.Identifier) .Include(x => x.Instance) .FirstOrDefaultAsync(cancellationToken); From 8fc4c36fd35fdab9c73fbf5fd9c829f739dc3dfe Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Mon, 18 Dec 2023 19:48:09 -0500 Subject: [PATCH 236/425] Nullify `Job` --- .../Components/Chat/Providers/Provider.cs | 5 ++++- src/Tgstation.Server.Host/Jobs/JobService.cs | 5 ++++- src/Tgstation.Server.Host/Models/Job.cs | 22 +++++++++---------- .../Chat/Providers/TestDiscordProvider.cs | 9 +++++--- .../Chat/Providers/TestIrcProvider.cs | 6 ++--- 5 files changed, 27 insertions(+), 20 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Chat/Providers/Provider.cs b/src/Tgstation.Server.Host/Components/Chat/Providers/Provider.cs index da4deecd11..4123521ad7 100644 --- a/src/Tgstation.Server.Host/Components/Chat/Providers/Provider.cs +++ b/src/Tgstation.Server.Host/Components/Chat/Providers/Provider.cs @@ -96,6 +96,9 @@ namespace Tgstation.Server.Host.Components.Chat.Providers Logger = logger ?? throw new ArgumentNullException(nameof(logger)); ChatBot = chatBot ?? throw new ArgumentNullException(nameof(chatBot)); + if (chatBot.Instance == null) + throw new ArgumentException("chatBot must have Instance!", nameof(chatBot)); + messageQueue = new Queue(); nextMessage = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); initialConnectionTcs = new TaskCompletionSource(); @@ -286,7 +289,7 @@ namespace Tgstation.Server.Host.Components.Chat.Providers connectNow = false; if (!Connected) { - var job = Job.Create(Api.Models.JobCode.ReconnectChatBot, null, ChatBot.Instance, ChatBotRights.WriteEnabled); + var job = Job.Create(Api.Models.JobCode.ReconnectChatBot, null, ChatBot.Instance!, ChatBotRights.WriteEnabled); job.Description += $": {ChatBot.Name}"; await jobManager.RegisterOperation( diff --git a/src/Tgstation.Server.Host/Jobs/JobService.cs b/src/Tgstation.Server.Host/Jobs/JobService.cs index 0e8714e307..ea2782a821 100644 --- a/src/Tgstation.Server.Host/Jobs/JobService.cs +++ b/src/Tgstation.Server.Host/Jobs/JobService.cs @@ -123,6 +123,9 @@ namespace Tgstation.Server.Host.Jobs if (job.StartedBy != null && job.StartedBy.Name == null) throw new InvalidOperationException("StartedBy User associated with job does not have a Name!"); + if (job.Instance == null) + throw new InvalidOperationException("No Instance associated with job!"); + job.StartedAt = DateTimeOffset.UtcNow; job.Cancelled = false; @@ -458,7 +461,7 @@ namespace Tgstation.Server.Host.Jobs logger.LogTrace("Starting job..."); await operation( - instanceCoreProvider.GetInstance(job.Instance), + instanceCoreProvider.GetInstance(job.Instance!), databaseContextFactory, job, new JobProgressReporter( diff --git a/src/Tgstation.Server.Host/Models/Job.cs b/src/Tgstation.Server.Host/Models/Job.cs index c9af1ffa50..85327de2e2 100644 --- a/src/Tgstation.Server.Host/Models/Job.cs +++ b/src/Tgstation.Server.Host/Models/Job.cs @@ -7,8 +7,6 @@ using Tgstation.Server.Api.Models; using Tgstation.Server.Api.Models.Response; using Tgstation.Server.Api.Rights; -#nullable disable - namespace Tgstation.Server.Host.Models { /// @@ -20,18 +18,18 @@ namespace Tgstation.Server.Host.Models /// See . /// [Required] - public User StartedBy { get; set; } + public User? StartedBy { get; set; } /// /// See . /// - public User CancelledBy { get; set; } + public User? CancelledBy { get; set; } /// /// The the job belongs to if any. /// [Required] - public Instance Instance { get; set; } + public Instance? Instance { get; set; } /// /// Creates a new job for registering in the . @@ -42,7 +40,7 @@ namespace Tgstation.Server.Host.Models /// The used to generate the value of . /// The value of . will be derived from this. /// A new ready to be registered with the . - public static Job Create(JobCode code, User startedBy, Api.Models.Instance instance, TRight cancelRight) + public static Job Create(JobCode code, User? startedBy, Api.Models.Instance instance, TRight cancelRight) where TRight : Enum => new( code, @@ -58,7 +56,7 @@ namespace Tgstation.Server.Host.Models /// The value of . If , the user will be used. /// The used to generate the value of . /// A new ready to be registered with the . - public static Job Create(JobCode code, User startedBy, Api.Models.Instance instance) + public static Job Create(JobCode code, User? startedBy, Api.Models.Instance instance) => new( code, startedBy, @@ -91,7 +89,7 @@ namespace Tgstation.Server.Host.Models /// The value of . /// The value of . /// The value of . - Job(JobCode code, User startedBy, Api.Models.Instance instance, RightsType? cancelRightsType, ulong? cancelRight) + Job(JobCode code, User? startedBy, Api.Models.Instance instance, RightsType? cancelRightsType, ulong? cancelRight) { StartedBy = startedBy; ArgumentNullException.ThrowIfNull(instance); @@ -100,7 +98,7 @@ namespace Tgstation.Server.Host.Models Id = instance.Id ?? throw new InvalidOperationException("Instance associated with job does not have an Id!"), }; Description = typeof(JobCode) - .GetField(code.ToString()) + .GetField(code.ToString())! .GetCustomAttributes(false) .OfType() .First() @@ -114,8 +112,8 @@ namespace Tgstation.Server.Host.Models public JobResponse ToApi() => new() { Id = Id, - JobCode = JobCode.Value, - InstanceId = Instance.Id.Value, + JobCode = this.Require(x => x.JobCode), + InstanceId = (Instance ?? throw new InvalidOperationException("Instance needs to be set!")).Require(x => x.Id), StartedAt = StartedAt, StoppedAt = StoppedAt, Cancelled = Cancelled, @@ -125,7 +123,7 @@ namespace Tgstation.Server.Host.Models Description = Description, ExceptionDetails = ExceptionDetails, ErrorCode = ErrorCode, - StartedBy = StartedBy.CreateUserName(), + StartedBy = (StartedBy ?? throw new InvalidOperationException("StartedBy needs to be set!")).CreateUserName(), }; } } diff --git a/tests/Tgstation.Server.Host.Tests/Components/Chat/Providers/TestDiscordProvider.cs b/tests/Tgstation.Server.Host.Tests/Components/Chat/Providers/TestDiscordProvider.cs index 61d61a19a3..58c63c6a99 100644 --- a/tests/Tgstation.Server.Host.Tests/Components/Chat/Providers/TestDiscordProvider.cs +++ b/tests/Tgstation.Server.Host.Tests/Components/Chat/Providers/TestDiscordProvider.cs @@ -1,11 +1,11 @@ using System; -using System.Collections.Generic; using System.Reflection; using System.Threading; using System.Threading.Tasks; using Microsoft.Extensions.Logging; using Microsoft.VisualStudio.TestTools.UnitTesting; + using Moq; using Tgstation.Server.Api.Models; @@ -31,7 +31,8 @@ namespace Tgstation.Server.Host.Components.Chat.Providers.Tests testToken1 = new ChatBot { ConnectionString = actualToken, - ReconnectionInterval = 1 + ReconnectionInterval = 1, + Instance = new Models.Instance() }; var mockSetup = new Mock(); @@ -52,6 +53,7 @@ namespace Tgstation.Server.Host.Components.Chat.Providers.Tests { ConnectionString = "fake_token", ReconnectionInterval = 1, + Instance = new Models.Instance(), }; Assert.ThrowsException(() => new DiscordProvider(null, null, null, null, null, null)); @@ -76,7 +78,8 @@ namespace Tgstation.Server.Host.Components.Chat.Providers.Tests await using var provider = new DiscordProvider(mockJobManager, Mock.Of(), mockLogger.Object, Mock.Of(), new ChatBot { ReconnectionInterval = 1, - ConnectionString = "asdf" + ConnectionString = "asdf", + Instance = new Models.Instance(), }, new GeneralConfiguration()); await Assert.ThrowsExceptionAsync(async () => await InvokeConnect(provider)); Assert.IsFalse(provider.Connected); diff --git a/tests/Tgstation.Server.Host.Tests/Components/Chat/Providers/TestIrcProvider.cs b/tests/Tgstation.Server.Host.Tests/Components/Chat/Providers/TestIrcProvider.cs index 60021ea019..3f1e050219 100644 --- a/tests/Tgstation.Server.Host.Tests/Components/Chat/Providers/TestIrcProvider.cs +++ b/tests/Tgstation.Server.Host.Tests/Components/Chat/Providers/TestIrcProvider.cs @@ -1,14 +1,12 @@ using System; -using System.Collections.Generic; using System.Reflection; using System.Threading; using System.Threading.Tasks; -using System.Xml.Linq; using Microsoft.Extensions.Logging; using Microsoft.VisualStudio.TestTools.UnitTesting; + using Moq; -using Serilog.Parsing; using Tgstation.Server.Api.Models; using Tgstation.Server.Host.Jobs; @@ -37,6 +35,7 @@ namespace Tgstation.Server.Host.Components.Chat.Providers.Tests var mockBot = new ChatBot { Name = "test", + Instance = new Models.Instance(), Provider = ChatProvider.Irc }; @@ -83,6 +82,7 @@ namespace Tgstation.Server.Host.Components.Chat.Providers.Tests { ConnectionString = actualToken, Provider = ChatProvider.Irc, + Instance = new Models.Instance(), }); Assert.IsFalse(provider.Connected); await InvokeConnect(provider); From d7b2d27934ebc1e2980c00aae448dd57672c79a7 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Mon, 18 Dec 2023 19:49:36 -0500 Subject: [PATCH 237/425] Nullify `OAuthConnection` --- src/Tgstation.Server.Host/Models/OAuthConnection.cs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/Tgstation.Server.Host/Models/OAuthConnection.cs b/src/Tgstation.Server.Host/Models/OAuthConnection.cs index df9a15732e..d622b358c8 100644 --- a/src/Tgstation.Server.Host/Models/OAuthConnection.cs +++ b/src/Tgstation.Server.Host/Models/OAuthConnection.cs @@ -1,6 +1,4 @@ -#nullable disable - -namespace Tgstation.Server.Host.Models +namespace Tgstation.Server.Host.Models { /// public sealed class OAuthConnection : Api.Models.OAuthConnection, IApiTransformable @@ -13,10 +11,10 @@ namespace Tgstation.Server.Host.Models /// /// The owning . /// - public User User { get; set; } + public User? User { get; set; } /// - public Api.Models.OAuthConnection ToApi() => new Api.Models.OAuthConnection + public Api.Models.OAuthConnection ToApi() => new() { Provider = Provider, ExternalUserId = ExternalUserId, From 5ef00c3988807e4493d503532b4fc311b6814e25 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Mon, 18 Dec 2023 20:46:33 -0500 Subject: [PATCH 238/425] Nullify `PermissionSet` --- src/Tgstation.Server.Host/Models/PermissionSet.cs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/Tgstation.Server.Host/Models/PermissionSet.cs b/src/Tgstation.Server.Host/Models/PermissionSet.cs index 704412c174..554956dd32 100644 --- a/src/Tgstation.Server.Host/Models/PermissionSet.cs +++ b/src/Tgstation.Server.Host/Models/PermissionSet.cs @@ -1,7 +1,5 @@ using System.Collections.Generic; -#nullable disable - namespace Tgstation.Server.Host.Models { /// @@ -20,17 +18,17 @@ namespace Tgstation.Server.Host.Models /// /// The the belongs to, if it is for a . /// - public User User { get; set; } + public User? User { get; set; } /// /// The the belongs to, if it is for a . /// - public UserGroup Group { get; set; } + public UserGroup? Group { get; set; } /// /// The s associated with the . /// - public ICollection InstancePermissionSets { get; set; } + public ICollection? InstancePermissionSets { get; set; } /// /// Convert the to it's API form. From f308112937d2201fcf1ee2ec5a8e2c5b63e4c126 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Mon, 18 Dec 2023 20:46:57 -0500 Subject: [PATCH 239/425] Nullify `ReattachInformation` --- src/Tgstation.Server.Host/Models/ReattachInformation.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Tgstation.Server.Host/Models/ReattachInformation.cs b/src/Tgstation.Server.Host/Models/ReattachInformation.cs index 80137b5004..9454e4acf6 100644 --- a/src/Tgstation.Server.Host/Models/ReattachInformation.cs +++ b/src/Tgstation.Server.Host/Models/ReattachInformation.cs @@ -1,7 +1,5 @@ using System.ComponentModel.DataAnnotations; -#nullable disable - namespace Tgstation.Server.Host.Models { /// @@ -13,7 +11,7 @@ namespace Tgstation.Server.Host.Models /// The for the . /// [Required] - public CompileJob CompileJob { get; set; } + public CompileJob? CompileJob { get; set; } /// /// The of . @@ -23,7 +21,7 @@ namespace Tgstation.Server.Host.Models /// /// The the server was initially launched with in the case of Windows. /// - public CompileJob InitialCompileJob { get; set; } + public CompileJob? InitialCompileJob { get; set; } /// /// The of . From 3520f33b82a6d03c72d117c7f91339eaced2f878 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Mon, 18 Dec 2023 20:47:19 -0500 Subject: [PATCH 240/425] Nullify `ReattachInformationBase` --- src/Tgstation.Server.Host/Models/ReattachInformationBase.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Models/ReattachInformationBase.cs b/src/Tgstation.Server.Host/Models/ReattachInformationBase.cs index 0f8106aa7b..b233f0c017 100644 --- a/src/Tgstation.Server.Host/Models/ReattachInformationBase.cs +++ b/src/Tgstation.Server.Host/Models/ReattachInformationBase.cs @@ -4,8 +4,6 @@ using Tgstation.Server.Api.Models; using Tgstation.Server.Host.Components.Interop; using Tgstation.Server.Host.Components.Session; -#nullable disable - namespace Tgstation.Server.Host.Models { /// From eefdc4741054c59dc3dea09442da1aead88d877b Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Mon, 18 Dec 2023 22:35:24 -0500 Subject: [PATCH 241/425] Nullify `RepositorySettings` --- src/Tgstation.Server.Host/Models/RepositorySettings.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Tgstation.Server.Host/Models/RepositorySettings.cs b/src/Tgstation.Server.Host/Models/RepositorySettings.cs index c5e1d904c2..78e2aada1a 100644 --- a/src/Tgstation.Server.Host/Models/RepositorySettings.cs +++ b/src/Tgstation.Server.Host/Models/RepositorySettings.cs @@ -2,8 +2,6 @@ using Tgstation.Server.Api.Models.Response; -#nullable disable - namespace Tgstation.Server.Host.Models { /// @@ -23,7 +21,7 @@ namespace Tgstation.Server.Host.Models /// The parent . /// [Required] - public Instance Instance { get; set; } + public Instance? Instance { get; set; } /// public RepositoryResponse ToApi() => new RepositoryResponse From 47c919052696008c331a9cbcfa604e1e5d3f2e35 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Mon, 18 Dec 2023 22:39:50 -0500 Subject: [PATCH 242/425] Nullify `ReviInfoTestMerge` --- .../Components/Instance.cs | 5 +--- .../Repository/RepositoryUpdateService.cs | 5 +--- .../Models/RevInfoTestMerge.cs | 26 ++++++++++++++++--- 3 files changed, 25 insertions(+), 11 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Instance.cs b/src/Tgstation.Server.Host/Components/Instance.cs index 10b0e89cd7..e1421476d1 100644 --- a/src/Tgstation.Server.Host/Components/Instance.cs +++ b/src/Tgstation.Server.Host/Components/Instance.cs @@ -368,10 +368,7 @@ namespace Tgstation.Server.Host.Components { var testMerges = updatedTestMerges ?? oldRevInfo.ActiveTestMerges.Select(x => x.TestMerge); var revInfoTestMerges = testMerges.Select( - testMerge => new RevInfoTestMerge - { - TestMerge = testMerge, - }) + testMerge => new RevInfoTestMerge(testMerge, currentRevInfo)) .ToList(); currentRevInfo.ActiveTestMerges = revInfoTestMerges; diff --git a/src/Tgstation.Server.Host/Components/Repository/RepositoryUpdateService.cs b/src/Tgstation.Server.Host/Components/Repository/RepositoryUpdateService.cs index 8b00701f69..130718f9e5 100644 --- a/src/Tgstation.Server.Host/Components/Repository/RepositoryUpdateService.cs +++ b/src/Tgstation.Server.Host/Components/Repository/RepositoryUpdateService.cs @@ -228,10 +228,7 @@ namespace Tgstation.Server.Host.Components.Repository foreach (var activeTestMerge in previousRevInfo.ActiveTestMerges) lastRevisionInfo.ActiveTestMerges.Add(activeTestMerge); - lastRevisionInfo.ActiveTestMerges.Add(new RevInfoTestMerge - { - TestMerge = testMergeToAdd, - }); + lastRevisionInfo.ActiveTestMerges.Add(new RevInfoTestMerge(testMergeToAdd, lastRevisionInfo)); lastRevisionInfo.PrimaryTestMerge = testMergeToAdd; needsUpdate = true; diff --git a/src/Tgstation.Server.Host/Models/RevInfoTestMerge.cs b/src/Tgstation.Server.Host/Models/RevInfoTestMerge.cs index 64b088343a..bed334b0bc 100644 --- a/src/Tgstation.Server.Host/Models/RevInfoTestMerge.cs +++ b/src/Tgstation.Server.Host/Models/RevInfoTestMerge.cs @@ -1,6 +1,5 @@ -using System.ComponentModel.DataAnnotations; - -#nullable disable +using System; +using System.ComponentModel.DataAnnotations; namespace Tgstation.Server.Host.Models { @@ -25,5 +24,26 @@ namespace Tgstation.Server.Host.Models /// [Required] public RevisionInformation RevisionInformation { get; set; } + + /// + /// Initializes a new instance of the class. + /// + [Obsolete("For use by EFCore only", true)] + public RevInfoTestMerge() + { + TestMerge = null!; + RevisionInformation = null!; + } + + /// + /// Initializes a new instance of the class. + /// + /// The value of . + /// The value of . + public RevInfoTestMerge(TestMerge testMerge, RevisionInformation revisionInformation) + { + TestMerge = testMerge ?? throw new ArgumentNullException(nameof(testMerge)); + RevisionInformation = revisionInformation ?? throw new ArgumentNullException(nameof(revisionInformation)); + } } } From daed19610443ed0e0fd3f9e0a9e5963d8518f1e2 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Mon, 18 Dec 2023 22:41:59 -0500 Subject: [PATCH 243/425] Nullify `RevisionInformation` --- .../Chat/Commands/PullRequestsCommand.cs | 6 +++--- .../Models/RevisionInformation.cs | 17 ++++++++--------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Chat/Commands/PullRequestsCommand.cs b/src/Tgstation.Server.Host/Components/Chat/Commands/PullRequestsCommand.cs index c4022d95d7..3fd8c9e64b 100644 --- a/src/Tgstation.Server.Host/Components/Chat/Commands/PullRequestsCommand.cs +++ b/src/Tgstation.Server.Host/Components/Chat/Commands/PullRequestsCommand.cs @@ -117,8 +117,8 @@ namespace Tgstation.Server.Host.Components.Chat.Commands async db => results = await db .RevisionInformations .AsQueryable() - .Where(x => x.Instance.Id == instance.Id && x.CommitSha == head) - .SelectMany(x => x.ActiveTestMerges) + .Where(x => x.Instance!.Id == instance.Id && x.CommitSha == head) + .SelectMany(x => x.ActiveTestMerges!) .Select(x => x.TestMerge) .Select(x => new Models.TestMerge { @@ -144,7 +144,7 @@ namespace Tgstation.Server.Host.Components.Chat.Commands compileJobToUse = null; } - results = compileJobToUse?.RevisionInformation.ActiveTestMerges.Select(x => x.TestMerge).ToList() ?? Enumerable.Empty(); + results = compileJobToUse?.RevisionInformation.ActiveTestMerges?.Select(x => x.TestMerge).ToList() ?? Enumerable.Empty(); } return new MessageContent diff --git a/src/Tgstation.Server.Host/Models/RevisionInformation.cs b/src/Tgstation.Server.Host/Models/RevisionInformation.cs index 8813e4c5bc..cbc8b82ad7 100644 --- a/src/Tgstation.Server.Host/Models/RevisionInformation.cs +++ b/src/Tgstation.Server.Host/Models/RevisionInformation.cs @@ -1,9 +1,8 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Linq; -#nullable disable - namespace Tgstation.Server.Host.Models { /// @@ -23,22 +22,22 @@ namespace Tgstation.Server.Host.Models /// The the belongs to. /// [Required] - public Instance Instance { get; set; } + public Instance? Instance { get; set; } /// /// See . /// - public TestMerge PrimaryTestMerge { get; set; } + public TestMerge? PrimaryTestMerge { get; set; } /// /// See . /// - public ICollection ActiveTestMerges { get; set; } + public ICollection? ActiveTestMerges { get; set; } /// /// See s made from this . /// - public ICollection CompileJobs { get; set; } + public ICollection? CompileJobs { get; set; } /// public Api.Models.RevisionInformation ToApi() => new Api.Models.RevisionInformation @@ -47,8 +46,8 @@ namespace Tgstation.Server.Host.Models Timestamp = Timestamp, OriginCommitSha = OriginCommitSha, PrimaryTestMerge = PrimaryTestMerge?.ToApi(), - ActiveTestMerges = ActiveTestMerges.Select(x => x.TestMerge.ToApi()).ToList(), - CompileJobs = CompileJobs.Select(x => new Api.Models.EntityId + ActiveTestMerges = (ActiveTestMerges ?? throw new InvalidOperationException("ActiveTestMerges must be set!")).Select(x => x.TestMerge.ToApi()).ToList(), + CompileJobs = (CompileJobs ?? throw new InvalidOperationException("CompileJobs must be set!")).Select(x => new Api.Models.EntityId { Id = x.Id, }).ToList(), From 67417b6ec8e7b7da2ba28d7037a6f3958ebaecde Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Mon, 18 Dec 2023 22:45:12 -0500 Subject: [PATCH 244/425] Nullify `TestMerge` --- src/Tgstation.Server.Host/Models/TestMerge.cs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/Tgstation.Server.Host/Models/TestMerge.cs b/src/Tgstation.Server.Host/Models/TestMerge.cs index 3733ca62fc..3641640378 100644 --- a/src/Tgstation.Server.Host/Models/TestMerge.cs +++ b/src/Tgstation.Server.Host/Models/TestMerge.cs @@ -1,8 +1,7 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.ComponentModel.DataAnnotations; -#nullable disable - namespace Tgstation.Server.Host.Models { /// @@ -12,13 +11,13 @@ namespace Tgstation.Server.Host.Models /// See . /// [Required] - public User MergedBy { get; set; } + public User? MergedBy { get; set; } /// /// The initial the was merged with. /// [Required] - public RevisionInformation PrimaryRevisionInformation { get; set; } + public RevisionInformation? PrimaryRevisionInformation { get; set; } /// /// Foreign key for . @@ -28,10 +27,10 @@ namespace Tgstation.Server.Host.Models /// /// All the for the . /// - public ICollection RevisonInformations { get; set; } + public ICollection? RevisonInformations { get; set; } /// - public Api.Models.TestMerge ToApi() => new Api.Models.TestMerge + public Api.Models.TestMerge ToApi() => new() { Author = Author, BodyAtMerge = BodyAtMerge, @@ -39,7 +38,7 @@ namespace Tgstation.Server.Host.Models TitleAtMerge = TitleAtMerge, Comment = Comment, Id = Id, - MergedBy = MergedBy.CreateUserName(), + MergedBy = (MergedBy ?? throw new InvalidOperationException("MergedBy must be set!")).CreateUserName(), Number = Number, TargetCommitSha = TargetCommitSha, Url = Url, From 029527494d4f1e8dd33a591e8ea1e5e98611fd70 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Mon, 18 Dec 2023 22:45:21 -0500 Subject: [PATCH 245/425] Simplify some `new()` expressions --- src/Tgstation.Server.Host/Models/PermissionSet.cs | 2 +- src/Tgstation.Server.Host/Models/RepositorySettings.cs | 2 +- src/Tgstation.Server.Host/Models/RevisionInformation.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Tgstation.Server.Host/Models/PermissionSet.cs b/src/Tgstation.Server.Host/Models/PermissionSet.cs index 554956dd32..2c18a2ae1f 100644 --- a/src/Tgstation.Server.Host/Models/PermissionSet.cs +++ b/src/Tgstation.Server.Host/Models/PermissionSet.cs @@ -34,7 +34,7 @@ namespace Tgstation.Server.Host.Models /// Convert the to it's API form. /// /// A new . - public Api.Models.PermissionSet ToApi() => new Api.Models.PermissionSet + public Api.Models.PermissionSet ToApi() => new() { Id = Id, AdministrationRights = AdministrationRights, diff --git a/src/Tgstation.Server.Host/Models/RepositorySettings.cs b/src/Tgstation.Server.Host/Models/RepositorySettings.cs index 78e2aada1a..e8fb7f6019 100644 --- a/src/Tgstation.Server.Host/Models/RepositorySettings.cs +++ b/src/Tgstation.Server.Host/Models/RepositorySettings.cs @@ -24,7 +24,7 @@ namespace Tgstation.Server.Host.Models public Instance? Instance { get; set; } /// - public RepositoryResponse ToApi() => new RepositoryResponse + public RepositoryResponse ToApi() => new() { // AccessToken = AccessToken, // never show this AccessUser = AccessUser, diff --git a/src/Tgstation.Server.Host/Models/RevisionInformation.cs b/src/Tgstation.Server.Host/Models/RevisionInformation.cs index cbc8b82ad7..eb99816ab6 100644 --- a/src/Tgstation.Server.Host/Models/RevisionInformation.cs +++ b/src/Tgstation.Server.Host/Models/RevisionInformation.cs @@ -40,7 +40,7 @@ namespace Tgstation.Server.Host.Models public ICollection? CompileJobs { get; set; } /// - public Api.Models.RevisionInformation ToApi() => new Api.Models.RevisionInformation + public Api.Models.RevisionInformation ToApi() => new() { CommitSha = CommitSha, Timestamp = Timestamp, From 052b0b9e2633678953d4e60938ce1215ee876878 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Mon, 18 Dec 2023 22:46:35 -0500 Subject: [PATCH 246/425] Cleanup some ChatManager messages --- src/Tgstation.Server.Host/Components/Chat/ChatManager.cs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Chat/ChatManager.cs b/src/Tgstation.Server.Host/Components/Chat/ChatManager.cs index b0586d81a9..505a94d817 100644 --- a/src/Tgstation.Server.Host/Components/Chat/ChatManager.cs +++ b/src/Tgstation.Server.Host/Components/Chat/ChatManager.cs @@ -812,11 +812,9 @@ namespace Tgstation.Server.Host.Components.Chat if (address.Length > 1 && (address.Last() == ':' || address.Last() == ',')) address = address[0..^1]; - address = address.ToUpperInvariant(); - var addressed = - address == CommonMention.ToUpperInvariant() - || address == provider.BotMention.ToUpperInvariant(); + address.Equals(CommonMention, StringComparison.OrdinalIgnoreCase) + || address.Equals(provider.BotMention, StringComparison.OrdinalIgnoreCase); // no mention if (!addressed && !message.User.Channel.IsPrivateChannel) @@ -1034,7 +1032,7 @@ namespace Tgstation.Server.Host.Components.Chat message.Embed != null ? " (with embed)" : String.Empty, String.Join(", ", channelIdsList)); - if (!channelIdsList.Any()) + if (channelIdsList.Count == 0) return ValueTask.CompletedTask; return ValueTaskExtensions.WhenAll( From 02e5e86f21113061acd26160d50c7c9d019ba6ff Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Mon, 18 Dec 2023 22:49:38 -0500 Subject: [PATCH 247/425] Nullify `User` --- .../Controllers/ApiRootController.cs | 4 ++-- .../Jobs/JobsHubGroupMapper.cs | 2 +- src/Tgstation.Server.Host/Models/User.cs | 18 ++++++++---------- .../Security/AuthenticationContext.cs | 2 +- .../Security/AuthenticationContextFactory.cs | 4 ++-- .../Security/CryptographySuite.cs | 3 +++ 6 files changed, 17 insertions(+), 16 deletions(-) diff --git a/src/Tgstation.Server.Host/Controllers/ApiRootController.cs b/src/Tgstation.Server.Host/Controllers/ApiRootController.cs index 334eba85a4..5248d3f313 100644 --- a/src/Tgstation.Server.Host/Controllers/ApiRootController.cs +++ b/src/Tgstation.Server.Host/Controllers/ApiRootController.cs @@ -263,13 +263,13 @@ namespace Tgstation.Server.Host.Controllers return Unauthorized(); query = query.Where( - x => x.OAuthConnections.Any( + x => x.OAuthConnections!.Any( y => y.Provider == oAuthProvider && y.ExternalUserId == externalUserId)); } else { - var canonicalUserName = Models.User.CanonicalizeName(ApiHeaders.Username); + var canonicalUserName = Models.User.CanonicalizeName(ApiHeaders.Username!); if (canonicalUserName == Models.User.CanonicalizeName(Models.User.TgsSystemUserName)) return Unauthorized(); diff --git a/src/Tgstation.Server.Host/Jobs/JobsHubGroupMapper.cs b/src/Tgstation.Server.Host/Jobs/JobsHubGroupMapper.cs index 6264c185d7..a961fbaef9 100644 --- a/src/Tgstation.Server.Host/Jobs/JobsHubGroupMapper.cs +++ b/src/Tgstation.Server.Host/Jobs/JobsHubGroupMapper.cs @@ -153,7 +153,7 @@ namespace Tgstation.Server.Host.Jobs logger.LogTrace("RefreshHubGroups"); var permissionSetUsers = await databaseContext .Users - .Where(x => x.PermissionSet.Id == permissionSetId) + .Where(x => x.PermissionSet!.Id == permissionSetId) .ToListAsync(cancellationToken); var allInstanceIds = await databaseContext .Instances diff --git a/src/Tgstation.Server.Host/Models/User.cs b/src/Tgstation.Server.Host/Models/User.cs index 4c4e2c03b0..0939dd8042 100644 --- a/src/Tgstation.Server.Host/Models/User.cs +++ b/src/Tgstation.Server.Host/Models/User.cs @@ -6,8 +6,6 @@ using System.Linq; using Tgstation.Server.Api.Models; using Tgstation.Server.Api.Models.Response; -#nullable disable - namespace Tgstation.Server.Host.Models { /// @@ -21,17 +19,17 @@ namespace Tgstation.Server.Host.Models /// /// The hash of the user's password. /// - public string PasswordHash { get; set; } + public string? PasswordHash { get; set; } /// /// See . /// - public User CreatedBy { get; set; } + public User? CreatedBy { get; set; } /// /// The the belongs to, if any. /// - public UserGroup Group { get; set; } + public UserGroup? Group { get; set; } /// /// The ID of the 's . @@ -41,14 +39,14 @@ namespace Tgstation.Server.Host.Models /// /// The the has, if any. /// - public PermissionSet PermissionSet { get; set; } + public PermissionSet? PermissionSet { get; set; } /// /// The uppercase invariant of . /// [Required] [StringLength(Limits.MaximumIndexableStringLength, MinimumLength = 1)] - public string CanonicalName { get; set; } + public string? CanonicalName { get; set; } /// /// When was last changed. @@ -58,17 +56,17 @@ namespace Tgstation.Server.Host.Models /// /// s created by this . /// - public ICollection CreatedUsers { get; set; } + public ICollection? CreatedUsers { get; set; } /// /// The s made by the . /// - public ICollection TestMerges { get; set; } + public ICollection? TestMerges { get; set; } /// /// The s made by the . /// - public ICollection OAuthConnections { get; set; } + public ICollection? OAuthConnections { get; set; } /// /// Change a into a . diff --git a/src/Tgstation.Server.Host/Security/AuthenticationContext.cs b/src/Tgstation.Server.Host/Security/AuthenticationContext.cs index c40d122743..61c6c36f44 100644 --- a/src/Tgstation.Server.Host/Security/AuthenticationContext.cs +++ b/src/Tgstation.Server.Host/Security/AuthenticationContext.cs @@ -56,7 +56,7 @@ namespace Tgstation.Server.Host.Security if (systemIdentity == null && User.SystemIdentifier != null) throw new ArgumentNullException(nameof(systemIdentity)); permissionSet = user.PermissionSet - ?? user.Group.PermissionSet + ?? user.Group!.PermissionSet ?? throw new ArgumentException("No PermissionSet provider", nameof(user)); InstancePermissionSet = instanceUser; SystemIdentity = systemIdentity; diff --git a/src/Tgstation.Server.Host/Security/AuthenticationContextFactory.cs b/src/Tgstation.Server.Host/Security/AuthenticationContextFactory.cs index 7fa7b2802f..ad9ecf014f 100644 --- a/src/Tgstation.Server.Host/Security/AuthenticationContextFactory.cs +++ b/src/Tgstation.Server.Host/Security/AuthenticationContextFactory.cs @@ -88,7 +88,7 @@ namespace Tgstation.Server.Host.Security .Include(x => x.CreatedBy) .Include(x => x.PermissionSet) .Include(x => x.Group) - .ThenInclude(x => x.PermissionSet) + .ThenInclude(x => x!.PermissionSet) .Include(x => x.OAuthConnections) .FirstOrDefaultAsync(cancellationToken); if (user == default) @@ -111,7 +111,7 @@ namespace Tgstation.Server.Host.Security systemIdentity = null; } - var userPermissionSet = user.PermissionSet ?? user.Group.PermissionSet; + var userPermissionSet = user.PermissionSet ?? user.Group!.PermissionSet; try { InstancePermissionSet? instancePermissionSet = null; diff --git a/src/Tgstation.Server.Host/Security/CryptographySuite.cs b/src/Tgstation.Server.Host/Security/CryptographySuite.cs index d98e61c303..6a401e7575 100644 --- a/src/Tgstation.Server.Host/Security/CryptographySuite.cs +++ b/src/Tgstation.Server.Host/Security/CryptographySuite.cs @@ -55,6 +55,9 @@ namespace Tgstation.Server.Host.Security ArgumentNullException.ThrowIfNull(user); ArgumentNullException.ThrowIfNull(password); + if (user.PasswordHash == null) + throw new ArgumentException("user must have PasswordHash!", nameof(user)); + var result = passwordHasher.VerifyHashedPassword(user, user.PasswordHash, password); switch (result) { From 3f0a5d0323e1f8c69bd2f9a0f3b4d0b621fed499 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Mon, 18 Dec 2023 22:50:54 -0500 Subject: [PATCH 248/425] Nullify `UserGroup` --- src/Tgstation.Server.Host/Models/UserGroup.cs | 11 +++++------ .../Security/AuthenticationContextFactory.cs | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/Tgstation.Server.Host/Models/UserGroup.cs b/src/Tgstation.Server.Host/Models/UserGroup.cs index 65c18474fa..4451c1a073 100644 --- a/src/Tgstation.Server.Host/Models/UserGroup.cs +++ b/src/Tgstation.Server.Host/Models/UserGroup.cs @@ -1,12 +1,11 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Linq; using Tgstation.Server.Api.Models; using Tgstation.Server.Api.Models.Response; -#nullable disable - namespace Tgstation.Server.Host.Models { /// @@ -18,12 +17,12 @@ namespace Tgstation.Server.Host.Models /// The the has. /// [Required] - public PermissionSet PermissionSet { get; set; } + public PermissionSet? PermissionSet { get; set; } /// /// The s the has. /// - public ICollection Users { get; set; } + public ICollection? Users { get; set; } /// /// Convert the to it's API form. @@ -34,7 +33,7 @@ namespace Tgstation.Server.Host.Models { Id = Id, Name = Name, - PermissionSet = PermissionSet.ToApi(), + PermissionSet = (PermissionSet ?? throw new InvalidOperationException("PermissionSet must be set!")).ToApi(), Users = showUsers ? Users ?.Select(x => x.CreateUserName()) diff --git a/src/Tgstation.Server.Host/Security/AuthenticationContextFactory.cs b/src/Tgstation.Server.Host/Security/AuthenticationContextFactory.cs index ad9ecf014f..80a9f1df92 100644 --- a/src/Tgstation.Server.Host/Security/AuthenticationContextFactory.cs +++ b/src/Tgstation.Server.Host/Security/AuthenticationContextFactory.cs @@ -119,7 +119,7 @@ namespace Tgstation.Server.Host.Security { instancePermissionSet = await databaseContext.InstancePermissionSets .AsQueryable() - .Where(x => x.PermissionSetId == userPermissionSet.Id && x.InstanceId == instanceId && x.Instance!.SwarmIdentifer == swarmConfiguration.Identifier) + .Where(x => x.PermissionSetId == userPermissionSet!.Id && x.InstanceId == instanceId && x.Instance!.SwarmIdentifer == swarmConfiguration.Identifier) .Include(x => x.Instance) .FirstOrDefaultAsync(cancellationToken); From 0159792cfe8649a57d96c4cb10750099342d88cd Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Mon, 18 Dec 2023 22:52:06 -0500 Subject: [PATCH 249/425] Remove an unused field --- .../Controllers/ApiRootController.cs | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/Tgstation.Server.Host/Controllers/ApiRootController.cs b/src/Tgstation.Server.Host/Controllers/ApiRootController.cs index 5248d3f313..061869345f 100644 --- a/src/Tgstation.Server.Host/Controllers/ApiRootController.cs +++ b/src/Tgstation.Server.Host/Controllers/ApiRootController.cs @@ -85,11 +85,6 @@ namespace Tgstation.Server.Host.Controllers /// readonly GeneralConfiguration generalConfiguration; - /// - /// The for the . - /// - readonly ControlPanelConfiguration controlPanelConfiguration; - /// /// Initializes a new instance of the class. /// @@ -105,7 +100,6 @@ namespace Tgstation.Server.Host.Controllers /// The value of . /// The value of . /// The containing the value of . - /// The containing the value of . /// The for the . /// The for the . public ApiRootController( @@ -121,7 +115,6 @@ namespace Tgstation.Server.Host.Controllers ISwarmService swarmService, IServerControl serverControl, IOptions generalConfigurationOptions, - IOptions controlPanelConfigurationOptions, ILogger logger, IApiHeadersProvider apiHeadersProvider) : base( @@ -141,7 +134,6 @@ namespace Tgstation.Server.Host.Controllers this.swarmService = swarmService ?? throw new ArgumentNullException(nameof(swarmService)); this.serverControl = serverControl ?? throw new ArgumentNullException(nameof(serverControl)); generalConfiguration = generalConfigurationOptions?.Value ?? throw new ArgumentNullException(nameof(generalConfigurationOptions)); - controlPanelConfiguration = controlPanelConfigurationOptions?.Value ?? throw new ArgumentNullException(nameof(controlPanelConfigurationOptions)); } /// From 63465d23cddc3c348dc4d24c7cd3ec4949ff77c8 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Mon, 18 Dec 2023 22:52:34 -0500 Subject: [PATCH 250/425] Cleanup a VS IDE message --- src/Tgstation.Server.Host/Controllers/ApiRootController.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Tgstation.Server.Host/Controllers/ApiRootController.cs b/src/Tgstation.Server.Host/Controllers/ApiRootController.cs index 061869345f..fa6b3e0c4b 100644 --- a/src/Tgstation.Server.Host/Controllers/ApiRootController.cs +++ b/src/Tgstation.Server.Host/Controllers/ApiRootController.cs @@ -162,7 +162,7 @@ namespace Tgstation.Server.Host.Controllers return HeadersIssue(ex); } - failIfUnauthed = Request.Headers.Authorization.Any(); + failIfUnauthed = Request.Headers.Authorization.Count > 0; } else failIfUnauthed = ApiHeaders.Token != null; From d0bf6eb086822ab74cb08c9644b8a2977b53c0ba Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Mon, 18 Dec 2023 22:53:04 -0500 Subject: [PATCH 251/425] Simplify a null check --- src/Tgstation.Server.Host/Security/AuthenticationContext.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Tgstation.Server.Host/Security/AuthenticationContext.cs b/src/Tgstation.Server.Host/Security/AuthenticationContext.cs index 61c6c36f44..53bf23c2a2 100644 --- a/src/Tgstation.Server.Host/Security/AuthenticationContext.cs +++ b/src/Tgstation.Server.Host/Security/AuthenticationContext.cs @@ -88,10 +88,8 @@ namespace Tgstation.Server.Host.Security isInstance ? InstancePermissionSet : PermissionSet, - Array.Empty()); - - if (right == null) - throw new InvalidOperationException("A user right was null!"); + Array.Empty()) + ?? throw new InvalidOperationException("A user right was null!"); return (ulong)right; } From b06be253decdfade9f72b14dcbf90f9a78ec2621 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Tue, 19 Dec 2023 09:20:01 -0500 Subject: [PATCH 252/425] Nullify `IRestartRegistration` --- src/Tgstation.Server.Host/Core/IRestartRegistration.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Core/IRestartRegistration.cs b/src/Tgstation.Server.Host/Core/IRestartRegistration.cs index ee2ddc7ddf..586d73f004 100644 --- a/src/Tgstation.Server.Host/Core/IRestartRegistration.cs +++ b/src/Tgstation.Server.Host/Core/IRestartRegistration.cs @@ -1,7 +1,5 @@ using System; -#nullable disable - namespace Tgstation.Server.Host.Core { /// From d58ef02d31a7b5332eb614752f2d18d55e464004 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Tue, 19 Dec 2023 22:24:32 -0500 Subject: [PATCH 253/425] This property is meant to be nullable --- .../Components/Deployment/DreamMaker.cs | 3 ++- src/Tgstation.Server.Host/Models/CompileJob.cs | 16 ++++++---------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Deployment/DreamMaker.cs b/src/Tgstation.Server.Host/Components/Deployment/DreamMaker.cs index 255c07dd54..89f69f7d7b 100644 --- a/src/Tgstation.Server.Host/Components/Deployment/DreamMaker.cs +++ b/src/Tgstation.Server.Host/Components/Deployment/DreamMaker.cs @@ -488,10 +488,11 @@ namespace Tgstation.Server.Host.Components.Deployment repository.RemoteRepositoryName, localCommitExistsOnRemote); - var compileJob = new Models.CompileJob(job, revisionInformation, engineLock.Version.ToString(), repository.Origin.ToString()) + var compileJob = new Models.CompileJob(job, revisionInformation, engineLock.Version.ToString()) { DirectoryName = Guid.NewGuid(), DmeName = dreamMakerSettings.ProjectName, + RepositoryOrigin = repository.Origin.ToString(), }; progressReporter.StageName = "Creating remote deployment notification"; diff --git a/src/Tgstation.Server.Host/Models/CompileJob.cs b/src/Tgstation.Server.Host/Models/CompileJob.cs index ea729e9217..0f75b830e7 100644 --- a/src/Tgstation.Server.Host/Models/CompileJob.cs +++ b/src/Tgstation.Server.Host/Models/CompileJob.cs @@ -50,7 +50,7 @@ namespace Tgstation.Server.Host.Models /// /// The origin of the repository the compile job was built from. /// - public string RepositoryOrigin { get; set; } + public string? RepositoryOrigin { get; set; } /// /// The source GitHub repository the deployment came from if any. @@ -86,7 +86,7 @@ namespace Tgstation.Server.Host.Models /// [Obsolete("For use by EFCore only", true)] public CompileJob() - : this(null!, null!, null!, null!, false) + : this(null!, null!, null!, false) { } @@ -96,9 +96,8 @@ namespace Tgstation.Server.Host.Models /// The value of . /// The value of . /// The value of . - /// The value of . - public CompileJob(Job job, RevisionInformation revisionInformation, string engineVersion, string repositoryOrigin) - : this(job, revisionInformation, engineVersion, repositoryOrigin, true) + public CompileJob(Job job, RevisionInformation revisionInformation, string engineVersion) + : this(job, revisionInformation, engineVersion, true) { } @@ -108,22 +107,19 @@ namespace Tgstation.Server.Host.Models /// The value of . /// The value of . /// The value of . - /// The value of . - /// If , , and should be checked for nulls. - CompileJob(Job job, RevisionInformation revisionInformation, string engineVersion, string repositoryOrigin, bool nullChecks) + /// If , , and should be checked for nulls. + CompileJob(Job job, RevisionInformation revisionInformation, string engineVersion, bool nullChecks) { if (nullChecks) { ArgumentNullException.ThrowIfNull(job); ArgumentNullException.ThrowIfNull(revisionInformation); ArgumentNullException.ThrowIfNull(engineVersion); - ArgumentNullException.ThrowIfNull(repositoryOrigin); } Job = job; RevisionInformation = revisionInformation; EngineVersion = engineVersion; - RepositoryOrigin = repositoryOrigin; } /// From 0df55f772ba0024ade9d695f5786921e6a63084b Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Tue, 19 Dec 2023 23:12:52 -0500 Subject: [PATCH 254/425] Add separate database field for topic port --- .../Components/Session/SessionController.cs | 6 +- .../Database/DatabaseContext.cs | 8 +- .../20231220032508_MSAddTopicPort.Designer.cs | 1076 ++++++++++++++++ .../20231220032508_MSAddTopicPort.cs | 32 + .../20231220032515_MYAddTopicPort.Designer.cs | 1110 +++++++++++++++++ .../20231220032515_MYAddTopicPort.cs | 32 + .../20231220032521_PGAddTopicPort.Designer.cs | 1070 ++++++++++++++++ .../20231220032521_PGAddTopicPort.cs | 32 + .../20231220032528_SLAddTopicPort.Designer.cs | 1042 ++++++++++++++++ .../20231220032528_SLAddTopicPort.cs | 32 + .../MySqlDatabaseContextModelSnapshot.cs | 20 +- ...PostgresSqlDatabaseContextModelSnapshot.cs | 18 +- .../SqlServerDatabaseContextModelSnapshot.cs | 18 +- .../SqliteDatabaseContextModelSnapshot.cs | 16 +- .../Models/ReattachInformationBase.cs | 8 +- 15 files changed, 4480 insertions(+), 40 deletions(-) create mode 100644 src/Tgstation.Server.Host/Database/Migrations/20231220032508_MSAddTopicPort.Designer.cs create mode 100644 src/Tgstation.Server.Host/Database/Migrations/20231220032508_MSAddTopicPort.cs create mode 100644 src/Tgstation.Server.Host/Database/Migrations/20231220032515_MYAddTopicPort.Designer.cs create mode 100644 src/Tgstation.Server.Host/Database/Migrations/20231220032515_MYAddTopicPort.cs create mode 100644 src/Tgstation.Server.Host/Database/Migrations/20231220032521_PGAddTopicPort.Designer.cs create mode 100644 src/Tgstation.Server.Host/Database/Migrations/20231220032521_PGAddTopicPort.cs create mode 100644 src/Tgstation.Server.Host/Database/Migrations/20231220032528_SLAddTopicPort.Designer.cs create mode 100644 src/Tgstation.Server.Host/Database/Migrations/20231220032528_SLAddTopicPort.cs diff --git a/src/Tgstation.Server.Host/Components/Session/SessionController.cs b/src/Tgstation.Server.Host/Components/Session/SessionController.cs index 5a5c5d909c..56ef1416c2 100644 --- a/src/Tgstation.Server.Host/Components/Session/SessionController.cs +++ b/src/Tgstation.Server.Host/Components/Session/SessionController.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Globalization; using System.Linq; @@ -679,7 +679,7 @@ namespace Tgstation.Server.Host.Components.Session { var newTopicPort = parameters.TopicPort.Value; Logger.LogInformation("Server is requesting use of port {topicPort} for topic communications", newTopicPort); - ReattachInformation.Port = newTopicPort; + ReattachInformation.TopicPort = newTopicPort; } // Load custom commands @@ -885,7 +885,7 @@ namespace Tgstation.Server.Host.Components.Session return null; } - var targetPort = ReattachInformation.Port; + var targetPort = ReattachInformation.TopicPort ?? ReattachInformation.Port; Byond.TopicSender.TopicResponse byondResponse; using (await TopicSendSemaphore.Lock(cancellationToken)) byondResponse = await byondTopicSender.SendWithOptionalPriority( diff --git a/src/Tgstation.Server.Host/Database/DatabaseContext.cs b/src/Tgstation.Server.Host/Database/DatabaseContext.cs index ec2095d274..978a73076b 100644 --- a/src/Tgstation.Server.Host/Database/DatabaseContext.cs +++ b/src/Tgstation.Server.Host/Database/DatabaseContext.cs @@ -375,22 +375,22 @@ namespace Tgstation.Server.Host.Database /// /// Used by unit tests to remind us to setup the correct MSSQL migration downgrades. /// - internal static readonly Type MSLatestMigration = typeof(MSRenameByondColumnsToEngine); + internal static readonly Type MSLatestMigration = typeof(MSAddTopicPort); /// /// Used by unit tests to remind us to setup the correct MYSQL migration downgrades. /// - internal static readonly Type MYLatestMigration = typeof(MYRenameByondColumnsToEngine); + internal static readonly Type MYLatestMigration = typeof(MYAddTopicPort); /// /// Used by unit tests to remind us to setup the correct PostgresSQL migration downgrades. /// - internal static readonly Type PGLatestMigration = typeof(PGRenameByondColumnsToEngine); + internal static readonly Type PGLatestMigration = typeof(PGAddTopicPort); /// /// Used by unit tests to remind us to setup the correct SQLite migration downgrades. /// - internal static readonly Type SLLatestMigration = typeof(SLRenameByondColumnsToEngine); + internal static readonly Type SLLatestMigration = typeof(SLAddTopicPort); /// #pragma warning disable CA1502 // Cyclomatic complexity diff --git a/src/Tgstation.Server.Host/Database/Migrations/20231220032508_MSAddTopicPort.Designer.cs b/src/Tgstation.Server.Host/Database/Migrations/20231220032508_MSAddTopicPort.Designer.cs new file mode 100644 index 0000000000..39d9629c7c --- /dev/null +++ b/src/Tgstation.Server.Host/Database/Migrations/20231220032508_MSAddTopicPort.Designer.cs @@ -0,0 +1,1076 @@ +// +using System; + +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; + +namespace Tgstation.Server.Host.Database.Migrations +{ + [DbContext(typeof(SqlServerDatabaseContext))] + [Migration("20231220032508_MSAddTopicPort")] + partial class MSAddTopicPort + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.0") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); + + modelBuilder.Entity("Tgstation.Server.Host.Models.ChatBot", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ChannelLimit") + .HasColumnType("int"); + + b.Property("ConnectionString") + .IsRequired() + .HasMaxLength(10000) + .HasColumnType("nvarchar(max)"); + + b.Property("Enabled") + .HasColumnType("bit"); + + b.Property("InstanceId") + .HasColumnType("bigint"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Provider") + .HasColumnType("int"); + + b.Property("ReconnectionInterval") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("InstanceId", "Name") + .IsUnique(); + + b.ToTable("ChatBots"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.ChatChannel", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ChatSettingsId") + .HasColumnType("bigint"); + + b.Property("DiscordChannelId") + .HasColumnType("decimal(20,0)"); + + b.Property("IrcChannel") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("IsAdminChannel") + .IsRequired() + .HasColumnType("bit"); + + b.Property("IsSystemChannel") + .IsRequired() + .HasColumnType("bit"); + + b.Property("IsUpdatesChannel") + .IsRequired() + .HasColumnType("bit"); + + b.Property("IsWatchdogChannel") + .IsRequired() + .HasColumnType("bit"); + + b.Property("Tag") + .HasMaxLength(10000) + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("ChatSettingsId", "DiscordChannelId") + .IsUnique() + .HasFilter("[DiscordChannelId] IS NOT NULL"); + + b.HasIndex("ChatSettingsId", "IrcChannel") + .IsUnique() + .HasFilter("[IrcChannel] IS NOT NULL"); + + b.ToTable("ChatChannels"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.CompileJob", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("DMApiMajorVersion") + .HasColumnType("int"); + + b.Property("DMApiMinorVersion") + .HasColumnType("int"); + + b.Property("DMApiPatchVersion") + .HasColumnType("int"); + + b.Property("DirectoryName") + .IsRequired() + .HasColumnType("uniqueidentifier"); + + b.Property("DmeName") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("EngineVersion") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("GitHubDeploymentId") + .HasColumnType("int"); + + b.Property("GitHubRepoId") + .HasColumnType("bigint"); + + b.Property("JobId") + .HasColumnType("bigint"); + + b.Property("MinimumSecurityLevel") + .HasColumnType("int"); + + b.Property("Output") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("RepositoryOrigin") + .HasColumnType("nvarchar(max)"); + + b.Property("RevisionInformationId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("DirectoryName"); + + b.HasIndex("JobId") + .IsUnique(); + + b.HasIndex("RevisionInformationId"); + + b.ToTable("CompileJobs"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.DreamDaemonSettings", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("AdditionalParameters") + .IsRequired() + .HasMaxLength(10000) + .HasColumnType("nvarchar(max)"); + + b.Property("AllowWebClient") + .IsRequired() + .HasColumnType("bit"); + + b.Property("AutoStart") + .IsRequired() + .HasColumnType("bit"); + + b.Property("DumpOnHealthCheckRestart") + .IsRequired() + .HasColumnType("bit"); + + b.Property("HealthCheckSeconds") + .HasColumnType("bigint"); + + b.Property("InstanceId") + .HasColumnType("bigint"); + + b.Property("LogOutput") + .IsRequired() + .HasColumnType("bit"); + + b.Property("MapThreads") + .HasColumnType("bigint"); + + b.Property("Port") + .HasColumnType("int"); + + b.Property("SecurityLevel") + .HasColumnType("int"); + + b.Property("StartProfiler") + .IsRequired() + .HasColumnType("bit"); + + b.Property("StartupTimeout") + .HasColumnType("bigint"); + + b.Property("TopicRequestTimeout") + .HasColumnType("bigint"); + + b.Property("Visibility") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("InstanceId") + .IsUnique(); + + b.ToTable("DreamDaemonSettings"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.DreamMakerSettings", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ApiValidationPort") + .HasColumnType("int"); + + b.Property("ApiValidationSecurityLevel") + .HasColumnType("int"); + + b.Property("InstanceId") + .HasColumnType("bigint"); + + b.Property("ProjectName") + .HasMaxLength(10000) + .HasColumnType("nvarchar(max)"); + + b.Property("RequireDMApiValidation") + .IsRequired() + .HasColumnType("bit"); + + b.Property("Timeout") + .IsRequired() + .HasColumnType("time"); + + b.HasKey("Id"); + + b.HasIndex("InstanceId") + .IsUnique(); + + b.ToTable("DreamMakerSettings"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.Instance", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("AutoUpdateInterval") + .HasColumnType("bigint"); + + b.Property("ChatBotLimit") + .HasColumnType("int"); + + b.Property("ConfigurationType") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Online") + .IsRequired() + .HasColumnType("bit"); + + b.Property("Path") + .IsRequired() + .HasColumnType("nvarchar(450)"); + + b.Property("SwarmIdentifer") + .HasColumnType("nvarchar(450)"); + + b.HasKey("Id"); + + b.HasIndex("Path", "SwarmIdentifer") + .IsUnique() + .HasFilter("[SwarmIdentifer] IS NOT NULL"); + + b.ToTable("Instances"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.InstancePermissionSet", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ChatBotRights") + .HasColumnType("decimal(20,0)"); + + b.Property("ConfigurationRights") + .HasColumnType("decimal(20,0)"); + + b.Property("DreamDaemonRights") + .HasColumnType("decimal(20,0)"); + + b.Property("DreamMakerRights") + .HasColumnType("decimal(20,0)"); + + b.Property("EngineRights") + .HasColumnType("decimal(20,0)"); + + b.Property("InstanceId") + .HasColumnType("bigint"); + + b.Property("InstancePermissionSetRights") + .HasColumnType("decimal(20,0)"); + + b.Property("PermissionSetId") + .HasColumnType("bigint"); + + b.Property("RepositoryRights") + .HasColumnType("decimal(20,0)"); + + b.HasKey("Id"); + + b.HasIndex("InstanceId"); + + b.HasIndex("PermissionSetId", "InstanceId") + .IsUnique(); + + b.ToTable("InstancePermissionSets"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.Job", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CancelRight") + .HasColumnType("decimal(20,0)"); + + b.Property("CancelRightsType") + .HasColumnType("decimal(20,0)"); + + b.Property("Cancelled") + .IsRequired() + .HasColumnType("bit"); + + b.Property("CancelledById") + .HasColumnType("bigint"); + + b.Property("Description") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("ErrorCode") + .HasColumnType("bigint"); + + b.Property("ExceptionDetails") + .HasColumnType("nvarchar(max)"); + + b.Property("InstanceId") + .HasColumnType("bigint"); + + b.Property("JobCode") + .HasColumnType("tinyint"); + + b.Property("StartedAt") + .IsRequired() + .HasColumnType("datetimeoffset"); + + b.Property("StartedById") + .HasColumnType("bigint"); + + b.Property("StoppedAt") + .HasColumnType("datetimeoffset"); + + b.HasKey("Id"); + + b.HasIndex("CancelledById"); + + b.HasIndex("InstanceId"); + + b.HasIndex("StartedById"); + + b.ToTable("Jobs"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.OAuthConnection", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("ExternalUserId") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("Provider") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.HasIndex("Provider", "ExternalUserId") + .IsUnique(); + + b.ToTable("OAuthConnections"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.PermissionSet", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("AdministrationRights") + .HasColumnType("decimal(20,0)"); + + b.Property("GroupId") + .HasColumnType("bigint"); + + b.Property("InstanceManagerRights") + .HasColumnType("decimal(20,0)"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("GroupId") + .IsUnique() + .HasFilter("[GroupId] IS NOT NULL"); + + b.HasIndex("UserId") + .IsUnique() + .HasFilter("[UserId] IS NOT NULL"); + + b.ToTable("PermissionSets"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.ReattachInformation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("AccessIdentifier") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("CompileJobId") + .HasColumnType("bigint"); + + b.Property("InitialCompileJobId") + .HasColumnType("bigint"); + + b.Property("LaunchSecurityLevel") + .HasColumnType("int"); + + b.Property("LaunchVisibility") + .HasColumnType("int"); + + b.Property("Port") + .HasColumnType("int"); + + b.Property("ProcessId") + .HasColumnType("int"); + + b.Property("RebootState") + .HasColumnType("int"); + + b.Property("TopicPort") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("CompileJobId"); + + b.HasIndex("InitialCompileJobId"); + + b.ToTable("ReattachInformations"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.RepositorySettings", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("AccessToken") + .HasMaxLength(10000) + .HasColumnType("nvarchar(max)"); + + b.Property("AccessUser") + .HasMaxLength(10000) + .HasColumnType("nvarchar(max)"); + + b.Property("AutoUpdatesKeepTestMerges") + .IsRequired() + .HasColumnType("bit"); + + b.Property("AutoUpdatesSynchronize") + .IsRequired() + .HasColumnType("bit"); + + b.Property("CommitterEmail") + .IsRequired() + .HasMaxLength(10000) + .HasColumnType("nvarchar(max)"); + + b.Property("CommitterName") + .IsRequired() + .HasMaxLength(10000) + .HasColumnType("nvarchar(max)"); + + b.Property("CreateGitHubDeployments") + .IsRequired() + .HasColumnType("bit"); + + b.Property("InstanceId") + .HasColumnType("bigint"); + + b.Property("PostTestMergeComment") + .IsRequired() + .HasColumnType("bit"); + + b.Property("PushTestMergeCommits") + .IsRequired() + .HasColumnType("bit"); + + b.Property("ShowTestMergeCommitters") + .IsRequired() + .HasColumnType("bit"); + + b.Property("UpdateSubmodules") + .IsRequired() + .HasColumnType("bit"); + + b.HasKey("Id"); + + b.HasIndex("InstanceId") + .IsUnique(); + + b.ToTable("RepositorySettings"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.RevInfoTestMerge", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("RevisionInformationId") + .HasColumnType("bigint"); + + b.Property("TestMergeId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("RevisionInformationId"); + + b.HasIndex("TestMergeId"); + + b.ToTable("RevInfoTestMerges"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.RevisionInformation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CommitSha") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("nvarchar(40)"); + + b.Property("InstanceId") + .HasColumnType("bigint"); + + b.Property("OriginCommitSha") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("nvarchar(40)"); + + b.Property("Timestamp") + .HasColumnType("datetimeoffset"); + + b.HasKey("Id"); + + b.HasIndex("InstanceId", "CommitSha") + .IsUnique(); + + b.ToTable("RevisionInformations"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.TestMerge", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Author") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("BodyAtMerge") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Comment") + .HasMaxLength(10000) + .HasColumnType("nvarchar(max)"); + + b.Property("MergedAt") + .HasColumnType("datetimeoffset"); + + b.Property("MergedById") + .HasColumnType("bigint"); + + b.Property("Number") + .HasColumnType("int"); + + b.Property("PrimaryRevisionInformationId") + .IsRequired() + .HasColumnType("bigint"); + + b.Property("TargetCommitSha") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("nvarchar(40)"); + + b.Property("TitleAtMerge") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.Property("Url") + .IsRequired() + .HasColumnType("nvarchar(max)"); + + b.HasKey("Id"); + + b.HasIndex("MergedById"); + + b.HasIndex("PrimaryRevisionInformationId") + .IsUnique(); + + b.ToTable("TestMerges"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("CanonicalName") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("CreatedAt") + .IsRequired() + .HasColumnType("datetimeoffset"); + + b.Property("CreatedById") + .HasColumnType("bigint"); + + b.Property("Enabled") + .IsRequired() + .HasColumnType("bit"); + + b.Property("GroupId") + .HasColumnType("bigint"); + + b.Property("LastPasswordUpdate") + .HasColumnType("datetimeoffset"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("PasswordHash") + .HasColumnType("nvarchar(max)"); + + b.Property("SystemIdentifier") + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("Id"); + + b.HasIndex("CanonicalName") + .IsUnique(); + + b.HasIndex("CreatedById"); + + b.HasIndex("GroupId"); + + b.HasIndex("SystemIdentifier") + .IsUnique() + .HasFilter("[SystemIdentifier] IS NOT NULL"); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.UserGroup", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("Id"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("Groups"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.ChatBot", b => + { + b.HasOne("Tgstation.Server.Host.Models.Instance", "Instance") + .WithMany("ChatSettings") + .HasForeignKey("InstanceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Instance"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.ChatChannel", b => + { + b.HasOne("Tgstation.Server.Host.Models.ChatBot", "ChatSettings") + .WithMany("Channels") + .HasForeignKey("ChatSettingsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ChatSettings"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.CompileJob", b => + { + b.HasOne("Tgstation.Server.Host.Models.Job", "Job") + .WithOne() + .HasForeignKey("Tgstation.Server.Host.Models.CompileJob", "JobId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tgstation.Server.Host.Models.RevisionInformation", "RevisionInformation") + .WithMany("CompileJobs") + .HasForeignKey("RevisionInformationId") + .OnDelete(DeleteBehavior.ClientNoAction) + .IsRequired(); + + b.Navigation("Job"); + + b.Navigation("RevisionInformation"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.DreamDaemonSettings", b => + { + b.HasOne("Tgstation.Server.Host.Models.Instance", "Instance") + .WithOne("DreamDaemonSettings") + .HasForeignKey("Tgstation.Server.Host.Models.DreamDaemonSettings", "InstanceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Instance"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.DreamMakerSettings", b => + { + b.HasOne("Tgstation.Server.Host.Models.Instance", "Instance") + .WithOne("DreamMakerSettings") + .HasForeignKey("Tgstation.Server.Host.Models.DreamMakerSettings", "InstanceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Instance"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.InstancePermissionSet", b => + { + b.HasOne("Tgstation.Server.Host.Models.Instance", "Instance") + .WithMany("InstancePermissionSets") + .HasForeignKey("InstanceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tgstation.Server.Host.Models.PermissionSet", "PermissionSet") + .WithMany("InstancePermissionSets") + .HasForeignKey("PermissionSetId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Instance"); + + b.Navigation("PermissionSet"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.Job", b => + { + b.HasOne("Tgstation.Server.Host.Models.User", "CancelledBy") + .WithMany() + .HasForeignKey("CancelledById"); + + b.HasOne("Tgstation.Server.Host.Models.Instance", "Instance") + .WithMany("Jobs") + .HasForeignKey("InstanceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tgstation.Server.Host.Models.User", "StartedBy") + .WithMany() + .HasForeignKey("StartedById") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CancelledBy"); + + b.Navigation("Instance"); + + b.Navigation("StartedBy"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.OAuthConnection", b => + { + b.HasOne("Tgstation.Server.Host.Models.User", "User") + .WithMany("OAuthConnections") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.PermissionSet", b => + { + b.HasOne("Tgstation.Server.Host.Models.UserGroup", "Group") + .WithOne("PermissionSet") + .HasForeignKey("Tgstation.Server.Host.Models.PermissionSet", "GroupId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("Tgstation.Server.Host.Models.User", "User") + .WithOne("PermissionSet") + .HasForeignKey("Tgstation.Server.Host.Models.PermissionSet", "UserId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("Group"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.ReattachInformation", b => + { + b.HasOne("Tgstation.Server.Host.Models.CompileJob", "CompileJob") + .WithMany() + .HasForeignKey("CompileJobId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tgstation.Server.Host.Models.CompileJob", "InitialCompileJob") + .WithMany() + .HasForeignKey("InitialCompileJobId"); + + b.Navigation("CompileJob"); + + b.Navigation("InitialCompileJob"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.RepositorySettings", b => + { + b.HasOne("Tgstation.Server.Host.Models.Instance", "Instance") + .WithOne("RepositorySettings") + .HasForeignKey("Tgstation.Server.Host.Models.RepositorySettings", "InstanceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Instance"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.RevInfoTestMerge", b => + { + b.HasOne("Tgstation.Server.Host.Models.RevisionInformation", "RevisionInformation") + .WithMany("ActiveTestMerges") + .HasForeignKey("RevisionInformationId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tgstation.Server.Host.Models.TestMerge", "TestMerge") + .WithMany("RevisonInformations") + .HasForeignKey("TestMergeId") + .OnDelete(DeleteBehavior.ClientNoAction) + .IsRequired(); + + b.Navigation("RevisionInformation"); + + b.Navigation("TestMerge"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.RevisionInformation", b => + { + b.HasOne("Tgstation.Server.Host.Models.Instance", "Instance") + .WithMany("RevisionInformations") + .HasForeignKey("InstanceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Instance"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.TestMerge", b => + { + b.HasOne("Tgstation.Server.Host.Models.User", "MergedBy") + .WithMany("TestMerges") + .HasForeignKey("MergedById") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Tgstation.Server.Host.Models.RevisionInformation", "PrimaryRevisionInformation") + .WithOne("PrimaryTestMerge") + .HasForeignKey("Tgstation.Server.Host.Models.TestMerge", "PrimaryRevisionInformationId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("MergedBy"); + + b.Navigation("PrimaryRevisionInformation"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.User", b => + { + b.HasOne("Tgstation.Server.Host.Models.User", "CreatedBy") + .WithMany("CreatedUsers") + .HasForeignKey("CreatedById"); + + b.HasOne("Tgstation.Server.Host.Models.UserGroup", "Group") + .WithMany("Users") + .HasForeignKey("GroupId"); + + b.Navigation("CreatedBy"); + + b.Navigation("Group"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.ChatBot", b => + { + b.Navigation("Channels"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.Instance", b => + { + b.Navigation("ChatSettings"); + + b.Navigation("DreamDaemonSettings"); + + b.Navigation("DreamMakerSettings"); + + b.Navigation("InstancePermissionSets"); + + b.Navigation("Jobs"); + + b.Navigation("RepositorySettings"); + + b.Navigation("RevisionInformations"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.PermissionSet", b => + { + b.Navigation("InstancePermissionSets"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.RevisionInformation", b => + { + b.Navigation("ActiveTestMerges"); + + b.Navigation("CompileJobs"); + + b.Navigation("PrimaryTestMerge"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.TestMerge", b => + { + b.Navigation("RevisonInformations"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.User", b => + { + b.Navigation("CreatedUsers"); + + b.Navigation("OAuthConnections"); + + b.Navigation("PermissionSet"); + + b.Navigation("TestMerges"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.UserGroup", b => + { + b.Navigation("PermissionSet") + .IsRequired(); + + b.Navigation("Users"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/Tgstation.Server.Host/Database/Migrations/20231220032508_MSAddTopicPort.cs b/src/Tgstation.Server.Host/Database/Migrations/20231220032508_MSAddTopicPort.cs new file mode 100644 index 0000000000..2c1754e5f1 --- /dev/null +++ b/src/Tgstation.Server.Host/Database/Migrations/20231220032508_MSAddTopicPort.cs @@ -0,0 +1,32 @@ +using System; + +using Microsoft.EntityFrameworkCore.Migrations; + +namespace Tgstation.Server.Host.Database.Migrations +{ + /// + public partial class MSAddTopicPort : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + ArgumentNullException.ThrowIfNull(migrationBuilder); + + migrationBuilder.AddColumn( + name: "TopicPort", + table: "ReattachInformations", + type: "int", + nullable: true); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + ArgumentNullException.ThrowIfNull(migrationBuilder); + + migrationBuilder.DropColumn( + name: "TopicPort", + table: "ReattachInformations"); + } + } +} diff --git a/src/Tgstation.Server.Host/Database/Migrations/20231220032515_MYAddTopicPort.Designer.cs b/src/Tgstation.Server.Host/Database/Migrations/20231220032515_MYAddTopicPort.Designer.cs new file mode 100644 index 0000000000..593d5f4db2 --- /dev/null +++ b/src/Tgstation.Server.Host/Database/Migrations/20231220032515_MYAddTopicPort.Designer.cs @@ -0,0 +1,1110 @@ +// +using System; + +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; + +namespace Tgstation.Server.Host.Database.Migrations +{ + [DbContext(typeof(MySqlDatabaseContext))] + [Migration("20231220032515_MYAddTopicPort")] + partial class MYAddTopicPort + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.0") + .HasAnnotation("Relational:MaxIdentifierLength", 64); + + modelBuilder.Entity("Tgstation.Server.Host.Models.ChatBot", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChannelLimit") + .IsRequired() + .HasColumnType("smallint unsigned"); + + b.Property("ConnectionString") + .IsRequired() + .HasMaxLength(10000) + .HasColumnType("longtext"); + + MySqlPropertyBuilderExtensions.HasCharSet(b.Property("ConnectionString"), "utf8mb4"); + + b.Property("Enabled") + .HasColumnType("tinyint(1)"); + + b.Property("InstanceId") + .HasColumnType("bigint"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + b.Property("Provider") + .HasColumnType("int"); + + b.Property("ReconnectionInterval") + .IsRequired() + .HasColumnType("int unsigned"); + + b.HasKey("Id"); + + b.HasIndex("InstanceId", "Name") + .IsUnique(); + + b.ToTable("ChatBots"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.ChatChannel", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChatSettingsId") + .HasColumnType("bigint"); + + b.Property("DiscordChannelId") + .HasColumnType("bigint unsigned"); + + b.Property("IrcChannel") + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + MySqlPropertyBuilderExtensions.HasCharSet(b.Property("IrcChannel"), "utf8mb4"); + + b.Property("IsAdminChannel") + .IsRequired() + .HasColumnType("tinyint(1)"); + + b.Property("IsSystemChannel") + .IsRequired() + .HasColumnType("tinyint(1)"); + + b.Property("IsUpdatesChannel") + .IsRequired() + .HasColumnType("tinyint(1)"); + + b.Property("IsWatchdogChannel") + .IsRequired() + .HasColumnType("tinyint(1)"); + + b.Property("Tag") + .HasMaxLength(10000) + .HasColumnType("longtext"); + + MySqlPropertyBuilderExtensions.HasCharSet(b.Property("Tag"), "utf8mb4"); + + b.HasKey("Id"); + + b.HasIndex("ChatSettingsId", "DiscordChannelId") + .IsUnique(); + + b.HasIndex("ChatSettingsId", "IrcChannel") + .IsUnique(); + + b.ToTable("ChatChannels"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.CompileJob", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("DMApiMajorVersion") + .HasColumnType("int"); + + b.Property("DMApiMinorVersion") + .HasColumnType("int"); + + b.Property("DMApiPatchVersion") + .HasColumnType("int"); + + b.Property("DirectoryName") + .IsRequired() + .HasColumnType("char(36)"); + + b.Property("DmeName") + .IsRequired() + .HasColumnType("longtext"); + + MySqlPropertyBuilderExtensions.HasCharSet(b.Property("DmeName"), "utf8mb4"); + + b.Property("EngineVersion") + .IsRequired() + .HasColumnType("longtext"); + + MySqlPropertyBuilderExtensions.HasCharSet(b.Property("EngineVersion"), "utf8mb4"); + + b.Property("GitHubDeploymentId") + .HasColumnType("int"); + + b.Property("GitHubRepoId") + .HasColumnType("bigint"); + + b.Property("JobId") + .HasColumnType("bigint"); + + b.Property("MinimumSecurityLevel") + .HasColumnType("int"); + + b.Property("Output") + .IsRequired() + .HasColumnType("longtext"); + + MySqlPropertyBuilderExtensions.HasCharSet(b.Property("Output"), "utf8mb4"); + + b.Property("RepositoryOrigin") + .HasColumnType("longtext"); + + MySqlPropertyBuilderExtensions.HasCharSet(b.Property("RepositoryOrigin"), "utf8mb4"); + + b.Property("RevisionInformationId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("DirectoryName"); + + b.HasIndex("JobId") + .IsUnique(); + + b.HasIndex("RevisionInformationId"); + + b.ToTable("CompileJobs"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.DreamDaemonSettings", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AdditionalParameters") + .IsRequired() + .HasMaxLength(10000) + .HasColumnType("longtext"); + + MySqlPropertyBuilderExtensions.HasCharSet(b.Property("AdditionalParameters"), "utf8mb4"); + + b.Property("AllowWebClient") + .IsRequired() + .HasColumnType("tinyint(1)"); + + b.Property("AutoStart") + .IsRequired() + .HasColumnType("tinyint(1)"); + + b.Property("DumpOnHealthCheckRestart") + .IsRequired() + .HasColumnType("tinyint(1)"); + + b.Property("HealthCheckSeconds") + .IsRequired() + .HasColumnType("int unsigned"); + + b.Property("InstanceId") + .HasColumnType("bigint"); + + b.Property("LogOutput") + .IsRequired() + .HasColumnType("tinyint(1)"); + + b.Property("MapThreads") + .IsRequired() + .HasColumnType("int unsigned"); + + b.Property("Port") + .IsRequired() + .HasColumnType("smallint unsigned"); + + b.Property("SecurityLevel") + .HasColumnType("int"); + + b.Property("StartProfiler") + .IsRequired() + .HasColumnType("tinyint(1)"); + + b.Property("StartupTimeout") + .IsRequired() + .HasColumnType("int unsigned"); + + b.Property("TopicRequestTimeout") + .IsRequired() + .HasColumnType("int unsigned"); + + b.Property("Visibility") + .HasColumnType("int"); + + b.HasKey("Id"); + + b.HasIndex("InstanceId") + .IsUnique(); + + b.ToTable("DreamDaemonSettings"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.DreamMakerSettings", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ApiValidationPort") + .IsRequired() + .HasColumnType("smallint unsigned"); + + b.Property("ApiValidationSecurityLevel") + .HasColumnType("int"); + + b.Property("InstanceId") + .HasColumnType("bigint"); + + b.Property("ProjectName") + .HasMaxLength(10000) + .HasColumnType("longtext"); + + MySqlPropertyBuilderExtensions.HasCharSet(b.Property("ProjectName"), "utf8mb4"); + + b.Property("RequireDMApiValidation") + .IsRequired() + .HasColumnType("tinyint(1)"); + + b.Property("Timeout") + .IsRequired() + .HasColumnType("time(6)"); + + b.HasKey("Id"); + + b.HasIndex("InstanceId") + .IsUnique(); + + b.ToTable("DreamMakerSettings"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.Instance", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AutoUpdateInterval") + .IsRequired() + .HasColumnType("int unsigned"); + + b.Property("ChatBotLimit") + .IsRequired() + .HasColumnType("smallint unsigned"); + + b.Property("ConfigurationType") + .HasColumnType("int"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + MySqlPropertyBuilderExtensions.HasCharSet(b.Property("Name"), "utf8mb4"); + + b.Property("Online") + .IsRequired() + .HasColumnType("tinyint(1)"); + + b.Property("Path") + .IsRequired() + .HasColumnType("varchar(255)"); + + MySqlPropertyBuilderExtensions.HasCharSet(b.Property("Path"), "utf8mb4"); + + b.Property("SwarmIdentifer") + .HasColumnType("varchar(255)"); + + MySqlPropertyBuilderExtensions.HasCharSet(b.Property("SwarmIdentifer"), "utf8mb4"); + + b.HasKey("Id"); + + b.HasIndex("Path", "SwarmIdentifer") + .IsUnique(); + + b.ToTable("Instances"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.InstancePermissionSet", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ChatBotRights") + .HasColumnType("bigint unsigned"); + + b.Property("ConfigurationRights") + .HasColumnType("bigint unsigned"); + + b.Property("DreamDaemonRights") + .HasColumnType("bigint unsigned"); + + b.Property("DreamMakerRights") + .HasColumnType("bigint unsigned"); + + b.Property("EngineRights") + .HasColumnType("bigint unsigned"); + + b.Property("InstanceId") + .HasColumnType("bigint"); + + b.Property("InstancePermissionSetRights") + .HasColumnType("bigint unsigned"); + + b.Property("PermissionSetId") + .HasColumnType("bigint"); + + b.Property("RepositoryRights") + .HasColumnType("bigint unsigned"); + + b.HasKey("Id"); + + b.HasIndex("InstanceId"); + + b.HasIndex("PermissionSetId", "InstanceId") + .IsUnique(); + + b.ToTable("InstancePermissionSets"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.Job", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CancelRight") + .HasColumnType("bigint unsigned"); + + b.Property("CancelRightsType") + .HasColumnType("bigint unsigned"); + + b.Property("Cancelled") + .IsRequired() + .HasColumnType("tinyint(1)"); + + b.Property("CancelledById") + .HasColumnType("bigint"); + + b.Property("Description") + .IsRequired() + .HasColumnType("longtext"); + + MySqlPropertyBuilderExtensions.HasCharSet(b.Property("Description"), "utf8mb4"); + + b.Property("ErrorCode") + .HasColumnType("int unsigned"); + + b.Property("ExceptionDetails") + .HasColumnType("longtext"); + + MySqlPropertyBuilderExtensions.HasCharSet(b.Property("ExceptionDetails"), "utf8mb4"); + + b.Property("InstanceId") + .HasColumnType("bigint"); + + b.Property("JobCode") + .HasColumnType("tinyint unsigned"); + + b.Property("StartedAt") + .IsRequired() + .HasColumnType("datetime(6)"); + + b.Property("StartedById") + .HasColumnType("bigint"); + + b.Property("StoppedAt") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("CancelledById"); + + b.HasIndex("InstanceId"); + + b.HasIndex("StartedById"); + + b.ToTable("Jobs"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.OAuthConnection", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("ExternalUserId") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + MySqlPropertyBuilderExtensions.HasCharSet(b.Property("ExternalUserId"), "utf8mb4"); + + b.Property("Provider") + .HasColumnType("int"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.HasIndex("Provider", "ExternalUserId") + .IsUnique(); + + b.ToTable("OAuthConnections"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.PermissionSet", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AdministrationRights") + .HasColumnType("bigint unsigned"); + + b.Property("GroupId") + .HasColumnType("bigint"); + + b.Property("InstanceManagerRights") + .HasColumnType("bigint unsigned"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("GroupId") + .IsUnique(); + + b.HasIndex("UserId") + .IsUnique(); + + b.ToTable("PermissionSets"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.ReattachInformation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AccessIdentifier") + .IsRequired() + .HasColumnType("longtext"); + + MySqlPropertyBuilderExtensions.HasCharSet(b.Property("AccessIdentifier"), "utf8mb4"); + + b.Property("CompileJobId") + .HasColumnType("bigint"); + + b.Property("InitialCompileJobId") + .HasColumnType("bigint"); + + b.Property("LaunchSecurityLevel") + .HasColumnType("int"); + + b.Property("LaunchVisibility") + .HasColumnType("int"); + + b.Property("Port") + .HasColumnType("smallint unsigned"); + + b.Property("ProcessId") + .HasColumnType("int"); + + b.Property("RebootState") + .HasColumnType("int"); + + b.Property("TopicPort") + .HasColumnType("smallint unsigned"); + + b.HasKey("Id"); + + b.HasIndex("CompileJobId"); + + b.HasIndex("InitialCompileJobId"); + + b.ToTable("ReattachInformations"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.RepositorySettings", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("AccessToken") + .HasMaxLength(10000) + .HasColumnType("longtext"); + + MySqlPropertyBuilderExtensions.HasCharSet(b.Property("AccessToken"), "utf8mb4"); + + b.Property("AccessUser") + .HasMaxLength(10000) + .HasColumnType("longtext"); + + MySqlPropertyBuilderExtensions.HasCharSet(b.Property("AccessUser"), "utf8mb4"); + + b.Property("AutoUpdatesKeepTestMerges") + .IsRequired() + .HasColumnType("tinyint(1)"); + + b.Property("AutoUpdatesSynchronize") + .IsRequired() + .HasColumnType("tinyint(1)"); + + b.Property("CommitterEmail") + .IsRequired() + .HasMaxLength(10000) + .HasColumnType("longtext"); + + MySqlPropertyBuilderExtensions.HasCharSet(b.Property("CommitterEmail"), "utf8mb4"); + + b.Property("CommitterName") + .IsRequired() + .HasMaxLength(10000) + .HasColumnType("longtext"); + + MySqlPropertyBuilderExtensions.HasCharSet(b.Property("CommitterName"), "utf8mb4"); + + b.Property("CreateGitHubDeployments") + .IsRequired() + .HasColumnType("tinyint(1)"); + + b.Property("InstanceId") + .HasColumnType("bigint"); + + b.Property("PostTestMergeComment") + .IsRequired() + .HasColumnType("tinyint(1)"); + + b.Property("PushTestMergeCommits") + .IsRequired() + .HasColumnType("tinyint(1)"); + + b.Property("ShowTestMergeCommitters") + .IsRequired() + .HasColumnType("tinyint(1)"); + + b.Property("UpdateSubmodules") + .IsRequired() + .HasColumnType("tinyint(1)"); + + b.HasKey("Id"); + + b.HasIndex("InstanceId") + .IsUnique(); + + b.ToTable("RepositorySettings"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.RevInfoTestMerge", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("RevisionInformationId") + .HasColumnType("bigint"); + + b.Property("TestMergeId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("RevisionInformationId"); + + b.HasIndex("TestMergeId"); + + b.ToTable("RevInfoTestMerges"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.RevisionInformation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CommitSha") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)"); + + MySqlPropertyBuilderExtensions.HasCharSet(b.Property("CommitSha"), "utf8mb4"); + + b.Property("InstanceId") + .HasColumnType("bigint"); + + b.Property("OriginCommitSha") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)"); + + MySqlPropertyBuilderExtensions.HasCharSet(b.Property("OriginCommitSha"), "utf8mb4"); + + b.Property("Timestamp") + .HasColumnType("datetime(6)"); + + b.HasKey("Id"); + + b.HasIndex("InstanceId", "CommitSha") + .IsUnique(); + + b.ToTable("RevisionInformations"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.TestMerge", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Author") + .IsRequired() + .HasColumnType("longtext"); + + MySqlPropertyBuilderExtensions.HasCharSet(b.Property("Author"), "utf8mb4"); + + b.Property("BodyAtMerge") + .IsRequired() + .HasColumnType("longtext"); + + MySqlPropertyBuilderExtensions.HasCharSet(b.Property("BodyAtMerge"), "utf8mb4"); + + b.Property("Comment") + .HasMaxLength(10000) + .HasColumnType("longtext"); + + MySqlPropertyBuilderExtensions.HasCharSet(b.Property("Comment"), "utf8mb4"); + + b.Property("MergedAt") + .HasColumnType("datetime(6)"); + + b.Property("MergedById") + .HasColumnType("bigint"); + + b.Property("Number") + .HasColumnType("int"); + + b.Property("PrimaryRevisionInformationId") + .IsRequired() + .HasColumnType("bigint"); + + b.Property("TargetCommitSha") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("varchar(40)"); + + MySqlPropertyBuilderExtensions.HasCharSet(b.Property("TargetCommitSha"), "utf8mb4"); + + b.Property("TitleAtMerge") + .IsRequired() + .HasColumnType("longtext"); + + MySqlPropertyBuilderExtensions.HasCharSet(b.Property("TitleAtMerge"), "utf8mb4"); + + b.Property("Url") + .IsRequired() + .HasColumnType("longtext"); + + MySqlPropertyBuilderExtensions.HasCharSet(b.Property("Url"), "utf8mb4"); + + b.HasKey("Id"); + + b.HasIndex("MergedById"); + + b.HasIndex("PrimaryRevisionInformationId") + .IsUnique(); + + b.ToTable("TestMerges"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("CanonicalName") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + MySqlPropertyBuilderExtensions.HasCharSet(b.Property("CanonicalName"), "utf8mb4"); + + b.Property("CreatedAt") + .IsRequired() + .HasColumnType("datetime(6)"); + + b.Property("CreatedById") + .HasColumnType("bigint"); + + b.Property("Enabled") + .IsRequired() + .HasColumnType("tinyint(1)"); + + b.Property("GroupId") + .HasColumnType("bigint"); + + b.Property("LastPasswordUpdate") + .HasColumnType("datetime(6)"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + MySqlPropertyBuilderExtensions.HasCharSet(b.Property("Name"), "utf8mb4"); + + b.Property("PasswordHash") + .HasColumnType("longtext"); + + MySqlPropertyBuilderExtensions.HasCharSet(b.Property("PasswordHash"), "utf8mb4"); + + b.Property("SystemIdentifier") + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + MySqlPropertyBuilderExtensions.HasCharSet(b.Property("SystemIdentifier"), "utf8mb4"); + + b.HasKey("Id"); + + b.HasIndex("CanonicalName") + .IsUnique(); + + b.HasIndex("CreatedById"); + + b.HasIndex("GroupId"); + + b.HasIndex("SystemIdentifier") + .IsUnique(); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.UserGroup", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("varchar(100)"); + + MySqlPropertyBuilderExtensions.HasCharSet(b.Property("Name"), "utf8mb4"); + + b.HasKey("Id"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("Groups"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.ChatBot", b => + { + b.HasOne("Tgstation.Server.Host.Models.Instance", "Instance") + .WithMany("ChatSettings") + .HasForeignKey("InstanceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Instance"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.ChatChannel", b => + { + b.HasOne("Tgstation.Server.Host.Models.ChatBot", "ChatSettings") + .WithMany("Channels") + .HasForeignKey("ChatSettingsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ChatSettings"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.CompileJob", b => + { + b.HasOne("Tgstation.Server.Host.Models.Job", "Job") + .WithOne() + .HasForeignKey("Tgstation.Server.Host.Models.CompileJob", "JobId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tgstation.Server.Host.Models.RevisionInformation", "RevisionInformation") + .WithMany("CompileJobs") + .HasForeignKey("RevisionInformationId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Job"); + + b.Navigation("RevisionInformation"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.DreamDaemonSettings", b => + { + b.HasOne("Tgstation.Server.Host.Models.Instance", "Instance") + .WithOne("DreamDaemonSettings") + .HasForeignKey("Tgstation.Server.Host.Models.DreamDaemonSettings", "InstanceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Instance"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.DreamMakerSettings", b => + { + b.HasOne("Tgstation.Server.Host.Models.Instance", "Instance") + .WithOne("DreamMakerSettings") + .HasForeignKey("Tgstation.Server.Host.Models.DreamMakerSettings", "InstanceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Instance"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.InstancePermissionSet", b => + { + b.HasOne("Tgstation.Server.Host.Models.Instance", "Instance") + .WithMany("InstancePermissionSets") + .HasForeignKey("InstanceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tgstation.Server.Host.Models.PermissionSet", "PermissionSet") + .WithMany("InstancePermissionSets") + .HasForeignKey("PermissionSetId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Instance"); + + b.Navigation("PermissionSet"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.Job", b => + { + b.HasOne("Tgstation.Server.Host.Models.User", "CancelledBy") + .WithMany() + .HasForeignKey("CancelledById"); + + b.HasOne("Tgstation.Server.Host.Models.Instance", "Instance") + .WithMany("Jobs") + .HasForeignKey("InstanceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tgstation.Server.Host.Models.User", "StartedBy") + .WithMany() + .HasForeignKey("StartedById") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CancelledBy"); + + b.Navigation("Instance"); + + b.Navigation("StartedBy"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.OAuthConnection", b => + { + b.HasOne("Tgstation.Server.Host.Models.User", "User") + .WithMany("OAuthConnections") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.PermissionSet", b => + { + b.HasOne("Tgstation.Server.Host.Models.UserGroup", "Group") + .WithOne("PermissionSet") + .HasForeignKey("Tgstation.Server.Host.Models.PermissionSet", "GroupId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("Tgstation.Server.Host.Models.User", "User") + .WithOne("PermissionSet") + .HasForeignKey("Tgstation.Server.Host.Models.PermissionSet", "UserId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("Group"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.ReattachInformation", b => + { + b.HasOne("Tgstation.Server.Host.Models.CompileJob", "CompileJob") + .WithMany() + .HasForeignKey("CompileJobId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tgstation.Server.Host.Models.CompileJob", "InitialCompileJob") + .WithMany() + .HasForeignKey("InitialCompileJobId"); + + b.Navigation("CompileJob"); + + b.Navigation("InitialCompileJob"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.RepositorySettings", b => + { + b.HasOne("Tgstation.Server.Host.Models.Instance", "Instance") + .WithOne("RepositorySettings") + .HasForeignKey("Tgstation.Server.Host.Models.RepositorySettings", "InstanceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Instance"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.RevInfoTestMerge", b => + { + b.HasOne("Tgstation.Server.Host.Models.RevisionInformation", "RevisionInformation") + .WithMany("ActiveTestMerges") + .HasForeignKey("RevisionInformationId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tgstation.Server.Host.Models.TestMerge", "TestMerge") + .WithMany("RevisonInformations") + .HasForeignKey("TestMergeId") + .OnDelete(DeleteBehavior.ClientNoAction) + .IsRequired(); + + b.Navigation("RevisionInformation"); + + b.Navigation("TestMerge"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.RevisionInformation", b => + { + b.HasOne("Tgstation.Server.Host.Models.Instance", "Instance") + .WithMany("RevisionInformations") + .HasForeignKey("InstanceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Instance"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.TestMerge", b => + { + b.HasOne("Tgstation.Server.Host.Models.User", "MergedBy") + .WithMany("TestMerges") + .HasForeignKey("MergedById") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Tgstation.Server.Host.Models.RevisionInformation", "PrimaryRevisionInformation") + .WithOne("PrimaryTestMerge") + .HasForeignKey("Tgstation.Server.Host.Models.TestMerge", "PrimaryRevisionInformationId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("MergedBy"); + + b.Navigation("PrimaryRevisionInformation"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.User", b => + { + b.HasOne("Tgstation.Server.Host.Models.User", "CreatedBy") + .WithMany("CreatedUsers") + .HasForeignKey("CreatedById"); + + b.HasOne("Tgstation.Server.Host.Models.UserGroup", "Group") + .WithMany("Users") + .HasForeignKey("GroupId"); + + b.Navigation("CreatedBy"); + + b.Navigation("Group"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.ChatBot", b => + { + b.Navigation("Channels"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.Instance", b => + { + b.Navigation("ChatSettings"); + + b.Navigation("DreamDaemonSettings"); + + b.Navigation("DreamMakerSettings"); + + b.Navigation("InstancePermissionSets"); + + b.Navigation("Jobs"); + + b.Navigation("RepositorySettings"); + + b.Navigation("RevisionInformations"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.PermissionSet", b => + { + b.Navigation("InstancePermissionSets"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.RevisionInformation", b => + { + b.Navigation("ActiveTestMerges"); + + b.Navigation("CompileJobs"); + + b.Navigation("PrimaryTestMerge"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.TestMerge", b => + { + b.Navigation("RevisonInformations"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.User", b => + { + b.Navigation("CreatedUsers"); + + b.Navigation("OAuthConnections"); + + b.Navigation("PermissionSet"); + + b.Navigation("TestMerges"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.UserGroup", b => + { + b.Navigation("PermissionSet") + .IsRequired(); + + b.Navigation("Users"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/Tgstation.Server.Host/Database/Migrations/20231220032515_MYAddTopicPort.cs b/src/Tgstation.Server.Host/Database/Migrations/20231220032515_MYAddTopicPort.cs new file mode 100644 index 0000000000..1630786ccf --- /dev/null +++ b/src/Tgstation.Server.Host/Database/Migrations/20231220032515_MYAddTopicPort.cs @@ -0,0 +1,32 @@ +using System; + +using Microsoft.EntityFrameworkCore.Migrations; + +namespace Tgstation.Server.Host.Database.Migrations +{ + /// + public partial class MYAddTopicPort : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + ArgumentNullException.ThrowIfNull(migrationBuilder); + + migrationBuilder.AddColumn( + name: "TopicPort", + table: "ReattachInformations", + type: "smallint unsigned", + nullable: true); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + ArgumentNullException.ThrowIfNull(migrationBuilder); + + migrationBuilder.DropColumn( + name: "TopicPort", + table: "ReattachInformations"); + } + } +} diff --git a/src/Tgstation.Server.Host/Database/Migrations/20231220032521_PGAddTopicPort.Designer.cs b/src/Tgstation.Server.Host/Database/Migrations/20231220032521_PGAddTopicPort.Designer.cs new file mode 100644 index 0000000000..6f31c5e109 --- /dev/null +++ b/src/Tgstation.Server.Host/Database/Migrations/20231220032521_PGAddTopicPort.Designer.cs @@ -0,0 +1,1070 @@ +// +using System; + +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; + +namespace Tgstation.Server.Host.Database.Migrations +{ + [DbContext(typeof(PostgresSqlDatabaseContext))] + [Migration("20231220032521_PGAddTopicPort")] + partial class PGAddTopicPort + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "8.0.0") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("Tgstation.Server.Host.Models.ChatBot", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ChannelLimit") + .HasColumnType("integer"); + + b.Property("ConnectionString") + .IsRequired() + .HasMaxLength(10000) + .HasColumnType("character varying(10000)"); + + b.Property("Enabled") + .HasColumnType("boolean"); + + b.Property("InstanceId") + .HasColumnType("bigint"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("character varying(100)"); + + b.Property("Provider") + .HasColumnType("integer"); + + b.Property("ReconnectionInterval") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("InstanceId", "Name") + .IsUnique(); + + b.ToTable("ChatBots"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.ChatChannel", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ChatSettingsId") + .HasColumnType("bigint"); + + b.Property("DiscordChannelId") + .HasColumnType("numeric(20,0)"); + + b.Property("IrcChannel") + .HasMaxLength(100) + .HasColumnType("character varying(100)"); + + b.Property("IsAdminChannel") + .IsRequired() + .HasColumnType("boolean"); + + b.Property("IsSystemChannel") + .IsRequired() + .HasColumnType("boolean"); + + b.Property("IsUpdatesChannel") + .IsRequired() + .HasColumnType("boolean"); + + b.Property("IsWatchdogChannel") + .IsRequired() + .HasColumnType("boolean"); + + b.Property("Tag") + .HasMaxLength(10000) + .HasColumnType("character varying(10000)"); + + b.HasKey("Id"); + + b.HasIndex("ChatSettingsId", "DiscordChannelId") + .IsUnique(); + + b.HasIndex("ChatSettingsId", "IrcChannel") + .IsUnique(); + + b.ToTable("ChatChannels"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.CompileJob", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("DMApiMajorVersion") + .HasColumnType("integer"); + + b.Property("DMApiMinorVersion") + .HasColumnType("integer"); + + b.Property("DMApiPatchVersion") + .HasColumnType("integer"); + + b.Property("DirectoryName") + .IsRequired() + .HasColumnType("uuid"); + + b.Property("DmeName") + .IsRequired() + .HasColumnType("text"); + + b.Property("EngineVersion") + .IsRequired() + .HasColumnType("text"); + + b.Property("GitHubDeploymentId") + .HasColumnType("integer"); + + b.Property("GitHubRepoId") + .HasColumnType("bigint"); + + b.Property("JobId") + .HasColumnType("bigint"); + + b.Property("MinimumSecurityLevel") + .HasColumnType("integer"); + + b.Property("Output") + .IsRequired() + .HasColumnType("text"); + + b.Property("RepositoryOrigin") + .HasColumnType("text"); + + b.Property("RevisionInformationId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("DirectoryName"); + + b.HasIndex("JobId") + .IsUnique(); + + b.HasIndex("RevisionInformationId"); + + b.ToTable("CompileJobs"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.DreamDaemonSettings", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AdditionalParameters") + .IsRequired() + .HasMaxLength(10000) + .HasColumnType("character varying(10000)"); + + b.Property("AllowWebClient") + .IsRequired() + .HasColumnType("boolean"); + + b.Property("AutoStart") + .IsRequired() + .HasColumnType("boolean"); + + b.Property("DumpOnHealthCheckRestart") + .IsRequired() + .HasColumnType("boolean"); + + b.Property("HealthCheckSeconds") + .HasColumnType("bigint"); + + b.Property("InstanceId") + .HasColumnType("bigint"); + + b.Property("LogOutput") + .IsRequired() + .HasColumnType("boolean"); + + b.Property("MapThreads") + .HasColumnType("bigint"); + + b.Property("Port") + .HasColumnType("integer"); + + b.Property("SecurityLevel") + .HasColumnType("integer"); + + b.Property("StartProfiler") + .IsRequired() + .HasColumnType("boolean"); + + b.Property("StartupTimeout") + .HasColumnType("bigint"); + + b.Property("TopicRequestTimeout") + .HasColumnType("bigint"); + + b.Property("Visibility") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("InstanceId") + .IsUnique(); + + b.ToTable("DreamDaemonSettings"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.DreamMakerSettings", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ApiValidationPort") + .HasColumnType("integer"); + + b.Property("ApiValidationSecurityLevel") + .HasColumnType("integer"); + + b.Property("InstanceId") + .HasColumnType("bigint"); + + b.Property("ProjectName") + .HasMaxLength(10000) + .HasColumnType("character varying(10000)"); + + b.Property("RequireDMApiValidation") + .IsRequired() + .HasColumnType("boolean"); + + b.Property("Timeout") + .IsRequired() + .HasColumnType("interval"); + + b.HasKey("Id"); + + b.HasIndex("InstanceId") + .IsUnique(); + + b.ToTable("DreamMakerSettings"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.Instance", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AutoUpdateInterval") + .HasColumnType("bigint"); + + b.Property("ChatBotLimit") + .HasColumnType("integer"); + + b.Property("ConfigurationType") + .HasColumnType("integer"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("character varying(100)"); + + b.Property("Online") + .IsRequired() + .HasColumnType("boolean"); + + b.Property("Path") + .IsRequired() + .HasColumnType("text"); + + b.Property("SwarmIdentifer") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("Path", "SwarmIdentifer") + .IsUnique(); + + b.ToTable("Instances"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.InstancePermissionSet", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ChatBotRights") + .HasColumnType("numeric(20,0)"); + + b.Property("ConfigurationRights") + .HasColumnType("numeric(20,0)"); + + b.Property("DreamDaemonRights") + .HasColumnType("numeric(20,0)"); + + b.Property("DreamMakerRights") + .HasColumnType("numeric(20,0)"); + + b.Property("EngineRights") + .HasColumnType("numeric(20,0)"); + + b.Property("InstanceId") + .HasColumnType("bigint"); + + b.Property("InstancePermissionSetRights") + .HasColumnType("numeric(20,0)"); + + b.Property("PermissionSetId") + .HasColumnType("bigint"); + + b.Property("RepositoryRights") + .HasColumnType("numeric(20,0)"); + + b.HasKey("Id"); + + b.HasIndex("InstanceId"); + + b.HasIndex("PermissionSetId", "InstanceId") + .IsUnique(); + + b.ToTable("InstancePermissionSets"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.Job", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CancelRight") + .HasColumnType("numeric(20,0)"); + + b.Property("CancelRightsType") + .HasColumnType("numeric(20,0)"); + + b.Property("Cancelled") + .IsRequired() + .HasColumnType("boolean"); + + b.Property("CancelledById") + .HasColumnType("bigint"); + + b.Property("Description") + .IsRequired() + .HasColumnType("text"); + + b.Property("ErrorCode") + .HasColumnType("bigint"); + + b.Property("ExceptionDetails") + .HasColumnType("text"); + + b.Property("InstanceId") + .HasColumnType("bigint"); + + b.Property("JobCode") + .HasColumnType("smallint"); + + b.Property("StartedAt") + .IsRequired() + .HasColumnType("timestamp with time zone"); + + b.Property("StartedById") + .HasColumnType("bigint"); + + b.Property("StoppedAt") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("CancelledById"); + + b.HasIndex("InstanceId"); + + b.HasIndex("StartedById"); + + b.ToTable("Jobs"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.OAuthConnection", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("ExternalUserId") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("character varying(100)"); + + b.Property("Provider") + .HasColumnType("integer"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.HasIndex("Provider", "ExternalUserId") + .IsUnique(); + + b.ToTable("OAuthConnections"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.PermissionSet", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AdministrationRights") + .HasColumnType("numeric(20,0)"); + + b.Property("GroupId") + .HasColumnType("bigint"); + + b.Property("InstanceManagerRights") + .HasColumnType("numeric(20,0)"); + + b.Property("UserId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("GroupId") + .IsUnique(); + + b.HasIndex("UserId") + .IsUnique(); + + b.ToTable("PermissionSets"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.ReattachInformation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccessIdentifier") + .IsRequired() + .HasColumnType("text"); + + b.Property("CompileJobId") + .HasColumnType("bigint"); + + b.Property("InitialCompileJobId") + .HasColumnType("bigint"); + + b.Property("LaunchSecurityLevel") + .HasColumnType("integer"); + + b.Property("LaunchVisibility") + .HasColumnType("integer"); + + b.Property("Port") + .HasColumnType("integer"); + + b.Property("ProcessId") + .HasColumnType("integer"); + + b.Property("RebootState") + .HasColumnType("integer"); + + b.Property("TopicPort") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("CompileJobId"); + + b.HasIndex("InitialCompileJobId"); + + b.ToTable("ReattachInformations"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.RepositorySettings", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("AccessToken") + .HasMaxLength(10000) + .HasColumnType("character varying(10000)"); + + b.Property("AccessUser") + .HasMaxLength(10000) + .HasColumnType("character varying(10000)"); + + b.Property("AutoUpdatesKeepTestMerges") + .IsRequired() + .HasColumnType("boolean"); + + b.Property("AutoUpdatesSynchronize") + .IsRequired() + .HasColumnType("boolean"); + + b.Property("CommitterEmail") + .IsRequired() + .HasMaxLength(10000) + .HasColumnType("character varying(10000)"); + + b.Property("CommitterName") + .IsRequired() + .HasMaxLength(10000) + .HasColumnType("character varying(10000)"); + + b.Property("CreateGitHubDeployments") + .IsRequired() + .HasColumnType("boolean"); + + b.Property("InstanceId") + .HasColumnType("bigint"); + + b.Property("PostTestMergeComment") + .IsRequired() + .HasColumnType("boolean"); + + b.Property("PushTestMergeCommits") + .IsRequired() + .HasColumnType("boolean"); + + b.Property("ShowTestMergeCommitters") + .IsRequired() + .HasColumnType("boolean"); + + b.Property("UpdateSubmodules") + .IsRequired() + .HasColumnType("boolean"); + + b.HasKey("Id"); + + b.HasIndex("InstanceId") + .IsUnique(); + + b.ToTable("RepositorySettings"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.RevInfoTestMerge", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("RevisionInformationId") + .HasColumnType("bigint"); + + b.Property("TestMergeId") + .HasColumnType("bigint"); + + b.HasKey("Id"); + + b.HasIndex("RevisionInformationId"); + + b.HasIndex("TestMergeId"); + + b.ToTable("RevInfoTestMerges"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.RevisionInformation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CommitSha") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("character varying(40)"); + + b.Property("InstanceId") + .HasColumnType("bigint"); + + b.Property("OriginCommitSha") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("character varying(40)"); + + b.Property("Timestamp") + .HasColumnType("timestamp with time zone"); + + b.HasKey("Id"); + + b.HasIndex("InstanceId", "CommitSha") + .IsUnique(); + + b.ToTable("RevisionInformations"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.TestMerge", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Author") + .IsRequired() + .HasColumnType("text"); + + b.Property("BodyAtMerge") + .IsRequired() + .HasColumnType("text"); + + b.Property("Comment") + .HasMaxLength(10000) + .HasColumnType("character varying(10000)"); + + b.Property("MergedAt") + .HasColumnType("timestamp with time zone"); + + b.Property("MergedById") + .HasColumnType("bigint"); + + b.Property("Number") + .HasColumnType("integer"); + + b.Property("PrimaryRevisionInformationId") + .IsRequired() + .HasColumnType("bigint"); + + b.Property("TargetCommitSha") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("character varying(40)"); + + b.Property("TitleAtMerge") + .IsRequired() + .HasColumnType("text"); + + b.Property("Url") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.HasIndex("MergedById"); + + b.HasIndex("PrimaryRevisionInformationId") + .IsUnique(); + + b.ToTable("TestMerges"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("CanonicalName") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("character varying(100)"); + + b.Property("CreatedAt") + .IsRequired() + .HasColumnType("timestamp with time zone"); + + b.Property("CreatedById") + .HasColumnType("bigint"); + + b.Property("Enabled") + .IsRequired() + .HasColumnType("boolean"); + + b.Property("GroupId") + .HasColumnType("bigint"); + + b.Property("LastPasswordUpdate") + .HasColumnType("timestamp with time zone"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("character varying(100)"); + + b.Property("PasswordHash") + .HasColumnType("text"); + + b.Property("SystemIdentifier") + .HasMaxLength(100) + .HasColumnType("character varying(100)"); + + b.HasKey("Id"); + + b.HasIndex("CanonicalName") + .IsUnique(); + + b.HasIndex("CreatedById"); + + b.HasIndex("GroupId"); + + b.HasIndex("SystemIdentifier") + .IsUnique(); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.UserGroup", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("bigint"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("character varying(100)"); + + b.HasKey("Id"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("Groups"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.ChatBot", b => + { + b.HasOne("Tgstation.Server.Host.Models.Instance", "Instance") + .WithMany("ChatSettings") + .HasForeignKey("InstanceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Instance"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.ChatChannel", b => + { + b.HasOne("Tgstation.Server.Host.Models.ChatBot", "ChatSettings") + .WithMany("Channels") + .HasForeignKey("ChatSettingsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ChatSettings"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.CompileJob", b => + { + b.HasOne("Tgstation.Server.Host.Models.Job", "Job") + .WithOne() + .HasForeignKey("Tgstation.Server.Host.Models.CompileJob", "JobId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tgstation.Server.Host.Models.RevisionInformation", "RevisionInformation") + .WithMany("CompileJobs") + .HasForeignKey("RevisionInformationId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Job"); + + b.Navigation("RevisionInformation"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.DreamDaemonSettings", b => + { + b.HasOne("Tgstation.Server.Host.Models.Instance", "Instance") + .WithOne("DreamDaemonSettings") + .HasForeignKey("Tgstation.Server.Host.Models.DreamDaemonSettings", "InstanceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Instance"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.DreamMakerSettings", b => + { + b.HasOne("Tgstation.Server.Host.Models.Instance", "Instance") + .WithOne("DreamMakerSettings") + .HasForeignKey("Tgstation.Server.Host.Models.DreamMakerSettings", "InstanceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Instance"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.InstancePermissionSet", b => + { + b.HasOne("Tgstation.Server.Host.Models.Instance", "Instance") + .WithMany("InstancePermissionSets") + .HasForeignKey("InstanceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tgstation.Server.Host.Models.PermissionSet", "PermissionSet") + .WithMany("InstancePermissionSets") + .HasForeignKey("PermissionSetId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Instance"); + + b.Navigation("PermissionSet"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.Job", b => + { + b.HasOne("Tgstation.Server.Host.Models.User", "CancelledBy") + .WithMany() + .HasForeignKey("CancelledById"); + + b.HasOne("Tgstation.Server.Host.Models.Instance", "Instance") + .WithMany("Jobs") + .HasForeignKey("InstanceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tgstation.Server.Host.Models.User", "StartedBy") + .WithMany() + .HasForeignKey("StartedById") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CancelledBy"); + + b.Navigation("Instance"); + + b.Navigation("StartedBy"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.OAuthConnection", b => + { + b.HasOne("Tgstation.Server.Host.Models.User", "User") + .WithMany("OAuthConnections") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.PermissionSet", b => + { + b.HasOne("Tgstation.Server.Host.Models.UserGroup", "Group") + .WithOne("PermissionSet") + .HasForeignKey("Tgstation.Server.Host.Models.PermissionSet", "GroupId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("Tgstation.Server.Host.Models.User", "User") + .WithOne("PermissionSet") + .HasForeignKey("Tgstation.Server.Host.Models.PermissionSet", "UserId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("Group"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.ReattachInformation", b => + { + b.HasOne("Tgstation.Server.Host.Models.CompileJob", "CompileJob") + .WithMany() + .HasForeignKey("CompileJobId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tgstation.Server.Host.Models.CompileJob", "InitialCompileJob") + .WithMany() + .HasForeignKey("InitialCompileJobId"); + + b.Navigation("CompileJob"); + + b.Navigation("InitialCompileJob"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.RepositorySettings", b => + { + b.HasOne("Tgstation.Server.Host.Models.Instance", "Instance") + .WithOne("RepositorySettings") + .HasForeignKey("Tgstation.Server.Host.Models.RepositorySettings", "InstanceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Instance"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.RevInfoTestMerge", b => + { + b.HasOne("Tgstation.Server.Host.Models.RevisionInformation", "RevisionInformation") + .WithMany("ActiveTestMerges") + .HasForeignKey("RevisionInformationId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tgstation.Server.Host.Models.TestMerge", "TestMerge") + .WithMany("RevisonInformations") + .HasForeignKey("TestMergeId") + .OnDelete(DeleteBehavior.ClientNoAction) + .IsRequired(); + + b.Navigation("RevisionInformation"); + + b.Navigation("TestMerge"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.RevisionInformation", b => + { + b.HasOne("Tgstation.Server.Host.Models.Instance", "Instance") + .WithMany("RevisionInformations") + .HasForeignKey("InstanceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Instance"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.TestMerge", b => + { + b.HasOne("Tgstation.Server.Host.Models.User", "MergedBy") + .WithMany("TestMerges") + .HasForeignKey("MergedById") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Tgstation.Server.Host.Models.RevisionInformation", "PrimaryRevisionInformation") + .WithOne("PrimaryTestMerge") + .HasForeignKey("Tgstation.Server.Host.Models.TestMerge", "PrimaryRevisionInformationId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("MergedBy"); + + b.Navigation("PrimaryRevisionInformation"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.User", b => + { + b.HasOne("Tgstation.Server.Host.Models.User", "CreatedBy") + .WithMany("CreatedUsers") + .HasForeignKey("CreatedById"); + + b.HasOne("Tgstation.Server.Host.Models.UserGroup", "Group") + .WithMany("Users") + .HasForeignKey("GroupId"); + + b.Navigation("CreatedBy"); + + b.Navigation("Group"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.ChatBot", b => + { + b.Navigation("Channels"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.Instance", b => + { + b.Navigation("ChatSettings"); + + b.Navigation("DreamDaemonSettings"); + + b.Navigation("DreamMakerSettings"); + + b.Navigation("InstancePermissionSets"); + + b.Navigation("Jobs"); + + b.Navigation("RepositorySettings"); + + b.Navigation("RevisionInformations"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.PermissionSet", b => + { + b.Navigation("InstancePermissionSets"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.RevisionInformation", b => + { + b.Navigation("ActiveTestMerges"); + + b.Navigation("CompileJobs"); + + b.Navigation("PrimaryTestMerge"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.TestMerge", b => + { + b.Navigation("RevisonInformations"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.User", b => + { + b.Navigation("CreatedUsers"); + + b.Navigation("OAuthConnections"); + + b.Navigation("PermissionSet"); + + b.Navigation("TestMerges"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.UserGroup", b => + { + b.Navigation("PermissionSet") + .IsRequired(); + + b.Navigation("Users"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/Tgstation.Server.Host/Database/Migrations/20231220032521_PGAddTopicPort.cs b/src/Tgstation.Server.Host/Database/Migrations/20231220032521_PGAddTopicPort.cs new file mode 100644 index 0000000000..1994a0b3f9 --- /dev/null +++ b/src/Tgstation.Server.Host/Database/Migrations/20231220032521_PGAddTopicPort.cs @@ -0,0 +1,32 @@ +using System; + +using Microsoft.EntityFrameworkCore.Migrations; + +namespace Tgstation.Server.Host.Database.Migrations +{ + /// + public partial class PGAddTopicPort : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + ArgumentNullException.ThrowIfNull(migrationBuilder); + + migrationBuilder.AddColumn( + name: "TopicPort", + table: "ReattachInformations", + type: "integer", + nullable: true); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + ArgumentNullException.ThrowIfNull(migrationBuilder); + + migrationBuilder.DropColumn( + name: "TopicPort", + table: "ReattachInformations"); + } + } +} diff --git a/src/Tgstation.Server.Host/Database/Migrations/20231220032528_SLAddTopicPort.Designer.cs b/src/Tgstation.Server.Host/Database/Migrations/20231220032528_SLAddTopicPort.Designer.cs new file mode 100644 index 0000000000..1352af4855 --- /dev/null +++ b/src/Tgstation.Server.Host/Database/Migrations/20231220032528_SLAddTopicPort.Designer.cs @@ -0,0 +1,1042 @@ +// +using System; + +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; + +namespace Tgstation.Server.Host.Database.Migrations +{ + [DbContext(typeof(SqliteDatabaseContext))] + [Migration("20231220032528_SLAddTopicPort")] + partial class SLAddTopicPort + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder.HasAnnotation("ProductVersion", "8.0.0"); + + modelBuilder.Entity("Tgstation.Server.Host.Models.ChatBot", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ChannelLimit") + .IsRequired() + .HasColumnType("INTEGER"); + + b.Property("ConnectionString") + .IsRequired() + .HasMaxLength(10000) + .HasColumnType("TEXT"); + + b.Property("Enabled") + .HasColumnType("INTEGER"); + + b.Property("InstanceId") + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("TEXT"); + + b.Property("Provider") + .HasColumnType("INTEGER"); + + b.Property("ReconnectionInterval") + .IsRequired() + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("InstanceId", "Name") + .IsUnique(); + + b.ToTable("ChatBots"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.ChatChannel", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ChatSettingsId") + .HasColumnType("INTEGER"); + + b.Property("DiscordChannelId") + .HasColumnType("INTEGER"); + + b.Property("IrcChannel") + .HasMaxLength(100) + .HasColumnType("TEXT"); + + b.Property("IsAdminChannel") + .IsRequired() + .HasColumnType("INTEGER"); + + b.Property("IsSystemChannel") + .IsRequired() + .HasColumnType("INTEGER"); + + b.Property("IsUpdatesChannel") + .IsRequired() + .HasColumnType("INTEGER"); + + b.Property("IsWatchdogChannel") + .IsRequired() + .HasColumnType("INTEGER"); + + b.Property("Tag") + .HasMaxLength(10000) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("ChatSettingsId", "DiscordChannelId") + .IsUnique(); + + b.HasIndex("ChatSettingsId", "IrcChannel") + .IsUnique(); + + b.ToTable("ChatChannels"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.CompileJob", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("DMApiMajorVersion") + .HasColumnType("INTEGER"); + + b.Property("DMApiMinorVersion") + .HasColumnType("INTEGER"); + + b.Property("DMApiPatchVersion") + .HasColumnType("INTEGER"); + + b.Property("DirectoryName") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("DmeName") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("EngineVersion") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("GitHubDeploymentId") + .HasColumnType("INTEGER"); + + b.Property("GitHubRepoId") + .HasColumnType("INTEGER"); + + b.Property("JobId") + .HasColumnType("INTEGER"); + + b.Property("MinimumSecurityLevel") + .HasColumnType("INTEGER"); + + b.Property("Output") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("RepositoryOrigin") + .HasColumnType("TEXT"); + + b.Property("RevisionInformationId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("DirectoryName"); + + b.HasIndex("JobId") + .IsUnique(); + + b.HasIndex("RevisionInformationId"); + + b.ToTable("CompileJobs"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.DreamDaemonSettings", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("AdditionalParameters") + .IsRequired() + .HasMaxLength(10000) + .HasColumnType("TEXT"); + + b.Property("AllowWebClient") + .IsRequired() + .HasColumnType("INTEGER"); + + b.Property("AutoStart") + .IsRequired() + .HasColumnType("INTEGER"); + + b.Property("DumpOnHealthCheckRestart") + .IsRequired() + .HasColumnType("INTEGER"); + + b.Property("HealthCheckSeconds") + .IsRequired() + .HasColumnType("INTEGER"); + + b.Property("InstanceId") + .HasColumnType("INTEGER"); + + b.Property("LogOutput") + .IsRequired() + .HasColumnType("INTEGER"); + + b.Property("MapThreads") + .IsRequired() + .HasColumnType("INTEGER"); + + b.Property("Port") + .IsRequired() + .HasColumnType("INTEGER"); + + b.Property("SecurityLevel") + .HasColumnType("INTEGER"); + + b.Property("StartProfiler") + .IsRequired() + .HasColumnType("INTEGER"); + + b.Property("StartupTimeout") + .IsRequired() + .HasColumnType("INTEGER"); + + b.Property("TopicRequestTimeout") + .IsRequired() + .HasColumnType("INTEGER"); + + b.Property("Visibility") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("InstanceId") + .IsUnique(); + + b.ToTable("DreamDaemonSettings"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.DreamMakerSettings", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ApiValidationPort") + .IsRequired() + .HasColumnType("INTEGER"); + + b.Property("ApiValidationSecurityLevel") + .HasColumnType("INTEGER"); + + b.Property("InstanceId") + .HasColumnType("INTEGER"); + + b.Property("ProjectName") + .HasMaxLength(10000) + .HasColumnType("TEXT"); + + b.Property("RequireDMApiValidation") + .IsRequired() + .HasColumnType("INTEGER"); + + b.Property("Timeout") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("InstanceId") + .IsUnique(); + + b.ToTable("DreamMakerSettings"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.Instance", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("AutoUpdateInterval") + .IsRequired() + .HasColumnType("INTEGER"); + + b.Property("ChatBotLimit") + .IsRequired() + .HasColumnType("INTEGER"); + + b.Property("ConfigurationType") + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("TEXT"); + + b.Property("Online") + .IsRequired() + .HasColumnType("INTEGER"); + + b.Property("Path") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("SwarmIdentifer") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Path", "SwarmIdentifer") + .IsUnique(); + + b.ToTable("Instances"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.InstancePermissionSet", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ChatBotRights") + .HasColumnType("INTEGER"); + + b.Property("ConfigurationRights") + .HasColumnType("INTEGER"); + + b.Property("DreamDaemonRights") + .HasColumnType("INTEGER"); + + b.Property("DreamMakerRights") + .HasColumnType("INTEGER"); + + b.Property("EngineRights") + .HasColumnType("INTEGER"); + + b.Property("InstanceId") + .HasColumnType("INTEGER"); + + b.Property("InstancePermissionSetRights") + .HasColumnType("INTEGER"); + + b.Property("PermissionSetId") + .HasColumnType("INTEGER"); + + b.Property("RepositoryRights") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("InstanceId"); + + b.HasIndex("PermissionSetId", "InstanceId") + .IsUnique(); + + b.ToTable("InstancePermissionSets"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.Job", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("CancelRight") + .HasColumnType("INTEGER"); + + b.Property("CancelRightsType") + .HasColumnType("INTEGER"); + + b.Property("Cancelled") + .IsRequired() + .HasColumnType("INTEGER"); + + b.Property("CancelledById") + .HasColumnType("INTEGER"); + + b.Property("Description") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("ErrorCode") + .HasColumnType("INTEGER"); + + b.Property("ExceptionDetails") + .HasColumnType("TEXT"); + + b.Property("InstanceId") + .HasColumnType("INTEGER"); + + b.Property("JobCode") + .HasColumnType("INTEGER"); + + b.Property("StartedAt") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("StartedById") + .HasColumnType("INTEGER"); + + b.Property("StoppedAt") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("CancelledById"); + + b.HasIndex("InstanceId"); + + b.HasIndex("StartedById"); + + b.ToTable("Jobs"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.OAuthConnection", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ExternalUserId") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("TEXT"); + + b.Property("Provider") + .HasColumnType("INTEGER"); + + b.Property("UserId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.HasIndex("Provider", "ExternalUserId") + .IsUnique(); + + b.ToTable("OAuthConnections"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.PermissionSet", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("AdministrationRights") + .HasColumnType("INTEGER"); + + b.Property("GroupId") + .HasColumnType("INTEGER"); + + b.Property("InstanceManagerRights") + .HasColumnType("INTEGER"); + + b.Property("UserId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("GroupId") + .IsUnique(); + + b.HasIndex("UserId") + .IsUnique(); + + b.ToTable("PermissionSets"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.ReattachInformation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("AccessIdentifier") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("CompileJobId") + .HasColumnType("INTEGER"); + + b.Property("InitialCompileJobId") + .HasColumnType("INTEGER"); + + b.Property("LaunchSecurityLevel") + .HasColumnType("INTEGER"); + + b.Property("LaunchVisibility") + .HasColumnType("INTEGER"); + + b.Property("Port") + .HasColumnType("INTEGER"); + + b.Property("ProcessId") + .HasColumnType("INTEGER"); + + b.Property("RebootState") + .HasColumnType("INTEGER"); + + b.Property("TopicPort") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("CompileJobId"); + + b.HasIndex("InitialCompileJobId"); + + b.ToTable("ReattachInformations"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.RepositorySettings", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("AccessToken") + .HasMaxLength(10000) + .HasColumnType("TEXT"); + + b.Property("AccessUser") + .HasMaxLength(10000) + .HasColumnType("TEXT"); + + b.Property("AutoUpdatesKeepTestMerges") + .IsRequired() + .HasColumnType("INTEGER"); + + b.Property("AutoUpdatesSynchronize") + .IsRequired() + .HasColumnType("INTEGER"); + + b.Property("CommitterEmail") + .IsRequired() + .HasMaxLength(10000) + .HasColumnType("TEXT"); + + b.Property("CommitterName") + .IsRequired() + .HasMaxLength(10000) + .HasColumnType("TEXT"); + + b.Property("CreateGitHubDeployments") + .IsRequired() + .HasColumnType("INTEGER"); + + b.Property("InstanceId") + .HasColumnType("INTEGER"); + + b.Property("PostTestMergeComment") + .IsRequired() + .HasColumnType("INTEGER"); + + b.Property("PushTestMergeCommits") + .IsRequired() + .HasColumnType("INTEGER"); + + b.Property("ShowTestMergeCommitters") + .IsRequired() + .HasColumnType("INTEGER"); + + b.Property("UpdateSubmodules") + .IsRequired() + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("InstanceId") + .IsUnique(); + + b.ToTable("RepositorySettings"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.RevInfoTestMerge", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("RevisionInformationId") + .HasColumnType("INTEGER"); + + b.Property("TestMergeId") + .HasColumnType("INTEGER"); + + b.HasKey("Id"); + + b.HasIndex("RevisionInformationId"); + + b.HasIndex("TestMergeId"); + + b.ToTable("RevInfoTestMerges"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.RevisionInformation", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("CommitSha") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("TEXT"); + + b.Property("InstanceId") + .HasColumnType("INTEGER"); + + b.Property("OriginCommitSha") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("TEXT"); + + b.Property("Timestamp") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("InstanceId", "CommitSha") + .IsUnique(); + + b.ToTable("RevisionInformations"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.TestMerge", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Author") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("BodyAtMerge") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Comment") + .HasMaxLength(10000) + .HasColumnType("TEXT"); + + b.Property("MergedAt") + .HasColumnType("TEXT"); + + b.Property("MergedById") + .HasColumnType("INTEGER"); + + b.Property("Number") + .HasColumnType("INTEGER"); + + b.Property("PrimaryRevisionInformationId") + .IsRequired() + .HasColumnType("INTEGER"); + + b.Property("TargetCommitSha") + .IsRequired() + .HasMaxLength(40) + .HasColumnType("TEXT"); + + b.Property("TitleAtMerge") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("Url") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("MergedById"); + + b.HasIndex("PrimaryRevisionInformationId") + .IsUnique(); + + b.ToTable("TestMerges"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("CanonicalName") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("TEXT"); + + b.Property("CreatedAt") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("CreatedById") + .HasColumnType("INTEGER"); + + b.Property("Enabled") + .IsRequired() + .HasColumnType("INTEGER"); + + b.Property("GroupId") + .HasColumnType("INTEGER"); + + b.Property("LastPasswordUpdate") + .HasColumnType("TEXT"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("TEXT"); + + b.Property("PasswordHash") + .HasColumnType("TEXT"); + + b.Property("SystemIdentifier") + .HasMaxLength(100) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("CanonicalName") + .IsUnique(); + + b.HasIndex("CreatedById"); + + b.HasIndex("GroupId"); + + b.HasIndex("SystemIdentifier") + .IsUnique(); + + b.ToTable("Users"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.UserGroup", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("Name") + .IsUnique(); + + b.ToTable("Groups"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.ChatBot", b => + { + b.HasOne("Tgstation.Server.Host.Models.Instance", "Instance") + .WithMany("ChatSettings") + .HasForeignKey("InstanceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Instance"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.ChatChannel", b => + { + b.HasOne("Tgstation.Server.Host.Models.ChatBot", "ChatSettings") + .WithMany("Channels") + .HasForeignKey("ChatSettingsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ChatSettings"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.CompileJob", b => + { + b.HasOne("Tgstation.Server.Host.Models.Job", "Job") + .WithOne() + .HasForeignKey("Tgstation.Server.Host.Models.CompileJob", "JobId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tgstation.Server.Host.Models.RevisionInformation", "RevisionInformation") + .WithMany("CompileJobs") + .HasForeignKey("RevisionInformationId") + .OnDelete(DeleteBehavior.ClientNoAction) + .IsRequired(); + + b.Navigation("Job"); + + b.Navigation("RevisionInformation"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.DreamDaemonSettings", b => + { + b.HasOne("Tgstation.Server.Host.Models.Instance", "Instance") + .WithOne("DreamDaemonSettings") + .HasForeignKey("Tgstation.Server.Host.Models.DreamDaemonSettings", "InstanceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Instance"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.DreamMakerSettings", b => + { + b.HasOne("Tgstation.Server.Host.Models.Instance", "Instance") + .WithOne("DreamMakerSettings") + .HasForeignKey("Tgstation.Server.Host.Models.DreamMakerSettings", "InstanceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Instance"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.InstancePermissionSet", b => + { + b.HasOne("Tgstation.Server.Host.Models.Instance", "Instance") + .WithMany("InstancePermissionSets") + .HasForeignKey("InstanceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tgstation.Server.Host.Models.PermissionSet", "PermissionSet") + .WithMany("InstancePermissionSets") + .HasForeignKey("PermissionSetId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Instance"); + + b.Navigation("PermissionSet"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.Job", b => + { + b.HasOne("Tgstation.Server.Host.Models.User", "CancelledBy") + .WithMany() + .HasForeignKey("CancelledById"); + + b.HasOne("Tgstation.Server.Host.Models.Instance", "Instance") + .WithMany("Jobs") + .HasForeignKey("InstanceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tgstation.Server.Host.Models.User", "StartedBy") + .WithMany() + .HasForeignKey("StartedById") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CancelledBy"); + + b.Navigation("Instance"); + + b.Navigation("StartedBy"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.OAuthConnection", b => + { + b.HasOne("Tgstation.Server.Host.Models.User", "User") + .WithMany("OAuthConnections") + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.PermissionSet", b => + { + b.HasOne("Tgstation.Server.Host.Models.UserGroup", "Group") + .WithOne("PermissionSet") + .HasForeignKey("Tgstation.Server.Host.Models.PermissionSet", "GroupId") + .OnDelete(DeleteBehavior.Cascade); + + b.HasOne("Tgstation.Server.Host.Models.User", "User") + .WithOne("PermissionSet") + .HasForeignKey("Tgstation.Server.Host.Models.PermissionSet", "UserId") + .OnDelete(DeleteBehavior.Cascade); + + b.Navigation("Group"); + + b.Navigation("User"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.ReattachInformation", b => + { + b.HasOne("Tgstation.Server.Host.Models.CompileJob", "CompileJob") + .WithMany() + .HasForeignKey("CompileJobId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tgstation.Server.Host.Models.CompileJob", "InitialCompileJob") + .WithMany() + .HasForeignKey("InitialCompileJobId"); + + b.Navigation("CompileJob"); + + b.Navigation("InitialCompileJob"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.RepositorySettings", b => + { + b.HasOne("Tgstation.Server.Host.Models.Instance", "Instance") + .WithOne("RepositorySettings") + .HasForeignKey("Tgstation.Server.Host.Models.RepositorySettings", "InstanceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Instance"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.RevInfoTestMerge", b => + { + b.HasOne("Tgstation.Server.Host.Models.RevisionInformation", "RevisionInformation") + .WithMany("ActiveTestMerges") + .HasForeignKey("RevisionInformationId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("Tgstation.Server.Host.Models.TestMerge", "TestMerge") + .WithMany("RevisonInformations") + .HasForeignKey("TestMergeId") + .OnDelete(DeleteBehavior.ClientNoAction) + .IsRequired(); + + b.Navigation("RevisionInformation"); + + b.Navigation("TestMerge"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.RevisionInformation", b => + { + b.HasOne("Tgstation.Server.Host.Models.Instance", "Instance") + .WithMany("RevisionInformations") + .HasForeignKey("InstanceId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Instance"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.TestMerge", b => + { + b.HasOne("Tgstation.Server.Host.Models.User", "MergedBy") + .WithMany("TestMerges") + .HasForeignKey("MergedById") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("Tgstation.Server.Host.Models.RevisionInformation", "PrimaryRevisionInformation") + .WithOne("PrimaryTestMerge") + .HasForeignKey("Tgstation.Server.Host.Models.TestMerge", "PrimaryRevisionInformationId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("MergedBy"); + + b.Navigation("PrimaryRevisionInformation"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.User", b => + { + b.HasOne("Tgstation.Server.Host.Models.User", "CreatedBy") + .WithMany("CreatedUsers") + .HasForeignKey("CreatedById"); + + b.HasOne("Tgstation.Server.Host.Models.UserGroup", "Group") + .WithMany("Users") + .HasForeignKey("GroupId"); + + b.Navigation("CreatedBy"); + + b.Navigation("Group"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.ChatBot", b => + { + b.Navigation("Channels"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.Instance", b => + { + b.Navigation("ChatSettings"); + + b.Navigation("DreamDaemonSettings"); + + b.Navigation("DreamMakerSettings"); + + b.Navigation("InstancePermissionSets"); + + b.Navigation("Jobs"); + + b.Navigation("RepositorySettings"); + + b.Navigation("RevisionInformations"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.PermissionSet", b => + { + b.Navigation("InstancePermissionSets"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.RevisionInformation", b => + { + b.Navigation("ActiveTestMerges"); + + b.Navigation("CompileJobs"); + + b.Navigation("PrimaryTestMerge"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.TestMerge", b => + { + b.Navigation("RevisonInformations"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.User", b => + { + b.Navigation("CreatedUsers"); + + b.Navigation("OAuthConnections"); + + b.Navigation("PermissionSet"); + + b.Navigation("TestMerges"); + }); + + modelBuilder.Entity("Tgstation.Server.Host.Models.UserGroup", b => + { + b.Navigation("PermissionSet") + .IsRequired(); + + b.Navigation("Users"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/src/Tgstation.Server.Host/Database/Migrations/20231220032528_SLAddTopicPort.cs b/src/Tgstation.Server.Host/Database/Migrations/20231220032528_SLAddTopicPort.cs new file mode 100644 index 0000000000..7ea822bd2a --- /dev/null +++ b/src/Tgstation.Server.Host/Database/Migrations/20231220032528_SLAddTopicPort.cs @@ -0,0 +1,32 @@ +using System; + +using Microsoft.EntityFrameworkCore.Migrations; + +namespace Tgstation.Server.Host.Database.Migrations +{ + /// + public partial class SLAddTopicPort : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + ArgumentNullException.ThrowIfNull(migrationBuilder); + + migrationBuilder.AddColumn( + name: "TopicPort", + table: "ReattachInformations", + type: "INTEGER", + nullable: true); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + ArgumentNullException.ThrowIfNull(migrationBuilder); + + migrationBuilder.DropColumn( + name: "TopicPort", + table: "ReattachInformations"); + } + } +} diff --git a/src/Tgstation.Server.Host/Database/Migrations/MySqlDatabaseContextModelSnapshot.cs b/src/Tgstation.Server.Host/Database/Migrations/MySqlDatabaseContextModelSnapshot.cs index e470e52b3c..1f42bd3856 100644 --- a/src/Tgstation.Server.Host/Database/Migrations/MySqlDatabaseContextModelSnapshot.cs +++ b/src/Tgstation.Server.Host/Database/Migrations/MySqlDatabaseContextModelSnapshot.cs @@ -13,7 +13,7 @@ namespace Tgstation.Server.Host.Database.Migrations { #pragma warning disable 612, 618 modelBuilder - .HasAnnotation("ProductVersion", "8.0.0-rc.1.23419.6") + .HasAnnotation("ProductVersion", "8.0.0") .HasAnnotation("Relational:MaxIdentifierLength", 64); modelBuilder.Entity("Tgstation.Server.Host.Models.ChatBot", b => @@ -116,13 +116,6 @@ namespace Tgstation.Server.Host.Database.Migrations .ValueGeneratedOnAdd() .HasColumnType("bigint"); - b.Property("ByondVersion") - .IsRequired() - .HasColumnType("longtext") - .HasColumnName("EngineVersion"); - - MySqlPropertyBuilderExtensions.HasCharSet(b.Property("ByondVersion"), "utf8mb4"); - b.Property("DMApiMajorVersion") .HasColumnType("int"); @@ -142,6 +135,12 @@ namespace Tgstation.Server.Host.Database.Migrations MySqlPropertyBuilderExtensions.HasCharSet(b.Property("DmeName"), "utf8mb4"); + b.Property("EngineVersion") + .IsRequired() + .HasColumnType("longtext"); + + MySqlPropertyBuilderExtensions.HasCharSet(b.Property("EngineVersion"), "utf8mb4"); + b.Property("GitHubDeploymentId") .HasColumnType("int"); @@ -498,7 +497,7 @@ namespace Tgstation.Server.Host.Database.Migrations modelBuilder.Entity("Tgstation.Server.Host.Models.ReattachInformation", b => { - b.Property("Id") + b.Property("Id") .ValueGeneratedOnAdd() .HasColumnType("bigint"); @@ -529,6 +528,9 @@ namespace Tgstation.Server.Host.Database.Migrations b.Property("RebootState") .HasColumnType("int"); + b.Property("TopicPort") + .HasColumnType("smallint unsigned"); + b.HasKey("Id"); b.HasIndex("CompileJobId"); diff --git a/src/Tgstation.Server.Host/Database/Migrations/PostgresSqlDatabaseContextModelSnapshot.cs b/src/Tgstation.Server.Host/Database/Migrations/PostgresSqlDatabaseContextModelSnapshot.cs index 96f60f6850..631cf53bc9 100644 --- a/src/Tgstation.Server.Host/Database/Migrations/PostgresSqlDatabaseContextModelSnapshot.cs +++ b/src/Tgstation.Server.Host/Database/Migrations/PostgresSqlDatabaseContextModelSnapshot.cs @@ -13,7 +13,7 @@ namespace Tgstation.Server.Host.Database.Migrations { #pragma warning disable 612, 618 modelBuilder - .HasAnnotation("ProductVersion", "8.0.0-rc.1.23419.6") + .HasAnnotation("ProductVersion", "8.0.0") .HasAnnotation("Relational:MaxIdentifierLength", 63); NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); @@ -116,11 +116,6 @@ namespace Tgstation.Server.Host.Database.Migrations NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); - b.Property("ByondVersion") - .IsRequired() - .HasColumnType("text") - .HasColumnName("EngineVersion"); - b.Property("DMApiMajorVersion") .HasColumnType("integer"); @@ -138,6 +133,10 @@ namespace Tgstation.Server.Host.Database.Migrations .IsRequired() .HasColumnType("text"); + b.Property("EngineVersion") + .IsRequired() + .HasColumnType("text"); + b.Property("GitHubDeploymentId") .HasColumnType("integer"); @@ -480,11 +479,11 @@ namespace Tgstation.Server.Host.Database.Migrations modelBuilder.Entity("Tgstation.Server.Host.Models.ReattachInformation", b => { - b.Property("Id") + b.Property("Id") .ValueGeneratedOnAdd() .HasColumnType("bigint"); - NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); b.Property("AccessIdentifier") .IsRequired() @@ -511,6 +510,9 @@ namespace Tgstation.Server.Host.Database.Migrations b.Property("RebootState") .HasColumnType("integer"); + b.Property("TopicPort") + .HasColumnType("integer"); + b.HasKey("Id"); b.HasIndex("CompileJobId"); diff --git a/src/Tgstation.Server.Host/Database/Migrations/SqlServerDatabaseContextModelSnapshot.cs b/src/Tgstation.Server.Host/Database/Migrations/SqlServerDatabaseContextModelSnapshot.cs index 30050cf789..1b1bb5276c 100644 --- a/src/Tgstation.Server.Host/Database/Migrations/SqlServerDatabaseContextModelSnapshot.cs +++ b/src/Tgstation.Server.Host/Database/Migrations/SqlServerDatabaseContextModelSnapshot.cs @@ -13,7 +13,7 @@ namespace Tgstation.Server.Host.Database.Migrations { #pragma warning disable 612, 618 modelBuilder - .HasAnnotation("ProductVersion", "8.0.0-rc.1.23419.6") + .HasAnnotation("ProductVersion", "8.0.0") .HasAnnotation("Relational:MaxIdentifierLength", 128); SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); @@ -118,11 +118,6 @@ namespace Tgstation.Server.Host.Database.Migrations SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); - b.Property("ByondVersion") - .IsRequired() - .HasColumnType("nvarchar(max)") - .HasColumnName("EngineVersion"); - b.Property("DMApiMajorVersion") .HasColumnType("int"); @@ -140,6 +135,10 @@ namespace Tgstation.Server.Host.Database.Migrations .IsRequired() .HasColumnType("nvarchar(max)"); + b.Property("EngineVersion") + .IsRequired() + .HasColumnType("nvarchar(max)"); + b.Property("GitHubDeploymentId") .HasColumnType("int"); @@ -485,11 +484,11 @@ namespace Tgstation.Server.Host.Database.Migrations modelBuilder.Entity("Tgstation.Server.Host.Models.ReattachInformation", b => { - b.Property("Id") + b.Property("Id") .ValueGeneratedOnAdd() .HasColumnType("bigint"); - SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); + SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id")); b.Property("AccessIdentifier") .IsRequired() @@ -516,6 +515,9 @@ namespace Tgstation.Server.Host.Database.Migrations b.Property("RebootState") .HasColumnType("int"); + b.Property("TopicPort") + .HasColumnType("int"); + b.HasKey("Id"); b.HasIndex("CompileJobId"); diff --git a/src/Tgstation.Server.Host/Database/Migrations/SqliteDatabaseContextModelSnapshot.cs b/src/Tgstation.Server.Host/Database/Migrations/SqliteDatabaseContextModelSnapshot.cs index 3f4daecc39..29d7469c65 100644 --- a/src/Tgstation.Server.Host/Database/Migrations/SqliteDatabaseContextModelSnapshot.cs +++ b/src/Tgstation.Server.Host/Database/Migrations/SqliteDatabaseContextModelSnapshot.cs @@ -12,7 +12,7 @@ namespace Tgstation.Server.Host.Database.Migrations protected override void BuildModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 - modelBuilder.HasAnnotation("ProductVersion", "8.0.0-rc.1.23419.6"); + modelBuilder.HasAnnotation("ProductVersion", "8.0.0"); modelBuilder.Entity("Tgstation.Server.Host.Models.ChatBot", b => { @@ -108,11 +108,6 @@ namespace Tgstation.Server.Host.Database.Migrations .ValueGeneratedOnAdd() .HasColumnType("INTEGER"); - b.Property("ByondVersion") - .IsRequired() - .HasColumnType("TEXT") - .HasColumnName("EngineVersion"); - b.Property("DMApiMajorVersion") .HasColumnType("INTEGER"); @@ -130,6 +125,10 @@ namespace Tgstation.Server.Host.Database.Migrations .IsRequired() .HasColumnType("TEXT"); + b.Property("EngineVersion") + .IsRequired() + .HasColumnType("TEXT"); + b.Property("GitHubDeploymentId") .HasColumnType("INTEGER"); @@ -466,7 +465,7 @@ namespace Tgstation.Server.Host.Database.Migrations modelBuilder.Entity("Tgstation.Server.Host.Models.ReattachInformation", b => { - b.Property("Id") + b.Property("Id") .ValueGeneratedOnAdd() .HasColumnType("INTEGER"); @@ -495,6 +494,9 @@ namespace Tgstation.Server.Host.Database.Migrations b.Property("RebootState") .HasColumnType("INTEGER"); + b.Property("TopicPort") + .HasColumnType("INTEGER"); + b.HasKey("Id"); b.HasIndex("CompileJobId"); diff --git a/src/Tgstation.Server.Host/Models/ReattachInformationBase.cs b/src/Tgstation.Server.Host/Models/ReattachInformationBase.cs index b233f0c017..3d3d4411cb 100644 --- a/src/Tgstation.Server.Host/Models/ReattachInformationBase.cs +++ b/src/Tgstation.Server.Host/Models/ReattachInformationBase.cs @@ -22,10 +22,15 @@ namespace Tgstation.Server.Host.Models public int ProcessId { get; set; } /// - /// The port DreamDaemon was last listening on. + /// The port the game server was last listening on. /// public ushort Port { get; set; } + /// + /// The port the game server was last listening on for topics. + /// + public ushort? TopicPort { get; set; } + /// /// The current DreamDaemon reboot state. /// @@ -58,6 +63,7 @@ namespace Tgstation.Server.Host.Models Id = copy.Id; AccessIdentifier = copy.AccessIdentifier; Port = copy.Port; + TopicPort = copy.TopicPort; ProcessId = copy.ProcessId; RebootState = copy.RebootState; LaunchSecurityLevel = copy.LaunchSecurityLevel; From 9711a787a8bf1ea8ebf408bfb3173212ed87063d Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Tue, 19 Dec 2023 23:23:15 -0500 Subject: [PATCH 255/425] Rename `IProcessBase` functions to avoid language conflicts --- .../Components/Session/SessionController.cs | 6 +++--- .../Components/Watchdog/AdvancedWatchdog.cs | 4 ++-- src/Tgstation.Server.Host/System/IProcessBase.cs | 4 ++-- src/Tgstation.Server.Host/System/Process.cs | 4 ++-- tests/Tgstation.Server.Tests/Live/Instance/WatchdogTest.cs | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Session/SessionController.cs b/src/Tgstation.Server.Host/Components/Session/SessionController.cs index 56ef1416c2..51f7cdc126 100644 --- a/src/Tgstation.Server.Host/Components/Session/SessionController.cs +++ b/src/Tgstation.Server.Host/Components/Session/SessionController.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Globalization; using System.Linq; @@ -432,10 +432,10 @@ namespace Tgstation.Server.Host.Components.Session public void AdjustPriority(bool higher) => process.AdjustPriority(higher); /// - public void Suspend() => process.Suspend(); + public void SuspendProcess() => process.SuspendProcess(); /// - public void Resume() => process.Resume(); + public void ResumeProcess() => process.ResumeProcess(); /// public IAsyncDisposable ReplaceDmbProvider(IDmbProvider dmbProvider) diff --git a/src/Tgstation.Server.Host/Components/Watchdog/AdvancedWatchdog.cs b/src/Tgstation.Server.Host/Components/Watchdog/AdvancedWatchdog.cs index cf1f30153b..0b08ed062b 100644 --- a/src/Tgstation.Server.Host/Components/Watchdog/AdvancedWatchdog.cs +++ b/src/Tgstation.Server.Host/Components/Watchdog/AdvancedWatchdog.cs @@ -387,7 +387,7 @@ namespace Tgstation.Server.Host.Components.Watchdog var server = Server; try { - server.Suspend(); + server.SuspendProcess(); suspended = true; } catch (Exception ex) @@ -404,7 +404,7 @@ namespace Tgstation.Server.Host.Components.Watchdog { // Let this throw hard if it fails if (suspended) - server.Resume(); + server.ResumeProcess(); } } diff --git a/src/Tgstation.Server.Host/System/IProcessBase.cs b/src/Tgstation.Server.Host/System/IProcessBase.cs index 8fc0bd4484..3d1030f645 100644 --- a/src/Tgstation.Server.Host/System/IProcessBase.cs +++ b/src/Tgstation.Server.Host/System/IProcessBase.cs @@ -22,12 +22,12 @@ namespace Tgstation.Server.Host.System /// /// Suspends the process. /// - void Suspend(); + void SuspendProcess(); /// /// Resumes the process. /// - void Resume(); + void ResumeProcess(); /// /// Create a dump file of the process. diff --git a/src/Tgstation.Server.Host/System/Process.cs b/src/Tgstation.Server.Host/System/Process.cs index e6c4c312e9..4362083247 100644 --- a/src/Tgstation.Server.Host/System/Process.cs +++ b/src/Tgstation.Server.Host/System/Process.cs @@ -183,7 +183,7 @@ namespace Tgstation.Server.Host.System } /// - public void Suspend() + public void SuspendProcess() { CheckDisposed(); try @@ -199,7 +199,7 @@ namespace Tgstation.Server.Host.System } /// - public void Resume() + public void ResumeProcess() { CheckDisposed(); try diff --git a/tests/Tgstation.Server.Tests/Live/Instance/WatchdogTest.cs b/tests/Tgstation.Server.Tests/Live/Instance/WatchdogTest.cs index 0df8a9755c..c1778e63fa 100644 --- a/tests/Tgstation.Server.Tests/Live/Instance/WatchdogTest.cs +++ b/tests/Tgstation.Server.Tests/Live/Instance/WatchdogTest.cs @@ -791,7 +791,7 @@ namespace Tgstation.Server.Tests.Live.Instance ValidateSessionId(ddStatus, true); global::System.Console.WriteLine($"WATCHDOG TEST {instanceClient.Metadata.Id}: COMMENCE PROCESS SUSPEND FOR HEALTH CHECK DEATH PID {ourProcessHandler.Id}."); - ourProcessHandler.Suspend(); + ourProcessHandler.SuspendProcess(); global::System.Console.WriteLine($"WATCHDOG TEST {instanceClient.Metadata.Id}: FINISH PROCESS SUSPEND FOR HEALTH CHECK DEATH. WAITING FOR LIFETIME {ourProcessHandler.Id}."); await Task.WhenAny(ourProcessHandler.Lifetime, Task.Delay(TimeSpan.FromMinutes(4), cancellationToken)); From 0883874186fa123d7f405d51a85dc2b30f90dbcf Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Tue, 19 Dec 2023 23:24:04 -0500 Subject: [PATCH 256/425] Support graceful OpenDream shutdowns - SessionController now uses `IEngineExectuableLock` to stop servers. - Kills servers by default. Uses the RobustToolbox WatchdogApi for OpenDream. --- .../Components/Engine/EngineExecutableLock.cs | 15 +++- .../Engine/EngineInstallationBase.cs | 18 ++++- .../Components/Engine/IEngineInstallation.cs | 17 +++- .../Engine/OpenDreamInstallation.cs | 79 ++++++++++++++++++- .../Components/Engine/OpenDreamInstaller.cs | 24 +++++- .../Engine/WindowsOpenDreamInstaller.cs | 8 ++ .../Components/Session/SessionController.cs | 23 +++--- src/Tgstation.Server.Host/System/IProcess.cs | 2 +- .../System/IProcessBase.cs | 2 +- .../Engine/TestOpenDreamInstaller.cs | 4 + .../Live/Instance/InstanceTest.cs | 4 + .../Live/Instance/WatchdogTest.cs | 2 +- 12 files changed, 180 insertions(+), 18 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Engine/EngineExecutableLock.cs b/src/Tgstation.Server.Host/Components/Engine/EngineExecutableLock.cs index 02d9bfe493..36944a876f 100644 --- a/src/Tgstation.Server.Host/Components/Engine/EngineExecutableLock.cs +++ b/src/Tgstation.Server.Host/Components/Engine/EngineExecutableLock.cs @@ -1,9 +1,13 @@ using System.Collections.Generic; +using System.Threading; using System.Threading.Tasks; +using Microsoft.Extensions.Logging; + using Tgstation.Server.Api.Models; using Tgstation.Server.Api.Models.Internal; using Tgstation.Server.Host.Components.Deployment; +using Tgstation.Server.Host.System; using Tgstation.Server.Host.Utils; #nullable disable @@ -11,7 +15,7 @@ using Tgstation.Server.Host.Utils; namespace Tgstation.Server.Host.Components.Engine { /// - sealed class EngineExecutableLock : ReferenceCounter, IEngineExecutableLock + class EngineExecutableLock : ReferenceCounter, IEngineExecutableLock { /// public EngineVersion Version => Instance.Version; @@ -51,5 +55,14 @@ namespace Tgstation.Server.Host.Components.Engine /// public string FormatCompilerArguments(string dmePath) => Instance.FormatCompilerArguments(dmePath); + + /// + public ValueTask StopServerProcess(ILogger logger, IProcess process, string accessIdentifier, ushort port, CancellationToken cancellationToken) + => Instance.StopServerProcess( + logger, + process, + accessIdentifier, + port, + cancellationToken); } } diff --git a/src/Tgstation.Server.Host/Components/Engine/EngineInstallationBase.cs b/src/Tgstation.Server.Host/Components/Engine/EngineInstallationBase.cs index 2133bdade4..f2da09f345 100644 --- a/src/Tgstation.Server.Host/Components/Engine/EngineInstallationBase.cs +++ b/src/Tgstation.Server.Host/Components/Engine/EngineInstallationBase.cs @@ -1,12 +1,16 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Threading; using System.Threading.Tasks; using System.Web; +using Microsoft.Extensions.Logging; + using Tgstation.Server.Api.Models; using Tgstation.Server.Api.Models.Internal; using Tgstation.Server.Host.Components.Deployment; +using Tgstation.Server.Host.System; #nullable disable @@ -58,6 +62,18 @@ namespace Tgstation.Server.Host.Components.Engine public abstract string FormatCompilerArguments(string dmePath); /// - public abstract string FormatServerArguments(IDmbProvider dmbProvider, IReadOnlyDictionary parameters, DreamDaemonLaunchParameters launchParameters, string logFilePath); + public abstract string FormatServerArguments( + IDmbProvider dmbProvider, + IReadOnlyDictionary parameters, + DreamDaemonLaunchParameters launchParameters, + string logFilePath); + + /// + public virtual async ValueTask StopServerProcess(ILogger logger, IProcess process, string accessIdentifier, ushort port, CancellationToken cancellationToken) + { + logger.LogTrace("Terminating engine server process..."); + process.Terminate(); + await process.Lifetime; + } } } diff --git a/src/Tgstation.Server.Host/Components/Engine/IEngineInstallation.cs b/src/Tgstation.Server.Host/Components/Engine/IEngineInstallation.cs index 861d6ebe90..bd7fa9e180 100644 --- a/src/Tgstation.Server.Host/Components/Engine/IEngineInstallation.cs +++ b/src/Tgstation.Server.Host/Components/Engine/IEngineInstallation.cs @@ -1,9 +1,13 @@ using System.Collections.Generic; +using System.Threading; using System.Threading.Tasks; +using Microsoft.Extensions.Logging; + using Tgstation.Server.Api.Models; using Tgstation.Server.Api.Models.Internal; using Tgstation.Server.Host.Components.Deployment; +using Tgstation.Server.Host.System; #nullable disable @@ -53,7 +57,7 @@ namespace Tgstation.Server.Host.Components.Engine /// Return the command line arguments for launching with given . /// /// The . - /// The map of parameter s as a . Should NOT include the of . + /// The map of parameter s as a . MUST include . Should NOT include the of . /// The . /// The full path to the log file, if any. /// The formatted arguments . @@ -69,5 +73,16 @@ namespace Tgstation.Server.Host.Components.Engine /// The full path to the .dme to compile. /// The formatted arguments . string FormatCompilerArguments(string dmePath); + + /// + /// Kills a given engine server . + /// + /// The to write to. + /// The to be terminated. + /// The of the session. + /// The port the server is running on. + /// The for the operation. + /// A representing the running operation. + ValueTask StopServerProcess(ILogger logger, IProcess process, string accessIdentifier, ushort port, CancellationToken cancellationToken); } } diff --git a/src/Tgstation.Server.Host/Components/Engine/OpenDreamInstallation.cs b/src/Tgstation.Server.Host/Components/Engine/OpenDreamInstallation.cs index db3e7a7392..7e1fc27e47 100644 --- a/src/Tgstation.Server.Host/Components/Engine/OpenDreamInstallation.cs +++ b/src/Tgstation.Server.Host/Components/Engine/OpenDreamInstallation.cs @@ -1,11 +1,22 @@ using System; using System.Collections.Generic; +using System.Net.Http; +using System.Net.Http.Headers; +using System.Net.Mime; +using System.Text; +using System.Threading; using System.Threading.Tasks; +using Microsoft.Extensions.Logging; + using Tgstation.Server.Api.Models; using Tgstation.Server.Api.Models.Internal; +using Tgstation.Server.Common.Http; using Tgstation.Server.Host.Components.Deployment; +using Tgstation.Server.Host.Components.Interop; using Tgstation.Server.Host.IO; +using Tgstation.Server.Host.System; +using Tgstation.Server.Host.Utils; #nullable disable @@ -42,22 +53,38 @@ namespace Tgstation.Server.Host.Components.Engine /// readonly IIOManager ioManager; + /// + /// The for the . + /// + readonly IAsyncDelayer asyncDelayer; + + /// + /// The for the . + /// + readonly IAbstractHttpClientFactory httpClientFactory; + /// /// Initializes a new instance of the class. /// /// The value of . + /// The value of . + /// The value of . /// The value of . /// The value of . /// The value of . /// The value of . public OpenDreamInstallation( IIOManager ioManager, + IAsyncDelayer asyncDelayer, + IAbstractHttpClientFactory httpClientFactory, string serverExePath, string compilerExePath, Task installationTask, EngineVersion version) { this.ioManager = ioManager ?? throw new ArgumentNullException(nameof(ioManager)); + this.asyncDelayer = asyncDelayer ?? throw new ArgumentNullException(nameof(asyncDelayer)); + this.httpClientFactory = httpClientFactory ?? throw new ArgumentNullException(nameof(httpClientFactory)); ServerExePath = serverExePath ?? throw new ArgumentNullException(nameof(serverExePath)); CompilerExePath = compilerExePath ?? throw new ArgumentNullException(nameof(compilerExePath)); InstallationTask = installationTask ?? throw new ArgumentNullException(nameof(installationTask)); @@ -78,15 +105,65 @@ namespace Tgstation.Server.Host.Components.Engine ArgumentNullException.ThrowIfNull(parameters); ArgumentNullException.ThrowIfNull(launchParameters); + if (!parameters.TryGetValue(DMApiConstants.ParamAccessIdentifier, out var accessIdentifier)) + throw new ArgumentException($"parameters must have \"{DMApiConstants.ParamAccessIdentifier}\" set!", nameof(parameters)); + var parametersString = EncodeParameters(parameters, launchParameters); var loggingEnabled = logFilePath != null; - var arguments = $"--cvar {(loggingEnabled ? $"log.path=\"{ioManager.GetDirectoryName(logFilePath)}\" --cvar log.format=\"{ioManager.GetFileName(logFilePath)}\"" : "log.enabled=false")} --cvar log.runtimelog=false --cvar net.port={launchParameters.Port.Value} --cvar opendream.topic_port=0 --cvar opendream.world_params=\"{parametersString}\" --cvar opendream.json_path=\"./{dmbProvider.DmbName}\""; + var arguments = $"--cvar {(loggingEnabled ? $"log.path=\"{ioManager.GetDirectoryName(logFilePath)}\" --cvar log.format=\"{ioManager.GetFileName(logFilePath)}\"" : "log.enabled=false")} --cvar watchdog.token={accessIdentifier} --cvar log.runtimelog=false --cvar net.port={launchParameters.Port.Value} --cvar opendream.topic_port=0 --cvar opendream.world_params=\"{parametersString}\" --cvar opendream.json_path=\"./{dmbProvider.DmbName}\""; return arguments; } /// public override string FormatCompilerArguments(string dmePath) => $"--suppress-unimplemented --notices-enabled \"{dmePath ?? throw new ArgumentNullException(nameof(dmePath))}\""; + + /// + public override async ValueTask StopServerProcess( + ILogger logger, + IProcess process, + string accessIdentifier, + ushort port, + CancellationToken cancellationToken) + { + const int MaximumTerminationSeconds = 5; + + logger.LogTrace("Attempting Robust.Server graceful exit (Timeout: {seconds}s)...", MaximumTerminationSeconds); + var timeout = asyncDelayer.Delay(TimeSpan.FromSeconds(MaximumTerminationSeconds), cancellationToken); + var lifetime = process.Lifetime; + + using var httpClient = httpClientFactory.CreateClient(); + using var request = new HttpRequestMessage(); + request.Headers.Add("WatchdogToken", accessIdentifier); + request.RequestUri = new Uri($"http://localhost:{port}/shutdown"); + request.Content = new StringContent( + "{\"Reason\":\"TGS session termination\"}", + Encoding.UTF8, + new MediaTypeHeaderValue(MediaTypeNames.Application.Json)); + request.Method = HttpMethod.Post; + + var responseTask = httpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead, cancellationToken); + + await Task.WhenAny(timeout, lifetime, responseTask); + if (responseTask.IsCompleted) + { + using var response = await responseTask; + if (response.IsSuccessStatusCode) + { + logger.LogDebug("Robust.Server responded to the shutdown command successfully. Waiting for exit..."); + await Task.WhenAny(timeout, lifetime); + } + } + + if (lifetime.IsCompleted) + { + logger.LogTrace("Robust.Server gracefully exited"); + return; + } + + logger.LogWarning("Robust.Server graceful exit timed out!"); + await base.StopServerProcess(logger, process, accessIdentifier, port, cancellationToken); + } } } diff --git a/src/Tgstation.Server.Host/Components/Engine/OpenDreamInstaller.cs b/src/Tgstation.Server.Host/Components/Engine/OpenDreamInstaller.cs index cefdadd504..886b419a3e 100644 --- a/src/Tgstation.Server.Host/Components/Engine/OpenDreamInstaller.cs +++ b/src/Tgstation.Server.Host/Components/Engine/OpenDreamInstaller.cs @@ -8,12 +8,14 @@ using Microsoft.Extensions.Options; using Tgstation.Server.Api.Models; using Tgstation.Server.Common.Extensions; +using Tgstation.Server.Common.Http; using Tgstation.Server.Host.Common; using Tgstation.Server.Host.Components.Repository; using Tgstation.Server.Host.Configuration; using Tgstation.Server.Host.IO; using Tgstation.Server.Host.Jobs; using Tgstation.Server.Host.System; +using Tgstation.Server.Host.Utils; #nullable disable @@ -52,6 +54,11 @@ namespace Tgstation.Server.Host.Components.Engine /// protected IProcessExecutor ProcessExecutor { get; } + /// + /// The for the . + /// + protected GeneralConfiguration GeneralConfiguration { get; } + /// /// The for the . /// @@ -63,9 +70,14 @@ namespace Tgstation.Server.Host.Components.Engine readonly IRepositoryManager repositoryManager; /// - /// The for the . + /// The for the . /// - protected GeneralConfiguration GeneralConfiguration { get; } + readonly IAsyncDelayer asyncDelayer; + + /// + /// The for the . + /// + readonly IAbstractHttpClientFactory httpClientFactory; /// /// Initializes a new instance of the class. @@ -75,6 +87,8 @@ namespace Tgstation.Server.Host.Components.Engine /// The value of . /// The value of . /// The value of . + /// The value of . + /// The value of . /// The containing value of . public OpenDreamInstaller( IIOManager ioManager, @@ -82,12 +96,16 @@ namespace Tgstation.Server.Host.Components.Engine IPlatformIdentifier platformIdentifier, IProcessExecutor processExecutor, IRepositoryManager repositoryManager, + IAsyncDelayer asyncDelayer, + IAbstractHttpClientFactory httpClientFactory, IOptions generalConfigurationOptions) : base(ioManager, logger) { this.platformIdentifier = platformIdentifier ?? throw new ArgumentNullException(nameof(platformIdentifier)); ProcessExecutor = processExecutor ?? throw new ArgumentNullException(nameof(processExecutor)); this.repositoryManager = repositoryManager ?? throw new ArgumentNullException(nameof(repositoryManager)); + this.asyncDelayer = asyncDelayer ?? throw new ArgumentNullException(nameof(asyncDelayer)); + this.httpClientFactory = httpClientFactory ?? throw new ArgumentNullException(nameof(httpClientFactory)); GeneralConfiguration = generalConfigurationOptions?.Value ?? throw new ArgumentNullException(nameof(generalConfigurationOptions)); } @@ -101,6 +119,8 @@ namespace Tgstation.Server.Host.Components.Engine GetExecutablePaths(path, out var serverExePath, out var compilerExePath); return new OpenDreamInstallation( IOManager, + asyncDelayer, + httpClientFactory, serverExePath, compilerExePath, installationTask, diff --git a/src/Tgstation.Server.Host/Components/Engine/WindowsOpenDreamInstaller.cs b/src/Tgstation.Server.Host/Components/Engine/WindowsOpenDreamInstaller.cs index 3aa19f3e38..2fb12e80de 100644 --- a/src/Tgstation.Server.Host/Components/Engine/WindowsOpenDreamInstaller.cs +++ b/src/Tgstation.Server.Host/Components/Engine/WindowsOpenDreamInstaller.cs @@ -7,11 +7,13 @@ using Microsoft.Extensions.Options; using Tgstation.Server.Api.Models; using Tgstation.Server.Common.Extensions; +using Tgstation.Server.Common.Http; using Tgstation.Server.Host.Components.Repository; using Tgstation.Server.Host.Configuration; using Tgstation.Server.Host.IO; using Tgstation.Server.Host.Jobs; using Tgstation.Server.Host.System; +using Tgstation.Server.Host.Utils; #nullable disable @@ -35,6 +37,8 @@ namespace Tgstation.Server.Host.Components.Engine /// The for the . /// The for the . /// The for the . + /// The for the . + /// The for the . /// The of for the . /// The value of . public WindowsOpenDreamInstaller( @@ -43,6 +47,8 @@ namespace Tgstation.Server.Host.Components.Engine IPlatformIdentifier platformIdentifier, IProcessExecutor processExecutor, IRepositoryManager repositoryManager, + IAsyncDelayer asyncDelayer, + IAbstractHttpClientFactory httpClientFactory, IOptions generalConfigurationOptions, IFilesystemLinkFactory linkFactory) : base( @@ -51,6 +57,8 @@ namespace Tgstation.Server.Host.Components.Engine platformIdentifier, processExecutor, repositoryManager, + asyncDelayer, + httpClientFactory, generalConfigurationOptions) { this.linkFactory = linkFactory ?? throw new ArgumentNullException(nameof(linkFactory)); diff --git a/src/Tgstation.Server.Host/Components/Session/SessionController.cs b/src/Tgstation.Server.Host/Components/Session/SessionController.cs index 51f7cdc126..9fbd96cca9 100644 --- a/src/Tgstation.Server.Host/Components/Session/SessionController.cs +++ b/src/Tgstation.Server.Host/Components/Session/SessionController.cs @@ -133,7 +133,7 @@ namespace Tgstation.Server.Host.Components.Session /// /// The for the . /// - readonly IEngineExecutableLock byondLock; + readonly IEngineExecutableLock engineLock; /// /// The for the . @@ -226,7 +226,7 @@ namespace Tgstation.Server.Host.Components.Session /// The value of . /// The owning . /// The value of . - /// The value of . + /// The value of . /// The value of . /// The used to populate . /// The value of . @@ -242,7 +242,7 @@ namespace Tgstation.Server.Host.Components.Session ReattachInformation reattachInformation, Api.Models.Instance metadata, IProcess process, - IEngineExecutableLock byondLock, + IEngineExecutableLock engineLock, Byond.TopicSender.ITopicClient byondTopicSender, IChatTrackingContext chatTrackingContext, IBridgeRegistrar bridgeRegistrar, @@ -259,7 +259,7 @@ namespace Tgstation.Server.Host.Components.Session ReattachInformation = reattachInformation ?? throw new ArgumentNullException(nameof(reattachInformation)); this.metadata = metadata ?? throw new ArgumentNullException(nameof(metadata)); this.process = process ?? throw new ArgumentNullException(nameof(process)); - this.byondLock = byondLock ?? throw new ArgumentNullException(nameof(byondLock)); + this.engineLock = engineLock ?? throw new ArgumentNullException(nameof(engineLock)); this.byondTopicSender = byondTopicSender ?? throw new ArgumentNullException(nameof(byondTopicSender)); this.chatTrackingContext = chatTrackingContext ?? throw new ArgumentNullException(nameof(chatTrackingContext)); ArgumentNullException.ThrowIfNull(bridgeRegistrar); @@ -340,16 +340,21 @@ namespace Tgstation.Server.Host.Components.Session Logger.LogTrace("Disposing..."); reattachTopicCts.Cancel(); - var semaphoreLockTask = TopicSendSemaphore.Lock(CancellationToken.None); // DCT: None available + var cancellationToken = CancellationToken.None; // DCT: None available + var semaphoreLockTask = TopicSendSemaphore.Lock(cancellationToken); if (!released) { - process.Terminate(); - await process.Lifetime; + await engineLock.StopServerProcess( + Logger, + process, + ReattachInformation.AccessIdentifier, + ReattachInformation.Port, + cancellationToken); } await process.DisposeAsync(); - byondLock.Dispose(); + engineLock.Dispose(); bridgeRegistration?.Dispose(); var regularDmbDisposeTask = ReattachInformation.Dmb.DisposeAsync(); var initialDmb = ReattachInformation.InitialDmb; @@ -395,7 +400,7 @@ namespace Tgstation.Server.Host.Components.Session ReattachInformation.Dmb.KeepAlive(); ReattachInformation.InitialDmb?.KeepAlive(); - byondLock.DoNotDeleteThisSession(); + engineLock.DoNotDeleteThisSession(); released = true; return DisposeAsync(); } diff --git a/src/Tgstation.Server.Host/System/IProcess.cs b/src/Tgstation.Server.Host/System/IProcess.cs index af7409ee9d..b0783cbd7e 100644 --- a/src/Tgstation.Server.Host/System/IProcess.cs +++ b/src/Tgstation.Server.Host/System/IProcess.cs @@ -7,7 +7,7 @@ namespace Tgstation.Server.Host.System /// /// Abstraction over a . /// - interface IProcess : IProcessBase, IAsyncDisposable + public interface IProcess : IProcessBase, IAsyncDisposable { /// /// The ' ID. diff --git a/src/Tgstation.Server.Host/System/IProcessBase.cs b/src/Tgstation.Server.Host/System/IProcessBase.cs index 3d1030f645..d7a20f43b7 100644 --- a/src/Tgstation.Server.Host/System/IProcessBase.cs +++ b/src/Tgstation.Server.Host/System/IProcessBase.cs @@ -6,7 +6,7 @@ namespace Tgstation.Server.Host.System /// /// Represents process lifetime. /// - interface IProcessBase + public interface IProcessBase { /// /// The resulting in the exit code of the process or if the process was detached. diff --git a/tests/Tgstation.Server.Host.Tests/Components/Engine/TestOpenDreamInstaller.cs b/tests/Tgstation.Server.Host.Tests/Components/Engine/TestOpenDreamInstaller.cs index 6b8024ddac..30d995f99c 100644 --- a/tests/Tgstation.Server.Host.Tests/Components/Engine/TestOpenDreamInstaller.cs +++ b/tests/Tgstation.Server.Host.Tests/Components/Engine/TestOpenDreamInstaller.cs @@ -9,10 +9,12 @@ using Moq; using Tgstation.Server.Api.Models; using Tgstation.Server.Api.Models.Internal; +using Tgstation.Server.Common.Http; using Tgstation.Server.Host.Components.Repository; using Tgstation.Server.Host.Configuration; using Tgstation.Server.Host.IO; using Tgstation.Server.Host.System; +using Tgstation.Server.Host.Utils; namespace Tgstation.Server.Host.Components.Engine.Tests { @@ -69,6 +71,8 @@ namespace Tgstation.Server.Host.Components.Engine.Tests Mock.Of(), Mock.Of(), mockRepositoryManager.Object, + Mock.Of(), + Mock.Of(), mockGeneralConfigOptions.Object); var data = await installer.DownloadVersion( diff --git a/tests/Tgstation.Server.Tests/Live/Instance/InstanceTest.cs b/tests/Tgstation.Server.Tests/Live/Instance/InstanceTest.cs index a50d4a6504..76bfa30b23 100644 --- a/tests/Tgstation.Server.Tests/Live/Instance/InstanceTest.cs +++ b/tests/Tgstation.Server.Tests/Live/Instance/InstanceTest.cs @@ -17,6 +17,7 @@ using Tgstation.Server.Api.Models.Request; using Tgstation.Server.Api.Models.Response; using Tgstation.Server.Client; using Tgstation.Server.Client.Components; +using Tgstation.Server.Common.Http; using Tgstation.Server.Host.Components; using Tgstation.Server.Host.Components.Engine; using Tgstation.Server.Host.Components.Events; @@ -25,6 +26,7 @@ using Tgstation.Server.Host.Configuration; using Tgstation.Server.Host.IO; using Tgstation.Server.Host.Jobs; using Tgstation.Server.Host.System; +using Tgstation.Server.Host.Utils; namespace Tgstation.Server.Tests.Live.Instance { @@ -116,6 +118,8 @@ namespace Tgstation.Server.Tests.Live.Instance Mock.Of>(), Mock.Of>(), genConfig), + Mock.Of(), + Mock.Of(), mockOptions.Object) : new PlatformIdentifier().IsWindows ? new WindowsByondInstaller( diff --git a/tests/Tgstation.Server.Tests/Live/Instance/WatchdogTest.cs b/tests/Tgstation.Server.Tests/Live/Instance/WatchdogTest.cs index c1778e63fa..4b08e3ae1f 100644 --- a/tests/Tgstation.Server.Tests/Live/Instance/WatchdogTest.cs +++ b/tests/Tgstation.Server.Tests/Live/Instance/WatchdogTest.cs @@ -1013,7 +1013,7 @@ namespace Tgstation.Server.Tests.Live.Instance Assert.IsNotNull(sessionObj); var session = (ISessionController)sessionObj; - return session.ReattachInformation.Port; + return session.ReattachInformation.TopicPort ?? session.ReattachInformation.Port; } // - Uses instance manager concrete From 523b3aa86e7e8155e32ced54c245536f6243be85 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Wed, 20 Dec 2023 14:02:52 -0500 Subject: [PATCH 257/425] Update `Z.EntityFramework.Plus.EFCore` --- src/Tgstation.Server.Host/Tgstation.Server.Host.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Tgstation.Server.Host/Tgstation.Server.Host.csproj b/src/Tgstation.Server.Host/Tgstation.Server.Host.csproj index 6bb958fb74..733400da3d 100644 --- a/src/Tgstation.Server.Host/Tgstation.Server.Host.csproj +++ b/src/Tgstation.Server.Host/Tgstation.Server.Host.csproj @@ -126,7 +126,7 @@ - + From 62d5dcb7ccf98d9e37f48e8e7da33b86a8f62a08 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Wed, 20 Dec 2023 14:09:56 -0500 Subject: [PATCH 258/425] Nullify `DreamDaemonController` --- .../Controllers/DreamDaemonController.cs | 41 +++++++++---------- .../Controllers/InstanceRequiredController.cs | 5 +++ 2 files changed, 25 insertions(+), 21 deletions(-) diff --git a/src/Tgstation.Server.Host/Controllers/DreamDaemonController.cs b/src/Tgstation.Server.Host/Controllers/DreamDaemonController.cs index 7c874e536a..f83ec8410f 100644 --- a/src/Tgstation.Server.Host/Controllers/DreamDaemonController.cs +++ b/src/Tgstation.Server.Host/Controllers/DreamDaemonController.cs @@ -25,8 +25,6 @@ using Tgstation.Server.Host.Utils; #pragma warning disable API1001 // Action method returns a success result without a corresponding ProducesResponseType. Somehow this happens ONLY IN THIS CONTROLLER??? -#nullable disable - namespace Tgstation.Server.Host.Controllers { /// @@ -174,7 +172,7 @@ namespace Tgstation.Server.Host.Controllers if (current == default) return this.Gone(); - if (model.Port.HasValue && model.Port.Value != current.Port.Value) + if (model.Port.HasValue && model.Port.Value != current.Port!.Value) { var verifiedPort = await portAllocator .GetAvailablePort( @@ -203,14 +201,15 @@ namespace Tgstation.Server.Host.Controllers return false; } + var ddRights = InstancePermissionSet.DreamDaemonRights!.Value; if (CheckModified(x => x.AllowWebClient, DreamDaemonRights.SetWebClient) || CheckModified(x => x.AutoStart, DreamDaemonRights.SetAutoStart) || CheckModified(x => x.Port, DreamDaemonRights.SetPort) || CheckModified(x => x.SecurityLevel, DreamDaemonRights.SetSecurity) || CheckModified(x => x.Visibility, DreamDaemonRights.SetVisibility) - || (model.SoftRestart.HasValue && !AuthenticationContext.InstancePermissionSet.DreamDaemonRights.Value.HasFlag(DreamDaemonRights.SoftRestart)) - || (model.SoftShutdown.HasValue && !AuthenticationContext.InstancePermissionSet.DreamDaemonRights.Value.HasFlag(DreamDaemonRights.SoftShutdown)) - || (!String.IsNullOrWhiteSpace(model.BroadcastMessage) && !AuthenticationContext.InstancePermissionSet.DreamDaemonRights.Value.HasFlag(DreamDaemonRights.BroadcastMessage)) + || (model.SoftRestart.HasValue && !ddRights.HasFlag(DreamDaemonRights.SoftRestart)) + || (model.SoftShutdown.HasValue && !ddRights.HasFlag(DreamDaemonRights.SoftShutdown)) + || (!String.IsNullOrWhiteSpace(model.BroadcastMessage) && !ddRights.HasFlag(DreamDaemonRights.BroadcastMessage)) || CheckModified(x => x.StartupTimeout, DreamDaemonRights.SetStartupTimeout) || CheckModified(x => x.HealthCheckSeconds, DreamDaemonRights.SetHealthCheckInterval) || CheckModified(x => x.DumpOnHealthCheckRestart, DreamDaemonRights.CreateDump) @@ -310,7 +309,7 @@ namespace Tgstation.Server.Host.Controllers /// If there was a settings change made that forced a switch to . /// The for the operation. /// A resulting in the of the operation. - ValueTask ReadImpl(DreamDaemonSettings settings, bool knownForcedReboot, CancellationToken cancellationToken) + ValueTask ReadImpl(DreamDaemonSettings? settings, bool knownForcedReboot, CancellationToken cancellationToken) => WithComponentInstance(async instance => { var dd = instance.Watchdog; @@ -324,7 +323,7 @@ namespace Tgstation.Server.Host.Controllers .Instances .AsQueryable() .Where(x => x.Id == Instance.Id) - .Select(x => x.DreamDaemonSettings) + .Select(x => x.DreamDaemonSettings!) .FirstOrDefaultAsync(cancellationToken); if (settings == default) return this.Gone(); @@ -336,13 +335,13 @@ namespace Tgstation.Server.Host.Controllers var alphaActive = dd.AlphaIsActive; var llp = dd.LastLaunchParameters; var rstate = dd.RebootState; - result.AutoStart = settings.AutoStart.Value; - result.CurrentPort = llp?.Port.Value; - result.CurrentSecurity = llp?.SecurityLevel.Value; - result.CurrentVisibility = llp?.Visibility.Value; - result.CurrentAllowWebclient = llp?.AllowWebClient.Value; - result.Port = settings.Port.Value; - result.AllowWebClient = settings.AllowWebClient.Value; + result.AutoStart = settings.AutoStart!.Value; + result.CurrentPort = llp?.Port!.Value; + result.CurrentSecurity = llp?.SecurityLevel!.Value; + result.CurrentVisibility = llp?.Visibility!.Value; + result.CurrentAllowWebclient = llp?.AllowWebClient!.Value; + result.Port = settings.Port!.Value; + result.AllowWebClient = settings.AllowWebClient!.Value; var firstIteration = true; do @@ -359,18 +358,18 @@ namespace Tgstation.Server.Host.Controllers } while (result.Status == WatchdogStatus.Online && !result.SessionId.HasValue); // this is the one invalid combo, it's not that racy - result.SecurityLevel = settings.SecurityLevel.Value; - result.Visibility = settings.Visibility.Value; + result.SecurityLevel = settings.SecurityLevel!.Value; + result.Visibility = settings.Visibility!.Value; result.SoftRestart = rstate == RebootState.Restart; result.SoftShutdown = rstate == RebootState.Shutdown; if (rstate == RebootState.Normal && knownForcedReboot) result.SoftRestart = true; - result.StartupTimeout = settings.StartupTimeout.Value; - result.HealthCheckSeconds = settings.HealthCheckSeconds.Value; - result.DumpOnHealthCheckRestart = settings.DumpOnHealthCheckRestart.Value; - result.TopicRequestTimeout = settings.TopicRequestTimeout.Value; + result.StartupTimeout = settings.StartupTimeout!.Value; + result.HealthCheckSeconds = settings.HealthCheckSeconds!.Value; + result.DumpOnHealthCheckRestart = settings.DumpOnHealthCheckRestart!.Value; + result.TopicRequestTimeout = settings.TopicRequestTimeout!.Value; result.AdditionalParameters = settings.AdditionalParameters; result.StartProfiler = settings.StartProfiler; result.LogOutput = settings.LogOutput; diff --git a/src/Tgstation.Server.Host/Controllers/InstanceRequiredController.cs b/src/Tgstation.Server.Host/Controllers/InstanceRequiredController.cs index 68dec10504..1e36f544b4 100644 --- a/src/Tgstation.Server.Host/Controllers/InstanceRequiredController.cs +++ b/src/Tgstation.Server.Host/Controllers/InstanceRequiredController.cs @@ -19,6 +19,11 @@ namespace Tgstation.Server.Host.Controllers /// protected new Models.Instance Instance => base.Instance!; + /// + /// The for the request. + /// + protected Models.InstancePermissionSet InstancePermissionSet => AuthenticationContext.InstancePermissionSet!; + /// /// Initializes a new instance of the class. /// From ecf95607e821c9934b0f832cbe0609c0babc5c46 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Wed, 20 Dec 2023 14:15:45 -0500 Subject: [PATCH 259/425] Nullify `DreamMakerController` --- .../Controllers/ApiController.cs | 4 +- .../Controllers/DreamMakerController.cs | 37 ++++++++++--------- 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/src/Tgstation.Server.Host/Controllers/ApiController.cs b/src/Tgstation.Server.Host/Controllers/ApiController.cs index ea8c4c3209..bad2e6c10f 100644 --- a/src/Tgstation.Server.Host/Controllers/ApiController.cs +++ b/src/Tgstation.Server.Host/Controllers/ApiController.cs @@ -267,7 +267,7 @@ namespace Tgstation.Server.Host.Controllers /// /// The of model being generated and returned. /// A resulting in a resulting in the generated . - /// A to transform the s after being queried. + /// Optional to transform the s after being queried. /// The requested page from the query. /// The requested page size from the query. /// The for the operation. @@ -297,7 +297,7 @@ namespace Tgstation.Server.Host.Controllers /// A resulting in the for the operation. protected ValueTask Paginated( Func>> queryGenerator, - Func resultTransformer, + Func? resultTransformer, int? pageQuery, int? pageSizeQuery, CancellationToken cancellationToken) diff --git a/src/Tgstation.Server.Host/Controllers/DreamMakerController.cs b/src/Tgstation.Server.Host/Controllers/DreamMakerController.cs index 9401f646d9..d1ef45fe48 100644 --- a/src/Tgstation.Server.Host/Controllers/DreamMakerController.cs +++ b/src/Tgstation.Server.Host/Controllers/DreamMakerController.cs @@ -21,8 +21,6 @@ using Tgstation.Server.Host.Models; using Tgstation.Server.Host.Security; using Tgstation.Server.Host.Utils; -#nullable disable - namespace Tgstation.Server.Host.Controllers { /// @@ -87,6 +85,10 @@ namespace Tgstation.Server.Host.Controllers .AsQueryable() .Where(x => x.InstanceId == Instance.Id) .FirstOrDefaultAsync(cancellationToken); + + if (dreamMakerSettings == null) + return this.Gone(); + return Json(dreamMakerSettings.ToApi()); } @@ -189,9 +191,10 @@ namespace Tgstation.Server.Host.Controllers if (hostModel == null) return this.Gone(); + var dreamMakerRights = InstancePermissionSet.DreamMakerRights!.Value; if (model.ProjectName != null) { - if (!AuthenticationContext.InstancePermissionSet.DreamMakerRights.Value.HasFlag(DreamMakerRights.SetDme)) + if (!dreamMakerRights.HasFlag(DreamMakerRights.SetDme)) return Forbid(); if (model.ProjectName.Length == 0) hostModel.ProjectName = null; @@ -201,10 +204,10 @@ namespace Tgstation.Server.Host.Controllers if (model.ApiValidationPort.HasValue) { - if (!AuthenticationContext.InstancePermissionSet.DreamMakerRights.Value.HasFlag(DreamMakerRights.SetApiValidationPort)) + if (!dreamMakerRights.HasFlag(DreamMakerRights.SetApiValidationPort)) return Forbid(); - if (model.ApiValidationPort.Value != hostModel.ApiValidationPort.Value) + if (model.ApiValidationPort.Value != hostModel.ApiValidationPort!.Value) { var verifiedPort = await portAllocator .GetAvailablePort( @@ -220,28 +223,28 @@ namespace Tgstation.Server.Host.Controllers if (model.ApiValidationSecurityLevel.HasValue) { - if (!AuthenticationContext.InstancePermissionSet.DreamMakerRights.Value.HasFlag(DreamMakerRights.SetSecurityLevel)) + if (!dreamMakerRights.HasFlag(DreamMakerRights.SetSecurityLevel)) return Forbid(); hostModel.ApiValidationSecurityLevel = model.ApiValidationSecurityLevel; } if (model.RequireDMApiValidation.HasValue) { - if (!AuthenticationContext.InstancePermissionSet.DreamMakerRights.Value.HasFlag(DreamMakerRights.SetApiValidationRequirement)) + if (!dreamMakerRights.HasFlag(DreamMakerRights.SetApiValidationRequirement)) return Forbid(); hostModel.RequireDMApiValidation = model.RequireDMApiValidation; } if (model.Timeout.HasValue) { - if (!AuthenticationContext.InstancePermissionSet.DreamMakerRights.Value.HasFlag(DreamMakerRights.SetTimeout)) + if (!dreamMakerRights.HasFlag(DreamMakerRights.SetTimeout)) return Forbid(); hostModel.Timeout = model.Timeout; } await DatabaseContext.Save(cancellationToken); - if ((AuthenticationContext.GetRight(RightsType.DreamMaker) & (ulong)DreamMakerRights.Read) == 0) + if (!dreamMakerRights.HasFlag(DreamMakerRights.Read)) return NoContent(); return await Read(cancellationToken); @@ -254,17 +257,17 @@ namespace Tgstation.Server.Host.Controllers IQueryable BaseCompileJobsQuery() => DatabaseContext .CompileJobs .AsQueryable() - .Include(x => x.Job) + .Include(x => x.Job!) .ThenInclude(x => x.StartedBy) - .Include(x => x.Job) + .Include(x => x.Job!) .ThenInclude(x => x.Instance) - .Include(x => x.RevisionInformation) - .ThenInclude(x => x.PrimaryTestMerge) + .Include(x => x.RevisionInformation!) + .ThenInclude(x => x.PrimaryTestMerge!) .ThenInclude(x => x.MergedBy) .Include(x => x.RevisionInformation) - .ThenInclude(x => x.ActiveTestMerges) - .ThenInclude(x => x.TestMerge) - .ThenInclude(x => x.MergedBy) - .Where(x => x.Job.Instance.Id == Instance.Id); + .ThenInclude(x => x.ActiveTestMerges!) + .ThenInclude(x => x!.TestMerge) + .ThenInclude(x => x!.MergedBy) + .Where(x => x.Job.Instance!.Id == Instance.Id); } } From 261d56655b5b328d276fb60796b516a797093fd0 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Wed, 20 Dec 2023 14:16:38 -0500 Subject: [PATCH 260/425] Remove unnecessary warning suppression --- src/Tgstation.Server.Host/Controllers/DreamMakerController.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Tgstation.Server.Host/Controllers/DreamMakerController.cs b/src/Tgstation.Server.Host/Controllers/DreamMakerController.cs index d1ef45fe48..680f8da731 100644 --- a/src/Tgstation.Server.Host/Controllers/DreamMakerController.cs +++ b/src/Tgstation.Server.Host/Controllers/DreamMakerController.cs @@ -27,7 +27,6 @@ namespace Tgstation.Server.Host.Controllers /// for managing the deployment system. /// [Route(Routes.DreamMaker)] -#pragma warning disable CA1506 // TODO: Decomplexify public sealed class DreamMakerController : InstanceRequiredController { /// From c9bb84236c7f79154bcf167c162e3446fd9d38c0 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Wed, 20 Dec 2023 14:23:41 -0500 Subject: [PATCH 261/425] Nullify `EngineController` --- .../Controllers/EngineController.cs | 43 +++++++++---------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/src/Tgstation.Server.Host/Controllers/EngineController.cs b/src/Tgstation.Server.Host/Controllers/EngineController.cs index a65ac97455..2f83a1afd8 100644 --- a/src/Tgstation.Server.Host/Controllers/EngineController.cs +++ b/src/Tgstation.Server.Host/Controllers/EngineController.cs @@ -23,8 +23,6 @@ using Tgstation.Server.Host.Security; using Tgstation.Server.Host.Transfer; using Tgstation.Server.Host.Utils; -#nullable disable - namespace Tgstation.Server.Host.Controllers { /// @@ -122,7 +120,7 @@ namespace Tgstation.Server.Host.Controllers EngineVersion = x, }) .AsQueryable() - .OrderBy(x => x.EngineVersion.ToString()))), + .OrderBy(x => x.EngineVersion!.ToString()))), null, page, pageSize, @@ -157,16 +155,16 @@ namespace Tgstation.Server.Host.Controllers var uploadingZip = model.UploadCustomZip == true; - var userByondRights = AuthenticationContext.InstancePermissionSet.EngineRights.Value; - var isByondEngine = model.EngineVersion.Engine.Value == EngineType.Byond; + var engineRights = InstancePermissionSet.EngineRights!.Value; + var isByondEngine = model.EngineVersion!.Engine!.Value == EngineType.Byond; var officialPerm = isByondEngine ? EngineRights.InstallOfficialOrChangeActiveByondVersion : EngineRights.InstallOfficialOrChangeActiveOpenDreamVersion; var customPerm = isByondEngine ? EngineRights.InstallCustomByondVersion : EngineRights.InstallCustomOpenDreamVersion; - if ((!userByondRights.HasFlag(officialPerm) && !uploadingZip) - || (!userByondRights.HasFlag(customPerm) && uploadingZip)) + if ((!engineRights.HasFlag(officialPerm) && !uploadingZip) + || (!engineRights.HasFlag(customPerm) && uploadingZip)) return Forbid(); // remove cruff fields @@ -219,7 +217,7 @@ namespace Tgstation.Server.Host.Controllers EngineRights.CancelInstall); job.Description += $" {model.EngineVersion}"; - IFileUploadTicket fileUploadTicket = null; + IFileUploadTicket? fileUploadTicket = null; if (uploadingZip) fileUploadTicket = fileTransferService.CreateUpload(FileUploadStreamKind.None); @@ -229,7 +227,7 @@ namespace Tgstation.Server.Host.Controllers job, async (core, databaseContextFactory, paramJob, progressHandler, jobCancellationToken) => { - MemoryStream zipFileStream = null; + MemoryStream? zipFileStream = null; if (fileUploadTicket != null) await using (fileUploadTicket) { @@ -293,18 +291,19 @@ namespace Tgstation.Server.Host.Controllers if (earlyOut != null) return earlyOut; - var notInstalledResponse = await WithComponentInstance( + var engineVersion = model.EngineVersion!; + var notInstalledResponse = await WithComponentInstanceNullable( instance => { var byondManager = instance.EngineManager; - if (model.EngineVersion.Equals(byondManager.ActiveVersion)) - return ValueTask.FromResult( + if (engineVersion.Equals(byondManager.ActiveVersion)) + return ValueTask.FromResult( Conflict(new ErrorMessageResponse(ErrorCode.EngineCannotDeleteActiveVersion))); - var versionNotInstalled = !byondManager.InstalledVersions.Any(x => x.Equals(model.EngineVersion)); + var versionNotInstalled = !byondManager.InstalledVersions.Any(x => x.Equals(engineVersion)); - return ValueTask.FromResult( + return ValueTask.FromResult( versionNotInstalled ? this.Gone() : null); @@ -313,24 +312,24 @@ namespace Tgstation.Server.Host.Controllers if (notInstalledResponse != null) return notInstalledResponse; - var isByondVersion = model.EngineVersion.Engine.Value == EngineType.Byond; + var isByondVersion = engineVersion.Engine!.Value == EngineType.Byond; // run the install through the job manager var cancelRight = isByondVersion - ? model.EngineVersion.CustomIteration.HasValue + ? engineVersion.CustomIteration.HasValue ? EngineRights.InstallCustomByondVersion : EngineRights.InstallOfficialOrChangeActiveByondVersion - : model.EngineVersion.CustomIteration.HasValue + : engineVersion.CustomIteration.HasValue ? EngineRights.InstallOfficialOrChangeActiveOpenDreamVersion : EngineRights.InstallCustomOpenDreamVersion; var job = Models.Job.Create(JobCode.EngineDelete, AuthenticationContext.User, Instance, cancelRight); - job.Description += $" {model.EngineVersion}"; + job.Description += $" {engineVersion}"; await jobManager.RegisterOperation( job, (instanceCore, databaseContextFactory, job, progressReporter, jobCancellationToken) - => instanceCore.EngineManager.DeleteVersion(progressReporter, model.EngineVersion, jobCancellationToken), + => instanceCore.EngineManager.DeleteVersion(progressReporter, engineVersion, jobCancellationToken), cancellationToken); var apiResponse = job.ToApi(); @@ -341,8 +340,8 @@ namespace Tgstation.Server.Host.Controllers /// Validate and normalize a given . /// /// The to validate and normalize. - /// The to return, if any. - BadRequestObjectResult ValidateEngineVersion(EngineVersion version) + /// The to return, if any. otherwise. + BadRequestObjectResult? ValidateEngineVersion(EngineVersion? version) { if (version == null || !version.Engine.HasValue) return BadRequest(new ErrorMessageResponse(ErrorCode.ModelValidationFailure)); @@ -359,7 +358,7 @@ namespace Tgstation.Server.Host.Controllers if (isByond) { - version.Version = NormalizeByondVersion(version.Version); + version.Version = NormalizeByondVersion(version.Version!); if (version.Version.Build != -1) return BadRequest(new ErrorMessageResponse(ErrorCode.ModelValidationFailure)); } From a5f69bf25429778c954d470e60a838e8f29f70e1 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Wed, 20 Dec 2023 14:42:46 -0500 Subject: [PATCH 262/425] Nullify `InstanceController` Also switch to using job codes for move job detection. --- src/Tgstation.Server.Api/Models/ErrorCode.cs | 6 +- src/Tgstation.Server.Api/Models/JobCode.cs | 2 +- .../Controllers/InstanceController.cs | 84 +++++++++---------- 3 files changed, 45 insertions(+), 47 deletions(-) diff --git a/src/Tgstation.Server.Api/Models/ErrorCode.cs b/src/Tgstation.Server.Api/Models/ErrorCode.cs index 886816346a..28f39a7638 100644 --- a/src/Tgstation.Server.Api/Models/ErrorCode.cs +++ b/src/Tgstation.Server.Api/Models/ErrorCode.cs @@ -150,10 +150,10 @@ namespace Tgstation.Server.Api.Models InstanceLimitReached, /// - /// Attempted to create an with a whitespace . + /// Attempted to create an with a whitespace or . /// - [Description("Instance names cannot be whitespace!")] - InstanceWhitespaceName, + [Description("Instance names and paths cannot be whitespace!")] + InstanceWhitespaceNameOrPath, /// /// The header was required but not set. diff --git a/src/Tgstation.Server.Api/Models/JobCode.cs b/src/Tgstation.Server.Api/Models/JobCode.cs index e82600b302..be5db8d5a6 100644 --- a/src/Tgstation.Server.Api/Models/JobCode.cs +++ b/src/Tgstation.Server.Api/Models/JobCode.cs @@ -16,7 +16,7 @@ namespace Tgstation.Server.Api.Models /// /// When the instance is being moved. /// - [Description("Instance move")] + [Description("Move instance")] Move, /// diff --git a/src/Tgstation.Server.Host/Controllers/InstanceController.cs b/src/Tgstation.Server.Host/Controllers/InstanceController.cs index 471a0fd006..ddad25bca7 100644 --- a/src/Tgstation.Server.Host/Controllers/InstanceController.cs +++ b/src/Tgstation.Server.Host/Controllers/InstanceController.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; using System.IO; using System.Linq; using System.Linq.Expressions; @@ -29,8 +30,6 @@ using Tgstation.Server.Host.Security; using Tgstation.Server.Host.System; using Tgstation.Server.Host.Utils; -#nullable disable - namespace Tgstation.Server.Host.Controllers { /// @@ -45,11 +44,6 @@ namespace Tgstation.Server.Host.Controllers /// public const string InstanceAttachFileName = "TGS4_ALLOW_INSTANCE_ATTACH"; - /// - /// Prefix for move s. - /// - const string MoveInstanceJobPrefix = "Move instance ID "; - /// /// The for the . /// @@ -147,8 +141,8 @@ namespace Tgstation.Server.Host.Controllers { ArgumentNullException.ThrowIfNull(model); - if (String.IsNullOrWhiteSpace(model.Name)) - return BadRequest(new ErrorMessageResponse(ErrorCode.InstanceWhitespaceName)); + if (String.IsNullOrWhiteSpace(model.Name) || String.IsNullOrWhiteSpace(model.Path)) + return BadRequest(new ErrorMessageResponse(ErrorCode.InstanceWhitespaceNameOrPath)); var unNormalizedPath = model.Path; var targetInstancePath = NormalizePath(unNormalizedPath); @@ -172,7 +166,7 @@ namespace Tgstation.Server.Host.Controllers return Conflict(new ErrorMessageResponse(ErrorCode.InstanceAtConflictingPath)); // Validate it's not a child of any other instance - IActionResult earlyOut = null; + IActionResult? earlyOut = null; ulong countOfOtherInstances = 0; using (var cts = CancellationTokenSource.CreateLinkedTokenSource(cancellationToken)) { @@ -192,7 +186,7 @@ namespace Tgstation.Server.Host.Controllers { if (++countOfOtherInstances >= generalConfiguration.InstanceLimit) earlyOut ??= Conflict(new ErrorMessageResponse(ErrorCode.InstanceLimitReached)); - else if (InstanceIsChildOf(otherInstance.Path)) + else if (InstanceIsChildOf(otherInstance.Path!)) earlyOut ??= Conflict(new ErrorMessageResponse(ErrorCode.InstanceAtConflictingPath)); if (earlyOut != null && !newCancellationToken.IsCancellationRequested) @@ -308,15 +302,16 @@ namespace Tgstation.Server.Host.Controllers .FirstOrDefaultAsync(cancellationToken); if (originalModel == default) return this.Gone(); - if (originalModel.Online.Value) + if (originalModel.Online!.Value) return Conflict(new ErrorMessageResponse(ErrorCode.InstanceDetachOnline)); DatabaseContext.Instances.Remove(originalModel); - var attachFileName = ioManager.ConcatPath(originalModel.Path, InstanceAttachFileName); + var originalPath = originalModel.Path!; + var attachFileName = ioManager.ConcatPath(originalPath, InstanceAttachFileName); try { - if (await ioManager.DirectoryExists(originalModel.Path, cancellationToken)) + if (await ioManager.DirectoryExists(originalPath, cancellationToken)) await ioManager.WriteAllBytes(attachFileName, Array.Empty(), cancellationToken); } catch (OperationCanceledException) @@ -355,14 +350,15 @@ namespace Tgstation.Server.Host.Controllers .Where(x => x.Id == model.Id && x.SwarmIdentifer == swarmConfiguration.Identifier); var moveJob = await InstanceQuery() - .SelectMany(x => x.Jobs). - Where(x => !x.StoppedAt.HasValue && x.Description.StartsWith(MoveInstanceJobPrefix)) - .Select(x => new Job(x.Id.Value)).FirstOrDefaultAsync(cancellationToken); + .SelectMany(x => x.Jobs) + .Where(x => !x.StoppedAt.HasValue && x.JobCode == JobCode.Move) + .Select(x => new Job(x.Id!.Value)) + .FirstOrDefaultAsync(cancellationToken); - if (moveJob != default) + if (moveJob != null) { // don't allow them to cancel it if they can't start it. - if (!AuthenticationContext.PermissionSet.InstanceManagerRights.Value.HasFlag(InstanceManagerRights.Relocate)) + if (!AuthenticationContext.PermissionSet.InstanceManagerRights!.Value.HasFlag(InstanceManagerRights.Relocate)) return Forbid(); await jobManager.CancelJob(moveJob, AuthenticationContext.User, true, cancellationToken); // cancel it now } @@ -395,8 +391,9 @@ namespace Tgstation.Server.Host.Controllers return false; } - string originalModelPath = null; - string rawPath = null; + string? originalModelPath = null; + string? rawPath = null; + var originalOnline = originalModel.Online!.Value; if (model.Path != null) { rawPath = NormalizePath(model.Path); @@ -405,7 +402,7 @@ namespace Tgstation.Server.Host.Controllers { if (!userRights.HasFlag(InstanceManagerRights.Relocate)) return Forbid(); - if (originalModel.Online.Value && model.Online != true) + if (originalOnline && model.Online != true) return Conflict(new ErrorMessageResponse(ErrorCode.InstanceRelocateOnline)); var dirExistsTask = ioManager.DirectoryExists(model.Path, cancellationToken); @@ -417,8 +414,7 @@ namespace Tgstation.Server.Host.Controllers } } - var oldAutoUpdateInterval = originalModel.AutoUpdateInterval.Value; - var originalOnline = originalModel.Online.Value; + var oldAutoUpdateInterval = originalModel.AutoUpdateInterval!.Value; var renamed = model.Name != null && originalModel.Name != model.Name; if (CheckModified(x => x.AutoUpdateInterval, InstanceManagerRights.SetAutoUpdate) @@ -445,7 +441,7 @@ namespace Tgstation.Server.Host.Controllers if (renamed) { // ignoring retval because we don't care if it's offline - await WithComponentInstance( + await WithComponentInstanceNullable( async componentInstance => { await componentInstance.InstanceRenamed(originalModel.Name, cancellationToken); @@ -454,7 +450,7 @@ namespace Tgstation.Server.Host.Controllers originalModel); } - var oldAutoStart = originalModel.DreamDaemonSettings.AutoStart; + var oldAutoStart = originalModel.DreamDaemonSettings!.AutoStart; try { if (originalOnline && model.Online == false) @@ -489,7 +485,7 @@ namespace Tgstation.Server.Host.Controllers var moving = originalModelPath != null; if (moving) { - var description = $"{MoveInstanceJobPrefix}{originalModel.Id} from {originalModelPath} to {rawPath}"; + var description = $"Move instance ID {originalModel.Id} from {originalModelPath} to {rawPath}"; var job = Job.Create(JobCode.Move, AuthenticationContext.User, originalModel, InstanceManagerRights.Relocate); job.Description = description; @@ -504,7 +500,7 @@ namespace Tgstation.Server.Host.Controllers if (model.AutoUpdateInterval.HasValue && oldAutoUpdateInterval != model.AutoUpdateInterval) { // ignoring retval because we don't care if it's offline - await WithComponentInstance( + await WithComponentInstanceNullable( async componentInstance => { await componentInstance.SetAutoUpdateInterval(model.AutoUpdateInterval.Value); @@ -540,9 +536,9 @@ namespace Tgstation.Server.Host.Controllers .Instances .AsQueryable() .Where(x => x.SwarmIdentifer == swarmConfiguration.Identifier); - if (!AuthenticationContext.PermissionSet.InstanceManagerRights.Value.HasFlag(InstanceManagerRights.List)) + if (!AuthenticationContext.PermissionSet.InstanceManagerRights!.Value.HasFlag(InstanceManagerRights.List)) query = query - .Where(x => x.InstancePermissionSets.Any(y => y.PermissionSetId == AuthenticationContext.PermissionSet.Id.Value)) + .Where(x => x.InstancePermissionSets.Any(y => y.PermissionSetId == AuthenticationContext.PermissionSet.Id)) .Where(x => x.InstancePermissionSets.Any(instanceUser => instanceUser.EngineRights != EngineRights.None || instanceUser.ChatBotRights != ChatBotRights.None || @@ -557,8 +553,9 @@ namespace Tgstation.Server.Host.Controllers var moveJobs = await GetBaseQuery() .SelectMany(x => x.Jobs) - .Where(x => !x.StoppedAt.HasValue && x.Description.StartsWith(MoveInstanceJobPrefix)) - .Include(x => x.StartedBy).ThenInclude(x => x.CreatedBy) + .Where(x => !x.StoppedAt.HasValue && x.JobCode == JobCode.Move) + .Include(x => x.StartedBy!) + .ThenInclude(x => x.CreatedBy) .Include(x => x.Instance) .ToListAsync(cancellationToken); @@ -571,7 +568,7 @@ namespace Tgstation.Server.Host.Controllers async instance => { needsUpdate |= ValidateInstanceOnlineStatus(instance); - instance.MoveJob = moveJobs.FirstOrDefault(x => x.Instance.Id == instance.Id)?.ToApi(); + instance.MoveJob = moveJobs.FirstOrDefault(x => x.Instance!.Id == instance.Id)?.ToApi(); await CheckAccessible(instance, cancellationToken); }, page, @@ -598,7 +595,7 @@ namespace Tgstation.Server.Host.Controllers [ProducesResponseType(typeof(ErrorMessageResponse), 410)] public async ValueTask GetId(long id, CancellationToken cancellationToken) { - var cantList = !AuthenticationContext.PermissionSet.InstanceManagerRights.Value.HasFlag(InstanceManagerRights.List); + var cantList = !AuthenticationContext.PermissionSet.InstanceManagerRights!.Value.HasFlag(InstanceManagerRights.List); IQueryable QueryForUser() { var query = DatabaseContext @@ -619,8 +616,8 @@ namespace Tgstation.Server.Host.Controllers if (ValidateInstanceOnlineStatus(instance)) await DatabaseContext.Save(cancellationToken); - if (cantList && !instance.InstancePermissionSets.Any(instanceUser => instanceUser.PermissionSetId == AuthenticationContext.PermissionSet.Id.Value && - (instanceUser.RepositoryRights != RepositoryRights.None || + if (cantList && !instance.InstancePermissionSets.Any(instanceUser => instanceUser.PermissionSetId == AuthenticationContext.PermissionSet.Require(x => x.Id) + && (instanceUser.RepositoryRights != RepositoryRights.None || instanceUser.EngineRights != EngineRights.None || instanceUser.ChatBotRights != ChatBotRights.None || instanceUser.ConfigurationRights != ConfigurationRights.None || @@ -633,8 +630,8 @@ namespace Tgstation.Server.Host.Controllers var moveJob = await QueryForUser() .SelectMany(x => x.Jobs) - .Where(x => !x.StoppedAt.HasValue && x.Description.StartsWith(MoveInstanceJobPrefix)) - .Include(x => x.StartedBy) + .Where(x => !x.StoppedAt.HasValue && x.JobCode == JobCode.Move) + .Include(x => x.StartedBy!) .ThenInclude(x => x.CreatedBy) .Include(x => x.Instance) .FirstOrDefaultAsync(cancellationToken); @@ -664,7 +661,7 @@ namespace Tgstation.Server.Host.Controllers // ensure the current user has write privilege on the instance var usersInstancePermissionSet = await BaseQuery() .SelectMany(x => x.InstancePermissionSets) - .Where(x => x.PermissionSetId == AuthenticationContext.PermissionSet.Id.Value) + .Where(x => x.PermissionSetId == AuthenticationContext.PermissionSet.Id) .FirstOrDefaultAsync(cancellationToken); if (usersInstancePermissionSet == default) { @@ -693,7 +690,7 @@ namespace Tgstation.Server.Host.Controllers /// The . /// The for the operation. /// A resulting in the new or if ports could not be allocated. - async ValueTask CreateDefaultInstance(InstanceCreateRequest initialSettings, CancellationToken cancellationToken) + async ValueTask CreateDefaultInstance(InstanceCreateRequest initialSettings, CancellationToken cancellationToken) { var ddPort = await portAllocator.GetAvailablePort(1024, false, cancellationToken); if (!ddPort.HasValue) @@ -773,12 +770,12 @@ namespace Tgstation.Server.Host.Controllers /// /// An optional existing to update. /// or a new with full rights. - InstancePermissionSet InstanceAdminPermissionSet(InstancePermissionSet permissionSetToModify) + InstancePermissionSet InstanceAdminPermissionSet(InstancePermissionSet? permissionSetToModify) { permissionSetToModify ??= new InstancePermissionSet() { PermissionSet = AuthenticationContext.PermissionSet, - PermissionSetId = AuthenticationContext.PermissionSet.Id.Value, + PermissionSetId = AuthenticationContext.PermissionSet.Require(x => x.Id), }; permissionSetToModify.EngineRights = RightsHelper.AllRights(); permissionSetToModify.ChatBotRights = RightsHelper.AllRights(); @@ -795,7 +792,8 @@ namespace Tgstation.Server.Host.Controllers /// /// The path to normalize. /// The normalized . - string NormalizePath(string path) + [return: NotNullIfNotNull(nameof(path))] + string? NormalizePath(string? path) { if (path == null) return null; From e02aff71d1b5cb3fbc9b5dd3c028182bcd9b693c Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Wed, 20 Dec 2023 14:44:50 -0500 Subject: [PATCH 263/425] Nullify `InstancePermissionSetController` --- .../InstancePermissionSetController.cs | 22 +++++++++---------- 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/src/Tgstation.Server.Host/Controllers/InstancePermissionSetController.cs b/src/Tgstation.Server.Host/Controllers/InstancePermissionSetController.cs index d5d4a0fb79..d86f0b7877 100644 --- a/src/Tgstation.Server.Host/Controllers/InstancePermissionSetController.cs +++ b/src/Tgstation.Server.Host/Controllers/InstancePermissionSetController.cs @@ -22,8 +22,6 @@ using Tgstation.Server.Host.Utils; using Z.EntityFramework.Plus; -#nullable disable - namespace Tgstation.Server.Host.Controllers { /// @@ -117,7 +115,7 @@ namespace Tgstation.Server.Host.Controllers RepositoryRights = RightsHelper.Clamp(model.RepositoryRights ?? RepositoryRights.None), InstancePermissionSetRights = RightsHelper.Clamp(model.InstancePermissionSetRights ?? InstancePermissionSetRights.None), PermissionSetId = model.PermissionSetId, - InstanceId = Instance.Id.Value, + InstanceId = Instance.Require(x => x.Id), }; DatabaseContext.InstancePermissionSets.Add(dbUser); @@ -158,16 +156,16 @@ namespace Tgstation.Server.Host.Controllers if (originalPermissionSet == null) return this.Gone(); - originalPermissionSet.EngineRights = RightsHelper.Clamp(model.EngineRights ?? originalPermissionSet.EngineRights.Value); - originalPermissionSet.RepositoryRights = RightsHelper.Clamp(model.RepositoryRights ?? originalPermissionSet.RepositoryRights.Value); - originalPermissionSet.InstancePermissionSetRights = RightsHelper.Clamp(model.InstancePermissionSetRights ?? originalPermissionSet.InstancePermissionSetRights.Value); - originalPermissionSet.ChatBotRights = RightsHelper.Clamp(model.ChatBotRights ?? originalPermissionSet.ChatBotRights.Value); - originalPermissionSet.ConfigurationRights = RightsHelper.Clamp(model.ConfigurationRights ?? originalPermissionSet.ConfigurationRights.Value); - originalPermissionSet.DreamDaemonRights = RightsHelper.Clamp(model.DreamDaemonRights ?? originalPermissionSet.DreamDaemonRights.Value); - originalPermissionSet.DreamMakerRights = RightsHelper.Clamp(model.DreamMakerRights ?? originalPermissionSet.DreamMakerRights.Value); + originalPermissionSet.EngineRights = RightsHelper.Clamp(model.EngineRights ?? originalPermissionSet.EngineRights!.Value); + originalPermissionSet.RepositoryRights = RightsHelper.Clamp(model.RepositoryRights ?? originalPermissionSet.RepositoryRights!.Value); + originalPermissionSet.InstancePermissionSetRights = RightsHelper.Clamp(model.InstancePermissionSetRights ?? originalPermissionSet.InstancePermissionSetRights!.Value); + originalPermissionSet.ChatBotRights = RightsHelper.Clamp(model.ChatBotRights ?? originalPermissionSet.ChatBotRights!.Value); + originalPermissionSet.ConfigurationRights = RightsHelper.Clamp(model.ConfigurationRights ?? originalPermissionSet.ConfigurationRights!.Value); + originalPermissionSet.DreamDaemonRights = RightsHelper.Clamp(model.DreamDaemonRights ?? originalPermissionSet.DreamDaemonRights!.Value); + originalPermissionSet.DreamMakerRights = RightsHelper.Clamp(model.DreamMakerRights ?? originalPermissionSet.DreamMakerRights!.Value); await DatabaseContext.Save(cancellationToken); - var showFullPermissionSet = originalPermissionSet.PermissionSetId == AuthenticationContext.PermissionSet.Id.Value + var showFullPermissionSet = originalPermissionSet.PermissionSetId == AuthenticationContext.PermissionSet.Require(x => x.Id) || (AuthenticationContext.GetRight(RightsType.InstancePermissionSet) & (ulong)InstancePermissionSetRights.Read) != 0; return Json( showFullPermissionSet @@ -186,7 +184,7 @@ namespace Tgstation.Server.Host.Controllers [HttpGet] [TgsAuthorize] [ProducesResponseType(typeof(InstancePermissionSetResponse), 200)] - public IActionResult Read() => Json(AuthenticationContext.InstancePermissionSet.ToApi()); + public IActionResult Read() => Json(InstancePermissionSet.ToApi()); /// /// Lists s for the instance. From 83d07d5071bb41d280ed8e108924d9626faf0c52 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Wed, 20 Dec 2023 14:45:18 -0500 Subject: [PATCH 264/425] Clean up a `ValueTask` message --- .../Components/Engine/TestOpenDreamInstaller.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Tgstation.Server.Host.Tests/Components/Engine/TestOpenDreamInstaller.cs b/tests/Tgstation.Server.Host.Tests/Components/Engine/TestOpenDreamInstaller.cs index 30d995f99c..f5d158259c 100644 --- a/tests/Tgstation.Server.Host.Tests/Components/Engine/TestOpenDreamInstaller.cs +++ b/tests/Tgstation.Server.Host.Tests/Components/Engine/TestOpenDreamInstaller.cs @@ -53,7 +53,7 @@ namespace Tgstation.Server.Host.Components.Engine.Tests true, It.IsAny())) .Callback(() => ++cloneAttempts) - .Returns(ValueTask.FromResult(needsClone ? mockRepository.Object : null)) + .ReturnsAsync(needsClone ? mockRepository.Object : null) .Verifiable(Times.Exactly(1)); mockRepositoryManager.Setup(x => x.LoadRepository( From 5031d54ea21b2581810144cbd8f725de8c478bf4 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Wed, 20 Dec 2023 14:47:15 -0500 Subject: [PATCH 265/425] Nullify `InstanceRequiredController` --- .../Controllers/InstanceRequiredController.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Controllers/InstanceRequiredController.cs b/src/Tgstation.Server.Host/Controllers/InstanceRequiredController.cs index 1e36f544b4..f3a6ff9bdc 100644 --- a/src/Tgstation.Server.Host/Controllers/InstanceRequiredController.cs +++ b/src/Tgstation.Server.Host/Controllers/InstanceRequiredController.cs @@ -5,8 +5,6 @@ using Tgstation.Server.Host.Database; using Tgstation.Server.Host.Security; using Tgstation.Server.Host.Utils; -#nullable disable - namespace Tgstation.Server.Host.Controllers { /// From 665868b1dffe935ef8071a1857e834bd55e1ddd6 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Wed, 20 Dec 2023 14:47:58 -0500 Subject: [PATCH 266/425] Nullify `JobController` --- src/Tgstation.Server.Host/Controllers/JobController.cs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/Tgstation.Server.Host/Controllers/JobController.cs b/src/Tgstation.Server.Host/Controllers/JobController.cs index 6019223426..2b9f1b15f1 100644 --- a/src/Tgstation.Server.Host/Controllers/JobController.cs +++ b/src/Tgstation.Server.Host/Controllers/JobController.cs @@ -19,8 +19,6 @@ using Tgstation.Server.Host.Models; using Tgstation.Server.Host.Security; using Tgstation.Server.Host.Utils; -#nullable disable - namespace Tgstation.Server.Host.Controllers { /// @@ -81,7 +79,7 @@ namespace Tgstation.Server.Host.Controllers .Include(x => x.StartedBy) .Include(x => x.CancelledBy) .Include(x => x.Instance) - .Where(x => x.Instance.Id == Instance.Id && !x.StoppedAt.HasValue) + .Where(x => x.Instance!.Id == Instance.Id && !x.StoppedAt.HasValue) .OrderByDescending(x => x.StartedAt))), AddJobProgressResponseTransformer, page, @@ -109,7 +107,7 @@ namespace Tgstation.Server.Host.Controllers .Include(x => x.StartedBy) .Include(x => x.CancelledBy) .Include(x => x.Instance) - .Where(x => x.Instance.Id == Instance.Id) + .Where(x => x.Instance!.Id == Instance.Id) .OrderByDescending(x => x.StartedAt))), AddJobProgressResponseTransformer, page, @@ -137,7 +135,7 @@ namespace Tgstation.Server.Host.Controllers .AsQueryable() .Include(x => x.StartedBy) .Include(x => x.Instance) - .Where(x => x.Id == id && x.Instance.Id == Instance.Id) + .Where(x => x.Id == id && x.Instance!.Id == Instance.Id) .FirstOrDefaultAsync(cancellationToken); if (job == default) return NotFound(); @@ -169,7 +167,7 @@ namespace Tgstation.Server.Host.Controllers var job = await DatabaseContext .Jobs .AsQueryable() - .Where(x => x.Id == id && x.Instance.Id == Instance.Id) + .Where(x => x.Id == id && x.Instance!.Id == Instance.Id) .Include(x => x.StartedBy) .Include(x => x.CancelledBy) .Include(x => x.Instance) From 0e34a666267ce80ec3465c6f68699c2008e85549 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Wed, 20 Dec 2023 14:50:04 -0500 Subject: [PATCH 267/425] Nullify `RepositoryController` --- .../Controllers/RepositoryController.cs | 42 +++++++++---------- 1 file changed, 19 insertions(+), 23 deletions(-) diff --git a/src/Tgstation.Server.Host/Controllers/RepositoryController.cs b/src/Tgstation.Server.Host/Controllers/RepositoryController.cs index dbf80a4171..dcff26b25e 100644 --- a/src/Tgstation.Server.Host/Controllers/RepositoryController.cs +++ b/src/Tgstation.Server.Host/Controllers/RepositoryController.cs @@ -24,8 +24,6 @@ using Tgstation.Server.Host.Models; using Tgstation.Server.Host.Security; using Tgstation.Server.Host.Utils; -#nullable disable - namespace Tgstation.Server.Host.Controllers { /// @@ -213,7 +211,7 @@ namespace Tgstation.Server.Host.Controllers await DatabaseContext.Save(cancellationToken); - Logger.LogInformation("Instance {instanceId} repository delete initiated by user {userId}", Instance.Id, AuthenticationContext.User.Id.Value); + Logger.LogInformation("Instance {instanceId} repository delete initiated by user {userId}", Instance.Id, AuthenticationContext.User.Require(x => x.Id)); var job = Job.Create(JobCode.RepositoryDelete, AuthenticationContext.User, Instance); var api = currentModel.ToApi(); @@ -378,23 +376,23 @@ namespace Tgstation.Server.Host.Controllers var api = canRead ? currentModel.ToApi() : new RepositoryResponse(); if (canRead) { - var earlyOut = await WithComponentInstance( - async instance => - { - var repoManager = instance.RepositoryManager; - if (repoManager.CloneInProgress) - return Conflict(new ErrorMessageResponse(ErrorCode.RepoCloning)); + var earlyOut = await WithComponentInstanceNullable( + async instance => + { + var repoManager = instance.RepositoryManager; + if (repoManager.CloneInProgress) + return Conflict(new ErrorMessageResponse(ErrorCode.RepoCloning)); - if (repoManager.InUse) - return Conflict(new ErrorMessageResponse(ErrorCode.RepoBusy)); + if (repoManager.InUse) + return Conflict(new ErrorMessageResponse(ErrorCode.RepoBusy)); - using var repo = await repoManager.LoadRepository(cancellationToken); - if (repo == null) - return Conflict(new ErrorMessageResponse(ErrorCode.RepoMissing)); - await PopulateApi(api, repo, DatabaseContext, Instance, cancellationToken); + using var repo = await repoManager.LoadRepository(cancellationToken); + if (repo == null) + return Conflict(new ErrorMessageResponse(ErrorCode.RepoMissing)); + await PopulateApi(api, repo, DatabaseContext, Instance, cancellationToken); - return null; - }); + return null; + }); if (earlyOut != null) return earlyOut; @@ -404,7 +402,7 @@ namespace Tgstation.Server.Host.Controllers await DatabaseContext.Save(cancellationToken); // format the job description - string description = null; + string? description = null; if (model.UpdateFromOrigin == true) if (model.Reference != null) description = String.Format(CultureInfo.InvariantCulture, "Fetch and hard reset repository to origin/{0}", model.Reference); @@ -424,7 +422,7 @@ namespace Tgstation.Server.Host.Controllers : "T", String.Join( ", ", - model.NewTestMerges.Select( + model.NewTestMerges!.Select( x => String.Format( CultureInfo.InvariantCulture, "#{0}{1}", @@ -450,7 +448,7 @@ namespace Tgstation.Server.Host.Controllers currentModel, AuthenticationContext.User, loggerFactory.CreateLogger(), - Instance.Id.Value); + Instance.Require(x => x.Id)); // Time to access git, do it in a job await jobManager.RegisterOperation( @@ -486,16 +484,14 @@ namespace Tgstation.Server.Host.Controllers apiResponse.Reference = repository.Reference; // rev info stuff - Models.RevisionInformation revisionInfo = null; var needsDbUpdate = await RepositoryUpdateService.LoadRevisionInformation( repository, databaseContext, Logger, instance, null, - newRevInfo => revisionInfo = newRevInfo, + newRevInfo => apiResponse.RevisionInformation = newRevInfo.ToApi(), cancellationToken); - apiResponse.RevisionInformation = revisionInfo.ToApi(); return needsDbUpdate; } } From ee0953ba81df24eef5723b4db557731f4392831e Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Wed, 20 Dec 2023 14:51:05 -0500 Subject: [PATCH 268/425] Nullify `RootController` --- src/Tgstation.Server.Host/Controllers/RootController.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Tgstation.Server.Host/Controllers/RootController.cs b/src/Tgstation.Server.Host/Controllers/RootController.cs index ffc7f05029..9ae6e7e942 100644 --- a/src/Tgstation.Server.Host/Controllers/RootController.cs +++ b/src/Tgstation.Server.Host/Controllers/RootController.cs @@ -12,8 +12,6 @@ using Tgstation.Server.Host.Extensions; using Tgstation.Server.Host.System; using Tgstation.Server.Host.Utils; -#nullable disable - namespace Tgstation.Server.Host.Controllers { /// @@ -106,7 +104,7 @@ namespace Tgstation.Server.Host.Controllers else return Redirect(ApiDocumentationRoute); - Dictionary links; + Dictionary? links; if (panelEnabled) links = new Dictionary() { @@ -136,7 +134,7 @@ namespace Tgstation.Server.Host.Controllers ? LogoSvgWindowsName : LogoSvgLinuxName; - return (IActionResult)this.TryServeFile(hostEnvironment, logger, $"{logoFileName}.svg") ?? NotFound(); + return (IActionResult?)this.TryServeFile(hostEnvironment, logger, $"{logoFileName}.svg") ?? NotFound(); } } } From d615983a70133843f0928bdbc4003a6008f83702 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Wed, 20 Dec 2023 14:56:57 -0500 Subject: [PATCH 269/425] Nullify `SwarmController` --- .../Controllers/SwarmController.cs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/Tgstation.Server.Host/Controllers/SwarmController.cs b/src/Tgstation.Server.Host/Controllers/SwarmController.cs index c56cfaa5c8..be171b19d8 100644 --- a/src/Tgstation.Server.Host/Controllers/SwarmController.cs +++ b/src/Tgstation.Server.Host/Controllers/SwarmController.cs @@ -19,8 +19,6 @@ using Tgstation.Server.Host.System; using Tgstation.Server.Host.Transfer; using Tgstation.Server.Host.Utils; -#nullable disable - namespace Tgstation.Server.Host.Controllers { /// @@ -34,7 +32,7 @@ namespace Tgstation.Server.Host.Controllers /// /// Get the current registration from the . /// - internal Guid RequestRegistrationId => Guid.Parse(Request.Headers[SwarmConstants.RegistrationIdHeader].First()); + internal Guid RequestRegistrationId => Guid.Parse(Request.Headers[SwarmConstants.RegistrationIdHeader].First()!); /// /// The for the . @@ -152,6 +150,9 @@ namespace Tgstation.Server.Host.Controllers { ArgumentNullException.ThrowIfNull(serversUpdateRequest); + if (serversUpdateRequest.SwarmServers == null) + return BadRequest(); + if (!ValidateRegistration()) return Forbid(); @@ -212,7 +213,7 @@ namespace Tgstation.Server.Host.Controllers } /// - protected override async ValueTask HookExecuteAction(Func executeAction, CancellationToken cancellationToken) + protected override async ValueTask HookExecuteAction(Func executeAction, CancellationToken cancellationToken) { using (LogContext.PushProperty(SerilogContextHelper.RequestPathContextProperty, $"{Request.Method} {Request.Path}")) { @@ -243,7 +244,7 @@ namespace Tgstation.Server.Host.Controllers if (ModelState?.IsValid == false) { var errorMessages = ModelState - .SelectMany(x => x.Value.Errors) + .SelectMany(x => x.Value!.Errors) .Select(x => x.ErrorMessage); logger.LogDebug( From a2d2123fe08e3b8e9db77799ac148381e900b090 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Wed, 20 Dec 2023 14:57:18 -0500 Subject: [PATCH 270/425] Nullify `TransferController` --- src/Tgstation.Server.Host/Controllers/TransferController.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Controllers/TransferController.cs b/src/Tgstation.Server.Host/Controllers/TransferController.cs index 07feea08a0..8a0a2ebcd3 100644 --- a/src/Tgstation.Server.Host/Controllers/TransferController.cs +++ b/src/Tgstation.Server.Host/Controllers/TransferController.cs @@ -16,8 +16,6 @@ using Tgstation.Server.Host.Security; using Tgstation.Server.Host.Transfer; using Tgstation.Server.Host.Utils; -#nullable disable - namespace Tgstation.Server.Host.Controllers { /// From 1b95ded829e8f182bbf9f6e396603f69263f8b64 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Wed, 20 Dec 2023 15:03:02 -0500 Subject: [PATCH 271/425] Nullify `UserController` And fix some `.Any()`/`.Count` issues. --- .../Controllers/UserController.cs | 28 +++++++++---------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/src/Tgstation.Server.Host/Controllers/UserController.cs b/src/Tgstation.Server.Host/Controllers/UserController.cs index 8eed28d3f5..68bccfa169 100644 --- a/src/Tgstation.Server.Host/Controllers/UserController.cs +++ b/src/Tgstation.Server.Host/Controllers/UserController.cs @@ -22,8 +22,6 @@ using Tgstation.Server.Host.Models; using Tgstation.Server.Host.Security; using Tgstation.Server.Host.Utils; -#nullable disable - namespace Tgstation.Server.Host.Controllers { /// @@ -105,7 +103,7 @@ namespace Tgstation.Server.Host.Controllers return BadRequest(new ErrorMessageResponse(ErrorCode.ModelValidationFailure)); if ((model.Password != null && model.SystemIdentifier != null) - || (model.Password == null && model.SystemIdentifier == null && model.OAuthConnections?.Any() != true)) + || (model.Password == null && model.SystemIdentifier == null && (model.OAuthConnections?.Count > 0) != true)) return BadRequest(new ErrorMessageResponse(ErrorCode.UserMismatchPasswordSid)); if (model.Group != null && model.PermissionSet != null) @@ -146,14 +144,14 @@ namespace Tgstation.Server.Host.Controllers { return RequiresPosixSystemIdentity(ex); } - else if (!(model.Password?.Length == 0 && model.OAuthConnections?.Any() == true)) + else if (!(model.Password?.Length == 0 && (model.OAuthConnections?.Count > 0) == true)) { - var result = TrySetPassword(dbUser, model.Password, true); + var result = TrySetPassword(dbUser, model.Password!, true); if (result != null) return result; } - dbUser.CanonicalName = Models.User.CanonicalizeName(dbUser.Name); + dbUser.CanonicalName = Models.User.CanonicalizeName(dbUser.Name!); DatabaseContext.Users.Add(dbUser); @@ -206,7 +204,7 @@ namespace Tgstation.Server.Host.Controllers .Where(x => x.Id == model.Id) .Include(x => x.CreatedBy) .Include(x => x.OAuthConnections) - .Include(x => x.Group) + .Include(x => x.Group!) .ThenInclude(x => x.PermissionSet) .Include(x => x.PermissionSet) .FirstOrDefaultAsync(cancellationToken); @@ -256,7 +254,7 @@ namespace Tgstation.Server.Host.Controllers bool userWasDisabled; if (model.Enabled.HasValue) { - userWasDisabled = originalUser.Enabled.Value && !model.Enabled.Value; + userWasDisabled = originalUser.Require(x => x.Enabled) && !model.Enabled.Value; if (userWasDisabled) originalUser.LastPasswordUpdate = DateTimeOffset.UtcNow; @@ -266,7 +264,7 @@ namespace Tgstation.Server.Host.Controllers userWasDisabled = false; if (model.OAuthConnections != null - && (model.OAuthConnections.Count != originalUser.OAuthConnections.Count + && (model.OAuthConnections.Count != originalUser.OAuthConnections!.Count || !model.OAuthConnections.All(x => originalUser.OAuthConnections.Any(y => y.Provider == x.Provider && y.ExternalUserId == x.ExternalUserId)))) { if (originalUser.CanonicalName == Models.User.CanonicalizeName(DefaultCredentials.AdminUserName)) @@ -374,7 +372,7 @@ namespace Tgstation.Server.Host.Controllers .Include(x => x.CreatedBy) .Include(x => x.PermissionSet) .Include(x => x.OAuthConnections) - .Include(x => x.Group) + .Include(x => x.Group!) .ThenInclude(x => x.PermissionSet) .OrderBy(x => x.Id))), null, @@ -407,7 +405,7 @@ namespace Tgstation.Server.Host.Controllers .Where(x => x.Id == id) .Include(x => x.CreatedBy) .Include(x => x.OAuthConnections) - .Include(x => x.Group) + .Include(x => x.Group!) .ThenInclude(x => x.PermissionSet) .Include(x => x.PermissionSet) .FirstOrDefaultAsync(cancellationToken); @@ -428,8 +426,8 @@ namespace Tgstation.Server.Host.Controllers /// A resulting in a new on success, if the requested did not exist. async ValueTask CreateNewUserFromModel(Api.Models.Internal.UserApiBase model, CancellationToken cancellationToken) { - Models.PermissionSet permissionSet = null; - UserGroup group = null; + Models.PermissionSet? permissionSet = null; + UserGroup? group = null; if (model.Group != null) group = await DatabaseContext .Groups @@ -471,7 +469,7 @@ namespace Tgstation.Server.Host.Controllers /// The to check. /// If this is a new . /// if is valid, a otherwise. - BadRequestObjectResult CheckValidName(UserUpdateRequest model, bool newUser) + BadRequestObjectResult? CheckValidName(UserUpdateRequest model, bool newUser) { var userInvalidWithNullName = newUser && model.Name == null && model.SystemIdentifier == null; if (userInvalidWithNullName || (model.Name != null && String.IsNullOrWhiteSpace(model.Name))) @@ -490,7 +488,7 @@ namespace Tgstation.Server.Host.Controllers /// The new password. /// If this is for a new . /// on success, if is too short. - BadRequestObjectResult TrySetPassword(User dbUser, string newPassword, bool newUser) + BadRequestObjectResult? TrySetPassword(User dbUser, string newPassword, bool newUser) { newPassword ??= String.Empty; if (newPassword.Length < generalConfiguration.MinimumPasswordLength) From c08e84a38a52a3894b2e6cad37c01a5a092b9333 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Wed, 20 Dec 2023 15:04:44 -0500 Subject: [PATCH 272/425] Nullify `UserGroupController` --- .../Controllers/UserGroupController.cs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/Tgstation.Server.Host/Controllers/UserGroupController.cs b/src/Tgstation.Server.Host/Controllers/UserGroupController.cs index d50bc8e9c5..b6f48b8197 100644 --- a/src/Tgstation.Server.Host/Controllers/UserGroupController.cs +++ b/src/Tgstation.Server.Host/Controllers/UserGroupController.cs @@ -23,8 +23,6 @@ using Tgstation.Server.Host.Utils; using Z.EntityFramework.Plus; -#nullable disable - namespace Tgstation.Server.Host.Controllers { /// @@ -133,7 +131,7 @@ namespace Tgstation.Server.Host.Controllers if (model.PermissionSet != null) { - currentGroup.PermissionSet.AdministrationRights = model.PermissionSet.AdministrationRights ?? currentGroup.PermissionSet.AdministrationRights; + currentGroup.PermissionSet!.AdministrationRights = model.PermissionSet.AdministrationRights ?? currentGroup.PermissionSet.AdministrationRights; currentGroup.PermissionSet.InstanceManagerRights = model.PermissionSet.InstanceManagerRights ?? currentGroup.PermissionSet.InstanceManagerRights; } @@ -141,7 +139,7 @@ namespace Tgstation.Server.Host.Controllers await DatabaseContext.Save(cancellationToken); - if (!AuthenticationContext.PermissionSet.AdministrationRights.Value.HasFlag(AdministrationRights.ReadUsers)) + if (!AuthenticationContext.PermissionSet.AdministrationRights!.Value.HasFlag(AdministrationRights.ReadUsers)) return Json(new UserGroupResponse { Id = currentGroup.Id, @@ -222,7 +220,7 @@ namespace Tgstation.Server.Host.Controllers var numDeleted = await DatabaseContext .Groups .AsQueryable() - .Where(x => x.Id == id && x.Users.Count == 0) + .Where(x => x.Id == id && x.Users!.Count == 0) .DeleteAsync(cancellationToken); if (numDeleted > 0) From 2cc1014ab615a390ed581660382bae9f9f77d0f0 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Wed, 20 Dec 2023 15:06:37 -0500 Subject: [PATCH 273/425] Handle HTTP error case with OD graceful shutdowns --- .../Engine/OpenDreamInstallation.cs | 26 ++++++++++++------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Engine/OpenDreamInstallation.cs b/src/Tgstation.Server.Host/Components/Engine/OpenDreamInstallation.cs index 7e1fc27e47..afc32931e4 100644 --- a/src/Tgstation.Server.Host/Components/Engine/OpenDreamInstallation.cs +++ b/src/Tgstation.Server.Host/Components/Engine/OpenDreamInstallation.cs @@ -144,25 +144,33 @@ namespace Tgstation.Server.Host.Components.Engine request.Method = HttpMethod.Post; var responseTask = httpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead, cancellationToken); - - await Task.WhenAny(timeout, lifetime, responseTask); - if (responseTask.IsCompleted) + try { - using var response = await responseTask; - if (response.IsSuccessStatusCode) + await Task.WhenAny(timeout, lifetime, responseTask); + if (responseTask.IsCompleted) { - logger.LogDebug("Robust.Server responded to the shutdown command successfully. Waiting for exit..."); - await Task.WhenAny(timeout, lifetime); + using var response = await responseTask; + if (response.IsSuccessStatusCode) + { + logger.LogDebug("Robust.Server responded to the shutdown command successfully. Waiting for exit..."); + await Task.WhenAny(timeout, lifetime); + } } + + if (!lifetime.IsCompleted) + logger.LogWarning("Robust.Server graceful exit timed out!"); + } + catch (HttpRequestException ex) + { + logger.LogDebug(ex, "Unable to send graceful exit request to Robust.Server watchdog API!"); } if (lifetime.IsCompleted) { - logger.LogTrace("Robust.Server gracefully exited"); + logger.LogTrace("Robust.Server exited without termination"); return; } - logger.LogWarning("Robust.Server graceful exit timed out!"); await base.StopServerProcess(logger, process, accessIdentifier, port, cancellationToken); } } From 34f142868c083a6e0aaa279cc085a5a270d36fd9 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Wed, 20 Dec 2023 16:36:36 -0500 Subject: [PATCH 274/425] Fix engine installs not respecting `Session:LowPriorityDeploymentProcesses` --- .../Components/Engine/OpenDreamInstaller.cs | 14 +++++++++++++- .../Components/Engine/WindowsByondInstaller.cs | 9 +++++++++ .../Components/Engine/WindowsOpenDreamInstaller.cs | 6 +++++- .../System/WindowsFirewallHelper.cs | 5 +++++ .../Components/Engine/TestOpenDreamInstaller.cs | 6 +++++- .../Live/Instance/EngineTest.cs | 1 + .../Live/Instance/InstanceTest.cs | 4 +++- tests/Tgstation.Server.Tests/TestVersions.cs | 2 ++ 8 files changed, 43 insertions(+), 4 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Engine/OpenDreamInstaller.cs b/src/Tgstation.Server.Host/Components/Engine/OpenDreamInstaller.cs index 886b419a3e..c5f03e1e32 100644 --- a/src/Tgstation.Server.Host/Components/Engine/OpenDreamInstaller.cs +++ b/src/Tgstation.Server.Host/Components/Engine/OpenDreamInstaller.cs @@ -59,6 +59,11 @@ namespace Tgstation.Server.Host.Components.Engine /// protected GeneralConfiguration GeneralConfiguration { get; } + /// + /// The for the . + /// + protected SessionConfiguration SessionConfiguration { get; } + /// /// The for the . /// @@ -90,6 +95,7 @@ namespace Tgstation.Server.Host.Components.Engine /// The value of . /// The value of . /// The containing value of . + /// The containing value of . public OpenDreamInstaller( IIOManager ioManager, ILogger logger, @@ -98,7 +104,8 @@ namespace Tgstation.Server.Host.Components.Engine IRepositoryManager repositoryManager, IAsyncDelayer asyncDelayer, IAbstractHttpClientFactory httpClientFactory, - IOptions generalConfigurationOptions) + IOptions generalConfigurationOptions, + IOptions sessionConfigurationOptions) : base(ioManager, logger) { this.platformIdentifier = platformIdentifier ?? throw new ArgumentNullException(nameof(platformIdentifier)); @@ -107,6 +114,7 @@ namespace Tgstation.Server.Host.Components.Engine this.asyncDelayer = asyncDelayer ?? throw new ArgumentNullException(nameof(asyncDelayer)); this.httpClientFactory = httpClientFactory ?? throw new ArgumentNullException(nameof(httpClientFactory)); GeneralConfiguration = generalConfigurationOptions?.Value ?? throw new ArgumentNullException(nameof(generalConfigurationOptions)); + SessionConfiguration = sessionConfigurationOptions?.Value ?? throw new ArgumentNullException(nameof(sessionConfigurationOptions)); } /// @@ -254,6 +262,10 @@ namespace Tgstation.Server.Host.Components.Engine null, !GeneralConfiguration.OpenDreamSuppressInstallOutput, !GeneralConfiguration.OpenDreamSuppressInstallOutput); + + if (SessionConfiguration.LowPriorityDeploymentProcesses) + buildProcess.AdjustPriority(false); + using (cancellationToken.Register(() => buildProcess.Terminate())) buildExitCode = await buildProcess.Lifetime; diff --git a/src/Tgstation.Server.Host/Components/Engine/WindowsByondInstaller.cs b/src/Tgstation.Server.Host/Components/Engine/WindowsByondInstaller.cs index e24a77a261..4020ed97cf 100644 --- a/src/Tgstation.Server.Host/Components/Engine/WindowsByondInstaller.cs +++ b/src/Tgstation.Server.Host/Components/Engine/WindowsByondInstaller.cs @@ -73,6 +73,11 @@ namespace Tgstation.Server.Host.Components.Engine /// readonly GeneralConfiguration generalConfiguration; + /// + /// The for the . + /// + readonly SessionConfiguration sessionConfiguration; + /// /// The for the . /// @@ -88,6 +93,7 @@ namespace Tgstation.Server.Host.Components.Engine /// /// The value of . /// The containing the value of . + /// The containing the value of . /// The for the . /// The for the . /// The for the . @@ -96,11 +102,13 @@ namespace Tgstation.Server.Host.Components.Engine IIOManager ioManager, IFileDownloader fileDownloader, IOptions generalConfigurationOptions, + IOptions sessionConfigurationOptions, ILogger logger) : base(ioManager, logger, fileDownloader) { this.processExecutor = processExecutor ?? throw new ArgumentNullException(nameof(processExecutor)); generalConfiguration = generalConfigurationOptions?.Value ?? throw new ArgumentNullException(nameof(generalConfigurationOptions)); + sessionConfiguration = sessionConfigurationOptions?.Value ?? throw new ArgumentNullException(nameof(sessionConfigurationOptions)); var documentsDirectory = Environment.GetFolderPath( Environment.SpecialFolder.MyDocuments, @@ -253,6 +261,7 @@ namespace Tgstation.Server.Host.Components.Engine Logger, ruleName, dreamDaemonPath, + sessionConfiguration.LowPriorityDeploymentProcesses, cancellationToken); } catch (Exception ex) diff --git a/src/Tgstation.Server.Host/Components/Engine/WindowsOpenDreamInstaller.cs b/src/Tgstation.Server.Host/Components/Engine/WindowsOpenDreamInstaller.cs index 2fb12e80de..d343c32802 100644 --- a/src/Tgstation.Server.Host/Components/Engine/WindowsOpenDreamInstaller.cs +++ b/src/Tgstation.Server.Host/Components/Engine/WindowsOpenDreamInstaller.cs @@ -40,6 +40,7 @@ namespace Tgstation.Server.Host.Components.Engine /// The for the . /// The for the . /// The of for the . + /// The of for the . /// The value of . public WindowsOpenDreamInstaller( IIOManager ioManager, @@ -50,6 +51,7 @@ namespace Tgstation.Server.Host.Components.Engine IAsyncDelayer asyncDelayer, IAbstractHttpClientFactory httpClientFactory, IOptions generalConfigurationOptions, + IOptions sessionConfigurationOptions, IFilesystemLinkFactory linkFactory) : base( ioManager, @@ -59,7 +61,8 @@ namespace Tgstation.Server.Host.Components.Engine repositoryManager, asyncDelayer, httpClientFactory, - generalConfigurationOptions) + generalConfigurationOptions, + sessionConfigurationOptions) { this.linkFactory = linkFactory ?? throw new ArgumentNullException(nameof(linkFactory)); } @@ -122,6 +125,7 @@ namespace Tgstation.Server.Host.Components.Engine Logger, ruleName, serverExePath, + SessionConfiguration.LowPriorityDeploymentProcesses, cancellationToken); } catch (Exception ex) diff --git a/src/Tgstation.Server.Host/System/WindowsFirewallHelper.cs b/src/Tgstation.Server.Host/System/WindowsFirewallHelper.cs index 74964a5569..fff1521092 100644 --- a/src/Tgstation.Server.Host/System/WindowsFirewallHelper.cs +++ b/src/Tgstation.Server.Host/System/WindowsFirewallHelper.cs @@ -18,6 +18,7 @@ namespace Tgstation.Server.Host.System /// The to write to. /// The name of the rule in Windows Firewall. /// The path to the .exe to add a firewall exception for. + /// If the "netsh.exe" process should be run with lower process priority. /// The for the operation. /// A resulting in the exit code of the call to netsh.exe. public static async ValueTask AddFirewallException( @@ -25,6 +26,7 @@ namespace Tgstation.Server.Host.System ILogger logger, string exceptionName, string exePath, + bool lowPriority, CancellationToken cancellationToken) { logger.LogInformation("Adding Windows Firewall exception for {path}...", exePath); @@ -36,6 +38,9 @@ namespace Tgstation.Server.Host.System readStandardHandles: true, noShellExecute: true); + if (lowPriority) + netshProcess.AdjustPriority(false); + int exitCode; using (cancellationToken.Register(() => netshProcess.Terminate())) exitCode = (await netshProcess.Lifetime).Value; diff --git a/tests/Tgstation.Server.Host.Tests/Components/Engine/TestOpenDreamInstaller.cs b/tests/Tgstation.Server.Host.Tests/Components/Engine/TestOpenDreamInstaller.cs index f5d158259c..2a62fea29a 100644 --- a/tests/Tgstation.Server.Host.Tests/Components/Engine/TestOpenDreamInstaller.cs +++ b/tests/Tgstation.Server.Host.Tests/Components/Engine/TestOpenDreamInstaller.cs @@ -37,8 +37,11 @@ namespace Tgstation.Server.Host.Components.Engine.Tests { var mockGeneralConfigOptions = new Mock>(); var generalConfig = new GeneralConfiguration(); + var mockSessionConfigOptions = new Mock>(); + var sessionConfig = new SessionConfiguration(); Assert.IsNotNull(generalConfig.OpenDreamGitUrl); mockGeneralConfigOptions.SetupGet(x => x.Value).Returns(generalConfig); + mockSessionConfigOptions.SetupGet(x => x.Value).Returns(sessionConfig); var cloneAttempts = 0; var mockRepository = new Mock(); @@ -73,7 +76,8 @@ namespace Tgstation.Server.Host.Components.Engine.Tests mockRepositoryManager.Object, Mock.Of(), Mock.Of(), - mockGeneralConfigOptions.Object); + mockGeneralConfigOptions.Object, + mockSessionConfigOptions.Object); var data = await installer.DownloadVersion( new EngineVersion diff --git a/tests/Tgstation.Server.Tests/Live/Instance/EngineTest.cs b/tests/Tgstation.Server.Tests/Live/Instance/EngineTest.cs index 57c4255130..626f9628c3 100644 --- a/tests/Tgstation.Server.Tests/Live/Instance/EngineTest.cs +++ b/tests/Tgstation.Server.Tests/Live/Instance/EngineTest.cs @@ -302,6 +302,7 @@ namespace Tgstation.Server.Tests.Live.Instance Mock.Of(), fileDownloader, generalConfigOptionsMock.Object, + sessionConfigOptionsMock.Object, Mock.Of>()) : new PosixByondInstaller( Mock.Of(), diff --git a/tests/Tgstation.Server.Tests/Live/Instance/InstanceTest.cs b/tests/Tgstation.Server.Tests/Live/Instance/InstanceTest.cs index 76bfa30b23..bbe349ca5c 100644 --- a/tests/Tgstation.Server.Tests/Live/Instance/InstanceTest.cs +++ b/tests/Tgstation.Server.Tests/Live/Instance/InstanceTest.cs @@ -120,13 +120,15 @@ namespace Tgstation.Server.Tests.Live.Instance genConfig), Mock.Of(), Mock.Of(), - mockOptions.Object) + mockOptions.Object, + Options.Create(new SessionConfiguration())) : new PlatformIdentifier().IsWindows ? new WindowsByondInstaller( Mock.Of(), Mock.Of(), fileDownloader, Options.Create(genConfig), + Options.Create(new SessionConfiguration()), Mock.Of>()) : new PosixByondInstaller( Mock.Of(), diff --git a/tests/Tgstation.Server.Tests/TestVersions.cs b/tests/Tgstation.Server.Tests/TestVersions.cs index 34dad9e006..01fdf2d0ec 100644 --- a/tests/Tgstation.Server.Tests/TestVersions.cs +++ b/tests/Tgstation.Server.Tests/TestVersions.cs @@ -126,6 +126,7 @@ namespace Tgstation.Server.Tests Mock.Of(), new CachingFileDownloader(Mock.Of>()), mockGeneralConfigurationOptions.Object, + mockSessionConfigurationOptions.Object, Mock.Of>()); const string ArchiveEntryPath = "byond/bin/dd.exe"; @@ -193,6 +194,7 @@ namespace Tgstation.Server.Tests Mock.Of(), fileDownloader, mockGeneralConfigurationOptions.Object, + mockSessionConfigurationOptions.Object, loggerFactory.CreateLogger()) : new PosixByondInstaller( new PosixPostWriteHandler(loggerFactory.CreateLogger()), From 022b374a449dccc00abd0ec6d844d969ca25f724 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Wed, 20 Dec 2023 16:38:49 -0500 Subject: [PATCH 275/425] Fix some IDE messages --- .../Components/Engine/WindowsByondInstaller.cs | 11 ++++++++--- .../Live/Instance/EngineTest.cs | 15 +++++---------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Engine/WindowsByondInstaller.cs b/src/Tgstation.Server.Host/Components/Engine/WindowsByondInstaller.cs index 4020ed97cf..2c3aad65bc 100644 --- a/src/Tgstation.Server.Host/Components/Engine/WindowsByondInstaller.cs +++ b/src/Tgstation.Server.Host/Components/Engine/WindowsByondInstaller.cs @@ -130,14 +130,19 @@ namespace Tgstation.Server.Host.Components.Engine CheckVersionValidity(version); ArgumentNullException.ThrowIfNull(path); + var noPromptTrustedTask = SetNoPromptTrusted(path, cancellationToken); + var installDirectXTask = InstallDirectX(path, cancellationToken); var tasks = new List(3) { - SetNoPromptTrusted(path, cancellationToken), - InstallDirectX(path, cancellationToken), + noPromptTrustedTask, + installDirectXTask, }; if (!generalConfiguration.SkipAddingByondFirewallException) - tasks.Add(AddDreamDaemonToFirewall(version, path, cancellationToken)); + { + var firewallTask = AddDreamDaemonToFirewall(version, path, cancellationToken); + tasks.Add(firewallTask); + } return ValueTaskExtensions.WhenAll(tasks); } diff --git a/tests/Tgstation.Server.Tests/Live/Instance/EngineTest.cs b/tests/Tgstation.Server.Tests/Live/Instance/EngineTest.cs index 626f9628c3..a2f8249544 100644 --- a/tests/Tgstation.Server.Tests/Live/Instance/EngineTest.cs +++ b/tests/Tgstation.Server.Tests/Live/Instance/EngineTest.cs @@ -134,17 +134,12 @@ namespace Tgstation.Server.Tests.Live.Instance cancellationToken), ErrorCode.ModelValidationFailure); public static int EngineInstallationTimeout(EngineVersion testVersion) - { - switch (testVersion.Engine.Value) + => testVersion.Engine.Value switch { - case EngineType.Byond: - return 30; - case EngineType.OpenDream: - return 500; - default: - throw new InvalidOperationException($"Unknown engine type: {testVersion.Engine.Value}"); - } - } + EngineType.Byond => 30, + EngineType.OpenDream => 500, + _ => throw new InvalidOperationException($"Unknown engine type: {testVersion.Engine.Value}"), + }; int EngineInstallationTimeout() => EngineInstallationTimeout(testVersion); From 79e76282367e7a11dd0ae3db031226a95a6a5e4f Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Wed, 20 Dec 2023 21:59:04 -0500 Subject: [PATCH 276/425] Cleanup OpenDream graceful shutdown handling --- .../Engine/EngineInstallationBase.cs | 1 + .../Engine/OpenDreamInstallation.cs | 63 +++++++++++-------- 2 files changed, 37 insertions(+), 27 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Engine/EngineInstallationBase.cs b/src/Tgstation.Server.Host/Components/Engine/EngineInstallationBase.cs index f2da09f345..bbf809ee25 100644 --- a/src/Tgstation.Server.Host/Components/Engine/EngineInstallationBase.cs +++ b/src/Tgstation.Server.Host/Components/Engine/EngineInstallationBase.cs @@ -71,6 +71,7 @@ namespace Tgstation.Server.Host.Components.Engine /// public virtual async ValueTask StopServerProcess(ILogger logger, IProcess process, string accessIdentifier, ushort port, CancellationToken cancellationToken) { + cancellationToken.ThrowIfCancellationRequested(); logger.LogTrace("Terminating engine server process..."); process.Terminate(); await process.Lifetime; diff --git a/src/Tgstation.Server.Host/Components/Engine/OpenDreamInstallation.cs b/src/Tgstation.Server.Host/Components/Engine/OpenDreamInstallation.cs index afc32931e4..c16e25c9a1 100644 --- a/src/Tgstation.Server.Host/Components/Engine/OpenDreamInstallation.cs +++ b/src/Tgstation.Server.Host/Components/Engine/OpenDreamInstallation.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Diagnostics; using System.Net.Http; using System.Net.Http.Headers; using System.Net.Mime; @@ -133,42 +134,50 @@ namespace Tgstation.Server.Host.Components.Engine var timeout = asyncDelayer.Delay(TimeSpan.FromSeconds(MaximumTerminationSeconds), cancellationToken); var lifetime = process.Lifetime; - using var httpClient = httpClientFactory.CreateClient(); - using var request = new HttpRequestMessage(); - request.Headers.Add("WatchdogToken", accessIdentifier); - request.RequestUri = new Uri($"http://localhost:{port}/shutdown"); - request.Content = new StringContent( - "{\"Reason\":\"TGS session termination\"}", - Encoding.UTF8, - new MediaTypeHeaderValue(MediaTypeNames.Application.Json)); - request.Method = HttpMethod.Post; - - var responseTask = httpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead, cancellationToken); + var stopwatch = Stopwatch.StartNew(); try { - await Task.WhenAny(timeout, lifetime, responseTask); - if (responseTask.IsCompleted) + using var httpClient = httpClientFactory.CreateClient(); + using var request = new HttpRequestMessage(); + request.Headers.Add("WatchdogToken", accessIdentifier); + request.RequestUri = new Uri($"http://localhost:{port}/shutdown"); + request.Content = new StringContent( + "{\"Reason\":\"TGS session termination\"}", + Encoding.UTF8, + new MediaTypeHeaderValue(MediaTypeNames.Application.Json)); + request.Method = HttpMethod.Post; + + var responseTask = httpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead, cancellationToken); + try { - using var response = await responseTask; - if (response.IsSuccessStatusCode) + await Task.WhenAny(timeout, lifetime, responseTask); + if (responseTask.IsCompleted) { - logger.LogDebug("Robust.Server responded to the shutdown command successfully. Waiting for exit..."); - await Task.WhenAny(timeout, lifetime); + using var response = await responseTask; + if (response.IsSuccessStatusCode) + { + logger.LogDebug("Robust.Server responded to the shutdown command successfully ({requestMs}ms). Waiting for exit...", stopwatch.ElapsedMilliseconds); + await Task.WhenAny(timeout, lifetime); + } } + + if (!lifetime.IsCompleted) + logger.LogWarning("Robust.Server graceful exit timed out!"); + } + catch (Exception ex) when (ex is not OperationCanceledException) + { + logger.LogDebug(ex, "Unable to send graceful exit request to Robust.Server watchdog API!"); } - if (!lifetime.IsCompleted) - logger.LogWarning("Robust.Server graceful exit timed out!"); + if (lifetime.IsCompleted) + { + logger.LogTrace("Robust.Server exited without termination"); + return; + } } - catch (HttpRequestException ex) + finally { - logger.LogDebug(ex, "Unable to send graceful exit request to Robust.Server watchdog API!"); - } - - if (lifetime.IsCompleted) - { - logger.LogTrace("Robust.Server exited without termination"); - return; + logger.LogTrace("Robust.Server graceful shutdown attempt took {totalMs}ms", stopwatch.ElapsedMilliseconds); } await base.StopServerProcess(logger, process, accessIdentifier, port, cancellationToken); From 679bc7d0cbbc2fea26ec82df4ea2e84f17c71c92 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Wed, 20 Dec 2023 22:27:07 -0500 Subject: [PATCH 277/425] Switch back to dynamic live tests port allocation --- tests/Tgstation.Server.Tests/Live/TestLiveServer.cs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/tests/Tgstation.Server.Tests/Live/TestLiveServer.cs b/tests/Tgstation.Server.Tests/Live/TestLiveServer.cs index 6edee102ea..60781753a2 100644 --- a/tests/Tgstation.Server.Tests/Live/TestLiveServer.cs +++ b/tests/Tgstation.Server.Tests/Live/TestLiveServer.cs @@ -147,9 +147,6 @@ namespace Tgstation.Server.Tests.Live static ushort FreeTcpPort(params ushort[] usedPorts) { - var portList = new ushort[] { 42069, 42070, 42071, 42072, 42073, 42074 }; - return portList.First(x => !usedPorts.Contains(x)); - /* ushort result; var listeners = new List(); @@ -171,7 +168,7 @@ namespace Tgstation.Server.Tests.Live result = (ushort)((IPEndPoint)l.LocalEndpoint).Port; } - while (usedPorts.Contains(result) || result < 10000); + while (usedPorts.Contains(result) || result < 20000); } finally { @@ -180,8 +177,9 @@ namespace Tgstation.Server.Tests.Live l.Stop(); } } + + Console.WriteLine($"Allocated port: {result}"); return result; - */ } [ClassInitialize] From fda4b98ec36b506e66e20997c52009bf50a112a8 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Wed, 20 Dec 2023 22:53:26 -0500 Subject: [PATCH 278/425] Nullify `IRenameNotifyee` --- src/Tgstation.Server.Host/Components/IRenameNotifyee.cs | 2 -- src/Tgstation.Server.Host/Controllers/InstanceController.cs | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/IRenameNotifyee.cs b/src/Tgstation.Server.Host/Components/IRenameNotifyee.cs index 5394921314..be22158bd9 100644 --- a/src/Tgstation.Server.Host/Components/IRenameNotifyee.cs +++ b/src/Tgstation.Server.Host/Components/IRenameNotifyee.cs @@ -1,8 +1,6 @@ using System.Threading; using System.Threading.Tasks; -#nullable disable - namespace Tgstation.Server.Host.Components { /// diff --git a/src/Tgstation.Server.Host/Controllers/InstanceController.cs b/src/Tgstation.Server.Host/Controllers/InstanceController.cs index ddad25bca7..a0bab0791d 100644 --- a/src/Tgstation.Server.Host/Controllers/InstanceController.cs +++ b/src/Tgstation.Server.Host/Controllers/InstanceController.cs @@ -444,7 +444,7 @@ namespace Tgstation.Server.Host.Controllers await WithComponentInstanceNullable( async componentInstance => { - await componentInstance.InstanceRenamed(originalModel.Name, cancellationToken); + await componentInstance.InstanceRenamed(originalModel.Name!, cancellationToken); return null; }, originalModel); From 54e07bb68360e93d074eabbf365e6dfe67c57cd5 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Wed, 20 Dec 2023 22:54:29 -0500 Subject: [PATCH 279/425] Nullify `InstanceWrapper` --- src/Tgstation.Server.Host/Components/InstanceWrapper.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/InstanceWrapper.cs b/src/Tgstation.Server.Host/Components/InstanceWrapper.cs index 21861d1706..5c525d9869 100644 --- a/src/Tgstation.Server.Host/Components/InstanceWrapper.cs +++ b/src/Tgstation.Server.Host/Components/InstanceWrapper.cs @@ -10,8 +10,6 @@ using Tgstation.Server.Host.Components.Watchdog; using Tgstation.Server.Host.Models; using Tgstation.Server.Host.Utils; -#nullable disable - namespace Tgstation.Server.Host.Components { /// From b49f47c686ca0749709965974196a8f7706066d7 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Wed, 20 Dec 2023 22:54:40 -0500 Subject: [PATCH 280/425] Nullify `IComponentService` --- src/Tgstation.Server.Host/Components/IComponentService.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/IComponentService.cs b/src/Tgstation.Server.Host/Components/IComponentService.cs index 6ef039f654..b094e0a092 100644 --- a/src/Tgstation.Server.Host/Components/IComponentService.cs +++ b/src/Tgstation.Server.Host/Components/IComponentService.cs @@ -1,7 +1,5 @@ using Microsoft.Extensions.Hosting; -#nullable disable - namespace Tgstation.Server.Host.Components { /// From 88788f91911e6d9821d79f318991dbc82279ac41 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Wed, 20 Dec 2023 22:54:54 -0500 Subject: [PATCH 281/425] Nullify `IInstance` --- src/Tgstation.Server.Host/Components/IInstance.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/IInstance.cs b/src/Tgstation.Server.Host/Components/IInstance.cs index b7b7505053..9d8c34988e 100644 --- a/src/Tgstation.Server.Host/Components/IInstance.cs +++ b/src/Tgstation.Server.Host/Components/IInstance.cs @@ -1,7 +1,5 @@ using System; -#nullable disable - namespace Tgstation.Server.Host.Components { /// From ecf5ac1c8589be2cd8525d19809d813780fa0ec4 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Wed, 20 Dec 2023 22:55:11 -0500 Subject: [PATCH 282/425] Nullify `IInstanceCore` --- src/Tgstation.Server.Host/Components/IInstanceCore.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/IInstanceCore.cs b/src/Tgstation.Server.Host/Components/IInstanceCore.cs index 1fd3a29d45..78bce9e3f3 100644 --- a/src/Tgstation.Server.Host/Components/IInstanceCore.cs +++ b/src/Tgstation.Server.Host/Components/IInstanceCore.cs @@ -7,8 +7,6 @@ using Tgstation.Server.Host.Components.Repository; using Tgstation.Server.Host.Components.StaticFiles; using Tgstation.Server.Host.Components.Watchdog; -#nullable disable - namespace Tgstation.Server.Host.Components { /// From 27f61eb693c95b64ae5015991904a50bf938e312 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Wed, 20 Dec 2023 22:55:37 -0500 Subject: [PATCH 283/425] Nullify `IInstanceFactory` --- src/Tgstation.Server.Host/Components/IInstanceFactory.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/IInstanceFactory.cs b/src/Tgstation.Server.Host/Components/IInstanceFactory.cs index 5728f7f632..6258614b5f 100644 --- a/src/Tgstation.Server.Host/Components/IInstanceFactory.cs +++ b/src/Tgstation.Server.Host/Components/IInstanceFactory.cs @@ -3,8 +3,6 @@ using Tgstation.Server.Host.Components.Interop.Bridge; using Tgstation.Server.Host.IO; -#nullable disable - namespace Tgstation.Server.Host.Components { /// From 468135464924fcf593ff787dd48cd37e3b89191c Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Wed, 20 Dec 2023 22:55:50 -0500 Subject: [PATCH 284/425] Nullify `IInstanceManager` --- src/Tgstation.Server.Host/Components/IInstanceManager.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/IInstanceManager.cs b/src/Tgstation.Server.Host/Components/IInstanceManager.cs index c9439c2bdb..3174686efe 100644 --- a/src/Tgstation.Server.Host/Components/IInstanceManager.cs +++ b/src/Tgstation.Server.Host/Components/IInstanceManager.cs @@ -2,8 +2,6 @@ using Tgstation.Server.Host.Components.Interop.Bridge; -#nullable disable - namespace Tgstation.Server.Host.Components { /// From 13e4691782b38a2527fd42e18a7d6b354cffb2aa Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Wed, 20 Dec 2023 22:57:19 -0500 Subject: [PATCH 285/425] Nullify `IInstanceOperations` --- src/Tgstation.Server.Host/Components/IInstanceOperations.cs | 2 -- .../Controllers/ComponentInterfacingController.cs | 5 +++-- src/Tgstation.Server.Host/Controllers/InstanceController.cs | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/IInstanceOperations.cs b/src/Tgstation.Server.Host/Components/IInstanceOperations.cs index 8d81a1d69c..3212d9d6dc 100644 --- a/src/Tgstation.Server.Host/Components/IInstanceOperations.cs +++ b/src/Tgstation.Server.Host/Components/IInstanceOperations.cs @@ -3,8 +3,6 @@ using System.Threading.Tasks; using Tgstation.Server.Host.Models; -#nullable disable - namespace Tgstation.Server.Host.Components { /// diff --git a/src/Tgstation.Server.Host/Controllers/ComponentInterfacingController.cs b/src/Tgstation.Server.Host/Controllers/ComponentInterfacingController.cs index 108390890f..34988a5812 100644 --- a/src/Tgstation.Server.Host/Controllers/ComponentInterfacingController.cs +++ b/src/Tgstation.Server.Host/Controllers/ComponentInterfacingController.cs @@ -75,10 +75,11 @@ namespace Tgstation.Server.Host.Controllers if (AuthenticationContext.InstancePermissionSet == null) return Forbid(); - if (ValidateInstanceOnlineStatus(Instance!)) + var instance = Instance!; + if (ValidateInstanceOnlineStatus(instance)) await DatabaseContext.Save(cancellationToken); - using var instanceReferenceCheck = instanceManager.GetInstanceReference(Instance); + using var instanceReferenceCheck = instanceManager.GetInstanceReference(instance); if (instanceReferenceCheck == null) return Conflict(new ErrorMessageResponse(ErrorCode.InstanceOffline)); diff --git a/src/Tgstation.Server.Host/Controllers/InstanceController.cs b/src/Tgstation.Server.Host/Controllers/InstanceController.cs index a0bab0791d..ded9313475 100644 --- a/src/Tgstation.Server.Host/Controllers/InstanceController.cs +++ b/src/Tgstation.Server.Host/Controllers/InstanceController.cs @@ -492,7 +492,7 @@ namespace Tgstation.Server.Host.Controllers await jobManager.RegisterOperation( job, (core, databaseContextFactory, paramJob, progressHandler, ct) // core will be null here since the instance is offline - => InstanceOperations.MoveInstance(originalModel, originalModelPath, ct), + => InstanceOperations.MoveInstance(originalModel, originalModelPath!, ct), cancellationToken); api.MoveJob = job.ToApi(); } From 6fd47236459112103ccd12c99e9fd5b28922a9e8 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Wed, 20 Dec 2023 22:57:34 -0500 Subject: [PATCH 286/425] Nullify `IInstanceReference` --- src/Tgstation.Server.Host/Components/IInstanceReference.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/IInstanceReference.cs b/src/Tgstation.Server.Host/Components/IInstanceReference.cs index 14a63a7649..55f9379e80 100644 --- a/src/Tgstation.Server.Host/Components/IInstanceReference.cs +++ b/src/Tgstation.Server.Host/Components/IInstanceReference.cs @@ -1,7 +1,5 @@ using System; -#nullable disable - namespace Tgstation.Server.Host.Components { /// From 4cba11841084c7f90520f2c72e1d301193653bd2 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Wed, 20 Dec 2023 23:02:04 -0500 Subject: [PATCH 287/425] Nullify `Instance` --- .../Components/Instance.cs | 36 +++++++++---------- 1 file changed, 17 insertions(+), 19 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Instance.cs b/src/Tgstation.Server.Host/Components/Instance.cs index e1421476d1..10be9b18a3 100644 --- a/src/Tgstation.Server.Host/Components/Instance.cs +++ b/src/Tgstation.Server.Host/Components/Instance.cs @@ -21,8 +21,6 @@ using Tgstation.Server.Host.Jobs; using Tgstation.Server.Host.Models; using Tgstation.Server.Host.Utils; -#nullable disable - namespace Tgstation.Server.Host.Components { /// @@ -95,12 +93,12 @@ namespace Tgstation.Server.Host.Components /// /// The auto update . /// - Task timerTask; + Task? timerTask; /// /// for . /// - CancellationTokenSource timerCts; + CancellationTokenSource? timerCts; /// /// Initializes a new instance of the class. @@ -185,7 +183,7 @@ namespace Tgstation.Server.Host.Components using (LogContext.PushProperty(SerilogContextHelper.InstanceIdContextProperty, metadata.Id)) { await Task.WhenAll( - SetAutoUpdateInterval(metadata.AutoUpdateInterval.Value).AsTask(), + SetAutoUpdateInterval(metadata.Require(x => x.AutoUpdateInterval)).AsTask(), Configuration.StartAsync(cancellationToken), EngineManager.StartAsync(cancellationToken), Chat.StartAsync(cancellationToken), @@ -223,7 +221,7 @@ namespace Tgstation.Server.Host.Components if (timerTask != null) { logger.LogTrace("Cancelling auto-update task"); - timerCts.Cancel(); + timerCts!.Cancel(); timerCts.Dispose(); toWait = timerTask; timerTask = null; @@ -317,18 +315,18 @@ namespace Tgstation.Server.Host.Components cancellationToken); var hasDbChanges = false; - RevisionInformation currentRevInfo = null; - Models.Instance attachedInstance = null; - async ValueTask UpdateRevInfo(string currentHead, bool onOrigin, IEnumerable updatedTestMerges) + RevisionInformation? currentRevInfo = null; + Models.Instance? attachedInstance = null; + async ValueTask UpdateRevInfo(string currentHead, bool onOrigin, IEnumerable? updatedTestMerges) { if (currentRevInfo == null) { logger.LogTrace("Loading revision info for commit {sha}...", startSha[..7]); currentRevInfo = await databaseContext - .RevisionInformations + .RevisionInformations .AsQueryable() - .Where(x => x.CommitSha == startSha && x.Instance.Id == metadata.Id) - .Include(x => x.ActiveTestMerges) + .Where(x => x.CommitSha == startSha && x.InstanceId == metadata.Id) + .Include(x => x.ActiveTestMerges!) .ThenInclude(x => x.TestMerge) .FirstOrDefaultAsync(cancellationToken); } @@ -366,7 +364,7 @@ namespace Tgstation.Server.Host.Components if (!onOrigin) { - var testMerges = updatedTestMerges ?? oldRevInfo.ActiveTestMerges.Select(x => x.TestMerge); + var testMerges = updatedTestMerges ?? oldRevInfo!.ActiveTestMerges!.Select(x => x.TestMerge); var revInfoTestMerges = testMerges.Select( testMerge => new RevInfoTestMerge(testMerge, currentRevInfo)) .ToList(); @@ -381,10 +379,10 @@ namespace Tgstation.Server.Host.Components // build current commit data if it's missing await UpdateRevInfo(repo.Head, false, null); - var preserveTestMerges = repositorySettings.AutoUpdatesKeepTestMerges.Value; + var preserveTestMerges = repositorySettings.AutoUpdatesKeepTestMerges!.Value; var remoteDeploymentManager = remoteDeploymentManagerFactory.CreateRemoteDeploymentManager( metadata, - repo.RemoteGitProvider.Value); + repo.RemoteGitProvider!.Value); var updatedTestMerges = await remoteDeploymentManager.RemoveMergedTestMerges( repo, @@ -434,7 +432,7 @@ namespace Tgstation.Server.Host.Components NextProgressReporter(StageName), repositorySettings.AccessUser, repositorySettings.AccessToken, - repositorySettings.UpdateSubmodules.Value, + repositorySettings.UpdateSubmodules!.Value, true, cancellationToken); @@ -442,7 +440,7 @@ namespace Tgstation.Server.Host.Components currentRevInfo = await databaseContext.RevisionInformations .AsQueryable() - .Where(x => x.CommitSha == currentHead && x.Instance.Id == metadata.Id) + .Where(x => x.CommitSha == currentHead && x.InstanceId == metadata.Id) .FirstOrDefaultAsync(cancellationToken); if (currentHead != startSha && currentRevInfo == default) @@ -452,7 +450,7 @@ namespace Tgstation.Server.Host.Components } // synch if necessary - if (repositorySettings.AutoUpdatesSynchronize.Value && startSha != repo.Head && (shouldSyncTracked || repositorySettings.PushTestMergeCommits.Value)) + if (repositorySettings.AutoUpdatesSynchronize!.Value && startSha != repo.Head && (shouldSyncTracked || repositorySettings.PushTestMergeCommits!.Value)) { var pushedOrigin = await repo.Sychronize( NextProgressReporter("Synchronize"), @@ -464,7 +462,7 @@ namespace Tgstation.Server.Host.Components true, cancellationToken); var currentHead = repo.Head; - if (currentHead != currentRevInfo.CommitSha) + if (currentHead != currentRevInfo!.CommitSha) await UpdateRevInfo(currentHead, pushedOrigin, null); } From 44d21478f10981b455c4b4ebfc0d2ff50ce7c448 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Wed, 20 Dec 2023 23:02:42 -0500 Subject: [PATCH 288/425] Nullify `InstanceFactory` --- src/Tgstation.Server.Host/Components/InstanceFactory.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/InstanceFactory.cs b/src/Tgstation.Server.Host/Components/InstanceFactory.cs index a9f5878c41..3f9cf25dc4 100644 --- a/src/Tgstation.Server.Host/Components/InstanceFactory.cs +++ b/src/Tgstation.Server.Host/Components/InstanceFactory.cs @@ -25,8 +25,6 @@ using Tgstation.Server.Host.System; using Tgstation.Server.Host.Transfer; using Tgstation.Server.Host.Utils; -#nullable disable - namespace Tgstation.Server.Host.Components { /// @@ -332,7 +330,7 @@ namespace Tgstation.Server.Host.Components eventConsumer.SetWatchdog(watchdog); commandFactory.SetWatchdog(watchdog); - Instance instance = null; + Instance? instance = null; var dreamMaker = new DreamMaker( engineManager, gameIoManager, @@ -406,6 +404,6 @@ namespace Tgstation.Server.Host.Components /// /// The . /// The for the . - IIOManager CreateInstanceIOManager(Models.Instance metadata) => new ResolvingIOManager(ioManager, metadata.Path); + IIOManager CreateInstanceIOManager(Models.Instance metadata) => new ResolvingIOManager(ioManager, metadata.Path!); } } From 87d3b916664bc8e73b79d1ec5dc7fe8e92ec8cd9 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Wed, 20 Dec 2023 23:03:44 -0500 Subject: [PATCH 289/425] Cleanup messages in `InstanceFactory` --- src/Tgstation.Server.Host/Components/InstanceFactory.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/InstanceFactory.cs b/src/Tgstation.Server.Host/Components/InstanceFactory.cs index 3f9cf25dc4..7f621333e8 100644 --- a/src/Tgstation.Server.Host/Components/InstanceFactory.cs +++ b/src/Tgstation.Server.Host/Components/InstanceFactory.cs @@ -150,7 +150,7 @@ namespace Tgstation.Server.Host.Components /// /// The instance's . /// The for the instance's "Game" directory. - static IIOManager CreateGameIOManager(IIOManager instanceIOManager) => new ResolvingIOManager(instanceIOManager, "Game"); + static ResolvingIOManager CreateGameIOManager(IIOManager instanceIOManager) => new(instanceIOManager, "Game"); #pragma warning disable CA1502 // TODO: Decomplexify /// @@ -404,6 +404,6 @@ namespace Tgstation.Server.Host.Components /// /// The . /// The for the . - IIOManager CreateInstanceIOManager(Models.Instance metadata) => new ResolvingIOManager(ioManager, metadata.Path!); + ResolvingIOManager CreateInstanceIOManager(Models.Instance metadata) => new(ioManager, metadata.Path!); } } From 476e903bb05c18f68274826d3ec6410328811eb0 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Wed, 20 Dec 2023 23:04:17 -0500 Subject: [PATCH 290/425] Cleanup messages in tests --- tests/Tgstation.Server.Tests/Live/TestLiveServer.cs | 12 ++++++------ tests/Tgstation.Server.Tests/TestVersions.cs | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/Tgstation.Server.Tests/Live/TestLiveServer.cs b/tests/Tgstation.Server.Tests/Live/TestLiveServer.cs index 60781753a2..96ee8ba640 100644 --- a/tests/Tgstation.Server.Tests/Live/TestLiveServer.cs +++ b/tests/Tgstation.Server.Tests/Live/TestLiveServer.cs @@ -54,12 +54,12 @@ namespace Tgstation.Server.Tests.Live { public static readonly Version TestUpdateVersion = new(5, 11, 0); - static readonly Lazy odDMPort = new Lazy(() => FreeTcpPort()); - static readonly Lazy odDDPort = new Lazy(() => FreeTcpPort(odDMPort.Value)); - static readonly Lazy compatDMPort = new Lazy(() => FreeTcpPort(odDDPort.Value, odDMPort.Value)); - static readonly Lazy compatDDPort = new Lazy(() => FreeTcpPort(odDDPort.Value, odDMPort.Value, compatDMPort.Value)); - static readonly Lazy mainDDPort = new Lazy(() => FreeTcpPort(odDDPort.Value, odDMPort.Value, compatDMPort.Value, compatDDPort.Value)); - static readonly Lazy mainDMPort = new Lazy(() => FreeTcpPort(odDDPort.Value, odDMPort.Value, compatDMPort.Value, compatDDPort.Value, mainDDPort.Value)); + static readonly Lazy odDMPort = new(() => FreeTcpPort()); + static readonly Lazy odDDPort = new(() => FreeTcpPort(odDMPort.Value)); + static readonly Lazy compatDMPort = new(() => FreeTcpPort(odDDPort.Value, odDMPort.Value)); + static readonly Lazy compatDDPort = new(() => FreeTcpPort(odDDPort.Value, odDMPort.Value, compatDMPort.Value)); + static readonly Lazy mainDDPort = new(() => FreeTcpPort(odDDPort.Value, odDMPort.Value, compatDMPort.Value, compatDDPort.Value)); + static readonly Lazy mainDMPort = new(() => FreeTcpPort(odDDPort.Value, odDMPort.Value, compatDMPort.Value, compatDDPort.Value, mainDDPort.Value)); readonly ServerClientFactory clientFactory = new (new ProductHeaderValue(Assembly.GetExecutingAssembly().GetName().Name, Assembly.GetExecutingAssembly().GetName().Version.ToString())); diff --git a/tests/Tgstation.Server.Tests/TestVersions.cs b/tests/Tgstation.Server.Tests/TestVersions.cs index 01fdf2d0ec..7b52b79773 100644 --- a/tests/Tgstation.Server.Tests/TestVersions.cs +++ b/tests/Tgstation.Server.Tests/TestVersions.cs @@ -494,7 +494,7 @@ namespace Tgstation.Server.Tests var shouldSupportMapThreads = engineVersion.Version >= MapThreadsVersion(); - await File.WriteAllBytesAsync("fake.dmb", Array.Empty(), CancellationToken.None); + await File.WriteAllBytesAsync("fake.dmb", [], CancellationToken.None); try { From 5bffb97cdb0eca9db40dbf46fce98735aca912c3 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Wed, 20 Dec 2023 23:11:33 -0500 Subject: [PATCH 291/425] Nullify `InstanceManager` --- .../Components/IInstanceCoreProvider.cs | 2 +- .../Components/IInstanceManager.cs | 2 +- .../Components/InstanceManager.cs | 57 +++++++++++-------- .../ComponentInterfacingController.cs | 2 +- src/Tgstation.Server.Host/Jobs/JobService.cs | 4 +- 5 files changed, 38 insertions(+), 29 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/IInstanceCoreProvider.cs b/src/Tgstation.Server.Host/Components/IInstanceCoreProvider.cs index 7e6b0b8dc5..ab1db54e91 100644 --- a/src/Tgstation.Server.Host/Components/IInstanceCoreProvider.cs +++ b/src/Tgstation.Server.Host/Components/IInstanceCoreProvider.cs @@ -10,6 +10,6 @@ /// /// The to get the for. /// The if it is online, otherwise. - IInstanceCore GetInstance(Models.Instance instance); + IInstanceCore? GetInstance(Models.Instance instance); } } diff --git a/src/Tgstation.Server.Host/Components/IInstanceManager.cs b/src/Tgstation.Server.Host/Components/IInstanceManager.cs index 3174686efe..516b2a8f30 100644 --- a/src/Tgstation.Server.Host/Components/IInstanceManager.cs +++ b/src/Tgstation.Server.Host/Components/IInstanceManager.cs @@ -19,6 +19,6 @@ namespace Tgstation.Server.Host.Components /// /// The of the desired . /// The associated with the given if it is online, otherwise. - IInstanceReference GetInstanceReference(Api.Models.Instance metadata); + IInstanceReference? GetInstanceReference(Api.Models.Instance metadata); } } diff --git a/src/Tgstation.Server.Host/Components/InstanceManager.cs b/src/Tgstation.Server.Host/Components/InstanceManager.cs index 50da066c52..eeadde0c30 100644 --- a/src/Tgstation.Server.Host/Components/InstanceManager.cs +++ b/src/Tgstation.Server.Host/Components/InstanceManager.cs @@ -21,13 +21,12 @@ using Tgstation.Server.Host.Database; using Tgstation.Server.Host.Extensions; using Tgstation.Server.Host.IO; using Tgstation.Server.Host.Jobs; +using Tgstation.Server.Host.Models; using Tgstation.Server.Host.Security; using Tgstation.Server.Host.Swarm; using Tgstation.Server.Host.System; using Tgstation.Server.Host.Utils; -#nullable disable - namespace Tgstation.Server.Host.Components { /// @@ -117,7 +116,7 @@ namespace Tgstation.Server.Host.Components readonly Dictionary bridgeHandlers; /// - /// used to guard calls to and . + /// used to guard calls to and . /// readonly SemaphoreSlim instanceStateChangeSemaphore; @@ -149,12 +148,12 @@ namespace Tgstation.Server.Host.Components /// /// The original of . /// - readonly string originalConsoleTitle; + readonly string? originalConsoleTitle; /// /// The returned by . /// - Task startupTask; + Task? startupTask; /// /// If the has been 'd. @@ -243,13 +242,13 @@ namespace Tgstation.Server.Host.Components } /// - public IInstanceReference GetInstanceReference(Api.Models.Instance metadata) + public IInstanceReference? GetInstanceReference(Api.Models.Instance metadata) { ArgumentNullException.ThrowIfNull(metadata); lock (instances) { - if (!instances.TryGetValue(metadata.Id.Value, out var instance)) + if (!instances.TryGetValue(metadata.Require(x => x.Id), out var instance)) return null; return instance.AddReference(); @@ -265,7 +264,7 @@ namespace Tgstation.Server.Host.Components using var instanceReferenceCheck = GetInstanceReference(instance); if (instanceReferenceCheck != null) throw new InvalidOperationException("Cannot move an online instance!"); - var newPath = instance.Path; + var newPath = instance.Path!; try { await ioManager.MoveDirectory(oldPath, newPath, cancellationToken); @@ -328,22 +327,23 @@ namespace Tgstation.Server.Host.Components } /// - public async ValueTask OfflineInstance(Models.Instance metadata, Models.User user, CancellationToken cancellationToken) + public async ValueTask OfflineInstance(Models.Instance metadata, User user, CancellationToken cancellationToken) { ArgumentNullException.ThrowIfNull(metadata); using (await SemaphoreSlimContext.Lock(instanceStateChangeSemaphore, cancellationToken)) { - ReferenceCountingContainer container; + ReferenceCountingContainer? container; + var instanceId = metadata.Require(x => x.Id); lock (instances) { - if (!instances.TryGetValue(metadata.Id.Value, out container)) + if (!instances.TryGetValue(instanceId, out container)) { logger.LogDebug("Not offlining removed instance {instanceId}", metadata.Id); return; } - instances.Remove(metadata.Id.Value); + instances.Remove(instanceId); } logger.LogInformation("Offlining instance ID {instanceId}", metadata.Id); @@ -353,15 +353,15 @@ namespace Tgstation.Server.Host.Components await container.OnZeroReferences.WaitAsync(cancellationToken); // we are the one responsible for cancelling his jobs - ValueTask groupedTask = default; + ValueTask groupedTask = default; await databaseContextFactory.UseContext( async db => { var jobs = await db .Jobs .AsQueryable() - .Where(x => x.Instance.Id == metadata.Id && !x.StoppedAt.HasValue) - .Select(x => new Models.Job(x.Id.Value)) + .Where(x => x.Instance!.Id == metadata.Id && !x.StoppedAt.HasValue) + .Select(x => new Job(x.Id!.Value)) .ToListAsync(cancellationToken); groupedTask = ValueTaskExtensions.WhenAll( @@ -375,7 +375,7 @@ namespace Tgstation.Server.Host.Components { // not too late to change your mind lock (instances) - instances.Add(metadata.Id.Value, container); + instances.Add(instanceId, container); throw; } @@ -397,9 +397,10 @@ namespace Tgstation.Server.Host.Components { ArgumentNullException.ThrowIfNull(metadata); + var instanceId = metadata.Require(x => x.Id); using var lockContext = await SemaphoreSlimContext.Lock(instanceStateChangeSemaphore, cancellationToken); lock (instances) - if (instances.ContainsKey(metadata.Id.Value)) + if (instances.ContainsKey(instanceId)) { logger.LogDebug("Aborting instance creation due to it seemingly already being online"); return; @@ -415,7 +416,7 @@ namespace Tgstation.Server.Host.Components { lock (instances) instances.Add( - metadata.Id.Value, + instanceId, new ReferenceCountingContainer(instance)); } catch (Exception ex) @@ -457,6 +458,12 @@ namespace Tgstation.Server.Host.Components using (cancellationToken.Register(shutdownCancellationTokenSource.Cancel)) try { + if (startupTask == null) + { + logger.LogWarning("InstanceManager was never started!"); + return; + } + logger.LogDebug("Stopping instance manager..."); if (!startupTask.IsCompleted) @@ -499,11 +506,11 @@ namespace Tgstation.Server.Host.Components } /// - public async ValueTask ProcessBridgeRequest(BridgeParameters parameters, CancellationToken cancellationToken) + public async ValueTask ProcessBridgeRequest(BridgeParameters parameters, CancellationToken cancellationToken) { ArgumentNullException.ThrowIfNull(parameters); - IBridgeHandler bridgeHandler = null; + IBridgeHandler? bridgeHandler = null; for (var i = 0; bridgeHandler == null && i < 30; ++i) { // There's a miniscule time period where we could potentially receive a bridge request and not have the registration ready when we launch DD @@ -550,11 +557,11 @@ namespace Tgstation.Server.Host.Components } /// - public IInstanceCore GetInstance(Models.Instance metadata) + public IInstanceCore? GetInstance(Models.Instance metadata) { lock (instances) { - instances.TryGetValue(metadata.Id.Value, out var container); + instances.TryGetValue(metadata.Require(x => x.Id), out var container); return container?.Instance; } } @@ -578,13 +585,13 @@ namespace Tgstation.Server.Host.Components await InitializeSwarm(cancellationToken); - List dbInstances = null; + List? dbInstances = null; async ValueTask EnumerateInstances(IDatabaseContext databaseContext) => dbInstances = await databaseContext .Instances .AsQueryable() - .Where(x => x.Online.Value && x.SwarmIdentifer == swarmConfiguration.Identifier) + .Where(x => x.Online!.Value && x.SwarmIdentifer == swarmConfiguration.Identifier) .Include(x => x.RepositorySettings) .Include(x => x.ChatSettings) .ThenInclude(x => x.Channels) @@ -598,7 +605,7 @@ namespace Tgstation.Server.Host.Components await Task.WhenAll(instanceEnumeration.AsTask(), factoryStartup, jobManagerStartup); - var instanceOnliningTasks = dbInstances.Select( + var instanceOnliningTasks = dbInstances!.Select( async metadata => { try diff --git a/src/Tgstation.Server.Host/Controllers/ComponentInterfacingController.cs b/src/Tgstation.Server.Host/Controllers/ComponentInterfacingController.cs index 34988a5812..f04e620d06 100644 --- a/src/Tgstation.Server.Host/Controllers/ComponentInterfacingController.cs +++ b/src/Tgstation.Server.Host/Controllers/ComponentInterfacingController.cs @@ -129,7 +129,7 @@ namespace Tgstation.Server.Host.Controllers instance ??= Instance ?? throw new InvalidOperationException("ComponentInterfacingController has no Instance!"); using var instanceReference = instanceManager.GetInstanceReference(instance); - using (LogContext.PushProperty(SerilogContextHelper.InstanceReferenceContextProperty, instanceReference.Uid)) + using (LogContext.PushProperty(SerilogContextHelper.InstanceReferenceContextProperty, instanceReference?.Uid)) { if (instanceReference == null) return Conflict(new ErrorMessageResponse(ErrorCode.InstanceOffline)); diff --git a/src/Tgstation.Server.Host/Jobs/JobService.cs b/src/Tgstation.Server.Host/Jobs/JobService.cs index ea2782a821..8db21d3068 100644 --- a/src/Tgstation.Server.Host/Jobs/JobService.cs +++ b/src/Tgstation.Server.Host/Jobs/JobService.cs @@ -460,8 +460,10 @@ namespace Tgstation.Server.Host.Jobs QueueHubUpdate(job.ToApi(), false); logger.LogTrace("Starting job..."); + var instanceCore = instanceCoreProvider.GetInstance(job.Instance!) + ?? throw new JobException("Could not retrieve instance core for job!"); await operation( - instanceCoreProvider.GetInstance(job.Instance!), + instanceCore, databaseContextFactory, job, new JobProgressReporter( From 9bab2f5d5ad74b12e2657805a3fcff55f6c50f9b Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Wed, 20 Dec 2023 23:16:15 -0500 Subject: [PATCH 292/425] Nullify `IConfiguration` --- .../Components/StaticFiles/IConfiguration.cs | 14 ++++++-------- .../Controllers/ConfigurationController.cs | 5 ++++- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/StaticFiles/IConfiguration.cs b/src/Tgstation.Server.Host/Components/StaticFiles/IConfiguration.cs index 63b940d646..db32cc1c2b 100644 --- a/src/Tgstation.Server.Host/Components/StaticFiles/IConfiguration.cs +++ b/src/Tgstation.Server.Host/Components/StaticFiles/IConfiguration.cs @@ -8,8 +8,6 @@ using Tgstation.Server.Api.Models.Response; using Tgstation.Server.Host.Components.Events; using Tgstation.Server.Host.Security; -#nullable disable - namespace Tgstation.Server.Host.Components.StaticFiles { /// @@ -24,7 +22,7 @@ namespace Tgstation.Server.Host.Components.StaticFiles /// Path to the destination folder. /// The for the operation. /// A resulting in the if any. - ValueTask CopyDMFilesTo(string dmeFile, string destination, CancellationToken cancellationToken); + ValueTask CopyDMFilesTo(string dmeFile, string destination, CancellationToken cancellationToken); /// /// Symlinks all directories in the GameData directory to . @@ -41,7 +39,7 @@ namespace Tgstation.Server.Host.Components.StaticFiles /// The for the operation. If , the operation will be performed as the user of the . /// The for the operation. /// A resulting in an of the s for the items in the directory. and will both be . will be returned if the operation failed due to access contention. - ValueTask> ListDirectory(string configurationRelativePath, ISystemIdentity systemIdentity, CancellationToken cancellationToken); + ValueTask> ListDirectory(string? configurationRelativePath, ISystemIdentity? systemIdentity, CancellationToken cancellationToken); /// /// Reads a given . @@ -50,7 +48,7 @@ namespace Tgstation.Server.Host.Components.StaticFiles /// The for the operation. If , the operation will be performed as the user of the . /// The for the operation. /// A resulting in the of the file. will be returned if the operation failed due to access contention. - ValueTask Read(string configurationRelativePath, ISystemIdentity systemIdentity, CancellationToken cancellationToken); + ValueTask Read(string configurationRelativePath, ISystemIdentity? systemIdentity, CancellationToken cancellationToken); /// /// Create an empty directory at . @@ -59,7 +57,7 @@ namespace Tgstation.Server.Host.Components.StaticFiles /// The for the operation. If , the operation will be performed as the user of the . /// The for the operation. Usage may result in partial writes. /// A resulting in if the directory already existed, otherwise. will be returned if the operation failed due to access contention. - ValueTask CreateDirectory(string configurationRelativePath, ISystemIdentity systemIdentity, CancellationToken cancellationToken); + ValueTask CreateDirectory(string configurationRelativePath, ISystemIdentity? systemIdentity, CancellationToken cancellationToken); /// /// Attempt to delete an empty directory at . @@ -68,7 +66,7 @@ namespace Tgstation.Server.Host.Components.StaticFiles /// The for the operation. If , the operation will be performed as the user of the . /// The for the operation. /// A resulting in if the directory was empty and deleted, otherwise. will be returned if the operation failed due to access contention. - ValueTask DeleteDirectory(string configurationRelativePath, ISystemIdentity systemIdentity, CancellationToken cancellationToken); + ValueTask DeleteDirectory(string configurationRelativePath, ISystemIdentity? systemIdentity, CancellationToken cancellationToken); /// /// Writes to a given . @@ -78,6 +76,6 @@ namespace Tgstation.Server.Host.Components.StaticFiles /// The hash any existing file must match in order for the write to succeed. /// The for the operation. Usage may result in partial writes. /// A resulting in the updated and associated writing . will be returned if the operation failed due to access contention. - ValueTask Write(string configurationRelativePath, ISystemIdentity systemIdentity, string previousHash, CancellationToken cancellationToken); + ValueTask Write(string configurationRelativePath, ISystemIdentity? systemIdentity, string? previousHash, CancellationToken cancellationToken); } } diff --git a/src/Tgstation.Server.Host/Controllers/ConfigurationController.cs b/src/Tgstation.Server.Host/Controllers/ConfigurationController.cs index 1df1fbc907..8232be095c 100644 --- a/src/Tgstation.Server.Host/Controllers/ConfigurationController.cs +++ b/src/Tgstation.Server.Host/Controllers/ConfigurationController.cs @@ -84,7 +84,7 @@ namespace Tgstation.Server.Host.Controllers var newFile = await instance .Configuration .Write( - model.Path, + model.Path!, systemIdentity, model.LastReadHash, cancellationToken); @@ -240,6 +240,9 @@ namespace Tgstation.Server.Host.Controllers { ArgumentNullException.ThrowIfNull(model); + if (model.Path == null) + return BadRequest(new ErrorMessageResponse(ErrorCode.ModelValidationFailure)); + if (ForbidDueToModeConflicts(model.Path, out var systemIdentity)) return Forbid(); From 921b2b44fc67ca2407277a1c47a2dd5abbed7ff6 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Wed, 20 Dec 2023 23:20:20 -0500 Subject: [PATCH 293/425] Nullify `Configuration` --- .../Components/StaticFiles/Configuration.cs | 41 +++++++++++-------- .../Components/StaticFiles/IConfiguration.cs | 2 +- .../StaticFiles/ServerSideModifications.cs | 6 +-- .../IO/DefaultIOManager.cs | 2 +- src/Tgstation.Server.Host/IO/IIOManager.cs | 2 +- 5 files changed, 29 insertions(+), 24 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/StaticFiles/Configuration.cs b/src/Tgstation.Server.Host/Components/StaticFiles/Configuration.cs index 3644f20991..b2e12d1947 100644 --- a/src/Tgstation.Server.Host/Components/StaticFiles/Configuration.cs +++ b/src/Tgstation.Server.Host/Components/StaticFiles/Configuration.cs @@ -23,8 +23,6 @@ using Tgstation.Server.Host.System; using Tgstation.Server.Host.Transfer; using Tgstation.Server.Host.Utils; -#nullable disable - namespace Tgstation.Server.Host.Components.StaticFiles { /// @@ -80,7 +78,7 @@ namespace Tgstation.Server.Host.Components.StaticFiles eventType => new KeyValuePair>( eventType, typeof(EventType) - .GetField(eventType.ToString()) + .GetField(eventType.ToString())! .GetCustomAttributes(false) .OfType() .First() @@ -201,7 +199,7 @@ namespace Tgstation.Server.Host.Components.StaticFiles } /// - public async ValueTask CopyDMFilesTo(string dmeFile, string destination, CancellationToken cancellationToken) + public async ValueTask CopyDMFilesTo(string dmeFile, string destination, CancellationToken cancellationToken) { using (await SemaphoreSlimContext.Lock(semaphore, cancellationToken)) { @@ -234,12 +232,19 @@ namespace Tgstation.Server.Host.Components.StaticFiles static string IncludeLine(string filePath) => String.Format(CultureInfo.InvariantCulture, "#include \"{0}\"", filePath); - return new ServerSideModifications(headFileExistsTask.Result ? IncludeLine(CodeModificationsHeadFile) : null, tailFileExistsTask.Result ? IncludeLine(CodeModificationsTailFile) : null, false); + return new ServerSideModifications( + headFileExistsTask.Result + ? IncludeLine(CodeModificationsHeadFile) + : null, + tailFileExistsTask.Result + ? IncludeLine(CodeModificationsTailFile) + : null, + false); } } /// - public async ValueTask> ListDirectory(string configurationRelativePath, ISystemIdentity systemIdentity, CancellationToken cancellationToken) + public async ValueTask?> ListDirectory(string? configurationRelativePath, ISystemIdentity? systemIdentity, CancellationToken cancellationToken) { await EnsureDirectories(cancellationToken); var path = ValidateConfigRelativePath(configurationRelativePath); @@ -286,12 +291,12 @@ namespace Tgstation.Server.Host.Components.StaticFiles } /// - public async ValueTask Read(string configurationRelativePath, ISystemIdentity systemIdentity, CancellationToken cancellationToken) + public async ValueTask Read(string configurationRelativePath, ISystemIdentity? systemIdentity, CancellationToken cancellationToken) { await EnsureDirectories(cancellationToken); var path = ValidateConfigRelativePath(configurationRelativePath); - ConfigurationFileResponse result = null; + ConfigurationFileResponse? result = null; void ReadImpl() { @@ -321,7 +326,7 @@ namespace Tgstation.Server.Host.Components.StaticFiles }, async cancellationToken => { - FileStream result = null; + FileStream? result = null; void GetFileStream() { result = ioManager.GetFileStream(path, false); @@ -332,7 +337,7 @@ namespace Tgstation.Server.Host.Components.StaticFiles else await systemIdentity.RunImpersonated(GetFileStream, cancellationToken); - return result; + return result!; }, path, false)); @@ -453,12 +458,12 @@ namespace Tgstation.Server.Host.Components.StaticFiles } /// - public async ValueTask Write(string configurationRelativePath, ISystemIdentity systemIdentity, string previousHash, CancellationToken cancellationToken) + public async ValueTask Write(string configurationRelativePath, ISystemIdentity? systemIdentity, string? previousHash, CancellationToken cancellationToken) { await EnsureDirectories(cancellationToken); var path = ValidateConfigRelativePath(configurationRelativePath); - ConfigurationFileResponse result = null; + ConfigurationFileResponse? result = null; void WriteImpl() { @@ -563,7 +568,7 @@ namespace Tgstation.Server.Host.Components.StaticFiles } /// - public async ValueTask CreateDirectory(string configurationRelativePath, ISystemIdentity systemIdentity, CancellationToken cancellationToken) + public async ValueTask CreateDirectory(string configurationRelativePath, ISystemIdentity? systemIdentity, CancellationToken cancellationToken) { await EnsureDirectories(cancellationToken); var path = ValidateConfigRelativePath(configurationRelativePath); @@ -585,7 +590,7 @@ namespace Tgstation.Server.Host.Components.StaticFiles await systemIdentity.RunImpersonated(DoCreate, cancellationToken); } - return result.Value; + return result!.Value; } /// @@ -659,7 +664,7 @@ namespace Tgstation.Server.Host.Components.StaticFiles } /// - public async ValueTask DeleteDirectory(string configurationRelativePath, ISystemIdentity systemIdentity, CancellationToken cancellationToken) + public async ValueTask DeleteDirectory(string configurationRelativePath, ISystemIdentity? systemIdentity, CancellationToken cancellationToken) { await EnsureDirectories(cancellationToken); var path = ValidateConfigRelativePath(configurationRelativePath); @@ -737,16 +742,16 @@ namespace Tgstation.Server.Host.Components.StaticFiles /// /// A relative path in the instance's configuration directory. /// The full on-disk path of . - string ValidateConfigRelativePath(string configurationRelativePath) + string ValidateConfigRelativePath(string? configurationRelativePath) { var nullOrEmptyCheck = String.IsNullOrEmpty(configurationRelativePath); if (nullOrEmptyCheck) configurationRelativePath = DefaultIOManager.CurrentDirectory; - if (configurationRelativePath[0] == Path.DirectorySeparatorChar || configurationRelativePath[0] == Path.AltDirectorySeparatorChar) + if (configurationRelativePath![0] == Path.DirectorySeparatorChar || configurationRelativePath[0] == Path.AltDirectorySeparatorChar) configurationRelativePath = DefaultIOManager.CurrentDirectory + configurationRelativePath; var resolved = ioManager.ResolvePath(configurationRelativePath); var local = !nullOrEmptyCheck ? ioManager.ResolvePath() : null; - if (!nullOrEmptyCheck && resolved.Length < local.Length) // .. fuccbois + if (!nullOrEmptyCheck && resolved.Length < local!.Length) // .. fuccbois throw new InvalidOperationException("Attempted to access file outside of configuration manager!"); return resolved; } diff --git a/src/Tgstation.Server.Host/Components/StaticFiles/IConfiguration.cs b/src/Tgstation.Server.Host/Components/StaticFiles/IConfiguration.cs index db32cc1c2b..d156df54cb 100644 --- a/src/Tgstation.Server.Host/Components/StaticFiles/IConfiguration.cs +++ b/src/Tgstation.Server.Host/Components/StaticFiles/IConfiguration.cs @@ -39,7 +39,7 @@ namespace Tgstation.Server.Host.Components.StaticFiles /// The for the operation. If , the operation will be performed as the user of the . /// The for the operation. /// A resulting in an of the s for the items in the directory. and will both be . will be returned if the operation failed due to access contention. - ValueTask> ListDirectory(string? configurationRelativePath, ISystemIdentity? systemIdentity, CancellationToken cancellationToken); + ValueTask?> ListDirectory(string? configurationRelativePath, ISystemIdentity? systemIdentity, CancellationToken cancellationToken); /// /// Reads a given . diff --git a/src/Tgstation.Server.Host/Components/StaticFiles/ServerSideModifications.cs b/src/Tgstation.Server.Host/Components/StaticFiles/ServerSideModifications.cs index 6b7e358f0b..e28920a06e 100644 --- a/src/Tgstation.Server.Host/Components/StaticFiles/ServerSideModifications.cs +++ b/src/Tgstation.Server.Host/Components/StaticFiles/ServerSideModifications.cs @@ -13,12 +13,12 @@ /// /// The #include line which should be added to the beginning of the .dme if any. /// - public string HeadIncludeLine { get; } + public string? HeadIncludeLine { get; } /// /// The #include line which should be added to the end of the .dme if any. /// - public string TailIncludeLine { get; } + public string? TailIncludeLine { get; } /// /// Initializes a new instance of the class. @@ -26,7 +26,7 @@ /// The value of . /// The value of . /// The value of . - public ServerSideModifications(string headIncludeLine, string tailIncludeLine, bool totalDmeOverwrite) + public ServerSideModifications(string? headIncludeLine, string? tailIncludeLine, bool totalDmeOverwrite) { HeadIncludeLine = headIncludeLine; TailIncludeLine = tailIncludeLine; diff --git a/src/Tgstation.Server.Host/IO/DefaultIOManager.cs b/src/Tgstation.Server.Host/IO/DefaultIOManager.cs index 89231a6a49..1126bafc7d 100644 --- a/src/Tgstation.Server.Host/IO/DefaultIOManager.cs +++ b/src/Tgstation.Server.Host/IO/DefaultIOManager.cs @@ -69,7 +69,7 @@ namespace Tgstation.Server.Host.IO /// public async ValueTask CopyDirectory( - IEnumerable ignore, + IEnumerable? ignore, Func? postCopyCallback, string src, string dest, diff --git a/src/Tgstation.Server.Host/IO/IIOManager.cs b/src/Tgstation.Server.Host/IO/IIOManager.cs index ed4a90fb52..d88ec3ec17 100644 --- a/src/Tgstation.Server.Host/IO/IIOManager.cs +++ b/src/Tgstation.Server.Host/IO/IIOManager.cs @@ -56,7 +56,7 @@ namespace Tgstation.Server.Host.IO /// The for the operation. /// A representing the running operation. ValueTask CopyDirectory( - IEnumerable ignore, + IEnumerable? ignore, Func? postCopyCallback, string src, string dest, From 5222c4ed1eb6a2df98e889a2401037fc050b94aa Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Wed, 20 Dec 2023 23:21:14 -0500 Subject: [PATCH 294/425] Simplify a collection initialization expression --- src/Tgstation.Server.Host/IO/DefaultIOManager.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Tgstation.Server.Host/IO/DefaultIOManager.cs b/src/Tgstation.Server.Host/IO/DefaultIOManager.cs index 1126bafc7d..cdae64ce44 100644 --- a/src/Tgstation.Server.Host/IO/DefaultIOManager.cs +++ b/src/Tgstation.Server.Host/IO/DefaultIOManager.cs @@ -303,11 +303,10 @@ namespace Tgstation.Server.Host.IO /// public bool PathContainsParentAccess(string path) => path ?.Split( - new[] - { + [ Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar, - }) + ]) .Any(x => x == "..") ?? throw new ArgumentNullException(nameof(path)); From 1e3868d72d6fb8f234501753aa4fd248931bffdb Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Wed, 20 Dec 2023 23:21:26 -0500 Subject: [PATCH 295/425] Nullify `EventConsumer` --- src/Tgstation.Server.Host/Components/Events/EventConsumer.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Events/EventConsumer.cs b/src/Tgstation.Server.Host/Components/Events/EventConsumer.cs index ae805853fb..8cc073ccda 100644 --- a/src/Tgstation.Server.Host/Components/Events/EventConsumer.cs +++ b/src/Tgstation.Server.Host/Components/Events/EventConsumer.cs @@ -6,8 +6,6 @@ using System.Threading.Tasks; using Tgstation.Server.Host.Components.StaticFiles; using Tgstation.Server.Host.Components.Watchdog; -#nullable disable - namespace Tgstation.Server.Host.Components.Events { /// @@ -21,7 +19,7 @@ namespace Tgstation.Server.Host.Components.Events /// /// The for the . /// - IWatchdog watchdog; + IWatchdog? watchdog; /// /// Initializes a new instance of the class. From 92f53a75c0c904f7fa476dc371e505964535fffc Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Wed, 20 Dec 2023 23:21:38 -0500 Subject: [PATCH 296/425] Nullify `EventScriptAttribute` --- .../Components/Events/EventScriptAttribute.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Events/EventScriptAttribute.cs b/src/Tgstation.Server.Host/Components/Events/EventScriptAttribute.cs index fafcd82562..ba93d34cf9 100644 --- a/src/Tgstation.Server.Host/Components/Events/EventScriptAttribute.cs +++ b/src/Tgstation.Server.Host/Components/Events/EventScriptAttribute.cs @@ -1,8 +1,6 @@ using System; using System.Collections.Generic; -#nullable disable - namespace Tgstation.Server.Host.Components.Events { /// From 0c16676596b7853c538c7b39d505a27598c4f672 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Wed, 20 Dec 2023 23:21:52 -0500 Subject: [PATCH 297/425] Nullify `IEventConsumer` --- src/Tgstation.Server.Host/Components/Events/IEventConsumer.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Events/IEventConsumer.cs b/src/Tgstation.Server.Host/Components/Events/IEventConsumer.cs index 4c2a7be5bd..7fddbb8950 100644 --- a/src/Tgstation.Server.Host/Components/Events/IEventConsumer.cs +++ b/src/Tgstation.Server.Host/Components/Events/IEventConsumer.cs @@ -2,8 +2,6 @@ using System.Threading; using System.Threading.Tasks; -#nullable disable - namespace Tgstation.Server.Host.Components.Events { /// From b3e0a891dfbe4e336fa444267ddcfa8a87f0eb97 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Wed, 20 Dec 2023 23:22:03 -0500 Subject: [PATCH 298/425] Nullify `NoopEventConsumer` --- .../Components/Events/NoopEventConsumer.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Events/NoopEventConsumer.cs b/src/Tgstation.Server.Host/Components/Events/NoopEventConsumer.cs index 531018f7b5..a8b07e4d7e 100644 --- a/src/Tgstation.Server.Host/Components/Events/NoopEventConsumer.cs +++ b/src/Tgstation.Server.Host/Components/Events/NoopEventConsumer.cs @@ -2,8 +2,6 @@ using System.Threading; using System.Threading.Tasks; -#nullable disable - namespace Tgstation.Server.Host.Components.Events { /// From f819766a5b503a21b6c90edf4f93db1ae73b8788 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Wed, 20 Dec 2023 23:34:29 -0500 Subject: [PATCH 299/425] Nullify `ChatUser` Clean up nullification of `ChannelRepresentation` as well --- .../Components/Chat/ChannelRepresentation.cs | 6 ++-- .../Components/Chat/ChatManager.cs | 2 +- .../Components/Chat/ChatUser.cs | 31 ++++++++++++++----- .../Chat/Providers/DiscordProvider.cs | 12 +++---- .../Components/Chat/Providers/IrcProvider.cs | 12 +++---- .../Live/DummyChatProvider.cs | 12 +++---- .../Live/Instance/WatchdogTest.cs | 14 +++------ 7 files changed, 47 insertions(+), 42 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Chat/ChannelRepresentation.cs b/src/Tgstation.Server.Host/Components/Chat/ChannelRepresentation.cs index b7bed776d6..b1d4aa3ad2 100644 --- a/src/Tgstation.Server.Host/Components/Chat/ChannelRepresentation.cs +++ b/src/Tgstation.Server.Host/Components/Chat/ChannelRepresentation.cs @@ -14,7 +14,7 @@ namespace Tgstation.Server.Host.Components.Chat /// /// Backing field for . Represented as a to avoid BYOND percision loss. /// - public string Id { get; set; } + public string Id { get; private set; } /// /// The channel Id. @@ -45,7 +45,7 @@ namespace Tgstation.Server.Host.Components.Chat /// /// If this is a 1-to-1 chat channel. /// - public bool IsPrivateChannel { get; set; } + public bool IsPrivateChannel { get; init; } /// /// For user use. @@ -55,7 +55,7 @@ namespace Tgstation.Server.Host.Components.Chat /// /// If this channel supports embeds. /// - public bool EmbedsSupported { get; set; } + public bool EmbedsSupported { get; init; } /// /// Initializes a new instance of the class. diff --git a/src/Tgstation.Server.Host/Components/Chat/ChatManager.cs b/src/Tgstation.Server.Host/Components/Chat/ChatManager.cs index 505a94d817..36812e7743 100644 --- a/src/Tgstation.Server.Host/Components/Chat/ChatManager.cs +++ b/src/Tgstation.Server.Host/Components/Chat/ChatManager.cs @@ -798,7 +798,7 @@ namespace Tgstation.Server.Host.Components.Chat var mappingChannelRepresentation = mappedChannel.Value.Value.Channel; - message.User.Channel.Id = mappingChannelRepresentation.Id; + message.User.Channel.RealId = mappingChannelRepresentation.RealId; message.User.Channel.Tag = mappingChannelRepresentation.Tag; message.User.Channel.IsAdminChannel = mappingChannelRepresentation.IsAdminChannel; } diff --git a/src/Tgstation.Server.Host/Components/Chat/ChatUser.cs b/src/Tgstation.Server.Host/Components/Chat/ChatUser.cs index 9660bc6c83..69757279b0 100644 --- a/src/Tgstation.Server.Host/Components/Chat/ChatUser.cs +++ b/src/Tgstation.Server.Host/Components/Chat/ChatUser.cs @@ -3,8 +3,6 @@ using System.Globalization; using Newtonsoft.Json; -#nullable disable - namespace Tgstation.Server.Host.Components.Chat { /// @@ -15,7 +13,7 @@ namespace Tgstation.Server.Host.Components.Chat /// /// Backing field for . Represented as a to avoid BYOND percision loss. /// - public string Id { get; set; } + public string Id { get; private set; } /// /// The internal user id. @@ -23,23 +21,40 @@ namespace Tgstation.Server.Host.Components.Chat [JsonIgnore] public ulong RealId { - get => UInt64.Parse(Id, CultureInfo.InvariantCulture); - set => Id = value.ToString(CultureInfo.InvariantCulture); + get => UInt64.Parse(Id!, CultureInfo.InvariantCulture); + private set => Id = value.ToString(CultureInfo.InvariantCulture); } /// /// The friendly name of the user. /// - public string FriendlyName { get; set; } + public string FriendlyName { get; } /// /// The text to mention the user. /// - public string Mention { get; set; } + public string Mention { get; } /// /// The the user spoke from. /// - public ChannelRepresentation Channel { get; set; } + public ChannelRepresentation Channel { get; } + + /// + /// Initializes a new instance of the class. + /// + /// The value of . + /// The value of . + /// The value of . + /// The value of . + public ChatUser(ChannelRepresentation channel, string friendlyName, string mention, ulong realId) + { + Channel = channel ?? throw new ArgumentNullException(nameof(channel)); + FriendlyName = friendlyName ?? throw new ArgumentNullException(nameof(friendlyName)); + Mention = mention ?? throw new ArgumentNullException(nameof(mention)); + + Id = null!; + RealId = realId; + } } } diff --git a/src/Tgstation.Server.Host/Components/Chat/Providers/DiscordProvider.cs b/src/Tgstation.Server.Host/Components/Chat/Providers/DiscordProvider.cs index 958aa54b26..6d06322dfc 100644 --- a/src/Tgstation.Server.Host/Components/Chat/Providers/DiscordProvider.cs +++ b/src/Tgstation.Server.Host/Components/Chat/Providers/DiscordProvider.cs @@ -531,10 +531,8 @@ namespace Tgstation.Server.Host.Components.Chat.Providers } var result = new DiscordMessage( - new ChatUser - { - RealId = messageCreateEvent.Author.ID.Value, - Channel = new ChannelRepresentation( + new ChatUser( + new ChannelRepresentation( pm ? messageCreateEvent.Author.Username : guildName, channelResponse.Entity.Name.Value!, messageCreateEvent.ChannelID.Value) @@ -544,9 +542,9 @@ namespace Tgstation.Server.Host.Components.Chat.Providers // isAdmin and Tag populated by manager }, - FriendlyName = messageCreateEvent.Author.Username, - Mention = NormalizeMentions($"<@{messageCreateEvent.Author.ID}>"), - }, + messageCreateEvent.Author.Username, + NormalizeMentions($"<@{messageCreateEvent.Author.ID}>"), + messageCreateEvent.Author.ID.Value), content, messageReference); diff --git a/src/Tgstation.Server.Host/Components/Chat/Providers/IrcProvider.cs b/src/Tgstation.Server.Host/Components/Chat/Providers/IrcProvider.cs index 5207cc380d..f8dfec4197 100644 --- a/src/Tgstation.Server.Host/Components/Chat/Providers/IrcProvider.cs +++ b/src/Tgstation.Server.Host/Components/Chat/Providers/IrcProvider.cs @@ -530,19 +530,17 @@ namespace Tgstation.Server.Host.Components.Chat.Providers var channelFriendlyName = isPrivate ? String.Format(CultureInfo.InvariantCulture, "PM: {0}", channelName) : channelName; var message = new Message( - new ChatUser - { - Channel = new ChannelRepresentation(address, channelFriendlyName, channelId) + new ChatUser( + new ChannelRepresentation(address, channelFriendlyName, channelId) { IsPrivateChannel = isPrivate, EmbedsSupported = false, // isAdmin and Tag populated by manager }, - FriendlyName = username, - RealId = userId, - Mention = username, - }, + username, + username, + userId), e.Data.Message); EnqueueMessage(message); diff --git a/tests/Tgstation.Server.Tests/Live/DummyChatProvider.cs b/tests/Tgstation.Server.Tests/Live/DummyChatProvider.cs index 8997c22841..debbf913b8 100644 --- a/tests/Tgstation.Server.Tests/Live/DummyChatProvider.cs +++ b/tests/Tgstation.Server.Tests/Live/DummyChatProvider.cs @@ -279,13 +279,11 @@ namespace Tgstation.Server.Tests.Live channel = enumerator[index].Value; } - var sender = new ChatUser - { - Channel = CloneChannel(channel), - FriendlyName = username, - RealId = i + 50000, - Mention = $"@{username}", - }; + var sender = new ChatUser( + CloneChannel(channel), + username, + $"@{username}", + i + 50000); var dice = random.Next(0, 100); string content; diff --git a/tests/Tgstation.Server.Tests/Live/Instance/WatchdogTest.cs b/tests/Tgstation.Server.Tests/Live/Instance/WatchdogTest.cs index 4b08e3ae1f..24e1dca471 100644 --- a/tests/Tgstation.Server.Tests/Live/Instance/WatchdogTest.cs +++ b/tests/Tgstation.Server.Tests/Live/Instance/WatchdogTest.cs @@ -1024,20 +1024,16 @@ namespace Tgstation.Server.Tests.Live.Instance var startTime = DateTimeOffset.UtcNow - TimeSpan.FromSeconds(5); using (var instanceReference = instanceManager.GetInstanceReference(instanceClient.Metadata)) { - var mockChatUser = new ChatUser - { - Channel = new ChannelRepresentation("test_connection", "Test Connection", 0) + var mockChatUser = new ChatUser( + new ChannelRepresentation("test_connection", "Test Connection", 42) { IsAdminChannel = true, EmbedsSupported = true, - Id = "test_channel_id", IsPrivateChannel = false, }, - FriendlyName = "Test Sender", - Id = "test_user_id", - Mention = "test_user_mention", - RealId = 1234, - }; + "Test Sender", + "test_user_mention", + 1234); var embedsResponseTask = ((WatchdogBase)instanceReference.Watchdog).HandleChatCommand( "embeds_test", From 6d435b7fddf7facb1c566a9d72a7b9d71c642203 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Wed, 20 Dec 2023 23:37:47 -0500 Subject: [PATCH 300/425] Re-enable control of random chat disconnections --- tests/Tgstation.Server.Tests/Live/DummyChatProvider.cs | 4 ++-- tests/Tgstation.Server.Tests/Live/Instance/WatchdogTest.cs | 2 +- tests/Tgstation.Server.Tests/Live/TestLiveServer.cs | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/Tgstation.Server.Tests/Live/DummyChatProvider.cs b/tests/Tgstation.Server.Tests/Live/DummyChatProvider.cs index debbf913b8..872e59e6e6 100644 --- a/tests/Tgstation.Server.Tests/Live/DummyChatProvider.cs +++ b/tests/Tgstation.Server.Tests/Live/DummyChatProvider.cs @@ -55,10 +55,10 @@ namespace Tgstation.Server.Tests.Live return mock.Object; } - public static Task RandomDisconnections(bool enabled, CancellationToken cancellationToken) + public static void RandomDisconnections(bool enabled) { // we just don't do random disconnections when live testing these days, too many potential issue vectors like thread exhaustion on actions runners - return Task.CompletedTask; + enableRandomDisconnections = enabled ? 1 : 0; } public DummyChatProvider( diff --git a/tests/Tgstation.Server.Tests/Live/Instance/WatchdogTest.cs b/tests/Tgstation.Server.Tests/Live/Instance/WatchdogTest.cs index 24e1dca471..678ef10fc7 100644 --- a/tests/Tgstation.Server.Tests/Live/Instance/WatchdogTest.cs +++ b/tests/Tgstation.Server.Tests/Live/Instance/WatchdogTest.cs @@ -158,7 +158,7 @@ namespace Tgstation.Server.Tests.Live.Instance await TestDMApiFreeDeploy(cancellationToken); // long running test likes consistency with the channels - await DummyChatProvider.RandomDisconnections(false, cancellationToken); + DummyChatProvider.RandomDisconnections(false); await RunLongRunningTestThenUpdate(cancellationToken); diff --git a/tests/Tgstation.Server.Tests/Live/TestLiveServer.cs b/tests/Tgstation.Server.Tests/Live/TestLiveServer.cs index 96ee8ba640..9ac95ce865 100644 --- a/tests/Tgstation.Server.Tests/Live/TestLiveServer.cs +++ b/tests/Tgstation.Server.Tests/Live/TestLiveServer.cs @@ -194,7 +194,7 @@ namespace Tgstation.Server.Tests.Live await CachingFileDownloader.InitializeAndInjectForLiveTests(default); - await DummyChatProvider.RandomDisconnections(true, default); + DummyChatProvider.RandomDisconnections(true); ServerClientFactory.ApiClientFactory = new RateLimitRetryingApiClientFactory(); var connectionString = Environment.GetEnvironmentVariable("TGS_TEST_CONNECTION_STRING"); @@ -1744,7 +1744,7 @@ namespace Tgstation.Server.Tests.Live await chatTestObj.RunPostTest(cancellationToken); await repoTest; - await DummyChatProvider.RandomDisconnections(false, cancellationToken); + DummyChatProvider.RandomDisconnections(false); jobsHubTest.CompleteNow(); await jobsHubTestTask; From d5b69657f990ed4bf91e7a058426cf1cec82428f Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Wed, 20 Dec 2023 23:55:08 -0500 Subject: [PATCH 301/425] Jobs can start will `null` `IInstanceCore`s --- src/Tgstation.Server.Host/Components/Instance.cs | 2 +- .../Controllers/DreamDaemonController.cs | 6 +++--- .../Controllers/DreamMakerController.cs | 2 +- src/Tgstation.Server.Host/Controllers/EngineController.cs | 4 ++-- .../Controllers/RepositoryController.cs | 4 ++-- src/Tgstation.Server.Host/Jobs/JobEntrypoint.cs | 2 +- src/Tgstation.Server.Host/Jobs/JobService.cs | 4 +--- 7 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Instance.cs b/src/Tgstation.Server.Host/Components/Instance.cs index 10be9b18a3..8693e5cb26 100644 --- a/src/Tgstation.Server.Host/Components/Instance.cs +++ b/src/Tgstation.Server.Host/Components/Instance.cs @@ -266,7 +266,7 @@ namespace Tgstation.Server.Host.Components /// A representing the running operation. #pragma warning disable CA1502 // Cyclomatic complexity ValueTask RepositoryAutoUpdateJob( - IInstanceCore core, + IInstanceCore? core, IDatabaseContextFactory databaseContextFactory, Job job, JobProgressReporter progressReporter, diff --git a/src/Tgstation.Server.Host/Controllers/DreamDaemonController.cs b/src/Tgstation.Server.Host/Controllers/DreamDaemonController.cs index f83ec8410f..069b272959 100644 --- a/src/Tgstation.Server.Host/Controllers/DreamDaemonController.cs +++ b/src/Tgstation.Server.Host/Controllers/DreamDaemonController.cs @@ -90,7 +90,7 @@ namespace Tgstation.Server.Host.Controllers var job = Job.Create(JobCode.WatchdogLaunch, AuthenticationContext.User, Instance, DreamDaemonRights.Shutdown); await jobManager.RegisterOperation( job, - (core, databaseContextFactory, paramJob, progressHandler, innerCt) => core.Watchdog.Launch(innerCt), + (core, databaseContextFactory, paramJob, progressHandler, innerCt) => core!.Watchdog.Launch(innerCt), cancellationToken); return Accepted(job.ToApi()); }); @@ -271,7 +271,7 @@ namespace Tgstation.Server.Host.Controllers await jobManager.RegisterOperation( job, - (core, paramJob, databaseContextFactory, progressReporter, ct) => core.Watchdog.Restart(false, ct), + (core, paramJob, databaseContextFactory, progressReporter, ct) => core!.Watchdog.Restart(false, ct), cancellationToken); return Accepted(job.ToApi()); }); @@ -297,7 +297,7 @@ namespace Tgstation.Server.Host.Controllers await jobManager.RegisterOperation( job, - (core, databaseContextFactory, paramJob, progressReporter, ct) => core.Watchdog.CreateDump(ct), + (core, databaseContextFactory, paramJob, progressReporter, ct) => core!.Watchdog.CreateDump(ct), cancellationToken); return Accepted(job.ToApi()); }); diff --git a/src/Tgstation.Server.Host/Controllers/DreamMakerController.cs b/src/Tgstation.Server.Host/Controllers/DreamMakerController.cs index 680f8da731..419bc9c90d 100644 --- a/src/Tgstation.Server.Host/Controllers/DreamMakerController.cs +++ b/src/Tgstation.Server.Host/Controllers/DreamMakerController.cs @@ -151,7 +151,7 @@ namespace Tgstation.Server.Host.Controllers await jobManager.RegisterOperation( job, (core, databaseContextFactory, paramJob, progressReporter, jobCancellationToken) - => core.DreamMaker.DeploymentProcess(paramJob, databaseContextFactory, progressReporter, jobCancellationToken), + => core!.DreamMaker.DeploymentProcess(paramJob, databaseContextFactory, progressReporter, jobCancellationToken), cancellationToken); return Accepted(job.ToApi()); } diff --git a/src/Tgstation.Server.Host/Controllers/EngineController.cs b/src/Tgstation.Server.Host/Controllers/EngineController.cs index 2f83a1afd8..d5072c597f 100644 --- a/src/Tgstation.Server.Host/Controllers/EngineController.cs +++ b/src/Tgstation.Server.Host/Controllers/EngineController.cs @@ -245,7 +245,7 @@ namespace Tgstation.Server.Host.Controllers } await using (zipFileStream) - await core.EngineManager.ChangeVersion( + await core!.EngineManager.ChangeVersion( progressHandler, model.EngineVersion, zipFileStream, @@ -329,7 +329,7 @@ namespace Tgstation.Server.Host.Controllers await jobManager.RegisterOperation( job, (instanceCore, databaseContextFactory, job, progressReporter, jobCancellationToken) - => instanceCore.EngineManager.DeleteVersion(progressReporter, engineVersion, jobCancellationToken), + => instanceCore!.EngineManager.DeleteVersion(progressReporter, engineVersion, jobCancellationToken), cancellationToken); var apiResponse = job.ToApi(); diff --git a/src/Tgstation.Server.Host/Controllers/RepositoryController.cs b/src/Tgstation.Server.Host/Controllers/RepositoryController.cs index dcff26b25e..5d4d686aaf 100644 --- a/src/Tgstation.Server.Host/Controllers/RepositoryController.cs +++ b/src/Tgstation.Server.Host/Controllers/RepositoryController.cs @@ -151,7 +151,7 @@ namespace Tgstation.Server.Host.Controllers job, async (core, databaseContextFactory, paramJob, progressReporter, ct) => { - var repoManager = core.RepositoryManager; + var repoManager = core!.RepositoryManager; using var repos = await repoManager.CloneRepository( origin, cloneBranch, @@ -217,7 +217,7 @@ namespace Tgstation.Server.Host.Controllers var api = currentModel.ToApi(); await jobManager.RegisterOperation( job, - (core, databaseContextFactory, paramJob, progressReporter, ct) => core.RepositoryManager.DeleteRepository(ct), + (core, databaseContextFactory, paramJob, progressReporter, ct) => core!.RepositoryManager.DeleteRepository(ct), cancellationToken); api.ActiveJob = job.ToApi(); return Accepted(api); diff --git a/src/Tgstation.Server.Host/Jobs/JobEntrypoint.cs b/src/Tgstation.Server.Host/Jobs/JobEntrypoint.cs index 79e71b5048..82e81a647c 100644 --- a/src/Tgstation.Server.Host/Jobs/JobEntrypoint.cs +++ b/src/Tgstation.Server.Host/Jobs/JobEntrypoint.cs @@ -17,7 +17,7 @@ namespace Tgstation.Server.Host.Jobs /// The for the operation. /// A representing the running operation. public delegate ValueTask JobEntrypoint( - IInstanceCore instance, + IInstanceCore? instance, IDatabaseContextFactory databaseContextFactory, Job job, JobProgressReporter progressReporter, diff --git a/src/Tgstation.Server.Host/Jobs/JobService.cs b/src/Tgstation.Server.Host/Jobs/JobService.cs index 8db21d3068..ea2782a821 100644 --- a/src/Tgstation.Server.Host/Jobs/JobService.cs +++ b/src/Tgstation.Server.Host/Jobs/JobService.cs @@ -460,10 +460,8 @@ namespace Tgstation.Server.Host.Jobs QueueHubUpdate(job.ToApi(), false); logger.LogTrace("Starting job..."); - var instanceCore = instanceCoreProvider.GetInstance(job.Instance!) - ?? throw new JobException("Could not retrieve instance core for job!"); await operation( - instanceCore, + instanceCoreProvider.GetInstance(job.Instance!), databaseContextFactory, job, new JobProgressReporter( From 6eb6d730332f37e3b052a56ad760ad7aba153463 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 21 Dec 2023 08:24:02 -0500 Subject: [PATCH 302/425] Set `WarningLevel=0` for OD DMAPI build --- .github/workflows/ci-pipeline.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-pipeline.yml b/.github/workflows/ci-pipeline.yml index 1efe65423b..483a030d50 100644 --- a/.github/workflows/ci-pipeline.yml +++ b/.github/workflows/ci-pipeline.yml @@ -203,7 +203,7 @@ jobs: - name: Create TGS Deployment run: | cd $HOME/OpenDream - dotnet run -c Release --project OpenDreamPackageTool -- --tgs -o tgs_deploy + dotnet run -c Release --project OpenDreamPackageTool --property WarningLevel=0 -- --tgs -o tgs_deploy - name: Build DMAPI run: | From 30592dec0cfbcf7e4f422187c6432468a112a22f Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 21 Dec 2023 09:05:00 -0500 Subject: [PATCH 303/425] Nullify `IChatManager` --- src/Tgstation.Server.Host/Components/Chat/ChatManager.cs | 4 ++-- src/Tgstation.Server.Host/Components/Chat/IChatManager.cs | 6 ++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Chat/ChatManager.cs b/src/Tgstation.Server.Host/Components/Chat/ChatManager.cs index 36812e7743..9c0ce9ffb0 100644 --- a/src/Tgstation.Server.Host/Components/Chat/ChatManager.cs +++ b/src/Tgstation.Server.Host/Components/Chat/ChatManager.cs @@ -380,8 +380,8 @@ namespace Tgstation.Server.Host.Components.Chat Models.RevisionInformation revisionInformation, EngineVersion engineVersion, DateTimeOffset? estimatedCompletionTime, - string gitHubOwner, - string gitHubRepo, + string? gitHubOwner, + string? gitHubRepo, bool localCommitPushed) { List wdChannels; diff --git a/src/Tgstation.Server.Host/Components/Chat/IChatManager.cs b/src/Tgstation.Server.Host/Components/Chat/IChatManager.cs index 435c867d3e..e053f7f1de 100644 --- a/src/Tgstation.Server.Host/Components/Chat/IChatManager.cs +++ b/src/Tgstation.Server.Host/Components/Chat/IChatManager.cs @@ -6,8 +6,6 @@ using System.Threading.Tasks; using Tgstation.Server.Api.Models.Internal; using Tgstation.Server.Host.Components.Interop; -#nullable disable - namespace Tgstation.Server.Host.Components.Chat { /// @@ -73,8 +71,8 @@ namespace Tgstation.Server.Host.Components.Chat Models.RevisionInformation revisionInformation, Api.Models.EngineVersion engineVersion, DateTimeOffset? estimatedCompletionTime, - string gitHubOwner, - string gitHubRepo, + string? gitHubOwner, + string? gitHubRepo, bool localCommitPushed); /// From 921e7ddee074726bf80fcea3bc07d3d4b94cc759 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 21 Dec 2023 09:05:34 -0500 Subject: [PATCH 304/425] Nullify `IChatManagerFactory` --- .../Components/Chat/IChatManagerFactory.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Chat/IChatManagerFactory.cs b/src/Tgstation.Server.Host/Components/Chat/IChatManagerFactory.cs index 4af42411be..bff29dc9c4 100644 --- a/src/Tgstation.Server.Host/Components/Chat/IChatManagerFactory.cs +++ b/src/Tgstation.Server.Host/Components/Chat/IChatManagerFactory.cs @@ -2,8 +2,6 @@ using Tgstation.Server.Host.Components.Chat.Commands; -#nullable disable - namespace Tgstation.Server.Host.Components.Chat { /// From a1d1dda9af314dc5727ac7c4b4d82fb10d005632 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 21 Dec 2023 09:05:51 -0500 Subject: [PATCH 305/425] Nullify `IChatTrackingContext` --- .../Components/Chat/IChatTrackingContext.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Chat/IChatTrackingContext.cs b/src/Tgstation.Server.Host/Components/Chat/IChatTrackingContext.cs index 284c0f5564..37e1da9584 100644 --- a/src/Tgstation.Server.Host/Components/Chat/IChatTrackingContext.cs +++ b/src/Tgstation.Server.Host/Components/Chat/IChatTrackingContext.cs @@ -3,8 +3,6 @@ using System.Collections.Generic; using Tgstation.Server.Host.Components.Chat.Commands; -#nullable disable - namespace Tgstation.Server.Host.Components.Chat { /// From e677124bd5238391ebe60df1751cf21e0b3444aa Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 21 Dec 2023 09:06:04 -0500 Subject: [PATCH 306/425] Nullify `ICustomCommandHandler` --- .../Components/Chat/ICustomCommandHandler.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Chat/ICustomCommandHandler.cs b/src/Tgstation.Server.Host/Components/Chat/ICustomCommandHandler.cs index 988f3faa2f..bf406bb421 100644 --- a/src/Tgstation.Server.Host/Components/Chat/ICustomCommandHandler.cs +++ b/src/Tgstation.Server.Host/Components/Chat/ICustomCommandHandler.cs @@ -3,8 +3,6 @@ using System.Threading.Tasks; using Tgstation.Server.Host.Components.Interop; -#nullable disable - namespace Tgstation.Server.Host.Components.Chat { /// From 31570e338a030c571cd3f1a1858bd1e06102a8a3 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 21 Dec 2023 09:06:28 -0500 Subject: [PATCH 307/425] Move a comment slightly --- src/Tgstation.Server.Host/Components/Chat/ChatManager.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Chat/ChatManager.cs b/src/Tgstation.Server.Host/Components/Chat/ChatManager.cs index 9c0ce9ffb0..3bedb438c8 100644 --- a/src/Tgstation.Server.Host/Components/Chat/ChatManager.cs +++ b/src/Tgstation.Server.Host/Components/Chat/ChatManager.cs @@ -24,8 +24,7 @@ using Tgstation.Server.Host.Utils; namespace Tgstation.Server.Host.Components.Chat { /// - // TODO: Decomplexify -#pragma warning disable CA1506 +#pragma warning disable CA1506 // TODO: Decomplexify sealed class ChatManager : IChatManager, IRestartHandler { /// From ae89dc3eb71bf31598a64b93836fa787f868dd56 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 21 Dec 2023 09:08:29 -0500 Subject: [PATCH 308/425] Nullify `IRemoteDeploymentManager` --- .../Deployment/Remote/IRemoteDeploymentManager.cs | 8 +++----- src/Tgstation.Server.Host/Components/Instance.cs | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Deployment/Remote/IRemoteDeploymentManager.cs b/src/Tgstation.Server.Host/Components/Deployment/Remote/IRemoteDeploymentManager.cs index de92f3d31b..e73f6a1063 100644 --- a/src/Tgstation.Server.Host/Components/Deployment/Remote/IRemoteDeploymentManager.cs +++ b/src/Tgstation.Server.Host/Components/Deployment/Remote/IRemoteDeploymentManager.cs @@ -6,8 +6,6 @@ using System.Threading.Tasks; using Tgstation.Server.Host.Components.Repository; using Tgstation.Server.Host.Models; -#nullable disable - namespace Tgstation.Server.Host.Components.Deployment.Remote { /// @@ -36,7 +34,7 @@ namespace Tgstation.Server.Host.Components.Deployment.Remote /// A representing the running operation. ValueTask StageDeployment( CompileJob compileJob, - Action activationCallback, + Action? activationCallback, CancellationToken cancellationToken); /// @@ -70,8 +68,8 @@ namespace Tgstation.Server.Host.Components.Deployment.Remote /// The deployed . /// The of the previous deployment. /// The . - /// The GitHub repostiory owner. - /// The GitHub repostiory name. + /// The remote repostiory owner. + /// The remote repostiory name. /// The for the operation. /// A representing the running operation. ValueTask PostDeploymentComments( diff --git a/src/Tgstation.Server.Host/Components/Instance.cs b/src/Tgstation.Server.Host/Components/Instance.cs index 8693e5cb26..9e6b2de4a5 100644 --- a/src/Tgstation.Server.Host/Components/Instance.cs +++ b/src/Tgstation.Server.Host/Components/Instance.cs @@ -387,7 +387,7 @@ namespace Tgstation.Server.Host.Components var updatedTestMerges = await remoteDeploymentManager.RemoveMergedTestMerges( repo, repositorySettings, - currentRevInfo, + currentRevInfo!, cancellationToken); var result = await repo.MergeOrigin( From 9beb48436ba6d333ee9eca255b1d1736b5a50da3 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 21 Dec 2023 14:53:00 -0500 Subject: [PATCH 309/425] Fix messages in `BaseRemoteDeploymentManager` --- .../Remote/BaseRemoteDeploymentManager.cs | 70 ++++++++++--------- 1 file changed, 38 insertions(+), 32 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Deployment/Remote/BaseRemoteDeploymentManager.cs b/src/Tgstation.Server.Host/Components/Deployment/Remote/BaseRemoteDeploymentManager.cs index b06a3f8662..7822d29061 100644 --- a/src/Tgstation.Server.Host/Components/Deployment/Remote/BaseRemoteDeploymentManager.cs +++ b/src/Tgstation.Server.Host/Components/Deployment/Remote/BaseRemoteDeploymentManager.cs @@ -96,7 +96,7 @@ namespace Tgstation.Server.Host.Components.Deployment.Remote .Any(y => y.TestMerge.Number == x.Number)) .ToList(); - if (!addedTestMerges.Any() && !removedTestMerges.Any() && !updatedTestMerges.Any()) + if (addedTestMerges.Count == 0 && removedTestMerges.Count == 0 && updatedTestMerges.Count == 0) return; Logger.LogTrace( @@ -107,48 +107,54 @@ namespace Tgstation.Server.Host.Components.Deployment.Remote var tasks = new List(addedTestMerges.Count + updatedTestMerges.Count + removedTestMerges.Count); foreach (var addedTestMerge in addedTestMerges) - tasks.Add( - CommentOnTestMergeSource( + { + var addCommentTask = CommentOnTestMergeSource( + repositorySettings, + repoOwner, + repoName, + FormatTestMerge( repositorySettings, + compileJob, + addedTestMerge, repoOwner, repoName, - FormatTestMerge( - repositorySettings, - compileJob, - addedTestMerge, - repoOwner, - repoName, - false), - addedTestMerge.Number, - cancellationToken)); + false), + addedTestMerge.Number, + cancellationToken); + tasks.Add(addCommentTask); + } foreach (var removedTestMerge in removedTestMerges) - tasks.Add( - CommentOnTestMergeSource( - repositorySettings, - repoOwner, - repoName, - "#### Test Merge Removed", - removedTestMerge.Number, - cancellationToken)); + { + var removeCommentTask = CommentOnTestMergeSource( + repositorySettings, + repoOwner, + repoName, + "#### Test Merge Removed", + removedTestMerge.Number, + cancellationToken); + tasks.Add(removeCommentTask); + } foreach (var updatedTestMerge in updatedTestMerges) - tasks.Add( - CommentOnTestMergeSource( + { + var updateCommentTask = CommentOnTestMergeSource( + repositorySettings, + repoOwner, + repoName, + FormatTestMerge( repositorySettings, + compileJob, + updatedTestMerge, repoOwner, repoName, - FormatTestMerge( - repositorySettings, - compileJob, - updatedTestMerge, - repoOwner, - repoName, - true), - updatedTestMerge.Number, - cancellationToken)); + true), + updatedTestMerge.Number, + cancellationToken); + tasks.Add(updateCommentTask); + } - if (tasks.Any()) + if (tasks.Count > 0) await ValueTaskExtensions.WhenAll(tasks); } From 4d9be5bdd67d3c6b74020cfb86b71c2025c47739 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 21 Dec 2023 15:09:04 -0500 Subject: [PATCH 310/425] Nullify `BaseRemoteDeploymentManager` --- .../Remote/BaseRemoteDeploymentManager.cs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Deployment/Remote/BaseRemoteDeploymentManager.cs b/src/Tgstation.Server.Host/Components/Deployment/Remote/BaseRemoteDeploymentManager.cs index 7822d29061..a2aea1401c 100644 --- a/src/Tgstation.Server.Host/Components/Deployment/Remote/BaseRemoteDeploymentManager.cs +++ b/src/Tgstation.Server.Host/Components/Deployment/Remote/BaseRemoteDeploymentManager.cs @@ -11,8 +11,6 @@ using Tgstation.Server.Common.Extensions; using Tgstation.Server.Host.Components.Repository; using Tgstation.Server.Host.Models; -#nullable disable - namespace Tgstation.Server.Host.Components.Deployment.Remote { /// @@ -65,7 +63,7 @@ namespace Tgstation.Server.Host.Components.Deployment.Remote var deployedRevisionInformation = compileJob.RevisionInformation; if ((previousRevisionInformation != null && previousRevisionInformation.CommitSha == deployedRevisionInformation.CommitSha) - || !repositorySettings.PostTestMergeComment.Value) + || !repositorySettings.PostTestMergeComment!.Value) return; previousRevisionInformation ??= new RevisionInformation(); @@ -163,7 +161,7 @@ namespace Tgstation.Server.Host.Components.Deployment.Remote { ArgumentNullException.ThrowIfNull(compileJob); - if (activationCallbacks.TryGetValue(compileJob.Id.Value, out var activationCallback)) + if (activationCallbacks.TryGetValue(compileJob.Require(x => x.Id), out var activationCallback)) activationCallback(true); return ApplyDeploymentImpl(compileJob, cancellationToken); @@ -177,7 +175,7 @@ namespace Tgstation.Server.Host.Components.Deployment.Remote { ArgumentNullException.ThrowIfNull(compileJob); - if (activationCallbacks.TryRemove(compileJob.Id.Value, out var activationCallback)) + if (activationCallbacks.TryRemove(compileJob.Require(x => x.Id), out var activationCallback)) activationCallback(false); return MarkInactiveImpl(compileJob, cancellationToken); @@ -191,12 +189,13 @@ namespace Tgstation.Server.Host.Components.Deployment.Remote CancellationToken cancellationToken); /// - public ValueTask StageDeployment(CompileJob compileJob, Action activationCallback, CancellationToken cancellationToken) + public ValueTask StageDeployment(CompileJob compileJob, Action? activationCallback, CancellationToken cancellationToken) { ArgumentNullException.ThrowIfNull(compileJob); - if (activationCallback != null && !activationCallbacks.TryAdd(compileJob.Id.Value, activationCallback)) - Logger.LogError("activationCallbacks conflicted on CompileJob #{id}!", compileJob.Id.Value); + var compileJobId = compileJob.Require(x => x.Id); + if (activationCallback != null && !activationCallbacks.TryAdd(compileJobId, activationCallback)) + Logger.LogError("activationCallbacks conflicted on CompileJob #{id}!", compileJobId); return StageDeploymentImpl(compileJob, cancellationToken); } From 9a36a4fd2afc8b038e8e91f65b5724aadb9f5256 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Fri, 22 Dec 2023 09:28:25 -0500 Subject: [PATCH 311/425] Nullify `GitHubRemoteDeploymentManager` --- .../Remote/GitHubRemoteDeploymentManager.cs | 48 ++++++++++--------- 1 file changed, 26 insertions(+), 22 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Deployment/Remote/GitHubRemoteDeploymentManager.cs b/src/Tgstation.Server.Host/Components/Deployment/Remote/GitHubRemoteDeploymentManager.cs index 493daab039..4e37e7d008 100644 --- a/src/Tgstation.Server.Host/Components/Deployment/Remote/GitHubRemoteDeploymentManager.cs +++ b/src/Tgstation.Server.Host/Components/Deployment/Remote/GitHubRemoteDeploymentManager.cs @@ -17,8 +17,6 @@ using Tgstation.Server.Host.Database; using Tgstation.Server.Host.Models; using Tgstation.Server.Host.Utils.GitHub; -#nullable disable - namespace Tgstation.Server.Host.Components.Deployment.Remote { /// @@ -67,7 +65,7 @@ namespace Tgstation.Server.Host.Components.Deployment.Remote Logger.LogTrace("Starting deployment..."); - RepositorySettings repositorySettings = null; + RepositorySettings? repositorySettings = null; await databaseContextFactory.UseContext( async databaseContext => repositorySettings = await databaseContext @@ -76,12 +74,12 @@ namespace Tgstation.Server.Host.Components.Deployment.Remote .Where(x => x.InstanceId == Metadata.Id) .FirstAsync(cancellationToken)); - var instanceAuthenticated = repositorySettings.AccessToken != null; - IAuthenticatedGitHubService authenticatedGitHubService; + var instanceAuthenticated = repositorySettings!.AccessToken != null; + IAuthenticatedGitHubService? authenticatedGitHubService; IGitHubService gitHubService; if (instanceAuthenticated) { - authenticatedGitHubService = gitHubServiceFactory.CreateService(repositorySettings.AccessToken); + authenticatedGitHubService = gitHubServiceFactory.CreateService(repositorySettings.AccessToken!); gitHubService = authenticatedGitHubService; } else @@ -90,12 +88,14 @@ namespace Tgstation.Server.Host.Components.Deployment.Remote gitHubService = gitHubServiceFactory.CreateService(); } + var repoOwner = remoteInformation.RemoteRepositoryOwner!; + var repoName = remoteInformation.RemoteRepositoryName!; var repositoryIdTask = gitHubService.GetRepositoryId( - remoteInformation.RemoteRepositoryOwner, - remoteInformation.RemoteRepositoryName, + repoOwner, + repoName, cancellationToken); - if (!repositorySettings.CreateGitHubDeployments.Value) + if (!repositorySettings.CreateGitHubDeployments!.Value) Logger.LogTrace("Not creating deployment"); else if (!instanceAuthenticated) Logger.LogWarning("Can't create GitHub deployment as no access token is set for repository!"); @@ -104,7 +104,7 @@ namespace Tgstation.Server.Host.Components.Deployment.Remote Logger.LogTrace("Creating deployment..."); try { - compileJob.GitHubDeploymentId = await authenticatedGitHubService.CreateDeployment( + compileJob.GitHubDeploymentId = await authenticatedGitHubService!.CreateDeployment( new NewDeployment(compileJob.RevisionInformation.CommitSha) { AutoMerge = false, @@ -113,8 +113,8 @@ namespace Tgstation.Server.Host.Components.Deployment.Remote ProductionEnvironment = true, RequiredContexts = new Collection(), }, - remoteInformation.RemoteRepositoryOwner, - remoteInformation.RemoteRepositoryName, + repoOwner, + repoName, cancellationToken); Logger.LogDebug("Created deployment ID {deploymentId}", compileJob.GitHubDeploymentId); @@ -125,8 +125,8 @@ namespace Tgstation.Server.Host.Components.Deployment.Remote Description = "The project is being deployed", AutoInactive = false, }, - remoteInformation.RemoteRepositoryOwner, - remoteInformation.RemoteRepositoryName, + repoOwner, + repoName, compileJob.GitHubDeploymentId.Value, cancellationToken); @@ -168,7 +168,7 @@ namespace Tgstation.Server.Host.Components.Deployment.Remote ArgumentNullException.ThrowIfNull(repositorySettings); ArgumentNullException.ThrowIfNull(revisionInformation); - if (revisionInformation.ActiveTestMerges?.Any() != true) + if ((revisionInformation.ActiveTestMerges?.Count > 0) != true) { Logger.LogTrace("No test merges to remove."); return Array.Empty(); @@ -180,7 +180,11 @@ namespace Tgstation.Server.Host.Components.Deployment.Remote var tasks = revisionInformation .ActiveTestMerges - .Select(x => gitHubService.GetPullRequest(repository.RemoteRepositoryOwner, repository.RemoteRepositoryName, x.TestMerge.Number, cancellationToken)); + .Select(x => gitHubService.GetPullRequest( + repository.RemoteRepositoryOwner!, + repository.RemoteRepositoryName!, + x.TestMerge.Number, + cancellationToken)); try { await Task.WhenAll(tasks); @@ -192,7 +196,7 @@ namespace Tgstation.Server.Host.Components.Deployment.Remote var newList = revisionInformation.ActiveTestMerges.Select(x => x.TestMerge).ToList(); - PullRequest lastMerged = null; + PullRequest? lastMerged = null; async ValueTask CheckRemovePR(Task task) { var pr = await task; @@ -251,7 +255,7 @@ namespace Tgstation.Server.Host.Components.Deployment.Remote int testMergeNumber, CancellationToken cancellationToken) { - var gitHubService = gitHubServiceFactory.CreateService(repositorySettings.AccessToken); + var gitHubService = gitHubServiceFactory.CreateService(repositorySettings.AccessToken!); try { @@ -274,12 +278,12 @@ namespace Tgstation.Server.Host.Components.Deployment.Remote CultureInfo.InvariantCulture, "#### Test Merge {4}{0}{0}
Details{0}{0}##### Server Instance{0}{5}{1}{0}{0}##### Revision{0}Origin: {6}{0}Pull Request: {2}{0}Server: {7}{3}{8}{0}
", Environment.NewLine, - repositorySettings.ShowTestMergeCommitters.Value + repositorySettings.ShowTestMergeCommitters!.Value ? String.Format( CultureInfo.InvariantCulture, "{0}{0}##### Merged By{0}{1}", Environment.NewLine, - testMerge.MergedBy.Name) + testMerge.MergedBy!.Name) : String.Empty, testMerge.TargetCommitSha, testMerge.Comment != null @@ -294,7 +298,7 @@ namespace Tgstation.Server.Host.Components.Deployment.Remote compileJob.RevisionInformation.OriginCommitSha, compileJob.RevisionInformation.CommitSha, compileJob.GitHubDeploymentId.HasValue - ? $"{Environment.NewLine}[GitHub Deployments](https://github.com/{remoteRepositoryOwner}/{remoteRepositoryName}/deployments/activity_log?environment=TGS%3A+{Metadata.Name.Replace(" ", "+", StringComparison.Ordinal)})" + ? $"{Environment.NewLine}[GitHub Deployments](https://github.com/{remoteRepositoryOwner}/{remoteRepositoryName}/deployments/activity_log?environment=TGS%3A+{Metadata.Name!.Replace(" ", "+", StringComparison.Ordinal)})" : String.Empty); /// @@ -321,7 +325,7 @@ namespace Tgstation.Server.Host.Components.Deployment.Remote Logger.LogTrace("Updating deployment {gitHubDeploymentId} to {deploymentState}...", compileJob.GitHubDeploymentId.Value, deploymentState); - string gitHubAccessToken = null; + string? gitHubAccessToken = null; await databaseContextFactory.UseContext( async databaseContext => gitHubAccessToken = await databaseContext From a48000711fd8820096eea49445b4e5421955d450 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Fri, 22 Dec 2023 09:36:40 -0500 Subject: [PATCH 312/425] Nullify `GitLabRemoteDeploymentManager` --- .../Deployment/Remote/GitLabRemoteDeploymentManager.cs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Deployment/Remote/GitLabRemoteDeploymentManager.cs b/src/Tgstation.Server.Host/Components/Deployment/Remote/GitLabRemoteDeploymentManager.cs index 0190d0c993..9d0adeaf37 100644 --- a/src/Tgstation.Server.Host/Components/Deployment/Remote/GitLabRemoteDeploymentManager.cs +++ b/src/Tgstation.Server.Host/Components/Deployment/Remote/GitLabRemoteDeploymentManager.cs @@ -14,8 +14,6 @@ using Microsoft.Extensions.Logging; using Tgstation.Server.Host.Components.Repository; using Tgstation.Server.Host.Models; -#nullable disable - namespace Tgstation.Server.Host.Components.Deployment.Remote { /// @@ -48,7 +46,7 @@ namespace Tgstation.Server.Host.Components.Deployment.Remote ArgumentNullException.ThrowIfNull(repositorySettings); ArgumentNullException.ThrowIfNull(revisionInformation); - if (revisionInformation.ActiveTestMerges?.Any() != true) + if ((revisionInformation.ActiveTestMerges?.Count > 0) != true) { Logger.LogTrace("No test merges to remove."); return Array.Empty(); @@ -77,7 +75,7 @@ namespace Tgstation.Server.Host.Components.Deployment.Remote var newList = revisionInformation.ActiveTestMerges.Select(x => x.TestMerge).ToList(); - MergeRequest lastMerged = null; + MergeRequest? lastMerged = null; async ValueTask CheckRemoveMR(Task task) { var mergeRequest = await task; @@ -164,12 +162,12 @@ namespace Tgstation.Server.Host.Components.Deployment.Remote CultureInfo.InvariantCulture, "#### Test Merge {4}{0}{0}##### Server Instance{0}{5}{1}{0}{0}##### Revision{0}Origin: {6}{0}Merge Request: {2}{0}Server: {7}{3}", Environment.NewLine, - repositorySettings.ShowTestMergeCommitters.Value + repositorySettings.ShowTestMergeCommitters!.Value ? String.Format( CultureInfo.InvariantCulture, "{0}{0}##### Merged By{0}{1}", Environment.NewLine, - testMerge.MergedBy.Name) + testMerge.MergedBy!.Name) : String.Empty, testMerge.TargetCommitSha, testMerge.Comment != null From 16e95b375613fbeeb88adceb9dd27a1dd2c60b26 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Fri, 22 Dec 2023 09:37:31 -0500 Subject: [PATCH 313/425] Nullify `IRemoteDeploymentManagerFactory` --- .../Deployment/Remote/IRemoteDeploymentManagerFactory.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Deployment/Remote/IRemoteDeploymentManagerFactory.cs b/src/Tgstation.Server.Host/Components/Deployment/Remote/IRemoteDeploymentManagerFactory.cs index 129d5aa35a..b3dce1f69c 100644 --- a/src/Tgstation.Server.Host/Components/Deployment/Remote/IRemoteDeploymentManagerFactory.cs +++ b/src/Tgstation.Server.Host/Components/Deployment/Remote/IRemoteDeploymentManagerFactory.cs @@ -2,8 +2,6 @@ using Tgstation.Server.Api.Models; -#nullable disable - namespace Tgstation.Server.Host.Components.Deployment.Remote { /// From b17693d8b34a3b780b76f66d5f34bd965816e17f Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Fri, 22 Dec 2023 09:37:50 -0500 Subject: [PATCH 314/425] Nullify `NoOpRemoteDeploymentManager` --- .../Components/Deployment/Remote/NoOpRemoteDeploymentManager.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Deployment/Remote/NoOpRemoteDeploymentManager.cs b/src/Tgstation.Server.Host/Components/Deployment/Remote/NoOpRemoteDeploymentManager.cs index 250b43bddf..6751f18184 100644 --- a/src/Tgstation.Server.Host/Components/Deployment/Remote/NoOpRemoteDeploymentManager.cs +++ b/src/Tgstation.Server.Host/Components/Deployment/Remote/NoOpRemoteDeploymentManager.cs @@ -10,8 +10,6 @@ using Tgstation.Server.Api.Models.Internal; using Tgstation.Server.Host.Components.Repository; using Tgstation.Server.Host.Models; -#nullable disable - namespace Tgstation.Server.Host.Components.Deployment.Remote { /// From 5be5c4e0ef0ed07581b64be30f636f4df1e65a41 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Fri, 22 Dec 2023 09:38:15 -0500 Subject: [PATCH 315/425] Nullify `RemoteDeploymentManagerFactory` --- .../Deployment/Remote/RemoteDeploymentManagerFactory.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Deployment/Remote/RemoteDeploymentManagerFactory.cs b/src/Tgstation.Server.Host/Components/Deployment/Remote/RemoteDeploymentManagerFactory.cs index d525d3dffe..0fdce864cf 100644 --- a/src/Tgstation.Server.Host/Components/Deployment/Remote/RemoteDeploymentManagerFactory.cs +++ b/src/Tgstation.Server.Host/Components/Deployment/Remote/RemoteDeploymentManagerFactory.cs @@ -9,8 +9,6 @@ using Tgstation.Server.Host.Components.Repository; using Tgstation.Server.Host.Database; using Tgstation.Server.Host.Utils.GitHub; -#nullable disable - namespace Tgstation.Server.Host.Components.Deployment.Remote { /// From fde9e5026803298ccc5c60e1856c3525777c3b9d Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Fri, 22 Dec 2023 09:39:20 -0500 Subject: [PATCH 316/425] Nullify `ILatestCompileJobProvider` --- .../Components/Deployment/ILatestCompileJobProvider.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Deployment/ILatestCompileJobProvider.cs b/src/Tgstation.Server.Host/Components/Deployment/ILatestCompileJobProvider.cs index d60ac9ad31..38a90c8dc6 100644 --- a/src/Tgstation.Server.Host/Components/Deployment/ILatestCompileJobProvider.cs +++ b/src/Tgstation.Server.Host/Components/Deployment/ILatestCompileJobProvider.cs @@ -1,7 +1,5 @@ using Tgstation.Server.Host.Models; -#nullable disable - namespace Tgstation.Server.Host.Components.Deployment { /// From dd971fe56beb4fcfd3b3026a50e1dc55438ee369 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Fri, 22 Dec 2023 09:39:59 -0500 Subject: [PATCH 317/425] Nullify `ICompileJobSink` --- .../Components/Deployment/ICompileJobSink.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Deployment/ICompileJobSink.cs b/src/Tgstation.Server.Host/Components/Deployment/ICompileJobSink.cs index 90a0f1596c..cf18fc0412 100644 --- a/src/Tgstation.Server.Host/Components/Deployment/ICompileJobSink.cs +++ b/src/Tgstation.Server.Host/Components/Deployment/ICompileJobSink.cs @@ -4,8 +4,6 @@ using System.Threading.Tasks; using Tgstation.Server.Host.Models; -#nullable disable - namespace Tgstation.Server.Host.Components.Deployment { /// @@ -17,9 +15,9 @@ namespace Tgstation.Server.Host.Components.Deployment /// Load a new into the . /// /// The to load. - /// An to be called when the becomes active or is discarded with or respectively. + /// An optional to be called when the becomes active or is discarded with or respectively. /// The for the operation. /// A representing the running operation. - ValueTask LoadCompileJob(CompileJob job, Action activationAction, CancellationToken cancellationToken); + ValueTask LoadCompileJob(CompileJob job, Action? activationAction, CancellationToken cancellationToken); } } From fb6704937f567f3c9629e07a787bd0afa4e3755f Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Fri, 22 Dec 2023 09:40:24 -0500 Subject: [PATCH 318/425] Nullify `IDmbProvider` --- src/Tgstation.Server.Host/Components/Deployment/IDmbProvider.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Deployment/IDmbProvider.cs b/src/Tgstation.Server.Host/Components/Deployment/IDmbProvider.cs index 20ef72dd33..820796c318 100644 --- a/src/Tgstation.Server.Host/Components/Deployment/IDmbProvider.cs +++ b/src/Tgstation.Server.Host/Components/Deployment/IDmbProvider.cs @@ -2,8 +2,6 @@ using Tgstation.Server.Api.Models; -#nullable disable - namespace Tgstation.Server.Host.Components.Deployment { /// From 7e15cc1ad29279d7cdaabf8b9cc6393b50a45622 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Fri, 22 Dec 2023 09:40:43 -0500 Subject: [PATCH 319/425] Nullify `IDreamMaker` --- src/Tgstation.Server.Host/Components/Deployment/IDreamMaker.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Deployment/IDreamMaker.cs b/src/Tgstation.Server.Host/Components/Deployment/IDreamMaker.cs index b9e8f4e88a..3244308016 100644 --- a/src/Tgstation.Server.Host/Components/Deployment/IDreamMaker.cs +++ b/src/Tgstation.Server.Host/Components/Deployment/IDreamMaker.cs @@ -5,8 +5,6 @@ using Tgstation.Server.Host.Database; using Tgstation.Server.Host.Jobs; using Tgstation.Server.Host.Models; -#nullable disable - namespace Tgstation.Server.Host.Components.Deployment { /// From d2ee58740ffedc949fb71f937ed8c764dc11d0cd Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Fri, 22 Dec 2023 09:41:06 -0500 Subject: [PATCH 320/425] Nullify `IDmbFactory` --- src/Tgstation.Server.Host/Components/Deployment/IDmbFactory.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Deployment/IDmbFactory.cs b/src/Tgstation.Server.Host/Components/Deployment/IDmbFactory.cs index a6c3173677..6ff04b0a00 100644 --- a/src/Tgstation.Server.Host/Components/Deployment/IDmbFactory.cs +++ b/src/Tgstation.Server.Host/Components/Deployment/IDmbFactory.cs @@ -4,8 +4,6 @@ using System.Threading.Tasks; using Tgstation.Server.Host.Models; -#nullable disable - namespace Tgstation.Server.Host.Components.Deployment { /// From 358e6ca1c83f48c4b594ef251ca113f3a84ffd84 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Fri, 22 Dec 2023 09:42:26 -0500 Subject: [PATCH 321/425] Fix IDE messages in `DmbFactory` --- .../Components/Deployment/DmbFactory.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Deployment/DmbFactory.cs b/src/Tgstation.Server.Host/Components/Deployment/DmbFactory.cs index 3e969409b4..d5dd1f13bd 100644 --- a/src/Tgstation.Server.Host/Components/Deployment/DmbFactory.cs +++ b/src/Tgstation.Server.Host/Components/Deployment/DmbFactory.cs @@ -76,7 +76,7 @@ namespace Tgstation.Server.Host.Components.Deployment /// /// Map of s to locks on them. /// - readonly IDictionary jobLockCounts; + readonly Dictionary jobLockCounts; /// /// resulting in the latest yet to exist. @@ -255,7 +255,7 @@ namespace Tgstation.Server.Host.Components.Deployment if (!EngineVersion.TryParse(compileJob.EngineVersion, out var engineVersion)) { - logger.LogWarning("Error loading compile job, bad engine version: {0}", compileJob.EngineVersion); + logger.LogWarning("Error loading compile job, bad engine version: {engineVersion}", compileJob.EngineVersion); return null; // omae wa mou shinderu } @@ -353,7 +353,7 @@ namespace Tgstation.Server.Host.Components.Deployment List jobUidsToNotErase = null; // find the uids of locked directories - if (jobIdsToSkip.Any()) + if (jobIdsToSkip.Count > 0) { await databaseContextFactory.UseContext(async db => { From 707d69d2e658caaba3272f309649e9e32be2ae04 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Fri, 22 Dec 2023 09:48:24 -0500 Subject: [PATCH 322/425] Nullify `DmbFactory` --- .../Components/Deployment/DmbFactory.cs | 93 ++++++++++--------- .../Components/Deployment/IDmbFactory.cs | 4 +- .../Deployment/ILatestCompileJobProvider.cs | 4 +- .../Components/Instance.cs | 2 +- .../Components/InstanceWrapper.cs | 2 +- 5 files changed, 54 insertions(+), 51 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Deployment/DmbFactory.cs b/src/Tgstation.Server.Host/Components/Deployment/DmbFactory.cs index d5dd1f13bd..aebfcda51a 100644 --- a/src/Tgstation.Server.Host/Components/Deployment/DmbFactory.cs +++ b/src/Tgstation.Server.Host/Components/Deployment/DmbFactory.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; using System.IO; using System.Linq; using System.Threading; @@ -16,8 +17,6 @@ using Tgstation.Server.Host.Database; using Tgstation.Server.Host.IO; using Tgstation.Server.Host.Models; -#nullable disable - namespace Tgstation.Server.Host.Components.Deployment { /// @@ -36,6 +35,7 @@ namespace Tgstation.Server.Host.Components.Deployment } /// + [MemberNotNullWhen(true, nameof(nextDmbProvider))] public bool DmbAvailable => nextDmbProvider != null; /// @@ -91,7 +91,7 @@ namespace Tgstation.Server.Host.Components.Deployment /// /// The latest . /// - IDmbProvider nextDmbProvider; + IDmbProvider? nextDmbProvider; /// /// If the is "started" via . @@ -132,7 +132,7 @@ namespace Tgstation.Server.Host.Components.Deployment public void Dispose() => cleanupCts.Dispose(); // we don't dispose nextDmbProvider here, since it might be the only thing we have /// - public async ValueTask LoadCompileJob(CompileJob job, Action activationAction, CancellationToken cancellationToken) + public async ValueTask LoadCompileJob(CompileJob job, Action? activationAction, CancellationToken cancellationToken) { ArgumentNullException.ThrowIfNull(job); @@ -175,8 +175,8 @@ namespace Tgstation.Server.Host.Components.Deployment throw new ArgumentOutOfRangeException(nameof(lockCount), lockCount, "lockCount must be greater than or equal to 0!"); lock (jobLockCounts) { - var jobId = nextDmbProvider.CompileJob.Id; - var incremented = jobLockCounts[jobId.Value] += lockCount; + var jobId = nextDmbProvider.CompileJob.Require(x => x.Id); + var incremented = jobLockCounts[jobId] += lockCount; logger.LogTrace("Compile job {jobId} lock count now: {lockCount}", jobId, incremented); return nextDmbProvider; } @@ -185,16 +185,15 @@ namespace Tgstation.Server.Host.Components.Deployment /// public async Task StartAsync(CancellationToken cancellationToken) { - CompileJob cj = null; - await databaseContextFactory.UseContext(async (db) => - { - cj = await db - .CompileJobs - .AsQueryable() - .Where(x => x.Job.Instance.Id == metadata.Id) - .OrderByDescending(x => x.Job.StoppedAt) - .FirstOrDefaultAsync(cancellationToken); - }); + CompileJob? cj = null; + await databaseContextFactory.UseContext( + async (db) => + cj = await db + .CompileJobs + .AsQueryable() + .Where(x => x.Job.Instance!.Id == metadata.Id) + .OrderByDescending(x => x.Job.StoppedAt) + .FirstOrDefaultAsync(cancellationToken)); try { @@ -229,28 +228,29 @@ namespace Tgstation.Server.Host.Components.Deployment /// #pragma warning disable CA1506 // TODO: Decomplexify - public async ValueTask FromCompileJob(CompileJob compileJob, CancellationToken cancellationToken) + public async ValueTask FromCompileJob(CompileJob compileJob, CancellationToken cancellationToken) { ArgumentNullException.ThrowIfNull(compileJob); // ensure we have the entire metadata tree - logger.LogTrace("Loading compile job {id}...", compileJob.Id); + var compileJobId = compileJob.Require(x => x.Id); + logger.LogTrace("Loading compile job {id}...", compileJobId); await databaseContextFactory.UseContext( async db => compileJob = await db .CompileJobs .AsQueryable() - .Where(x => x.Id == compileJob.Id) - .Include(x => x.Job) + .Where(x => x!.Id == compileJobId) + .Include(x => x.Job!) .ThenInclude(x => x.StartedBy) - .Include(x => x.Job) + .Include(x => x.Job!) .ThenInclude(x => x.Instance) - .Include(x => x.RevisionInformation) - .ThenInclude(x => x.PrimaryTestMerge) - .ThenInclude(x => x.MergedBy) - .Include(x => x.RevisionInformation) - .ThenInclude(x => x.ActiveTestMerges) - .ThenInclude(x => x.TestMerge) - .ThenInclude(x => x.MergedBy) + .Include(x => x.RevisionInformation!) + .ThenInclude(x => x.PrimaryTestMerge!) + .ThenInclude(x => x.MergedBy) + .Include(x => x.RevisionInformation!) + .ThenInclude(x => x.ActiveTestMerges!) + .ThenInclude(x => x.TestMerge!) + .ThenInclude(x => x.MergedBy) .FirstAsync(cancellationToken)); // can't wait to see that query if (!EngineVersion.TryParse(compileJob.EngineVersion, out var engineVersion)) @@ -318,17 +318,17 @@ namespace Tgstation.Server.Host.Components.Deployment lock (jobLockCounts) { - if (!jobLockCounts.TryGetValue(compileJob.Id.Value, out int value)) + if (!jobLockCounts.TryGetValue(compileJobId, out int value)) { value = 1; - jobLockCounts.Add(compileJob.Id.Value, 1); + jobLockCounts.Add(compileJobId, 1); } else - jobLockCounts[compileJob.Id.Value] = ++value; + jobLockCounts[compileJobId] = ++value; providerSubmitted = true; - logger.LogTrace("Compile job {id} lock count now: {lockCount}", compileJob.Id, value); + logger.LogTrace("Compile job {id} lock count now: {lockCount}", compileJobId, value); return newProvider; } } @@ -350,7 +350,7 @@ namespace Tgstation.Server.Host.Components.Deployment lock (jobLockCounts) jobIdsToSkip = jobLockCounts.Keys.ToList(); - List jobUidsToNotErase = null; + List? jobUidsToNotErase = null; // find the uids of locked directories if (jobIdsToSkip.Count > 0) @@ -361,9 +361,9 @@ namespace Tgstation.Server.Host.Components.Deployment .CompileJobs .AsQueryable() .Where( - x => x.Job.Instance.Id == metadata.Id - && jobIdsToSkip.Contains(x.Id.Value)) - .Select(x => x.DirectoryName.Value) + x => x.Job.Instance!.Id == metadata.Id + && jobIdsToSkip.Contains(x.Id!.Value)) + .Select(x => x.DirectoryName!.Value) .ToListAsync(cancellationToken)) .Select(x => x.ToString()) .ToList(); @@ -372,7 +372,7 @@ namespace Tgstation.Server.Host.Components.Deployment else jobUidsToNotErase = new List(); - jobUidsToNotErase.Add(SwappableDmbProvider.LiveGameDirectory); + jobUidsToNotErase!.Add(SwappableDmbProvider.LiveGameDirectory); logger.LogTrace("We will not clean the following directories: {directoriesToNotClean}", String.Join(", ", jobUidsToNotErase)); @@ -407,7 +407,7 @@ namespace Tgstation.Server.Host.Components.Deployment #pragma warning restore CA1506 /// - public CompileJob LatestCompileJob() + public CompileJob? LatestCompileJob() { if (!DmbAvailable) return null; @@ -428,7 +428,7 @@ namespace Tgstation.Server.Host.Components.Deployment // DCT: None available var deploymentJob = remoteDeploymentManager.MarkInactive(job, CancellationToken.None); - var deleteTask = DeleteCompileJobContent(job.DirectoryName.ToString(), cleanupCts.Token); + var deleteTask = DeleteCompileJobContent(job.DirectoryName!.Value.ToString(), cleanupCts.Token); var otherTask = cleanupTask; async Task WrapThrowableTasks() @@ -447,20 +447,23 @@ namespace Tgstation.Server.Host.Components.Deployment } lock (jobLockCounts) - if (jobLockCounts.TryGetValue(job.Id.Value, out var currentVal)) + { + var jobId = job.Require(x => x.Id); + if (jobLockCounts.TryGetValue(jobId, out var currentVal)) if (currentVal == 1) { - jobLockCounts.Remove(job.Id.Value); - logger.LogDebug("Cleaning lock-free compile job {id} => {dirName}", job.Id, job.DirectoryName); + jobLockCounts.Remove(jobId); + logger.LogDebug("Cleaning lock-free compile job {id} => {dirName}", jobId, job.DirectoryName); cleanupTask = HandleCleanup(); } else { - var decremented = --jobLockCounts[job.Id.Value]; - logger.LogTrace("Compile job {id} lock count now: {lockCount}", job.Id, decremented); + var decremented = --jobLockCounts[jobId]; + logger.LogTrace("Compile job {id} lock count now: {lockCount}", jobId, decremented); } else - logger.LogError("Extra Dispose of DmbProvider for CompileJob {compileJobId}!", job.Id); + logger.LogError("Extra Dispose of DmbProvider for CompileJob {compileJobId}!", jobId); + } } /// diff --git a/src/Tgstation.Server.Host/Components/Deployment/IDmbFactory.cs b/src/Tgstation.Server.Host/Components/Deployment/IDmbFactory.cs index 6ff04b0a00..08d1a782b5 100644 --- a/src/Tgstation.Server.Host/Components/Deployment/IDmbFactory.cs +++ b/src/Tgstation.Server.Host/Components/Deployment/IDmbFactory.cs @@ -23,7 +23,7 @@ namespace Tgstation.Server.Host.Components.Deployment bool DmbAvailable { get; } /// - /// Gets the next . + /// Gets the next . is a precondition. /// /// The amount of locks to give the resulting . It's must be called this many times to properly clean the job. /// A new . @@ -35,7 +35,7 @@ namespace Tgstation.Server.Host.Components.Deployment /// The to make the for. /// The for the operation. /// A resulting in a new representing the on success, on failure. - ValueTask FromCompileJob(CompileJob compileJob, CancellationToken cancellationToken); + ValueTask FromCompileJob(CompileJob compileJob, CancellationToken cancellationToken); /// /// Deletes all compile jobs that are inactive in the Game folder. diff --git a/src/Tgstation.Server.Host/Components/Deployment/ILatestCompileJobProvider.cs b/src/Tgstation.Server.Host/Components/Deployment/ILatestCompileJobProvider.cs index 38a90c8dc6..021f62602d 100644 --- a/src/Tgstation.Server.Host/Components/Deployment/ILatestCompileJobProvider.cs +++ b/src/Tgstation.Server.Host/Components/Deployment/ILatestCompileJobProvider.cs @@ -10,7 +10,7 @@ namespace Tgstation.Server.Host.Components.Deployment /// /// Gets the latest . /// - /// The latest . - CompileJob LatestCompileJob(); + /// The latest or if none are available. + CompileJob? LatestCompileJob(); } } diff --git a/src/Tgstation.Server.Host/Components/Instance.cs b/src/Tgstation.Server.Host/Components/Instance.cs index 9e6b2de4a5..38932c5277 100644 --- a/src/Tgstation.Server.Host/Components/Instance.cs +++ b/src/Tgstation.Server.Host/Components/Instance.cs @@ -253,7 +253,7 @@ namespace Tgstation.Server.Host.Components } /// - public CompileJob LatestCompileJob() => dmbFactory.LatestCompileJob(); + public CompileJob? LatestCompileJob() => dmbFactory.LatestCompileJob(); /// /// The for updating the repository. diff --git a/src/Tgstation.Server.Host/Components/InstanceWrapper.cs b/src/Tgstation.Server.Host/Components/InstanceWrapper.cs index 5c525d9869..ba2c84d688 100644 --- a/src/Tgstation.Server.Host/Components/InstanceWrapper.cs +++ b/src/Tgstation.Server.Host/Components/InstanceWrapper.cs @@ -58,6 +58,6 @@ namespace Tgstation.Server.Host.Components public ValueTask SetAutoUpdateInterval(uint newInterval) => Instance.SetAutoUpdateInterval(newInterval); /// - public CompileJob LatestCompileJob() => Instance.LatestCompileJob(); + public CompileJob? LatestCompileJob() => Instance.LatestCompileJob(); } } From 083f7ca85ec7cc0d9dcd5faf355c46026456eabb Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Fri, 22 Dec 2023 09:53:15 -0500 Subject: [PATCH 323/425] Nullify `DmbProvider` --- .../Components/Deployment/DmbFactory.cs | 5 ++++- .../Components/Deployment/DmbProvider.cs | 8 +++----- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Deployment/DmbFactory.cs b/src/Tgstation.Server.Host/Components/Deployment/DmbFactory.cs index aebfcda51a..0c5c43d31e 100644 --- a/src/Tgstation.Server.Host/Components/Deployment/DmbFactory.cs +++ b/src/Tgstation.Server.Host/Components/Deployment/DmbFactory.cs @@ -253,11 +253,14 @@ namespace Tgstation.Server.Host.Components.Deployment .ThenInclude(x => x.MergedBy) .FirstAsync(cancellationToken)); // can't wait to see that query - if (!EngineVersion.TryParse(compileJob.EngineVersion, out var engineVersion)) + EngineVersion engineVersion; + if (!EngineVersion.TryParse(compileJob.EngineVersion, out var engineVersionNullable)) { logger.LogWarning("Error loading compile job, bad engine version: {engineVersion}", compileJob.EngineVersion); return null; // omae wa mou shinderu } + else + engineVersion = engineVersionNullable!; if (!compileJob.Job.StoppedAt.HasValue) { diff --git a/src/Tgstation.Server.Host/Components/Deployment/DmbProvider.cs b/src/Tgstation.Server.Host/Components/Deployment/DmbProvider.cs index 359fc615e2..4a21e4e8d2 100644 --- a/src/Tgstation.Server.Host/Components/Deployment/DmbProvider.cs +++ b/src/Tgstation.Server.Host/Components/Deployment/DmbProvider.cs @@ -5,15 +5,13 @@ using Tgstation.Server.Api.Models; using Tgstation.Server.Api.Models.Internal; using Tgstation.Server.Host.IO; -#nullable disable - namespace Tgstation.Server.Host.Components.Deployment { /// sealed class DmbProvider : DmbProviderBase, IDmbProvider { /// - public override string Directory => ioManager.ResolvePath(CompileJob.DirectoryName.ToString() + directoryAppend); + public override string Directory => ioManager.ResolvePath(CompileJob.DirectoryName!.Value.ToString() + directoryAppend); /// public override Models.CompileJob CompileJob { get; } @@ -34,7 +32,7 @@ namespace Tgstation.Server.Host.Components.Deployment /// /// The to run when is called. /// - Action onDispose; + Action? onDispose; /// /// Initializes a new instance of the class. @@ -44,7 +42,7 @@ namespace Tgstation.Server.Host.Components.Deployment /// The value of . /// The value of . /// The optional value of . - public DmbProvider(Models.CompileJob compileJob, EngineVersion engineVersion, IIOManager ioManager, Action onDispose, string directoryAppend = null) + public DmbProvider(Models.CompileJob compileJob, EngineVersion engineVersion, IIOManager ioManager, Action onDispose, string? directoryAppend = null) { CompileJob = compileJob ?? throw new ArgumentNullException(nameof(compileJob)); EngineVersion = engineVersion ?? throw new ArgumentNullException(nameof(engineVersion)); From dba8721f3ead686f54de8235012a10218ee99c25 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Fri, 22 Dec 2023 09:54:13 -0500 Subject: [PATCH 324/425] Nullify `DmbProviderBase` --- .../Components/Deployment/DmbProviderBase.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Deployment/DmbProviderBase.cs b/src/Tgstation.Server.Host/Components/Deployment/DmbProviderBase.cs index cdc57215ac..5929b74167 100644 --- a/src/Tgstation.Server.Host/Components/Deployment/DmbProviderBase.cs +++ b/src/Tgstation.Server.Host/Components/Deployment/DmbProviderBase.cs @@ -5,8 +5,6 @@ using Tgstation.Server.Api.Models; using Tgstation.Server.Api.Models.Internal; using Tgstation.Server.Host.Models; -#nullable disable - namespace Tgstation.Server.Host.Components.Deployment { /// @@ -15,11 +13,11 @@ namespace Tgstation.Server.Host.Components.Deployment /// public string DmbName => String.Concat( CompileJob.DmeName, - EngineVersion.Engine.Value switch + EngineVersion.Engine switch { EngineType.Byond => ".dmb", EngineType.OpenDream => ".json", - _ => throw new InvalidOperationException($"Invalid EngineType: {EngineVersion.Engine.Value}"), + _ => throw new InvalidOperationException($"Invalid EngineType: {EngineVersion.Engine}"), }); /// From 7db53b03712c59db6e5c3a434d98eae91cbb514e Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Fri, 22 Dec 2023 10:04:14 -0500 Subject: [PATCH 325/425] Nullify `DreamMaker` --- .../Components/Chat/ChatManager.cs | 6 +- .../Components/Chat/IChatManager.cs | 2 +- .../Chat/Providers/DiscordProvider.cs | 2 +- .../Components/Chat/Providers/IProvider.cs | 2 +- .../Components/Chat/Providers/IrcProvider.cs | 2 +- .../Components/Chat/Providers/Provider.cs | 2 +- .../Components/Deployment/DreamMaker.cs | 93 +++++++++---------- .../Remote/BaseRemoteDeploymentManager.cs | 13 ++- .../Remote/IRemoteDeploymentManager.cs | 8 +- 9 files changed, 67 insertions(+), 63 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Chat/ChatManager.cs b/src/Tgstation.Server.Host/Components/Chat/ChatManager.cs index 3bedb438c8..d53e997b25 100644 --- a/src/Tgstation.Server.Host/Components/Chat/ChatManager.cs +++ b/src/Tgstation.Server.Host/Components/Chat/ChatManager.cs @@ -375,7 +375,7 @@ namespace Tgstation.Server.Host.Components.Chat } /// - public Func> QueueDeploymentMessage( + public Func> QueueDeploymentMessage( Models.RevisionInformation revisionInformation, EngineVersion engineVersion, DateTimeOffset? estimatedCompletionTime, @@ -389,7 +389,7 @@ namespace Tgstation.Server.Host.Components.Chat logger.LogTrace("Sending deployment message for RevisionInformation: {revisionInfoId}", revisionInformation.Id); - var callbacks = new List>>>(); + var callbacks = new List>>>(); var task = Task.WhenAll( wdChannels.Select( @@ -431,7 +431,7 @@ namespace Tgstation.Server.Host.Components.Chat Task callbackTask; Func? finalUpdateAction = null; - async Task CallbackTask(string errorMessage, string dreamMakerOutput) + async Task CallbackTask(string? errorMessage, string dreamMakerOutput) { await task; var callbackResults = await ValueTaskExtensions.WhenAll( diff --git a/src/Tgstation.Server.Host/Components/Chat/IChatManager.cs b/src/Tgstation.Server.Host/Components/Chat/IChatManager.cs index e053f7f1de..8a0aa33fe4 100644 --- a/src/Tgstation.Server.Host/Components/Chat/IChatManager.cs +++ b/src/Tgstation.Server.Host/Components/Chat/IChatManager.cs @@ -67,7 +67,7 @@ namespace Tgstation.Server.Host.Components.Chat /// The repository GitHub name, if any. /// if the local deployment commit was pushed to the remote repository. /// A to call to update the message at the deployment's conclusion. Parameters: Error message if any, DreamMaker output if any. Returns an to call to mark the deployment as active/inactive. Parameter: If the deployment is being activated or inactivated. - Func> QueueDeploymentMessage( + Func> QueueDeploymentMessage( Models.RevisionInformation revisionInformation, Api.Models.EngineVersion engineVersion, DateTimeOffset? estimatedCompletionTime, diff --git a/src/Tgstation.Server.Host/Components/Chat/Providers/DiscordProvider.cs b/src/Tgstation.Server.Host/Components/Chat/Providers/DiscordProvider.cs index 6d06322dfc..047febbe00 100644 --- a/src/Tgstation.Server.Host/Components/Chat/Providers/DiscordProvider.cs +++ b/src/Tgstation.Server.Host/Components/Chat/Providers/DiscordProvider.cs @@ -285,7 +285,7 @@ namespace Tgstation.Server.Host.Components.Chat.Providers } /// - public override async ValueTask>>> SendUpdateMessage( + public override async ValueTask>>> SendUpdateMessage( Models.RevisionInformation revisionInformation, EngineVersion engineVersion, DateTimeOffset? estimatedCompletionTime, diff --git a/src/Tgstation.Server.Host/Components/Chat/Providers/IProvider.cs b/src/Tgstation.Server.Host/Components/Chat/Providers/IProvider.cs index 01b0d29a5e..845892d9e0 100644 --- a/src/Tgstation.Server.Host/Components/Chat/Providers/IProvider.cs +++ b/src/Tgstation.Server.Host/Components/Chat/Providers/IProvider.cs @@ -92,7 +92,7 @@ namespace Tgstation.Server.Host.Components.Chat.Providers /// if the local deployment commit was pushed to the remote repository. /// The for the operation. /// A resulting in a to call to update the message at the deployment's conclusion. Parameters: Error message if any, DreamMaker output if any. Returns another callback which should be called to mark the deployment as active. - ValueTask>>> SendUpdateMessage( + ValueTask>>> SendUpdateMessage( Models.RevisionInformation revisionInformation, Api.Models.EngineVersion engineVersion, DateTimeOffset? estimatedCompletionTime, diff --git a/src/Tgstation.Server.Host/Components/Chat/Providers/IrcProvider.cs b/src/Tgstation.Server.Host/Components/Chat/Providers/IrcProvider.cs index f8dfec4197..ad83a80b18 100644 --- a/src/Tgstation.Server.Host/Components/Chat/Providers/IrcProvider.cs +++ b/src/Tgstation.Server.Host/Components/Chat/Providers/IrcProvider.cs @@ -218,7 +218,7 @@ namespace Tgstation.Server.Host.Components.Chat.Providers } /// - public override async ValueTask>>> SendUpdateMessage( + public override async ValueTask>>> SendUpdateMessage( Models.RevisionInformation revisionInformation, EngineVersion engineVersion, DateTimeOffset? estimatedCompletionTime, diff --git a/src/Tgstation.Server.Host/Components/Chat/Providers/Provider.cs b/src/Tgstation.Server.Host/Components/Chat/Providers/Provider.cs index 4123521ad7..6be6b71521 100644 --- a/src/Tgstation.Server.Host/Components/Chat/Providers/Provider.cs +++ b/src/Tgstation.Server.Host/Components/Chat/Providers/Provider.cs @@ -197,7 +197,7 @@ namespace Tgstation.Server.Host.Components.Chat.Providers public abstract ValueTask SendMessage(Message? replyTo, MessageContent message, ulong channelId, CancellationToken cancellationToken); /// - public abstract ValueTask>>> SendUpdateMessage( + public abstract ValueTask>>> SendUpdateMessage( RevisionInformation revisionInformation, Api.Models.EngineVersion engineVersion, DateTimeOffset? estimatedCompletionTime, diff --git a/src/Tgstation.Server.Host/Components/Deployment/DreamMaker.cs b/src/Tgstation.Server.Host/Components/Deployment/DreamMaker.cs index 89f69f7d7b..f72d848082 100644 --- a/src/Tgstation.Server.Host/Components/Deployment/DreamMaker.cs +++ b/src/Tgstation.Server.Host/Components/Deployment/DreamMaker.cs @@ -25,8 +25,6 @@ using Tgstation.Server.Host.Models; using Tgstation.Server.Host.System; using Tgstation.Server.Host.Utils; -#nullable disable - namespace Tgstation.Server.Host.Components.Deployment { /// @@ -115,12 +113,12 @@ namespace Tgstation.Server.Host.Components.Deployment /// /// The active callback from . /// - Func> currentChatCallback; + Func>? currentChatCallback; /// /// Cached for . /// - string currentDreamMakerOutput; + string? currentDreamMakerOutput; /// /// If a compile job is running. @@ -209,18 +207,18 @@ namespace Tgstation.Server.Host.Components.Deployment currentChatCallback = null; currentDreamMakerOutput = null; - Models.CompileJob compileJob = null; + Models.CompileJob? compileJob = null; try { - string repoOwner = null; - string repoName = null; + string? repoOwner = null; + string? repoName = null; TimeSpan? averageSpan = null; - Models.RepositorySettings repositorySettings = null; - Models.DreamDaemonSettings ddSettings = null; - Models.DreamMakerSettings dreamMakerSettings = null; - IRepository repo = null; - IRemoteDeploymentManager remoteDeploymentManager = null; - Models.RevisionInformation revInfo = null; + Models.RepositorySettings? repositorySettings = null; + Models.DreamDaemonSettings? ddSettings = null; + Models.DreamMakerSettings? dreamMakerSettings = null; + IRepository? repo = null; + IRemoteDeploymentManager? remoteDeploymentManager = null; + Models.RevisionInformation? revInfo = null; await databaseContextFactory.UseContext( async databaseContext => { @@ -270,7 +268,7 @@ namespace Tgstation.Server.Host.Components.Deployment throw new JobException(ErrorCode.RepoMissing); remoteDeploymentManager = remoteDeploymentManagerFactory - .CreateRemoteDeploymentManager(metadata, repo.RemoteGitProvider.Value); + .CreateRemoteDeploymentManager(metadata, repo.RemoteGitProvider!.Value); var repoSha = repo.Head; repoOwner = repo.RemoteRepositoryOwner; @@ -278,13 +276,13 @@ namespace Tgstation.Server.Host.Components.Deployment revInfo = await databaseContext .RevisionInformations .AsQueryable() - .Where(x => x.CommitSha == repoSha && x.Instance.Id == metadata.Id) - .Include(x => x.ActiveTestMerges) - .ThenInclude(x => x.TestMerge) - .ThenInclude(x => x.MergedBy) + .Where(x => x.CommitSha == repoSha && x.InstanceId == metadata.Id) + .Include(x => x.ActiveTestMerges!) + .ThenInclude(x => x.TestMerge!) + .ThenInclude(x => x.MergedBy) .FirstOrDefaultAsync(cancellationToken); - if (revInfo == default) + if (revInfo == null) { revInfo = new Models.RevisionInformation { @@ -312,17 +310,17 @@ namespace Tgstation.Server.Host.Components.Deployment }); var likelyPushedTestMergeCommit = - repositorySettings.PushTestMergeCommits.Value + repositorySettings!.PushTestMergeCommits!.Value && repositorySettings.AccessToken != null && repositorySettings.AccessUser != null; using (repo) compileJob = await Compile( job, - revInfo, - dreamMakerSettings, - ddSettings, - repo, - remoteDeploymentManager, + revInfo!, + dreamMakerSettings!, + ddSettings!, + repo!, + remoteDeploymentManager!, progressReporter, averageSpan, likelyPushedTestMergeCommit, @@ -335,11 +333,11 @@ namespace Tgstation.Server.Host.Components.Deployment async databaseContext => { var fullJob = compileJob.Job; - compileJob.Job = new Models.Job(job.Id.Value); + compileJob.Job = new Models.Job(job.Require(x => x.Id)); var fullRevInfo = compileJob.RevisionInformation; compileJob.RevisionInformation = new Models.RevisionInformation { - Id = revInfo.Id, + Id = revInfo!.Id, }; databaseContext.Jobs.Attach(compileJob.Job); @@ -351,7 +349,7 @@ namespace Tgstation.Server.Host.Components.Deployment logger.LogTrace("Created CompileJob {compileJobId}", compileJob.Id); try { - var chatNotificationAction = currentChatCallback(null, compileJob.Output); + var chatNotificationAction = currentChatCallback!(null, compileJob.Output!); await compileJobConsumer.LoadCompileJob(compileJob, chatNotificationAction, cancellationToken); } catch @@ -370,11 +368,11 @@ namespace Tgstation.Server.Host.Components.Deployment } catch (Exception ex) { - await CleanupFailedCompile(compileJob, remoteDeploymentManager, ex); + await CleanupFailedCompile(compileJob, remoteDeploymentManager!, ex); throw; } - var commentsTask = remoteDeploymentManager.PostDeploymentComments( + var commentsTask = remoteDeploymentManager!.PostDeploymentComments( compileJob, activeCompileJob?.RevisionInformation, repositorySettings, @@ -401,7 +399,7 @@ namespace Tgstation.Server.Host.Components.Deployment { currentChatCallback?.Invoke( FormatExceptionForUsers(ex), - currentDreamMakerOutput); + currentDreamMakerOutput!); throw; } @@ -423,13 +421,13 @@ namespace Tgstation.Server.Host.Components.Deployment var previousCompileJobs = await databaseContext .CompileJobs .AsQueryable() - .Where(x => x.Job.Instance.Id == metadata.Id) + .Where(x => x.Job.Instance!.Id == metadata.Id) .OrderByDescending(x => x.Job.StoppedAt) .Take(10) .Select(x => new { - x.Job.StoppedAt, - x.Job.StartedAt, + StoppedAt = x.Job.StoppedAt!.Value, + StartedAt = x.Job.StartedAt!.Value, }) .ToListAsync(cancellationToken); @@ -438,7 +436,7 @@ namespace Tgstation.Server.Host.Components.Deployment { var totalSpan = TimeSpan.Zero; foreach (var previousCompileJob in previousCompileJobs) - totalSpan += previousCompileJob.StoppedAt.Value - previousCompileJob.StartedAt.Value; + totalSpan += previousCompileJob.StoppedAt - previousCompileJob.StartedAt; averageSpan = totalSpan / previousCompileJobs.Count; } @@ -501,7 +499,7 @@ namespace Tgstation.Server.Host.Components.Deployment compileJob, cancellationToken); - logger.LogTrace("Deployment will timeout at {timeoutTime}", DateTimeOffset.UtcNow + dreamMakerSettings.Timeout.Value); + logger.LogTrace("Deployment will timeout at {timeoutTime}", DateTimeOffset.UtcNow + dreamMakerSettings.Timeout!.Value); using var timeoutTokenSource = new CancellationTokenSource(dreamMakerSettings.Timeout.Value); var timeoutToken = timeoutTokenSource.Token; using (timeoutToken.Register(() => logger.LogWarning("Deployment timed out!"))) @@ -563,7 +561,7 @@ namespace Tgstation.Server.Host.Components.Deployment IRemoteDeploymentManager remoteDeploymentManager, CancellationToken cancellationToken) { - var outputDirectory = job.DirectoryName.ToString(); + var outputDirectory = job.DirectoryName!.Value.ToString(); logger.LogTrace("Compile output GUID: {dirGuid}", outputDirectory); try @@ -647,13 +645,13 @@ namespace Tgstation.Server.Host.Components.Deployment progressReporter.StageName = "Validating DMAPI"; await VerifyApi( - launchParameters.StartupTimeout.Value, - dreamMakerSettings.ApiValidationSecurityLevel.Value, + launchParameters.StartupTimeout!.Value, + dreamMakerSettings.ApiValidationSecurityLevel!.Value, job, engineLock, - dreamMakerSettings.ApiValidationPort.Value, - dreamMakerSettings.RequireDMApiValidation.Value, - launchParameters.LogOutput.Value, + dreamMakerSettings.ApiValidationPort!.Value, + dreamMakerSettings.RequireDMApiValidation!.Value, + launchParameters.LogOutput!.Value, cancellationToken); } catch (JobException) @@ -799,7 +797,7 @@ namespace Tgstation.Server.Host.Components.Deployment ApiValidationStatus validationStatus; await using (var provider = new TemporaryDmbProvider( - ioManager.ResolvePath(job.DirectoryName.ToString()), + ioManager.ResolvePath(job.DirectoryName!.Value.ToString()), job, engineLock.Version)) await using (var controller = await sessionControllerFactory.LaunchNew(provider, engineLock, launchParameters, true, cancellationToken)) @@ -859,7 +857,7 @@ namespace Tgstation.Server.Host.Components.Deployment await using var dm = processExecutor.LaunchProcess( engineLock.CompilerExePath, ioManager.ResolvePath( - job.DirectoryName.ToString()), + job.DirectoryName!.Value.ToString()), arguments, readStandardHandles: true, noShellExecute: true); @@ -889,14 +887,15 @@ namespace Tgstation.Server.Host.Components.Deployment async ValueTask ModifyDme(Models.CompileJob job, CancellationToken cancellationToken) { var dmeFileName = String.Join('.', job.DmeName, DmeExtension); - var dmePath = ioManager.ConcatPath(job.DirectoryName.ToString(), dmeFileName); + var stringDirectoryName = job.DirectoryName!.Value.ToString(); + var dmePath = ioManager.ConcatPath(stringDirectoryName, dmeFileName); var dmeReadTask = ioManager.ReadAllBytes(dmePath, cancellationToken); var dmeModificationsTask = configuration.CopyDMFilesTo( dmeFileName, ioManager.ResolvePath( ioManager.ConcatPath( - job.DirectoryName.ToString(), + stringDirectoryName, ioManager.GetDirectoryName(dmeFileName))), cancellationToken); @@ -955,7 +954,7 @@ namespace Tgstation.Server.Host.Components.Deployment async ValueTask CleanDir() { logger.LogTrace("Cleaning compile directory..."); - var jobPath = job.DirectoryName.ToString(); + var jobPath = job.DirectoryName!.Value.ToString(); try { // DCT: None available diff --git a/src/Tgstation.Server.Host/Components/Deployment/Remote/BaseRemoteDeploymentManager.cs b/src/Tgstation.Server.Host/Components/Deployment/Remote/BaseRemoteDeploymentManager.cs index a2aea1401c..0f8c86732f 100644 --- a/src/Tgstation.Server.Host/Components/Deployment/Remote/BaseRemoteDeploymentManager.cs +++ b/src/Tgstation.Server.Host/Components/Deployment/Remote/BaseRemoteDeploymentManager.cs @@ -52,13 +52,18 @@ namespace Tgstation.Server.Host.Components.Deployment.Remote /// public async ValueTask PostDeploymentComments( CompileJob compileJob, - RevisionInformation previousRevisionInformation, + RevisionInformation? previousRevisionInformation, RepositorySettings repositorySettings, - string repoOwner, - string repoName, + string? repoOwner, + string? repoName, CancellationToken cancellationToken) { - if (repositorySettings?.AccessToken == null) + ArgumentNullException.ThrowIfNull(compileJob); + ArgumentNullException.ThrowIfNull(repositorySettings); + ArgumentNullException.ThrowIfNull(repoOwner); + ArgumentNullException.ThrowIfNull(repoName); + + if (repositorySettings.AccessToken == null) return; var deployedRevisionInformation = compileJob.RevisionInformation; diff --git a/src/Tgstation.Server.Host/Components/Deployment/Remote/IRemoteDeploymentManager.cs b/src/Tgstation.Server.Host/Components/Deployment/Remote/IRemoteDeploymentManager.cs index e73f6a1063..d8017a6686 100644 --- a/src/Tgstation.Server.Host/Components/Deployment/Remote/IRemoteDeploymentManager.cs +++ b/src/Tgstation.Server.Host/Components/Deployment/Remote/IRemoteDeploymentManager.cs @@ -66,7 +66,7 @@ namespace Tgstation.Server.Host.Components.Deployment.Remote /// Post deployment comments to the test merge ticket. /// /// The deployed . - /// The of the previous deployment. + /// The optional of the previous deployment. /// The . /// The remote repostiory owner. /// The remote repostiory name. @@ -74,10 +74,10 @@ namespace Tgstation.Server.Host.Components.Deployment.Remote /// A representing the running operation. ValueTask PostDeploymentComments( CompileJob compileJob, - RevisionInformation previousRevisionInformation, + RevisionInformation? previousRevisionInformation, RepositorySettings repositorySettings, - string repoOwner, - string repoName, + string? repoOwner, + string? repoName, CancellationToken cancellationToken); /// From 84294a7069d9004a78500caa8165098faa8db8a9 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Fri, 22 Dec 2023 10:19:53 -0500 Subject: [PATCH 326/425] Nullify `HardLinkDmbProvider` --- .../Components/Deployment/HardLinkDmbProvider.cs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Deployment/HardLinkDmbProvider.cs b/src/Tgstation.Server.Host/Components/Deployment/HardLinkDmbProvider.cs index 99fd9c4bc2..98a8361e34 100644 --- a/src/Tgstation.Server.Host/Components/Deployment/HardLinkDmbProvider.cs +++ b/src/Tgstation.Server.Host/Components/Deployment/HardLinkDmbProvider.cs @@ -15,8 +15,6 @@ using Tgstation.Server.Host.Extensions; using Tgstation.Server.Host.IO; using Tgstation.Server.Host.Utils; -#nullable disable - namespace Tgstation.Server.Host.Components.Deployment { /// @@ -155,7 +153,7 @@ namespace Tgstation.Server.Host.Components.Deployment if (taskThrottle.HasValue && taskThrottle < 1) throw new ArgumentOutOfRangeException(nameof(taskThrottle), taskThrottle, "taskThrottle must be at least 1!"); - var src = IOManager.ResolvePath(CompileJob.DirectoryName.ToString()); + var src = IOManager.ResolvePath(CompileJob.DirectoryName!.Value.ToString()); var dest = IOManager.ResolvePath(mirrorGuid.ToString()); using var semaphore = taskThrottle.HasValue ? new SemaphoreSlim(taskThrottle.Value) : null; @@ -180,10 +178,10 @@ namespace Tgstation.Server.Host.Components.Deployment /// The for the operation. /// A of s representing the running operations. The first returned is always the necessary call to . /// I genuinely don't know how this will work with symlinked files. Waiting for the issue report I guess. - IEnumerable MirrorDirectoryImpl(string src, string dest, SemaphoreSlim semaphore, CancellationToken cancellationToken) + IEnumerable MirrorDirectoryImpl(string src, string dest, SemaphoreSlim? semaphore, CancellationToken cancellationToken) { var dir = new DirectoryInfo(src); - Task subdirCreationTask = null; + Task? subdirCreationTask = null; var dreamDaemonWillAcceptOutOfDirectorySymlinks = CompileJob.MinimumSecurityLevel == DreamDaemonSecurity.Trusted; foreach (var subDirectory in dir.EnumerateDirectories()) { @@ -193,7 +191,8 @@ namespace Tgstation.Server.Host.Components.Deployment if (subDirectory.Attributes.HasFlag(FileAttributes.ReparsePoint)) if (dreamDaemonWillAcceptOutOfDirectorySymlinks) { - var target = subDirectory.ResolveLinkTarget(false); + var target = subDirectory.ResolveLinkTarget(false) + ?? throw new InvalidOperationException($"\"{subDirectory.FullName}\" was incorrectly identified as a symlinked directory!"); logger.LogDebug("Recreating directory {name} as symlink to {target}", subDirectory.Name, target); if (subdirCreationTask == null) { @@ -252,7 +251,9 @@ namespace Tgstation.Server.Host.Components.Deployment if (fileInfo.Attributes.HasFlag(FileAttributes.ReparsePoint)) { // AHHHHHHHHHHHHH - var target = fileInfo.ResolveLinkTarget(!dreamDaemonWillAcceptOutOfDirectorySymlinks); + var target = fileInfo.ResolveLinkTarget(!dreamDaemonWillAcceptOutOfDirectorySymlinks) + ?? throw new InvalidOperationException($"\"{fileInfo.FullName}\" was incorrectly identified as a symlinked file!"); + if (dreamDaemonWillAcceptOutOfDirectorySymlinks) { logger.LogDebug("Recreating symlinked file {name} as symlink to {target}", fileInfo.Name, target.FullName); From 1a4c22987a95e0cafeae1bf4a7b208c8f19c37af Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Fri, 22 Dec 2023 10:20:42 -0500 Subject: [PATCH 327/425] Nullify `SwappableDmbProvider` --- .../Components/Deployment/SwappableDmbProvider.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Deployment/SwappableDmbProvider.cs b/src/Tgstation.Server.Host/Components/Deployment/SwappableDmbProvider.cs index 954fa920be..75c5a1b6bb 100644 --- a/src/Tgstation.Server.Host/Components/Deployment/SwappableDmbProvider.cs +++ b/src/Tgstation.Server.Host/Components/Deployment/SwappableDmbProvider.cs @@ -5,8 +5,6 @@ using System.Threading.Tasks; using Tgstation.Server.Api.Models; using Tgstation.Server.Host.IO; -#nullable disable - namespace Tgstation.Server.Host.Components.Deployment { /// From 5b2ce9e57edccba4ef5690b8beec8f0b87e59b37 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Fri, 22 Dec 2023 10:21:03 -0500 Subject: [PATCH 328/425] Nullify `SymlinkDmbProvider` --- .../Components/Deployment/SymlinkDmbProvider.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Deployment/SymlinkDmbProvider.cs b/src/Tgstation.Server.Host/Components/Deployment/SymlinkDmbProvider.cs index a920641d0d..edb570bcb8 100644 --- a/src/Tgstation.Server.Host/Components/Deployment/SymlinkDmbProvider.cs +++ b/src/Tgstation.Server.Host/Components/Deployment/SymlinkDmbProvider.cs @@ -3,8 +3,6 @@ using System.Threading.Tasks; using Tgstation.Server.Host.IO; -#nullable disable - namespace Tgstation.Server.Host.Components.Deployment { /// From ee88f8d32e89e0efc443e5f63641fd176d1a9cd9 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Fri, 22 Dec 2023 10:21:19 -0500 Subject: [PATCH 329/425] Nullify `TemporaryDmbProvider` --- .../Components/Deployment/TemporaryDmbProvider.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Deployment/TemporaryDmbProvider.cs b/src/Tgstation.Server.Host/Components/Deployment/TemporaryDmbProvider.cs index 38c5067c55..4d528d7ba1 100644 --- a/src/Tgstation.Server.Host/Components/Deployment/TemporaryDmbProvider.cs +++ b/src/Tgstation.Server.Host/Components/Deployment/TemporaryDmbProvider.cs @@ -3,8 +3,6 @@ using System.Threading.Tasks; using Tgstation.Server.Api.Models; -#nullable disable - namespace Tgstation.Server.Host.Components.Deployment { /// From ed5d16d96e0c35686d5a5301b484d5d46e46ab95 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Fri, 22 Dec 2023 15:43:31 -0500 Subject: [PATCH 330/425] Nullify `ByondInstallation` --- .../Components/Engine/ByondInstallation.cs | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Engine/ByondInstallation.cs b/src/Tgstation.Server.Host/Components/Engine/ByondInstallation.cs index b1cc0a9d5d..575d55975c 100644 --- a/src/Tgstation.Server.Host/Components/Engine/ByondInstallation.cs +++ b/src/Tgstation.Server.Host/Components/Engine/ByondInstallation.cs @@ -7,8 +7,6 @@ using Tgstation.Server.Api.Models; using Tgstation.Server.Api.Models.Internal; using Tgstation.Server.Host.Components.Deployment; -#nullable disable - namespace Tgstation.Server.Host.Components.Engine { /// @@ -94,8 +92,8 @@ namespace Tgstation.Server.Host.Components.Engine InstallationTask = installationTask ?? throw new ArgumentNullException(nameof(installationTask)); ArgumentNullException.ThrowIfNull(version); - if (version.Engine.Value != EngineType.Byond) - throw new ArgumentException($"Invalid EngineType: {version.Engine.Value}", nameof(version)); + if (version.Engine != EngineType.Byond) + throw new ArgumentException($"Invalid EngineType: {version.Engine}", nameof(version)); Version = version ?? throw new ArgumentNullException(nameof(version)); ServerExePath = dreamDaemonPath ?? throw new ArgumentNullException(nameof(dreamDaemonPath)); @@ -122,19 +120,19 @@ namespace Tgstation.Server.Host.Components.Engine CultureInfo.InvariantCulture, "{0} -port {1} -ports 1-65535 {2}-close -verbose -{3} -{4}{5}{6}{7} -params \"{8}\"", dmbProvider.DmbName, - launchParameters.Port.Value, - launchParameters.AllowWebClient.Value + launchParameters.Port!.Value, + launchParameters.AllowWebClient!.Value ? "-webclient " : String.Empty, - SecurityWord(launchParameters.SecurityLevel.Value), - VisibilityWord(launchParameters.Visibility.Value), + SecurityWord(launchParameters.SecurityLevel!.Value), + VisibilityWord(launchParameters.Visibility!.Value), logFilePath != null ? $" -logself -log {logFilePath}" : String.Empty, // DD doesn't output anything if -logself is set??? - launchParameters.StartProfiler.Value + launchParameters.StartProfiler!.Value ? " -profile" : String.Empty, - supportsMapThreads && launchParameters.MapThreads.Value != 0 + supportsMapThreads && launchParameters.MapThreads!.Value != 0 ? $" -map-threads {launchParameters.MapThreads.Value}" : String.Empty, parametersString); From 1528a3d28df3ff2b2d2a59aac539cae0b95241ad Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Fri, 22 Dec 2023 15:34:26 -0500 Subject: [PATCH 331/425] Add the `DisposeInvoker` util class Closes #1730 --- .../Components/Chat/ChatTrackingContext.cs | 48 ++++++------------ .../Components/Deployment/DmbFactory.cs | 5 +- .../Components/Deployment/DmbProvider.cs | 7 +-- .../Interop/Bridge/BridgeRegistration.cs | 31 +++--------- .../Components/Repository/Repository.cs | 43 +++++----------- .../Core/RestartRegistration.cs | 14 +++--- src/Tgstation.Server.Host/Server.cs | 14 +++--- .../Utils/DisposeInvoker.cs | 49 +++++++++++++++++++ 8 files changed, 105 insertions(+), 106 deletions(-) create mode 100644 src/Tgstation.Server.Host/Utils/DisposeInvoker.cs diff --git a/src/Tgstation.Server.Host/Components/Chat/ChatTrackingContext.cs b/src/Tgstation.Server.Host/Components/Chat/ChatTrackingContext.cs index 1f3d196bcd..02b6675323 100644 --- a/src/Tgstation.Server.Host/Components/Chat/ChatTrackingContext.cs +++ b/src/Tgstation.Server.Host/Components/Chat/ChatTrackingContext.cs @@ -7,16 +7,17 @@ using System.Threading.Tasks; using Microsoft.Extensions.Logging; using Tgstation.Server.Host.Components.Chat.Commands; +using Tgstation.Server.Host.Utils; namespace Tgstation.Server.Host.Components.Chat { /// - sealed class ChatTrackingContext : IChatTrackingContext + sealed class ChatTrackingContext : DisposeInvoker, IChatTrackingContext { /// public bool Active { - get => active && onDispose != null; + get => active && !IsDisposed; set { if (active == value) @@ -61,25 +62,20 @@ namespace Tgstation.Server.Host.Components.Chat readonly ILogger logger; /// - /// for modifying , , and . + /// for modifying and calling . /// readonly object synchronizationLock; + /// + /// The if any. + /// + volatile IChannelSink? channelSink; + /// /// Backing field for . /// IReadOnlyCollection customCommands; - /// - /// The if any. - /// - IChannelSink? channelSink; - - /// - /// The to run when d. - /// - Action? onDispose; - /// /// Backing field for . /// @@ -91,45 +87,31 @@ namespace Tgstation.Server.Host.Components.Chat /// The value of . /// The initial value of . /// The value of . - /// The value of . + /// The action for the . public ChatTrackingContext( ICustomCommandHandler customCommandHandler, IEnumerable initialChannels, ILogger logger, - Action onDispose) + Action disposeAction) + : base(disposeAction) { this.customCommandHandler = customCommandHandler ?? throw new ArgumentNullException(nameof(customCommandHandler)); Channels = initialChannels?.ToList() ?? throw new ArgumentNullException(nameof(initialChannels)); this.logger = logger ?? throw new ArgumentNullException(nameof(logger)); - this.onDispose = onDispose ?? throw new ArgumentNullException(nameof(onDispose)); synchronizationLock = new object(); Active = true; customCommands = Array.Empty(); } - /// - public void Dispose() - { - lock (synchronizationLock) - { - onDispose?.Invoke(); - onDispose = null; - } - } - /// public void SetChannelSink(IChannelSink channelSink) { ArgumentNullException.ThrowIfNull(channelSink); - lock (synchronizationLock) - { - if (this.channelSink != null) - throw new InvalidOperationException("channelSink already set!"); - - this.channelSink = channelSink; - } + var originalValue = Interlocked.CompareExchange(ref this.channelSink, channelSink, null); + if (originalValue != null) + throw new InvalidOperationException("channelSink already set!"); } /// diff --git a/src/Tgstation.Server.Host/Components/Deployment/DmbFactory.cs b/src/Tgstation.Server.Host/Components/Deployment/DmbFactory.cs index 0c5c43d31e..3b6695313b 100644 --- a/src/Tgstation.Server.Host/Components/Deployment/DmbFactory.cs +++ b/src/Tgstation.Server.Host/Components/Deployment/DmbFactory.cs @@ -16,6 +16,7 @@ using Tgstation.Server.Host.Components.Events; using Tgstation.Server.Host.Database; using Tgstation.Server.Host.IO; using Tgstation.Server.Host.Models; +using Tgstation.Server.Host.Utils; namespace Tgstation.Server.Host.Components.Deployment { @@ -279,7 +280,7 @@ namespace Tgstation.Server.Host.Components.Deployment CleanRegisteredCompileJob(compileJob); } - var newProvider = new DmbProvider(compileJob, engineVersion, ioManager, CleanupAction); + var newProvider = new DmbProvider(compileJob, engineVersion, ioManager, new DisposeInvoker(CleanupAction)); try { const string LegacyADirectoryName = "A"; @@ -316,7 +317,7 @@ namespace Tgstation.Server.Host.Components.Deployment // rebuild the provider because it's using the legacy style directories // Don't dispose it logger.LogDebug("Creating legacy two folder .dmb provider targeting {aDirName} directory...", LegacyADirectoryName); - newProvider = new DmbProvider(compileJob, engineVersion, ioManager, CleanupAction, Path.DirectorySeparatorChar + LegacyADirectoryName); + newProvider = new DmbProvider(compileJob, engineVersion, ioManager, new DisposeInvoker(CleanupAction), Path.DirectorySeparatorChar + LegacyADirectoryName); } lock (jobLockCounts) diff --git a/src/Tgstation.Server.Host/Components/Deployment/DmbProvider.cs b/src/Tgstation.Server.Host/Components/Deployment/DmbProvider.cs index 4a21e4e8d2..be47aeb6b3 100644 --- a/src/Tgstation.Server.Host/Components/Deployment/DmbProvider.cs +++ b/src/Tgstation.Server.Host/Components/Deployment/DmbProvider.cs @@ -4,6 +4,7 @@ using System.Threading.Tasks; using Tgstation.Server.Api.Models; using Tgstation.Server.Api.Models.Internal; using Tgstation.Server.Host.IO; +using Tgstation.Server.Host.Utils; namespace Tgstation.Server.Host.Components.Deployment { @@ -32,7 +33,7 @@ namespace Tgstation.Server.Host.Components.Deployment /// /// The to run when is called. /// - Action? onDispose; + DisposeInvoker? onDispose; /// /// Initializes a new instance of the class. @@ -42,7 +43,7 @@ namespace Tgstation.Server.Host.Components.Deployment /// The value of . /// The value of . /// The optional value of . - public DmbProvider(Models.CompileJob compileJob, EngineVersion engineVersion, IIOManager ioManager, Action onDispose, string? directoryAppend = null) + public DmbProvider(Models.CompileJob compileJob, EngineVersion engineVersion, IIOManager ioManager, DisposeInvoker onDispose, string? directoryAppend = null) { CompileJob = compileJob ?? throw new ArgumentNullException(nameof(compileJob)); EngineVersion = engineVersion ?? throw new ArgumentNullException(nameof(engineVersion)); @@ -54,7 +55,7 @@ namespace Tgstation.Server.Host.Components.Deployment /// public override ValueTask DisposeAsync() { - onDispose?.Invoke(); + onDispose?.Dispose(); return ValueTask.CompletedTask; } diff --git a/src/Tgstation.Server.Host/Components/Interop/Bridge/BridgeRegistration.cs b/src/Tgstation.Server.Host/Components/Interop/Bridge/BridgeRegistration.cs index e209a63aa6..38acfd827d 100644 --- a/src/Tgstation.Server.Host/Components/Interop/Bridge/BridgeRegistration.cs +++ b/src/Tgstation.Server.Host/Components/Interop/Bridge/BridgeRegistration.cs @@ -1,40 +1,21 @@ using System; +using Tgstation.Server.Host.Utils; + #nullable disable namespace Tgstation.Server.Host.Components.Interop.Bridge { /// - sealed class BridgeRegistration : IBridgeRegistration + sealed class BridgeRegistration : DisposeInvoker, IBridgeRegistration { - /// - /// for accessing . - /// - readonly object lockObject; - - /// - /// to run when d. - /// - Action onDispose; - /// /// Initializes a new instance of the class. /// - /// The value of . - public BridgeRegistration(Action onDispose) + /// The action for the . + public BridgeRegistration(Action disposeAction) + : base(disposeAction) { - this.onDispose = onDispose ?? throw new ArgumentNullException(nameof(onDispose)); - lockObject = new object(); - } - - /// - public void Dispose() - { - lock (lockObject) - { - onDispose?.Invoke(); - onDispose = null; - } } } } diff --git a/src/Tgstation.Server.Host/Components/Repository/Repository.cs b/src/Tgstation.Server.Host/Components/Repository/Repository.cs index 6ef027416e..c083dfdde6 100644 --- a/src/Tgstation.Server.Host/Components/Repository/Repository.cs +++ b/src/Tgstation.Server.Host/Components/Repository/Repository.cs @@ -17,6 +17,7 @@ using Tgstation.Server.Host.Configuration; using Tgstation.Server.Host.Extensions; using Tgstation.Server.Host.IO; using Tgstation.Server.Host.Jobs; +using Tgstation.Server.Host.Utils; #nullable disable @@ -24,7 +25,7 @@ namespace Tgstation.Server.Host.Components.Repository { /// #pragma warning disable CA1506 // TODO: Decomplexify - sealed class Repository : IRepository + sealed class Repository : DisposeInvoker, IRepository { /// /// The default username for committers. @@ -117,16 +118,6 @@ namespace Tgstation.Server.Host.Components.Repository /// readonly GeneralConfiguration generalConfiguration; - /// - /// to be taken when is called. - /// - readonly Action onDispose; - - /// - /// If the was disposed. - /// - bool disposed; - /// /// Initializes a new instance of the class. /// @@ -139,7 +130,7 @@ namespace Tgstation.Server.Host.Components.Repository /// The to provide the value of . /// The value of . /// The value of . - /// The value if . + /// The action for the . public Repository( LibGit2Sharp.IRepository libGitRepo, ILibGit2Commands commands, @@ -150,7 +141,8 @@ namespace Tgstation.Server.Host.Components.Repository IGitRemoteFeaturesFactory gitRemoteFeaturesFactory, ILogger logger, GeneralConfiguration generalConfiguration, - Action onDispose) + Action disposeAction) + : base(disposeAction) { this.libGitRepo = libGitRepo ?? throw new ArgumentNullException(nameof(libGitRepo)); this.commands = commands ?? throw new ArgumentNullException(nameof(commands)); @@ -162,27 +154,10 @@ namespace Tgstation.Server.Host.Components.Repository this.logger = logger ?? throw new ArgumentNullException(nameof(logger)); this.generalConfiguration = generalConfiguration ?? throw new ArgumentNullException(nameof(generalConfiguration)); - this.onDispose = onDispose ?? throw new ArgumentNullException(nameof(onDispose)); gitRemoteFeatures = gitRemoteFeaturesFactory.CreateGitRemoteFeatures(this); } - /// - public void Dispose() - { - lock (onDispose) - { - if (disposed) - return; - - disposed = true; - } - - logger.LogTrace("Disposing..."); - libGitRepo.Dispose(); - onDispose(); - } - /// #pragma warning disable CA1506 // TODO: Decomplexify public async ValueTask AddTestMerge( @@ -869,6 +844,14 @@ namespace Tgstation.Server.Host.Components.Repository DefaultIOManager.BlockingTaskCreationOptions, TaskScheduler.Current); + /// + protected override void DisposeImpl() + { + logger.LogTrace("Disposing..."); + libGitRepo.Dispose(); + base.DisposeImpl(); + } + /// /// Runs a blocking force checkout to . /// diff --git a/src/Tgstation.Server.Host/Core/RestartRegistration.cs b/src/Tgstation.Server.Host/Core/RestartRegistration.cs index 8f4ab937d6..2cd24e307d 100644 --- a/src/Tgstation.Server.Host/Core/RestartRegistration.cs +++ b/src/Tgstation.Server.Host/Core/RestartRegistration.cs @@ -1,4 +1,4 @@ -using System; +using Tgstation.Server.Host.Utils; namespace Tgstation.Server.Host.Core { @@ -6,20 +6,20 @@ namespace Tgstation.Server.Host.Core sealed class RestartRegistration : IRestartRegistration { /// - /// The . + /// The . /// - readonly Action? onDispose; + readonly DisposeInvoker? disposeInvoker; /// /// Initializes a new instance of the class. /// - /// The value of . - public RestartRegistration(Action? onDispose) + /// The value of . + public RestartRegistration(DisposeInvoker? disposeInvoker) { - this.onDispose = onDispose; + this.disposeInvoker = disposeInvoker; } /// - public void Dispose() => onDispose?.Invoke(); + public void Dispose() => disposeInvoker?.Dispose(); } } diff --git a/src/Tgstation.Server.Host/Server.cs b/src/Tgstation.Server.Host/Server.cs index b832be6e87..751cd2d453 100644 --- a/src/Tgstation.Server.Host/Server.cs +++ b/src/Tgstation.Server.Host/Server.cs @@ -13,6 +13,7 @@ using Microsoft.Extensions.Options; using Tgstation.Server.Common.Extensions; using Tgstation.Server.Host.Configuration; using Tgstation.Server.Host.Core; +using Tgstation.Server.Host.Utils; namespace Tgstation.Server.Host { @@ -234,12 +235,13 @@ namespace Tgstation.Server.Host { logger.LogTrace("Registering restart handler {handlerImplementationName}...", handler); restartHandlers.Add(handler); - return new RestartRegistration(() => - { - lock (restartLock) - if (!shutdownInProgress) - restartHandlers.Remove(handler); - }); + return new RestartRegistration( + new DisposeInvoker(() => + { + lock (restartLock) + if (!shutdownInProgress) + restartHandlers.Remove(handler); + })); } logger.LogWarning("Restart handler {handlerImplementationName} register after a shutdown had begun!", handler); diff --git a/src/Tgstation.Server.Host/Utils/DisposeInvoker.cs b/src/Tgstation.Server.Host/Utils/DisposeInvoker.cs new file mode 100644 index 0000000000..b90d01318b --- /dev/null +++ b/src/Tgstation.Server.Host/Utils/DisposeInvoker.cs @@ -0,0 +1,49 @@ +using System; +using System.Threading; + +namespace Tgstation.Server.Host.Utils +{ + /// + /// Runs a given on . + /// + class DisposeInvoker : IDisposable + { + /// + /// If was called. + /// + public bool IsDisposed => disposeRan != 0; + + /// + /// The to run on . + /// + readonly Action disposeAction; + + /// + /// An representation of a indicating if has ran. + /// + volatile int disposeRan; + + /// + /// Initializes a new instance of the class. + /// + /// The value of . + public DisposeInvoker(Action disposeAction) + { + this.disposeAction = disposeAction ?? throw new ArgumentNullException(nameof(disposeAction)); + } + + /// + public void Dispose() + { + if (Interlocked.Exchange(ref disposeRan, 1) != 0) + return; + + DisposeImpl(); + } + + /// + /// Implementation of run after reentrancy check. + /// + protected virtual void DisposeImpl() => disposeAction(); + } +} From 594b4fc42a8587eca13cea98e74e3e629cee63db Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Fri, 22 Dec 2023 18:16:55 -0500 Subject: [PATCH 332/425] Nullify `ByondInstallerBase` --- .../Components/Engine/ByondInstallerBase.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Engine/ByondInstallerBase.cs b/src/Tgstation.Server.Host/Components/Engine/ByondInstallerBase.cs index 7aef964b9c..28ac0990bc 100644 --- a/src/Tgstation.Server.Host/Components/Engine/ByondInstallerBase.cs +++ b/src/Tgstation.Server.Host/Components/Engine/ByondInstallerBase.cs @@ -11,8 +11,6 @@ using Tgstation.Server.Host.IO; using Tgstation.Server.Host.Jobs; using Tgstation.Server.Host.Utils; -#nullable disable - namespace Tgstation.Server.Host.Components.Engine { /// @@ -100,7 +98,7 @@ namespace Tgstation.Server.Host.Components.Engine IOManager.ConcatPath( binPathForVersion, GetDreamDaemonName( - version.Version, + version.Version!, out var supportsCli))), IOManager.ResolvePath( IOManager.ConcatPath( @@ -237,7 +235,7 @@ namespace Tgstation.Server.Host.Components.Engine Uri GetDownloadZipUrl(EngineVersion version) { CheckVersionValidity(version); - var url = String.Format(CultureInfo.InvariantCulture, ByondRevisionsUrlTemplate, version.Version.Major, version.Version.Minor); + var url = String.Format(CultureInfo.InvariantCulture, ByondRevisionsUrlTemplate, version.Version!.Major, version.Version.Minor); return new Uri(url); } } From 9ef9bf325ab1885151d4a21b2050410433386c3f Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Fri, 22 Dec 2023 18:17:39 -0500 Subject: [PATCH 333/425] Nullify `DelegatingEngineInstaller` --- .../Components/Engine/DelegatingEngineInstaller.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Engine/DelegatingEngineInstaller.cs b/src/Tgstation.Server.Host/Components/Engine/DelegatingEngineInstaller.cs index c9e859f37d..1c68bf1dc2 100644 --- a/src/Tgstation.Server.Host/Components/Engine/DelegatingEngineInstaller.cs +++ b/src/Tgstation.Server.Host/Components/Engine/DelegatingEngineInstaller.cs @@ -7,8 +7,6 @@ using System.Threading.Tasks; using Tgstation.Server.Api.Models; using Tgstation.Server.Host.Jobs; -#nullable disable - namespace Tgstation.Server.Host.Components.Engine { /// @@ -64,7 +62,7 @@ namespace Tgstation.Server.Host.Components.Engine TReturn DelegateCall(EngineVersion version, Func call) { ArgumentNullException.ThrowIfNull(version); - return call(delegatedInstallers[version.Engine.Value]); + return call(delegatedInstallers[version.Engine!.Value]); } } } From f23d21e7edba36fd61fbf8e5e8e6d0413dda5a1b Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Fri, 22 Dec 2023 18:22:17 -0500 Subject: [PATCH 334/425] Nullify `EngineExecutableLock` --- .../Components/Engine/EngineExecutableLock.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Engine/EngineExecutableLock.cs b/src/Tgstation.Server.Host/Components/Engine/EngineExecutableLock.cs index 36944a876f..af04f89224 100644 --- a/src/Tgstation.Server.Host/Components/Engine/EngineExecutableLock.cs +++ b/src/Tgstation.Server.Host/Components/Engine/EngineExecutableLock.cs @@ -10,8 +10,6 @@ using Tgstation.Server.Host.Components.Deployment; using Tgstation.Server.Host.System; using Tgstation.Server.Host.Utils; -#nullable disable - namespace Tgstation.Server.Host.Components.Engine { /// From dec95b8eb9a533dbcd766307fe87bcffa0f4e91a Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Fri, 22 Dec 2023 18:26:00 -0500 Subject: [PATCH 335/425] Nullify `EngineInstallationBase` --- .../Components/Engine/EngineInstallationBase.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Engine/EngineInstallationBase.cs b/src/Tgstation.Server.Host/Components/Engine/EngineInstallationBase.cs index bbf809ee25..2443860623 100644 --- a/src/Tgstation.Server.Host/Components/Engine/EngineInstallationBase.cs +++ b/src/Tgstation.Server.Host/Components/Engine/EngineInstallationBase.cs @@ -12,8 +12,6 @@ using Tgstation.Server.Api.Models.Internal; using Tgstation.Server.Host.Components.Deployment; using Tgstation.Server.Host.System; -#nullable disable - namespace Tgstation.Server.Host.Components.Engine { /// From b27be9426d5c9bb62db2afae02a4b534440822fe Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Fri, 22 Dec 2023 18:32:33 -0500 Subject: [PATCH 336/425] Nullify `EngineInstallerBase` --- .../Components/Engine/EngineInstallerBase.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Engine/EngineInstallerBase.cs b/src/Tgstation.Server.Host/Components/Engine/EngineInstallerBase.cs index 6e2d5ad3cc..1993c55f1b 100644 --- a/src/Tgstation.Server.Host/Components/Engine/EngineInstallerBase.cs +++ b/src/Tgstation.Server.Host/Components/Engine/EngineInstallerBase.cs @@ -8,8 +8,6 @@ using Tgstation.Server.Api.Models; using Tgstation.Server.Host.IO; using Tgstation.Server.Host.Jobs; -#nullable disable - namespace Tgstation.Server.Host.Components.Engine { /// @@ -66,7 +64,7 @@ namespace Tgstation.Server.Host.Components.Engine protected void CheckVersionValidity(EngineVersion version) { ArgumentNullException.ThrowIfNull(version); - if (version.Engine.Value != TargetEngineType) + if (version.Engine!.Value != TargetEngineType) throw new InvalidOperationException($"Non-{TargetEngineType} engine specified: {version.Engine.Value}"); } } From 05f8278f4a6d8ad7c886cbd4acf68333b82cc1af Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Fri, 22 Dec 2023 19:40:58 -0500 Subject: [PATCH 337/425] Nullify `EngineManager` and `IEngineManager` Fix a potential `NullReferenceException` with no `JobProgressReporter` --- .../Components/Chat/Commands/EngineCommand.cs | 2 +- .../Components/Engine/EngineManager.cs | 47 +++++++++++-------- .../Components/Engine/IEngineManager.cs | 12 ++--- .../Components/Events/EventConsumer.cs | 2 +- .../Components/Events/IEventConsumer.cs | 2 +- .../Components/Events/NoopEventConsumer.cs | 2 +- .../Components/StaticFiles/Configuration.cs | 5 +- .../Controllers/EngineController.cs | 4 +- 8 files changed, 42 insertions(+), 34 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Chat/Commands/EngineCommand.cs b/src/Tgstation.Server.Host/Components/Chat/Commands/EngineCommand.cs index 21789bb258..c0bf80ea59 100644 --- a/src/Tgstation.Server.Host/Components/Chat/Commands/EngineCommand.cs +++ b/src/Tgstation.Server.Host/Components/Chat/Commands/EngineCommand.cs @@ -48,7 +48,7 @@ namespace Tgstation.Server.Host.Components.Chat.Commands /// public ValueTask Invoke(string arguments, ChatUser user, CancellationToken cancellationToken) { - EngineVersion engineVersion; + EngineVersion? engineVersion; if (arguments.Split(' ').Any(x => x.Equals("--active", StringComparison.OrdinalIgnoreCase))) engineVersion = engineManager.ActiveVersion; else diff --git a/src/Tgstation.Server.Host/Components/Engine/EngineManager.cs b/src/Tgstation.Server.Host/Components/Engine/EngineManager.cs index ab76763167..529eec0fb8 100644 --- a/src/Tgstation.Server.Host/Components/Engine/EngineManager.cs +++ b/src/Tgstation.Server.Host/Components/Engine/EngineManager.cs @@ -16,8 +16,6 @@ using Tgstation.Server.Host.IO; using Tgstation.Server.Host.Jobs; using Tgstation.Server.Host.Utils; -#nullable disable - namespace Tgstation.Server.Host.Components.Engine { /// @@ -34,7 +32,7 @@ namespace Tgstation.Server.Host.Components.Engine const string ActiveVersionFileName = "ActiveVersion.txt"; /// - public EngineVersion ActiveVersion { get; private set; } + public EngineVersion? ActiveVersion { get; private set; } /// public IReadOnlyList InstalledVersions @@ -120,9 +118,9 @@ namespace Tgstation.Server.Host.Components.Engine /// public async ValueTask ChangeVersion( - JobProgressReporter progressReporter, + JobProgressReporter? progressReporter, EngineVersion version, - Stream customVersionStream, + Stream? customVersionStream, bool allowInstallation, CancellationToken cancellationToken) { @@ -145,7 +143,7 @@ namespace Tgstation.Server.Host.Components.Engine await ioManager.WriteAllBytes(ActiveVersionFileName, Encoding.UTF8.GetBytes(stringVersion), cancellationToken); await eventConsumer.HandleEvent( EventType.EngineActiveVersionChange, - new List + new List { ActiveVersion?.ToString(), stringVersion, @@ -162,7 +160,7 @@ namespace Tgstation.Server.Host.Components.Engine } /// - public async ValueTask UseExecutables(EngineVersion requiredVersion, string trustDmbFullPath, CancellationToken cancellationToken) + public async ValueTask UseExecutables(EngineVersion? requiredVersion, string? trustDmbFullPath, CancellationToken cancellationToken) { logger.LogTrace( "Acquiring lock on BYOND version {version}...", @@ -198,19 +196,21 @@ namespace Tgstation.Server.Host.Components.Engine logger.LogTrace("DeleteVersion {version}", version); - if (version.Equals(ActiveVersion)) + var activeVersion = ActiveVersion; + if (activeVersion != null && version.Equals(activeVersion)) throw new JobException(ErrorCode.EngineCannotDeleteActiveVersion); ReferenceCountingContainer container; logger.LogTrace("Waiting to acquire installedVersions lock..."); lock (installedVersions) { - if (!installedVersions.TryGetValue(version, out container)) + if (!installedVersions.TryGetValue(version, out var containerNullable)) { logger.LogTrace("Version {version} already deleted.", version); return; } + container = containerNullable; logger.LogTrace("Installation container acquired for deletion"); } @@ -238,7 +238,8 @@ namespace Tgstation.Server.Host.Components.Engine using (await SemaphoreSlimContext.Lock(changeDeleteSemaphore, cancellationToken)) { // check again because it could have become the active version. - if (version.Equals(ActiveVersion)) + activeVersion = ActiveVersion; + if (activeVersion != null && version.Equals(activeVersion)) throw new JobException(ErrorCode.EngineCannotDeleteActiveVersion); bool proceed; @@ -296,7 +297,7 @@ namespace Tgstation.Server.Host.Components.Engine /// public async Task StartAsync(CancellationToken cancellationToken) { - async ValueTask GetActiveVersion() + async ValueTask GetActiveVersion() { var activeVersionFileExists = await ioManager.FileExists(ActiveVersionFileName, cancellationToken); return !activeVersionFileExists ? null : await ioManager.ReadAllBytes(ActiveVersionFileName, cancellationToken); @@ -321,12 +322,15 @@ namespace Tgstation.Server.Host.Components.Engine var bytes = await ioManager.ReadAllBytes(versionFile, cancellationToken); var text = Encoding.UTF8.GetString(bytes); - if (!EngineVersion.TryParse(text, out var version)) + EngineVersion version; + if (!EngineVersion.TryParse(text, out var versionNullable)) { logger.LogWarning("Cleaning path with unparsable version file: {versionPath}", ioManager.ResolvePath(path)); await ioManager.DeleteDirectory(path, cancellationToken); // cleanup return; } + else + version = versionNullable!; try { @@ -362,11 +366,11 @@ namespace Tgstation.Server.Host.Components.Engine { var activeVersionString = Encoding.UTF8.GetString(activeVersionBytes); - EngineVersion activeVersion; + EngineVersion? activeVersion; bool hasRequestedActiveVersion; lock (installedVersions) hasRequestedActiveVersion = EngineVersion.TryParse(activeVersionString, out activeVersion) - && installedVersions.ContainsKey(activeVersion); + && installedVersions.ContainsKey(activeVersion!); if (hasRequestedActiveVersion) ActiveVersion = activeVersion; // not setting TCS because there's no need during init @@ -386,15 +390,15 @@ namespace Tgstation.Server.Host.Components.Engine /// /// The optional for the operation. /// The to install. - /// Custom zip file to use. Will cause a number to be added. + /// Optional custom zip file to use. Will cause a number to be added. /// If this BYOND version is required as part of a locking operation. /// If an installation should be performed if the is not installed. If and an installation is required an will be thrown. /// The for the operation. /// A resulting in the . async ValueTask AssertAndLockVersion( - JobProgressReporter progressReporter, + JobProgressReporter? progressReporter, EngineVersion version, - Stream customVersionStream, + Stream? customVersionStream, bool neededForLock, bool allowInstallation, CancellationToken cancellationToken) @@ -415,7 +419,8 @@ namespace Tgstation.Server.Host.Components.Engine while (installedVersions.ContainsKey(version)); } - installedOrInstalling = installedVersions.TryGetValue(version, out var installationContainer); + installedOrInstalling = installedVersions.TryGetValue(version, out var installationContainerNullable); + ReferenceCountingContainer installationContainer; if (!installedOrInstalling) { if (!allowInstallation) @@ -426,6 +431,8 @@ namespace Tgstation.Server.Host.Components.Engine ioManager.ResolvePath(version.ToString()), ourTcs.Task); } + else + installationContainer = installationContainerNullable!; installation = installationContainer.Instance; installLock = installationContainer.AddReference(); @@ -499,7 +506,7 @@ namespace Tgstation.Server.Host.Components.Engine /// Custom zip file to use. Will cause a number to be added. /// The for the operation. /// A representing the running operation. - async ValueTask InstallVersionFiles(JobProgressReporter progressReporter, EngineVersion version, Stream customVersionStream, CancellationToken cancellationToken) + async ValueTask InstallVersionFiles(JobProgressReporter? progressReporter, EngineVersion version, Stream? customVersionStream, CancellationToken cancellationToken) { var installFullPath = ioManager.ResolvePath(version.ToString()); async ValueTask DirectoryCleanup() @@ -519,7 +526,7 @@ namespace Tgstation.Server.Host.Components.Engine engineInstallationData = await engineInstaller.DownloadVersion(version, progressReporter, cancellationToken); - progressReporter.ReportProgress(null); + progressReporter?.ReportProgress(null); } else #pragma warning disable CA2000 // Dispose objects before losing scope, false positive diff --git a/src/Tgstation.Server.Host/Components/Engine/IEngineManager.cs b/src/Tgstation.Server.Host/Components/Engine/IEngineManager.cs index d53d77c53a..18af1469e6 100644 --- a/src/Tgstation.Server.Host/Components/Engine/IEngineManager.cs +++ b/src/Tgstation.Server.Host/Components/Engine/IEngineManager.cs @@ -7,8 +7,6 @@ using System.Threading.Tasks; using Tgstation.Server.Api.Models; using Tgstation.Server.Host.Jobs; -#nullable disable - namespace Tgstation.Server.Host.Components.Engine { /// @@ -20,7 +18,7 @@ namespace Tgstation.Server.Host.Components.Engine /// /// The currently active . /// - EngineVersion ActiveVersion { get; } + EngineVersion? ActiveVersion { get; } /// /// The installed s. @@ -37,9 +35,9 @@ namespace Tgstation.Server.Host.Components.Engine /// The for the operation. /// A representing the running operation. ValueTask ChangeVersion( - JobProgressReporter progressReporter, + JobProgressReporter? progressReporter, EngineVersion version, - Stream customVersionStream, + Stream? customVersionStream, bool allowInstallation, CancellationToken cancellationToken); @@ -60,8 +58,8 @@ namespace Tgstation.Server.Host.Components.Engine /// The for the operation. /// A resulting in the requested . ValueTask UseExecutables( - EngineVersion requiredVersion, - string trustDmbFullPath, + EngineVersion? requiredVersion, + string? trustDmbFullPath, CancellationToken cancellationToken); } } diff --git a/src/Tgstation.Server.Host/Components/Events/EventConsumer.cs b/src/Tgstation.Server.Host/Components/Events/EventConsumer.cs index 8cc073ccda..6c8b681128 100644 --- a/src/Tgstation.Server.Host/Components/Events/EventConsumer.cs +++ b/src/Tgstation.Server.Host/Components/Events/EventConsumer.cs @@ -31,7 +31,7 @@ namespace Tgstation.Server.Host.Components.Events } /// - public async ValueTask HandleEvent(EventType eventType, IEnumerable parameters, bool deploymentPipeline, CancellationToken cancellationToken) + public async ValueTask HandleEvent(EventType eventType, IEnumerable parameters, bool deploymentPipeline, CancellationToken cancellationToken) { ArgumentNullException.ThrowIfNull(parameters); diff --git a/src/Tgstation.Server.Host/Components/Events/IEventConsumer.cs b/src/Tgstation.Server.Host/Components/Events/IEventConsumer.cs index 7fddbb8950..4d268011f1 100644 --- a/src/Tgstation.Server.Host/Components/Events/IEventConsumer.cs +++ b/src/Tgstation.Server.Host/Components/Events/IEventConsumer.cs @@ -17,6 +17,6 @@ namespace Tgstation.Server.Host.Components.Events /// If this event is part of the deployment pipeline. /// The for the operation. /// A representing the running operation. - ValueTask HandleEvent(EventType eventType, IEnumerable parameters, bool deploymentPipeline, CancellationToken cancellationToken); + ValueTask HandleEvent(EventType eventType, IEnumerable parameters, bool deploymentPipeline, CancellationToken cancellationToken); } } diff --git a/src/Tgstation.Server.Host/Components/Events/NoopEventConsumer.cs b/src/Tgstation.Server.Host/Components/Events/NoopEventConsumer.cs index a8b07e4d7e..dde777572a 100644 --- a/src/Tgstation.Server.Host/Components/Events/NoopEventConsumer.cs +++ b/src/Tgstation.Server.Host/Components/Events/NoopEventConsumer.cs @@ -10,7 +10,7 @@ namespace Tgstation.Server.Host.Components.Events sealed class NoopEventConsumer : IEventConsumer { /// - public ValueTask HandleEvent(EventType eventType, IEnumerable parameters, bool deploymentPipeline, CancellationToken cancellationToken) + public ValueTask HandleEvent(EventType eventType, IEnumerable parameters, bool deploymentPipeline, CancellationToken cancellationToken) => ValueTask.CompletedTask; } } diff --git a/src/Tgstation.Server.Host/Components/StaticFiles/Configuration.cs b/src/Tgstation.Server.Host/Components/StaticFiles/Configuration.cs index b2e12d1947..8261afe918 100644 --- a/src/Tgstation.Server.Host/Components/StaticFiles/Configuration.cs +++ b/src/Tgstation.Server.Host/Components/StaticFiles/Configuration.cs @@ -600,7 +600,7 @@ namespace Tgstation.Server.Host.Components.StaticFiles public Task StopAsync(CancellationToken cancellationToken) => EnsureDirectories(cancellationToken); /// - public async ValueTask HandleEvent(EventType eventType, IEnumerable parameters, bool deploymentPipeline, CancellationToken cancellationToken) + public async ValueTask HandleEvent(EventType eventType, IEnumerable parameters, bool deploymentPipeline, CancellationToken cancellationToken) { ArgumentNullException.ThrowIfNull(parameters); @@ -637,6 +637,9 @@ namespace Tgstation.Server.Host.Components.StaticFiles ' ', parameters.Select(arg => { + if (arg == null) + return "(NULL)"; + if (!arg.Contains(' ', StringComparison.Ordinal)) return arg; diff --git a/src/Tgstation.Server.Host/Controllers/EngineController.cs b/src/Tgstation.Server.Host/Controllers/EngineController.cs index d5072c597f..c1a20fe99c 100644 --- a/src/Tgstation.Server.Host/Controllers/EngineController.cs +++ b/src/Tgstation.Server.Host/Controllers/EngineController.cs @@ -296,8 +296,8 @@ namespace Tgstation.Server.Host.Controllers instance => { var byondManager = instance.EngineManager; - - if (engineVersion.Equals(byondManager.ActiveVersion)) + var activeVersion = byondManager.ActiveVersion; + if (activeVersion != null && engineVersion.Equals(activeVersion)) return ValueTask.FromResult( Conflict(new ErrorMessageResponse(ErrorCode.EngineCannotDeleteActiveVersion))); From 9ebfbebf15a2b627cc369ecb3871546c3c254856 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Fri, 22 Dec 2023 19:41:23 -0500 Subject: [PATCH 338/425] Nullify `IEngineExecutableLock` --- .../Components/Engine/IEngineExecutableLock.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Engine/IEngineExecutableLock.cs b/src/Tgstation.Server.Host/Components/Engine/IEngineExecutableLock.cs index 5d7bb087f9..66031902fb 100644 --- a/src/Tgstation.Server.Host/Components/Engine/IEngineExecutableLock.cs +++ b/src/Tgstation.Server.Host/Components/Engine/IEngineExecutableLock.cs @@ -1,7 +1,5 @@ using System; -#nullable disable - namespace Tgstation.Server.Host.Components.Engine { /// From 080859b530f217635c2039068687e9cdc649f918 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Fri, 22 Dec 2023 20:41:28 -0500 Subject: [PATCH 339/425] Nullify `IEngineInstallationData` --- .../Components/Engine/IEngineInstallationData.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Engine/IEngineInstallationData.cs b/src/Tgstation.Server.Host/Components/Engine/IEngineInstallationData.cs index 6385be5a9e..b3d8458973 100644 --- a/src/Tgstation.Server.Host/Components/Engine/IEngineInstallationData.cs +++ b/src/Tgstation.Server.Host/Components/Engine/IEngineInstallationData.cs @@ -2,8 +2,6 @@ using System.Threading; using System.Threading.Tasks; -#nullable disable - namespace Tgstation.Server.Host.Components.Engine { /// From 217669d262d1e463137db2dde20b7ecc0a3cca35 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Fri, 22 Dec 2023 20:41:13 -0500 Subject: [PATCH 340/425] Nullify `IEngineInstallation` --- .../Components/Engine/ByondInstallation.cs | 2 +- .../Components/Engine/EngineExecutableLock.cs | 2 +- .../Components/Engine/EngineInstallationBase.cs | 2 +- .../Components/Engine/IEngineInstallation.cs | 4 +--- 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Engine/ByondInstallation.cs b/src/Tgstation.Server.Host/Components/Engine/ByondInstallation.cs index 575d55975c..fce9b2c5bc 100644 --- a/src/Tgstation.Server.Host/Components/Engine/ByondInstallation.cs +++ b/src/Tgstation.Server.Host/Components/Engine/ByondInstallation.cs @@ -108,7 +108,7 @@ namespace Tgstation.Server.Host.Components.Engine IDmbProvider dmbProvider, IReadOnlyDictionary parameters, DreamDaemonLaunchParameters launchParameters, - string logFilePath) + string? logFilePath) { ArgumentNullException.ThrowIfNull(dmbProvider); ArgumentNullException.ThrowIfNull(parameters); diff --git a/src/Tgstation.Server.Host/Components/Engine/EngineExecutableLock.cs b/src/Tgstation.Server.Host/Components/Engine/EngineExecutableLock.cs index af04f89224..5d7a1d7fef 100644 --- a/src/Tgstation.Server.Host/Components/Engine/EngineExecutableLock.cs +++ b/src/Tgstation.Server.Host/Components/Engine/EngineExecutableLock.cs @@ -44,7 +44,7 @@ namespace Tgstation.Server.Host.Components.Engine IDmbProvider dmbProvider, IReadOnlyDictionary parameters, DreamDaemonLaunchParameters launchParameters, - string logFilePath) + string? logFilePath) => Instance.FormatServerArguments( dmbProvider, parameters, diff --git a/src/Tgstation.Server.Host/Components/Engine/EngineInstallationBase.cs b/src/Tgstation.Server.Host/Components/Engine/EngineInstallationBase.cs index 2443860623..5edf44609f 100644 --- a/src/Tgstation.Server.Host/Components/Engine/EngineInstallationBase.cs +++ b/src/Tgstation.Server.Host/Components/Engine/EngineInstallationBase.cs @@ -64,7 +64,7 @@ namespace Tgstation.Server.Host.Components.Engine IDmbProvider dmbProvider, IReadOnlyDictionary parameters, DreamDaemonLaunchParameters launchParameters, - string logFilePath); + string? logFilePath); /// public virtual async ValueTask StopServerProcess(ILogger logger, IProcess process, string accessIdentifier, ushort port, CancellationToken cancellationToken) diff --git a/src/Tgstation.Server.Host/Components/Engine/IEngineInstallation.cs b/src/Tgstation.Server.Host/Components/Engine/IEngineInstallation.cs index bd7fa9e180..ff2e4155f3 100644 --- a/src/Tgstation.Server.Host/Components/Engine/IEngineInstallation.cs +++ b/src/Tgstation.Server.Host/Components/Engine/IEngineInstallation.cs @@ -9,8 +9,6 @@ using Tgstation.Server.Api.Models.Internal; using Tgstation.Server.Host.Components.Deployment; using Tgstation.Server.Host.System; -#nullable disable - namespace Tgstation.Server.Host.Components.Engine { /// @@ -65,7 +63,7 @@ namespace Tgstation.Server.Host.Components.Engine IDmbProvider dmbProvider, IReadOnlyDictionary parameters, DreamDaemonLaunchParameters launchParameters, - string logFilePath); + string? logFilePath); /// /// Return the command line arguments for compiling a given if compilation is necessary. From c922ade2d7c89c1e75f9a8529bca6a232c6da848 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Fri, 22 Dec 2023 20:46:18 -0500 Subject: [PATCH 341/425] Nullify `IEngineInstaller` --- .../Components/Engine/ByondInstallerBase.cs | 2 +- .../Components/Engine/DelegatingEngineInstaller.cs | 2 +- .../Components/Engine/EngineInstallerBase.cs | 2 +- .../Components/Engine/IEngineInstaller.cs | 4 +--- 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Engine/ByondInstallerBase.cs b/src/Tgstation.Server.Host/Components/Engine/ByondInstallerBase.cs index 28ac0990bc..02691acfc0 100644 --- a/src/Tgstation.Server.Host/Components/Engine/ByondInstallerBase.cs +++ b/src/Tgstation.Server.Host/Components/Engine/ByondInstallerBase.cs @@ -194,7 +194,7 @@ namespace Tgstation.Server.Host.Components.Engine } /// - public override async ValueTask DownloadVersion(EngineVersion version, JobProgressReporter progressReporter, CancellationToken cancellationToken) + public override async ValueTask DownloadVersion(EngineVersion version, JobProgressReporter? progressReporter, CancellationToken cancellationToken) { CheckVersionValidity(version); diff --git a/src/Tgstation.Server.Host/Components/Engine/DelegatingEngineInstaller.cs b/src/Tgstation.Server.Host/Components/Engine/DelegatingEngineInstaller.cs index 1c68bf1dc2..c7c5363a95 100644 --- a/src/Tgstation.Server.Host/Components/Engine/DelegatingEngineInstaller.cs +++ b/src/Tgstation.Server.Host/Components/Engine/DelegatingEngineInstaller.cs @@ -37,7 +37,7 @@ namespace Tgstation.Server.Host.Components.Engine => DelegateCall(version, installer => installer.CreateInstallation(version, path, installationTask)); /// - public ValueTask DownloadVersion(EngineVersion version, JobProgressReporter jobProgressReporter, CancellationToken cancellationToken) + public ValueTask DownloadVersion(EngineVersion version, JobProgressReporter? jobProgressReporter, CancellationToken cancellationToken) => DelegateCall(version, installer => installer.DownloadVersion(version, jobProgressReporter, cancellationToken)); /// diff --git a/src/Tgstation.Server.Host/Components/Engine/EngineInstallerBase.cs b/src/Tgstation.Server.Host/Components/Engine/EngineInstallerBase.cs index 1993c55f1b..7c25c0a13c 100644 --- a/src/Tgstation.Server.Host/Components/Engine/EngineInstallerBase.cs +++ b/src/Tgstation.Server.Host/Components/Engine/EngineInstallerBase.cs @@ -52,7 +52,7 @@ namespace Tgstation.Server.Host.Components.Engine public abstract ValueTask UpgradeInstallation(EngineVersion version, string path, CancellationToken cancellationToken); /// - public abstract ValueTask DownloadVersion(EngineVersion version, JobProgressReporter jobProgressReporter, CancellationToken cancellationToken); + public abstract ValueTask DownloadVersion(EngineVersion version, JobProgressReporter? jobProgressReporter, CancellationToken cancellationToken); /// public abstract ValueTask TrustDmbPath(EngineVersion version, string fullDmbPath, CancellationToken cancellationToken); diff --git a/src/Tgstation.Server.Host/Components/Engine/IEngineInstaller.cs b/src/Tgstation.Server.Host/Components/Engine/IEngineInstaller.cs index 427ebfe55f..7169ffe4b5 100644 --- a/src/Tgstation.Server.Host/Components/Engine/IEngineInstaller.cs +++ b/src/Tgstation.Server.Host/Components/Engine/IEngineInstaller.cs @@ -4,8 +4,6 @@ using System.Threading.Tasks; using Tgstation.Server.Api.Models; using Tgstation.Server.Host.Jobs; -#nullable disable - namespace Tgstation.Server.Host.Components.Engine { /// @@ -29,7 +27,7 @@ namespace Tgstation.Server.Host.Components.Engine /// The optional for the operation. /// The for the operation. /// A resulting in the for the download. - ValueTask DownloadVersion(EngineVersion version, JobProgressReporter jobProgressReporter, CancellationToken cancellationToken); + ValueTask DownloadVersion(EngineVersion version, JobProgressReporter? jobProgressReporter, CancellationToken cancellationToken); /// /// Does actions necessary to get an extracted installation working. From 38fe6df7dae16716c4a96237da76d7dd01ed7eb1 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Fri, 22 Dec 2023 20:47:46 -0500 Subject: [PATCH 342/425] Nullify `OpenDreamInstallation` --- .../Components/Engine/OpenDreamInstallation.cs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Engine/OpenDreamInstallation.cs b/src/Tgstation.Server.Host/Components/Engine/OpenDreamInstallation.cs index c16e25c9a1..ab9eb923d8 100644 --- a/src/Tgstation.Server.Host/Components/Engine/OpenDreamInstallation.cs +++ b/src/Tgstation.Server.Host/Components/Engine/OpenDreamInstallation.cs @@ -19,8 +19,6 @@ using Tgstation.Server.Host.IO; using Tgstation.Server.Host.System; using Tgstation.Server.Host.Utils; -#nullable disable - namespace Tgstation.Server.Host.Components.Engine { /// @@ -91,7 +89,7 @@ namespace Tgstation.Server.Host.Components.Engine InstallationTask = installationTask ?? throw new ArgumentNullException(nameof(installationTask)); Version = version ?? throw new ArgumentNullException(nameof(version)); - if (version.Engine.Value != EngineType.OpenDream) + if (version.Engine!.Value != EngineType.OpenDream) throw new ArgumentException($"Invalid EngineType: {version.Engine.Value}", nameof(version)); } @@ -100,7 +98,7 @@ namespace Tgstation.Server.Host.Components.Engine IDmbProvider dmbProvider, IReadOnlyDictionary parameters, DreamDaemonLaunchParameters launchParameters, - string logFilePath) + string? logFilePath) { ArgumentNullException.ThrowIfNull(dmbProvider); ArgumentNullException.ThrowIfNull(parameters); @@ -111,8 +109,7 @@ namespace Tgstation.Server.Host.Components.Engine var parametersString = EncodeParameters(parameters, launchParameters); - var loggingEnabled = logFilePath != null; - var arguments = $"--cvar {(loggingEnabled ? $"log.path=\"{ioManager.GetDirectoryName(logFilePath)}\" --cvar log.format=\"{ioManager.GetFileName(logFilePath)}\"" : "log.enabled=false")} --cvar watchdog.token={accessIdentifier} --cvar log.runtimelog=false --cvar net.port={launchParameters.Port.Value} --cvar opendream.topic_port=0 --cvar opendream.world_params=\"{parametersString}\" --cvar opendream.json_path=\"./{dmbProvider.DmbName}\""; + var arguments = $"--cvar {(logFilePath != null ? $"log.path=\"{ioManager.GetDirectoryName(logFilePath)}\" --cvar log.format=\"{ioManager.GetFileName(logFilePath)}\"" : "log.enabled=false")} --cvar watchdog.token={accessIdentifier} --cvar log.runtimelog=false --cvar net.port={launchParameters.Port!.Value} --cvar opendream.topic_port=0 --cvar opendream.world_params=\"{parametersString}\" --cvar opendream.json_path=\"./{dmbProvider.DmbName}\""; return arguments; } From 91dcb5cda63ed819fa2a4d293dac4863330ecab4 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Fri, 22 Dec 2023 20:48:59 -0500 Subject: [PATCH 343/425] Nullify `OpenDreamInstaller` --- .../Components/Engine/OpenDreamInstaller.cs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Engine/OpenDreamInstaller.cs b/src/Tgstation.Server.Host/Components/Engine/OpenDreamInstaller.cs index c5f03e1e32..5244816ead 100644 --- a/src/Tgstation.Server.Host/Components/Engine/OpenDreamInstaller.cs +++ b/src/Tgstation.Server.Host/Components/Engine/OpenDreamInstaller.cs @@ -17,8 +17,6 @@ using Tgstation.Server.Host.Jobs; using Tgstation.Server.Host.System; using Tgstation.Server.Host.Utils; -#nullable disable - namespace Tgstation.Server.Host.Components.Engine { /// @@ -136,7 +134,7 @@ namespace Tgstation.Server.Host.Components.Engine } /// - public override async ValueTask DownloadVersion(EngineVersion version, JobProgressReporter jobProgressReporter, CancellationToken cancellationToken) + public override async ValueTask DownloadVersion(EngineVersion version, JobProgressReporter? jobProgressReporter, CancellationToken cancellationToken) { CheckVersionValidity(version); @@ -172,7 +170,7 @@ namespace Tgstation.Server.Host.Components.Engine var progressSection2 = jobProgressReporter?.CreateSection("Checking out OpenDream version", 0.5f); var committish = version.SourceSHA - ?? $"{GeneralConfiguration.OpenDreamGitTagPrefix}{version.Version.Semver()}"; + ?? $"{GeneralConfiguration.OpenDreamGitTagPrefix}{version.Version!.Semver()}"; await repo.CheckoutObject( committish, @@ -269,8 +267,7 @@ namespace Tgstation.Server.Host.Components.Engine using (cancellationToken.Register(() => buildProcess.Terminate())) buildExitCode = await buildProcess.Lifetime; - string output; - + string? output; if (!GeneralConfiguration.OpenDreamSuppressInstallOutput) { var buildOutputTask = buildProcess.GetCombinedOutput(cancellationToken); From ba7710fc9dfa56962775013a08963d1bb7925618 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Fri, 22 Dec 2023 20:49:30 -0500 Subject: [PATCH 344/425] Nullify `PosixByondInstaller` --- .../Components/Engine/PosixByondInstaller.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Engine/PosixByondInstaller.cs b/src/Tgstation.Server.Host/Components/Engine/PosixByondInstaller.cs index 165be04ada..037cacd437 100644 --- a/src/Tgstation.Server.Host/Components/Engine/PosixByondInstaller.cs +++ b/src/Tgstation.Server.Host/Components/Engine/PosixByondInstaller.cs @@ -10,8 +10,6 @@ using Tgstation.Server.Api.Models; using Tgstation.Server.Common.Extensions; using Tgstation.Server.Host.IO; -#nullable disable - namespace Tgstation.Server.Host.Components.Engine { /// @@ -95,7 +93,7 @@ namespace Tgstation.Server.Host.Components.Engine var basePath = IOManager.ConcatPath(path, ByondBinPath); var ddTask = WriteAndMakeExecutable( - IOManager.ConcatPath(basePath, GetDreamDaemonName(version.Version, out _)), + IOManager.ConcatPath(basePath, GetDreamDaemonName(version.Version!, out _)), dreamDaemonScript); var dmTask = WriteAndMakeExecutable( From 606bea53acf6269b5a2f5c2540454d08abf7cea8 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Fri, 22 Dec 2023 20:49:56 -0500 Subject: [PATCH 345/425] Nullify `RepositoryEngineInstallationData` --- .../Components/Engine/RepositoryEngineInstallationData.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Engine/RepositoryEngineInstallationData.cs b/src/Tgstation.Server.Host/Components/Engine/RepositoryEngineInstallationData.cs index 2c96b6f311..88fbb77911 100644 --- a/src/Tgstation.Server.Host/Components/Engine/RepositoryEngineInstallationData.cs +++ b/src/Tgstation.Server.Host/Components/Engine/RepositoryEngineInstallationData.cs @@ -5,8 +5,6 @@ using System.Threading.Tasks; using Tgstation.Server.Host.Components.Repository; using Tgstation.Server.Host.IO; -#nullable disable - namespace Tgstation.Server.Host.Components.Engine { /// From 5fb9b773d47e7f9e11b88c7c9335b433c3abd59f Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Fri, 22 Dec 2023 20:50:22 -0500 Subject: [PATCH 346/425] Nullify `WindowsByondInstaller` --- .../Components/Engine/WindowsByondInstaller.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Engine/WindowsByondInstaller.cs b/src/Tgstation.Server.Host/Components/Engine/WindowsByondInstaller.cs index 2c3aad65bc..87424718d5 100644 --- a/src/Tgstation.Server.Host/Components/Engine/WindowsByondInstaller.cs +++ b/src/Tgstation.Server.Host/Components/Engine/WindowsByondInstaller.cs @@ -15,8 +15,6 @@ using Tgstation.Server.Host.Jobs; using Tgstation.Server.Host.System; using Tgstation.Server.Host.Utils; -#nullable disable - namespace Tgstation.Server.Host.Components.Engine { /// @@ -245,7 +243,7 @@ namespace Tgstation.Server.Host.Components.Engine /// A representing the running operation. async ValueTask AddDreamDaemonToFirewall(EngineVersion version, string path, CancellationToken cancellationToken) { - var dreamDaemonName = GetDreamDaemonName(version.Version, out var usesDDExe); + var dreamDaemonName = GetDreamDaemonName(version.Version!, out var usesDDExe); var dreamDaemonPath = IOManager.ResolvePath( IOManager.ConcatPath( From 60b636e32e0b15f85b59ee6437e80f73c715efcb Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Fri, 22 Dec 2023 20:50:43 -0500 Subject: [PATCH 347/425] Nullify `WindowsOpenDreamInstaller` --- .../Components/Engine/WindowsOpenDreamInstaller.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Engine/WindowsOpenDreamInstaller.cs b/src/Tgstation.Server.Host/Components/Engine/WindowsOpenDreamInstaller.cs index d343c32802..25968446fe 100644 --- a/src/Tgstation.Server.Host/Components/Engine/WindowsOpenDreamInstaller.cs +++ b/src/Tgstation.Server.Host/Components/Engine/WindowsOpenDreamInstaller.cs @@ -15,8 +15,6 @@ using Tgstation.Server.Host.Jobs; using Tgstation.Server.Host.System; using Tgstation.Server.Host.Utils; -#nullable disable - namespace Tgstation.Server.Host.Components.Engine { /// From 7c37bd80dc1b08507685b24f61729c3651b1449c Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Fri, 22 Dec 2023 20:51:10 -0500 Subject: [PATCH 348/425] Nullify `ZipStreamEngineInstallationData` --- .../Components/Engine/ZipStreamEngineInstallationData.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Engine/ZipStreamEngineInstallationData.cs b/src/Tgstation.Server.Host/Components/Engine/ZipStreamEngineInstallationData.cs index 71c26b92ef..292b725981 100644 --- a/src/Tgstation.Server.Host/Components/Engine/ZipStreamEngineInstallationData.cs +++ b/src/Tgstation.Server.Host/Components/Engine/ZipStreamEngineInstallationData.cs @@ -5,8 +5,6 @@ using System.Threading.Tasks; using Tgstation.Server.Host.IO; -#nullable disable - namespace Tgstation.Server.Host.Components.Engine { /// From 51d78df776d2132184d82c81066c1e190f50a000 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 23 Dec 2023 09:51:05 -0500 Subject: [PATCH 349/425] Make `EventConsumer` thread safe --- src/Tgstation.Server.Host/Components/Events/EventConsumer.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Events/EventConsumer.cs b/src/Tgstation.Server.Host/Components/Events/EventConsumer.cs index 6c8b681128..559e584a27 100644 --- a/src/Tgstation.Server.Host/Components/Events/EventConsumer.cs +++ b/src/Tgstation.Server.Host/Components/Events/EventConsumer.cs @@ -50,10 +50,9 @@ namespace Tgstation.Server.Host.Components.Events public void SetWatchdog(IWatchdog watchdog) { ArgumentNullException.ThrowIfNull(watchdog); - if (this.watchdog != null) + var oldWatchdog = Interlocked.CompareExchange(ref this.watchdog, watchdog, null); + if (oldWatchdog != null) throw new InvalidOperationException("watchdog already set!"); - - this.watchdog = watchdog; } } } From a6d557eabe4a50c806e6a55b25cd6cf8dd2da702 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 23 Dec 2023 09:52:55 -0500 Subject: [PATCH 350/425] Nullify `BridgeParameters` --- .../Components/Interop/Bridge/BridgeParameters.cs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Interop/Bridge/BridgeParameters.cs b/src/Tgstation.Server.Host/Components/Interop/Bridge/BridgeParameters.cs index a1475ed1f9..e633a4c240 100644 --- a/src/Tgstation.Server.Host/Components/Interop/Bridge/BridgeParameters.cs +++ b/src/Tgstation.Server.Host/Components/Interop/Bridge/BridgeParameters.cs @@ -4,8 +4,6 @@ using System.Collections.Generic; using Tgstation.Server.Api.Models; using Tgstation.Server.Host.Components.Chat.Commands; -#nullable disable - namespace Tgstation.Server.Host.Components.Interop.Bridge { /// @@ -26,12 +24,12 @@ namespace Tgstation.Server.Host.Components.Interop.Bridge /// /// The DMAPI for requests. /// - public Version Version { get; set; } + public Version? Version { get; set; } /// /// The DMAPI s for requests. /// - public ICollection CustomCommands { get; set; } + public ICollection? CustomCommands { get; set; } /// /// The minimum required level for requests. @@ -41,12 +39,12 @@ namespace Tgstation.Server.Host.Components.Interop.Bridge /// /// The for requests. /// - public ChatMessage ChatMessage { get; set; } + public ChatMessage? ChatMessage { get; set; } /// /// The for requests. /// - public ChunkData Chunk { get; set; } + public ChunkData? Chunk { get; set; } /// /// The port that should be used to send world topics, if not the default. From c192bd543bdccabeaa993a6b1d361cd825305cf2 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 23 Dec 2023 09:53:11 -0500 Subject: [PATCH 351/425] Nullify `BridgeRegistration` --- .../Components/Interop/Bridge/BridgeRegistration.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Interop/Bridge/BridgeRegistration.cs b/src/Tgstation.Server.Host/Components/Interop/Bridge/BridgeRegistration.cs index 38acfd827d..1ba9673ee6 100644 --- a/src/Tgstation.Server.Host/Components/Interop/Bridge/BridgeRegistration.cs +++ b/src/Tgstation.Server.Host/Components/Interop/Bridge/BridgeRegistration.cs @@ -2,8 +2,6 @@ using Tgstation.Server.Host.Utils; -#nullable disable - namespace Tgstation.Server.Host.Components.Interop.Bridge { /// From 59306d1cbd04e6e3fe47a9d02ee7ccde757058b6 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 23 Dec 2023 09:55:00 -0500 Subject: [PATCH 352/425] Nullify `BridgeResponse` --- .../Components/Interop/Bridge/BridgeResponse.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Interop/Bridge/BridgeResponse.cs b/src/Tgstation.Server.Host/Components/Interop/Bridge/BridgeResponse.cs index 27113567b2..620241fafb 100644 --- a/src/Tgstation.Server.Host/Components/Interop/Bridge/BridgeResponse.cs +++ b/src/Tgstation.Server.Host/Components/Interop/Bridge/BridgeResponse.cs @@ -1,7 +1,5 @@ using System.Collections.Generic; -#nullable disable - namespace Tgstation.Server.Host.Components.Interop.Bridge { /// @@ -17,11 +15,11 @@ namespace Tgstation.Server.Host.Components.Interop.Bridge /// /// The for requests. /// - public RuntimeInformation RuntimeInformation { get; set; } + public RuntimeInformation? RuntimeInformation { get; set; } /// /// The s missing from a chunked request. /// - public IReadOnlyCollection MissingChunks { get; set; } + public IReadOnlyCollection? MissingChunks { get; set; } } } From f2f576fd7884867bdf2aad9ff08b9439bba7781f Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 23 Dec 2023 09:55:32 -0500 Subject: [PATCH 353/425] Nullify `IBridgeDispatcher` --- .../Components/Interop/Bridge/IBridgeDispatcher.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Interop/Bridge/IBridgeDispatcher.cs b/src/Tgstation.Server.Host/Components/Interop/Bridge/IBridgeDispatcher.cs index 166daa4a21..8035583442 100644 --- a/src/Tgstation.Server.Host/Components/Interop/Bridge/IBridgeDispatcher.cs +++ b/src/Tgstation.Server.Host/Components/Interop/Bridge/IBridgeDispatcher.cs @@ -1,8 +1,6 @@ using System.Threading; using System.Threading.Tasks; -#nullable disable - namespace Tgstation.Server.Host.Components.Interop.Bridge { /// @@ -16,6 +14,6 @@ namespace Tgstation.Server.Host.Components.Interop.Bridge /// The to handle. /// The for the operation. /// A resulting in the for the request or if the request could not be dispatched. - ValueTask ProcessBridgeRequest(BridgeParameters parameters, CancellationToken cancellationToken); + ValueTask ProcessBridgeRequest(BridgeParameters parameters, CancellationToken cancellationToken); } } From e39577c7f45fcde20573d62b04bf3aa23161cc35 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 23 Dec 2023 09:55:54 -0500 Subject: [PATCH 354/425] Nullify `IBridgeRegistration` --- .../Components/Interop/Bridge/IBridgeRegistration.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Interop/Bridge/IBridgeRegistration.cs b/src/Tgstation.Server.Host/Components/Interop/Bridge/IBridgeRegistration.cs index 50f17cf912..189846f081 100644 --- a/src/Tgstation.Server.Host/Components/Interop/Bridge/IBridgeRegistration.cs +++ b/src/Tgstation.Server.Host/Components/Interop/Bridge/IBridgeRegistration.cs @@ -1,7 +1,5 @@ using System; -#nullable disable - namespace Tgstation.Server.Host.Components.Interop.Bridge { /// From d854a630ce3e623aee3d4960b31a46cababa728c Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 23 Dec 2023 10:02:05 -0500 Subject: [PATCH 355/425] Nullify `RuntimeInformation` --- .../Components/Interop/Bridge/RuntimeInformation.cs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Interop/Bridge/RuntimeInformation.cs b/src/Tgstation.Server.Host/Components/Interop/Bridge/RuntimeInformation.cs index a24a17a614..a011dad75a 100644 --- a/src/Tgstation.Server.Host/Components/Interop/Bridge/RuntimeInformation.cs +++ b/src/Tgstation.Server.Host/Components/Interop/Bridge/RuntimeInformation.cs @@ -9,8 +9,6 @@ using Tgstation.Server.Host.Components.Chat; using Tgstation.Server.Host.Components.Deployment; using Tgstation.Server.Host.System; -#nullable disable - namespace Tgstation.Server.Host.Components.Interop.Bridge { /// @@ -93,11 +91,11 @@ namespace Tgstation.Server.Host.Components.Interop.Bridge OriginCommitSha = dmbProvider.CompileJob.RevisionInformation.OriginCommitSha, }; - TestMerges = (IReadOnlyCollection)dmbProvider + TestMerges = (IReadOnlyCollection?)dmbProvider .CompileJob .RevisionInformation - .ActiveTestMerges? - .Select(x => x.TestMerge) + .ActiveTestMerges + ?.Select(x => x.TestMerge) .Select(x => new TestMergeInformation(x, Revision)) .ToList() ?? Array.Empty(); From fadecee5784720fb993de7ede03d95eae12fe2d3 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 23 Dec 2023 10:06:19 -0500 Subject: [PATCH 356/425] Nullify `TestMergeInformation` --- .../Components/Interop/Bridge/TestMergeInformation.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Interop/Bridge/TestMergeInformation.cs b/src/Tgstation.Server.Host/Components/Interop/Bridge/TestMergeInformation.cs index 3543f052bb..4537c56bd9 100644 --- a/src/Tgstation.Server.Host/Components/Interop/Bridge/TestMergeInformation.cs +++ b/src/Tgstation.Server.Host/Components/Interop/Bridge/TestMergeInformation.cs @@ -3,8 +3,6 @@ using System.Globalization; using Tgstation.Server.Api.Models.Internal; -#nullable disable - namespace Tgstation.Server.Host.Components.Interop.Bridge { /// @@ -20,10 +18,10 @@ namespace Tgstation.Server.Host.Components.Interop.Bridge /// /// Backing field for needed to continue to support DMAPI 5. /// - public string PullRequestRevision { get; set; } + public string? PullRequestRevision { get; set; } /// - public override string TargetCommitSha + public override string? TargetCommitSha { get => PullRequestRevision; set => PullRequestRevision = value; From d663b97aedf83a80a133f8c5ceb4a1e9a0d25310 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 23 Dec 2023 10:06:49 -0500 Subject: [PATCH 357/425] Nullify `ChatCommand` --- .../Components/Interop/Topic/ChatCommand.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Interop/Topic/ChatCommand.cs b/src/Tgstation.Server.Host/Components/Interop/Topic/ChatCommand.cs index 34aeed50e7..5f50d6bba8 100644 --- a/src/Tgstation.Server.Host/Components/Interop/Topic/ChatCommand.cs +++ b/src/Tgstation.Server.Host/Components/Interop/Topic/ChatCommand.cs @@ -2,8 +2,6 @@ using Tgstation.Server.Host.Components.Chat; -#nullable disable - namespace Tgstation.Server.Host.Components.Interop.Topic { /// From 7747df9afda9dcc0800578830f802b4bba92eeb4 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 23 Dec 2023 10:07:39 -0500 Subject: [PATCH 358/425] Nullify `ChunkedTopicParameters` --- .../Components/Interop/Topic/ChunkedTopicParameters.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Interop/Topic/ChunkedTopicParameters.cs b/src/Tgstation.Server.Host/Components/Interop/Topic/ChunkedTopicParameters.cs index 99bf573d9b..0940281ece 100644 --- a/src/Tgstation.Server.Host/Components/Interop/Topic/ChunkedTopicParameters.cs +++ b/src/Tgstation.Server.Host/Components/Interop/Topic/ChunkedTopicParameters.cs @@ -1,7 +1,5 @@ using System.Collections.Generic; -#nullable disable - namespace Tgstation.Server.Host.Components.Interop.Topic { /// @@ -10,7 +8,7 @@ namespace Tgstation.Server.Host.Components.Interop.Topic sealed class ChunkedTopicParameters : TopicParameters, IMissingPayloadsCommunication, IChunkPayloadId { /// - public IReadOnlyCollection MissingChunks { get; set; } + public IReadOnlyCollection? MissingChunks { get; set; } /// public uint? PayloadId { get; set; } From 6f9808f2b859ec721acca71dc368b52c75b3c812 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 23 Dec 2023 10:09:00 -0500 Subject: [PATCH 359/425] Nullify `EventNotification` --- .../Components/Interop/Topic/EventNotification.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Interop/Topic/EventNotification.cs b/src/Tgstation.Server.Host/Components/Interop/Topic/EventNotification.cs index 6977a27554..75eb3bc9f4 100644 --- a/src/Tgstation.Server.Host/Components/Interop/Topic/EventNotification.cs +++ b/src/Tgstation.Server.Host/Components/Interop/Topic/EventNotification.cs @@ -4,8 +4,6 @@ using System.Linq; using Tgstation.Server.Host.Components.Events; -#nullable disable - namespace Tgstation.Server.Host.Components.Interop.Topic { /// @@ -22,14 +20,14 @@ namespace Tgstation.Server.Host.Components.Interop.Topic /// /// The set of parameters. /// - public IReadOnlyCollection Parameters { get; } + public IReadOnlyCollection Parameters { get; } /// /// Initializes a new instance of the class. /// /// The value of . /// The that forms the value of . - public EventNotification(EventType eventType, IEnumerable parameters = null) + public EventNotification(EventType eventType, IEnumerable parameters) { Type = eventType; Parameters = parameters?.ToList() ?? throw new ArgumentNullException(nameof(parameters)); From 2f90ef455355c990b3367da4f681cdf236aee7e6 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 23 Dec 2023 10:09:22 -0500 Subject: [PATCH 360/425] Nullify `TopicCommandType` --- .../Components/Interop/Topic/TopicCommandType.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Interop/Topic/TopicCommandType.cs b/src/Tgstation.Server.Host/Components/Interop/Topic/TopicCommandType.cs index 08d8917a66..286c605d07 100644 --- a/src/Tgstation.Server.Host/Components/Interop/Topic/TopicCommandType.cs +++ b/src/Tgstation.Server.Host/Components/Interop/Topic/TopicCommandType.cs @@ -1,7 +1,5 @@ using System; -#nullable disable - namespace Tgstation.Server.Host.Components.Interop.Topic { /// From aea5ecac1c636a0eef3698d749c7f95f83d74a7e Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 23 Dec 2023 10:10:06 -0500 Subject: [PATCH 361/425] Nullify `TopicParameters` --- .../Components/Interop/Topic/TopicParameters.cs | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Interop/Topic/TopicParameters.cs b/src/Tgstation.Server.Host/Components/Interop/Topic/TopicParameters.cs index 8674e0679d..f84a404289 100644 --- a/src/Tgstation.Server.Host/Components/Interop/Topic/TopicParameters.cs +++ b/src/Tgstation.Server.Host/Components/Interop/Topic/TopicParameters.cs @@ -4,8 +4,6 @@ using Newtonsoft.Json; using Tgstation.Server.Host.Components.Session; -#nullable disable - namespace Tgstation.Server.Host.Components.Interop.Topic { /// @@ -22,12 +20,12 @@ namespace Tgstation.Server.Host.Components.Interop.Topic /// /// The for requests. /// - public ChatCommand ChatCommand { get; } + public ChatCommand? ChatCommand { get; } /// /// The for requests. /// - public EventNotification EventNotification { get; } + public EventNotification? EventNotification { get; } /// /// The new port for or requests. @@ -42,27 +40,27 @@ namespace Tgstation.Server.Host.Components.Interop.Topic /// /// The new for requests. /// - public string NewInstanceName { get; } + public string? NewInstanceName { get; } /// /// The message to broadcast for requests. /// - public string BroadcastMessage { get; } + public string? BroadcastMessage { get; } /// /// The for requests. /// - public ChatUpdate ChatUpdate { get; } + public ChatUpdate? ChatUpdate { get; } /// /// The new server after a reattach. /// - public Version NewServerVersion { get; } + public Version? NewServerVersion { get; } /// /// The for a partial request. /// - public ChunkData Chunk { get; } + public ChunkData? Chunk { get; } /// /// Whether or not the constitute a priority request. From 4c3de49eda7dbba25477e985e3c751dbdb32d78d Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 23 Dec 2023 10:10:35 -0500 Subject: [PATCH 362/425] Nullify `TopicResponse` --- .../Components/Interop/Topic/TopicResponse.cs | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Interop/Topic/TopicResponse.cs b/src/Tgstation.Server.Host/Components/Interop/Topic/TopicResponse.cs index 3b936b514e..12db6f3ef1 100644 --- a/src/Tgstation.Server.Host/Components/Interop/Topic/TopicResponse.cs +++ b/src/Tgstation.Server.Host/Components/Interop/Topic/TopicResponse.cs @@ -2,8 +2,6 @@ using Tgstation.Server.Host.Components.Chat.Commands; -#nullable disable - namespace Tgstation.Server.Host.Components.Interop.Topic { /// @@ -14,29 +12,29 @@ namespace Tgstation.Server.Host.Components.Interop.Topic /// /// The text to reply with as the result of a request, if any. Deprecated circa Interop 5.4.0. /// - public string CommandResponseMessage { get; set; } + public string? CommandResponseMessage { get; set; } /// /// The response from a . Added in Interop 5.4.0. /// - public ChatMessage CommandResponse { get; set; } + public ChatMessage? CommandResponse { get; set; } /// /// The s to send as the result of a request, if any. /// - public ICollection ChatResponses { get; set; } + public ICollection? ChatResponses { get; set; } /// /// The DMAPI s for requests. /// - public ICollection CustomCommands { get; set; } + public ICollection? CustomCommands { get; set; } /// /// The for a partial response. /// - public ChunkData Chunk { get; set; } + public ChunkData? Chunk { get; set; } /// - public IReadOnlyCollection MissingChunks { get; set; } + public IReadOnlyCollection? MissingChunks { get; set; } } } From e2dba1ccbc60aa6e0d6253a0659f5813f6b18e34 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 23 Dec 2023 10:11:23 -0500 Subject: [PATCH 363/425] Nullify `ChatEmbed` --- .../Components/Interop/ChatEmbed.cs | 26 +++++++++---------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Interop/ChatEmbed.cs b/src/Tgstation.Server.Host/Components/Interop/ChatEmbed.cs index e76c2bcbd8..41563191f3 100644 --- a/src/Tgstation.Server.Host/Components/Interop/ChatEmbed.cs +++ b/src/Tgstation.Server.Host/Components/Interop/ChatEmbed.cs @@ -1,7 +1,5 @@ using System.Collections.Generic; -#nullable disable - namespace Tgstation.Server.Host.Components.Interop { /// @@ -12,63 +10,63 @@ namespace Tgstation.Server.Host.Components.Interop /// /// The title of the embed. /// - public string Title { get; set; } + public string? Title { get; set; } /// /// The description of the embed. /// - public string Description { get; set; } + public string? Description { get; set; } /// /// The URL of the embed. /// #pragma warning disable CA1056 // Uri properties should not be strings - public string Url { get; set; } + public string? Url { get; set; } #pragma warning restore CA1056 // Uri properties should not be strings /// /// The ISO 8601 timestamp of the embed. /// - public string Timestamp { get; set; } + public string? Timestamp { get; set; } /// /// The colour of the embed in the format hex "#AARRGGBB". /// - public string Colour { get; set; } + public string? Colour { get; set; } /// /// The . /// - public ChatEmbedFooter Footer { get; set; } + public ChatEmbedFooter? Footer { get; set; } /// /// The for an image. /// - public ChatEmbedMedia Image { get; set; } + public ChatEmbedMedia? Image { get; set; } /// /// The for a thumbnail. /// - public ChatEmbedMedia Thumbnail { get; set; } + public ChatEmbedMedia? Thumbnail { get; set; } /// /// The for a video. /// - public ChatEmbedMedia Video { get; set; } + public ChatEmbedMedia? Video { get; set; } /// /// The . /// - public ChatEmbedProvider Provider { get; set; } + public ChatEmbedProvider? Provider { get; set; } /// /// The . /// - public ChatEmbedAuthor Author { get; set; } + public ChatEmbedAuthor? Author { get; set; } /// /// The s. /// - public ICollection Fields { get; set; } + public ICollection? Fields { get; set; } } } From b5b408fc1efb3ad2d7d33840aefd1ff6813d5cf1 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 23 Dec 2023 10:11:45 -0500 Subject: [PATCH 364/425] Nullify `ChatEmbedAuthor` --- .../Components/Interop/ChatEmbedAuthor.cs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Interop/ChatEmbedAuthor.cs b/src/Tgstation.Server.Host/Components/Interop/ChatEmbedAuthor.cs index 97b5d26fd4..d136b895b0 100644 --- a/src/Tgstation.Server.Host/Components/Interop/ChatEmbedAuthor.cs +++ b/src/Tgstation.Server.Host/Components/Interop/ChatEmbedAuthor.cs @@ -1,6 +1,4 @@ -#nullable disable - -namespace Tgstation.Server.Host.Components.Interop +namespace Tgstation.Server.Host.Components.Interop { /// /// Represents information about a author. @@ -11,12 +9,12 @@ namespace Tgstation.Server.Host.Components.Interop /// Gets the icon URL of the author. /// #pragma warning disable CA1056 // Uri properties should not be strings - public string IconUrl { get; set; } + public string? IconUrl { get; set; } /// /// Gets the proxied icon URL of the thumbnail. /// - public string ProxyIconUrl { get; set; } + public string? ProxyIconUrl { get; set; } #pragma warning restore CA1056 // Uri properties should not be strings } } From 4bfc321e45c5c6d31386095aad2ac4fcc8fc1279 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 23 Dec 2023 10:12:31 -0500 Subject: [PATCH 365/425] Nullify `ChatEmbedField` --- .../Components/Chat/Providers/DiscordProvider.cs | 2 +- .../Components/Interop/ChatEmbedField.cs | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Chat/Providers/DiscordProvider.cs b/src/Tgstation.Server.Host/Components/Chat/Providers/DiscordProvider.cs index 047febbe00..1ee21f9ca0 100644 --- a/src/Tgstation.Server.Host/Components/Chat/Providers/DiscordProvider.cs +++ b/src/Tgstation.Server.Host/Components/Chat/Providers/DiscordProvider.cs @@ -995,7 +995,7 @@ namespace Tgstation.Server.Host.Components.Chat.Providers if (invalid) continue; - fields.Add(new EmbedField(field.Name, field.Value) + fields.Add(new EmbedField(field.Name!, field.Value!) { IsInline = field.IsInline ?? default(Optional), }); diff --git a/src/Tgstation.Server.Host/Components/Interop/ChatEmbedField.cs b/src/Tgstation.Server.Host/Components/Interop/ChatEmbedField.cs index f584557992..70b3c37c9f 100644 --- a/src/Tgstation.Server.Host/Components/Interop/ChatEmbedField.cs +++ b/src/Tgstation.Server.Host/Components/Interop/ChatEmbedField.cs @@ -1,6 +1,4 @@ -#nullable disable - -namespace Tgstation.Server.Host.Components.Interop +namespace Tgstation.Server.Host.Components.Interop { /// /// Represents a field in a . @@ -10,12 +8,12 @@ namespace Tgstation.Server.Host.Components.Interop /// /// Gets the name of the field. /// - public string Name { get; set; } + public string? Name { get; set; } /// /// Gets the value of the field. /// - public string Value { get; set; } + public string? Value { get; set; } /// /// Gets a value indicating whether the field should display inline. From 82d1b3090fb548560e5785a2ac1192ba29c36668 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 23 Dec 2023 10:14:02 -0500 Subject: [PATCH 366/425] Nullify `ChatEmbedFooter` --- .../Components/Chat/Providers/DiscordProvider.cs | 2 +- .../Components/Interop/ChatEmbedFooter.cs | 10 ++++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Chat/Providers/DiscordProvider.cs b/src/Tgstation.Server.Host/Components/Chat/Providers/DiscordProvider.cs index 1ee21f9ca0..b21202ed37 100644 --- a/src/Tgstation.Server.Host/Components/Chat/Providers/DiscordProvider.cs +++ b/src/Tgstation.Server.Host/Components/Chat/Providers/DiscordProvider.cs @@ -1045,7 +1045,7 @@ namespace Tgstation.Server.Host.Components.Chat.Providers Description = embed.Description ?? default(Optional), Fields = fields ?? default(Optional>), Footer = embed.Footer != null - ? (Optional)new EmbedFooter(embed.Footer.Text) + ? (Optional)new EmbedFooter(embed.Footer.Text!) { IconUrl = embed.Footer.IconUrl ?? default(Optional), ProxyIconUrl = embed.Footer.ProxyIconUrl ?? default(Optional), diff --git a/src/Tgstation.Server.Host/Components/Interop/ChatEmbedFooter.cs b/src/Tgstation.Server.Host/Components/Interop/ChatEmbedFooter.cs index 2105603d92..57d45ec7eb 100644 --- a/src/Tgstation.Server.Host/Components/Interop/ChatEmbedFooter.cs +++ b/src/Tgstation.Server.Host/Components/Interop/ChatEmbedFooter.cs @@ -1,6 +1,4 @@ -#nullable disable - -namespace Tgstation.Server.Host.Components.Interop +namespace Tgstation.Server.Host.Components.Interop { /// /// Represents a footer in a . @@ -10,18 +8,18 @@ namespace Tgstation.Server.Host.Components.Interop /// /// Gets the text of the footer. /// - public string Text { get; set; } + public string? Text { get; set; } /// /// Gets the URL of the footer icon. Only supports http(s) and attachments. /// #pragma warning disable CA1056 // Uri properties should not be strings - public string IconUrl { get; set; } + public string? IconUrl { get; set; } /// /// Gets the proxied icon URL. /// - public string ProxyIconUrl { get; set; } + public string? ProxyIconUrl { get; set; } #pragma warning restore CA1056 // Uri properties should not be strings } } From e9b6cbdc66d44867099fff60baeb1c2df7c91911 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 23 Dec 2023 10:14:50 -0500 Subject: [PATCH 367/425] Nullify `ChatEmbedFooter` --- .../Components/Chat/Providers/DiscordProvider.cs | 4 ++-- .../Components/Interop/ChatEmbedMedia.cs | 8 +++----- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Chat/Providers/DiscordProvider.cs b/src/Tgstation.Server.Host/Components/Chat/Providers/DiscordProvider.cs index b21202ed37..610baacc98 100644 --- a/src/Tgstation.Server.Host/Components/Chat/Providers/DiscordProvider.cs +++ b/src/Tgstation.Server.Host/Components/Chat/Providers/DiscordProvider.cs @@ -1052,7 +1052,7 @@ namespace Tgstation.Server.Host.Components.Chat.Providers } : default, Image = embed.Image != null - ? new EmbedImage(embed.Image.Url) + ? new EmbedImage(embed.Image.Url!) { Width = embed.Image.Width ?? default(Optional), Height = embed.Image.Height ?? default(Optional), @@ -1067,7 +1067,7 @@ namespace Tgstation.Server.Host.Components.Chat.Providers } : default(Optional), Thumbnail = embed.Thumbnail != null - ? new EmbedThumbnail(embed.Thumbnail.Url) + ? new EmbedThumbnail(embed.Thumbnail.Url!) { Width = embed.Thumbnail.Width ?? default(Optional), Height = embed.Thumbnail.Height ?? default(Optional), diff --git a/src/Tgstation.Server.Host/Components/Interop/ChatEmbedMedia.cs b/src/Tgstation.Server.Host/Components/Interop/ChatEmbedMedia.cs index ebab7bfa80..c031a01e92 100644 --- a/src/Tgstation.Server.Host/Components/Interop/ChatEmbedMedia.cs +++ b/src/Tgstation.Server.Host/Components/Interop/ChatEmbedMedia.cs @@ -1,6 +1,4 @@ -#nullable disable - -namespace Tgstation.Server.Host.Components.Interop +namespace Tgstation.Server.Host.Components.Interop { /// /// Represents information about a thumbnail in a . @@ -11,12 +9,12 @@ namespace Tgstation.Server.Host.Components.Interop /// Gets the source URL of the media. Only supports http(s) and attachments. /// #pragma warning disable CA1056 // Uri properties should not be strings - public string Url { get; set; } + public string? Url { get; set; } /// /// Gets the proxied URL of the media. /// - public string ProxyUrl { get; set; } + public string? ProxyUrl { get; set; } #pragma warning restore CA1056 // Uri properties should not be strings /// From 34571a19cd35fa8ba8a4d63f0e4daff7b2a47570 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 23 Dec 2023 10:15:32 -0500 Subject: [PATCH 368/425] Nullify `ChatEmbedProvider` --- .../Components/Chat/Providers/DiscordProvider.cs | 2 +- .../Components/Interop/ChatEmbedProvider.cs | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Chat/Providers/DiscordProvider.cs b/src/Tgstation.Server.Host/Components/Chat/Providers/DiscordProvider.cs index 610baacc98..02914f87d7 100644 --- a/src/Tgstation.Server.Host/Components/Chat/Providers/DiscordProvider.cs +++ b/src/Tgstation.Server.Host/Components/Chat/Providers/DiscordProvider.cs @@ -1034,7 +1034,7 @@ namespace Tgstation.Server.Host.Components.Chat.Providers var discordEmbed = new Embed { Author = embed.Author != null - ? new EmbedAuthor(embed.Author.Name) + ? new EmbedAuthor(embed.Author.Name!) { IconUrl = embed.Author.IconUrl ?? default(Optional), ProxyIconUrl = embed.Author.ProxyIconUrl ?? default(Optional), diff --git a/src/Tgstation.Server.Host/Components/Interop/ChatEmbedProvider.cs b/src/Tgstation.Server.Host/Components/Interop/ChatEmbedProvider.cs index c7a29b039e..bc4dba30d7 100644 --- a/src/Tgstation.Server.Host/Components/Interop/ChatEmbedProvider.cs +++ b/src/Tgstation.Server.Host/Components/Interop/ChatEmbedProvider.cs @@ -1,6 +1,4 @@ -#nullable disable - -namespace Tgstation.Server.Host.Components.Interop +namespace Tgstation.Server.Host.Components.Interop { /// /// Represents information about a provider. @@ -10,13 +8,13 @@ namespace Tgstation.Server.Host.Components.Interop /// /// Gets the name of the provider. /// - public string Name { get; set; } + public string? Name { get; set; } /// /// Gets the URL of the provider. /// #pragma warning disable CA1056 // Uri properties should not be strings - public string Url { get; set; } + public string? Url { get; set; } #pragma warning restore CA1056 // Uri properties should not be strings } } From 617dea50c3e420c987d24ac0efad82747226bbd1 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 23 Dec 2023 10:15:56 -0500 Subject: [PATCH 369/425] Nullify `ChatMessage` --- src/Tgstation.Server.Host/Components/Interop/ChatMessage.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Interop/ChatMessage.cs b/src/Tgstation.Server.Host/Components/Interop/ChatMessage.cs index 2178cc1a1d..c84e44e6cc 100644 --- a/src/Tgstation.Server.Host/Components/Interop/ChatMessage.cs +++ b/src/Tgstation.Server.Host/Components/Interop/ChatMessage.cs @@ -1,7 +1,5 @@ using System.Collections.Generic; -#nullable disable - namespace Tgstation.Server.Host.Components.Interop { /// @@ -12,6 +10,6 @@ namespace Tgstation.Server.Host.Components.Interop /// /// The of s to sent the to. Must be safe to parse as s. /// - public ICollection ChannelIds { get; set; } + public ICollection? ChannelIds { get; set; } } } From 545717fc4835ce04c7e611e6df7ccaf853dee3eb Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 23 Dec 2023 10:16:28 -0500 Subject: [PATCH 370/425] Nullify `ChatUpdate` --- src/Tgstation.Server.Host/Components/Interop/ChatUpdate.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Interop/ChatUpdate.cs b/src/Tgstation.Server.Host/Components/Interop/ChatUpdate.cs index af902de7b6..12e9b408ab 100644 --- a/src/Tgstation.Server.Host/Components/Interop/ChatUpdate.cs +++ b/src/Tgstation.Server.Host/Components/Interop/ChatUpdate.cs @@ -4,8 +4,6 @@ using System.Linq; using Tgstation.Server.Host.Components.Chat; -#nullable disable - namespace Tgstation.Server.Host.Components.Interop { /// From 62ef4e3b9b3cd8a45cf9b74d76e1b05d6c740d2a Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 23 Dec 2023 10:16:47 -0500 Subject: [PATCH 371/425] Nullify `ChunkData` --- src/Tgstation.Server.Host/Components/Interop/ChunkData.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Interop/ChunkData.cs b/src/Tgstation.Server.Host/Components/Interop/ChunkData.cs index 8c442413c5..409179b660 100644 --- a/src/Tgstation.Server.Host/Components/Interop/ChunkData.cs +++ b/src/Tgstation.Server.Host/Components/Interop/ChunkData.cs @@ -1,6 +1,4 @@ -#nullable disable - -namespace Tgstation.Server.Host.Components.Interop +namespace Tgstation.Server.Host.Components.Interop { /// /// A packet of a split serialized set of data. @@ -16,6 +14,6 @@ namespace Tgstation.Server.Host.Components.Interop /// /// The partial JSON payload of the chunk. /// - public string Payload { get; set; } + public string? Payload { get; set; } } } From f847ec6b6e8b7997552e8e25acfc203c1c177d4b Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 23 Dec 2023 10:20:01 -0500 Subject: [PATCH 372/425] Nullify `Chunker` --- .../Components/Interop/Chunker.cs | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Interop/Chunker.cs b/src/Tgstation.Server.Host/Components/Interop/Chunker.cs index df02f84e61..c95d97b9e6 100644 --- a/src/Tgstation.Server.Host/Components/Interop/Chunker.cs +++ b/src/Tgstation.Server.Host/Components/Interop/Chunker.cs @@ -7,8 +7,6 @@ using Microsoft.Extensions.Logging; using Newtonsoft.Json; -#nullable disable - namespace Tgstation.Server.Host.Components.Interop { /// @@ -16,6 +14,11 @@ namespace Tgstation.Server.Host.Components.Interop /// abstract class Chunker { + /// + /// The for the . + /// + protected ILogger Logger { get; } + /// /// Gets a payload ID for use in a new . /// @@ -41,11 +44,6 @@ namespace Tgstation.Server.Host.Components.Interop /// uint highestSeenPayloadId; - /// - /// The for the . - /// - protected ILogger Logger { get; } - /// /// Initializes a new instance of the class. /// @@ -67,7 +65,7 @@ namespace Tgstation.Server.Host.Components.Interop /// The for the operation. /// A resulting in the for the chunked request. protected async ValueTask ProcessChunk( - Func> completionCallback, + Func> completionCallback, Func chunkErrorCallback, ChunkData chunk, CancellationToken cancellationToken) @@ -82,6 +80,9 @@ namespace Tgstation.Server.Host.Components.Interop if (!chunk.SequenceId.HasValue) return chunkErrorCallback("Missing chunk sequenceId!"); + if (chunk.Payload == null) + return chunkErrorCallback("Missing chunk payload!"); + ChunkSetInfo requestInfo; string[] payloads; lock (chunkSets) @@ -104,13 +105,13 @@ namespace Tgstation.Server.Host.Components.Interop if (chunk.TotalChunks != requestInfo.TotalChunks) { - chunkSets.Remove(requestInfo.PayloadId.Value); + chunkSets.Remove(requestInfo.PayloadId!.Value); return chunkErrorCallback("Received differing total chunks for same payloadId! Invalidating payloadId!"); } if (payloads[chunk.SequenceId.Value] != null && payloads[chunk.SequenceId.Value] != chunk.Payload) { - chunkSets.Remove(requestInfo.PayloadId.Value); + chunkSets.Remove(requestInfo.PayloadId!.Value); return chunkErrorCallback("Received differing payload for same sequenceId! Invalidating payloadId!"); } @@ -127,10 +128,10 @@ namespace Tgstation.Server.Host.Components.Interop }; Logger.LogTrace("Received all chunks for P{payloadId}, processing request...", requestInfo.PayloadId); - chunkSets.Remove(requestInfo.PayloadId.Value); + chunkSets.Remove(requestInfo.PayloadId!.Value); } - TCommunication completedCommunication; + TCommunication? completedCommunication; var fullCommunicationJson = String.Concat(payloads); try { From 0d64959ebdbab705cf39122e9f4b173c6a7fad1f Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 23 Dec 2023 10:21:24 -0500 Subject: [PATCH 373/425] Nullify `DMApiConstants` --- .../Components/Interop/DMApiConstants.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Interop/DMApiConstants.cs b/src/Tgstation.Server.Host/Components/Interop/DMApiConstants.cs index def2cb27e7..7386e85669 100644 --- a/src/Tgstation.Server.Host/Components/Interop/DMApiConstants.cs +++ b/src/Tgstation.Server.Host/Components/Interop/DMApiConstants.cs @@ -6,8 +6,6 @@ using Newtonsoft.Json.Serialization; using Tgstation.Server.Host.Extensions.Converters; using Tgstation.Server.Host.Properties; -#nullable disable - namespace Tgstation.Server.Host.Components.Interop { /// @@ -42,12 +40,12 @@ namespace Tgstation.Server.Host.Components.Interop public const uint MaximumBridgeRequestLength = 8198; /// - /// The maximum length in bytes of a payload. + /// The maximum length in bytes of a payload. /// public const uint MaximumTopicRequestLength = 65528; /// - /// The maximum length in bytes of a response. + /// The maximum length in bytes of a response. /// public const uint MaximumTopicResponseLength = 65529; From aa0fe2ed72a6a7d81081e72f736bf1befd807619 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 23 Dec 2023 10:30:44 -0500 Subject: [PATCH 374/425] Nullify `DMApiParameters` --- .../Components/InstanceManager.cs | 16 +++++++++++++--- .../Components/Interop/DMApiParameters.cs | 4 +--- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/InstanceManager.cs b/src/Tgstation.Server.Host/Components/InstanceManager.cs index eeadde0c30..cc0dd09972 100644 --- a/src/Tgstation.Server.Host/Components/InstanceManager.cs +++ b/src/Tgstation.Server.Host/Components/InstanceManager.cs @@ -510,6 +510,13 @@ namespace Tgstation.Server.Host.Components { ArgumentNullException.ThrowIfNull(parameters); + var accessIdentifier = parameters.AccessIdentifier; + if (accessIdentifier == null) + { + logger.LogWarning("Received invalid bridge request with null access identifier!"); + return null; + } + IBridgeHandler? bridgeHandler = null; for (var i = 0; bridgeHandler == null && i < 30; ++i) { @@ -517,7 +524,7 @@ namespace Tgstation.Server.Host.Components // This is a stopgap Task delayTask = Task.CompletedTask; lock (bridgeHandlers) - if (!bridgeHandlers.TryGetValue(parameters.AccessIdentifier, out bridgeHandler)) + if (!bridgeHandlers.TryGetValue(accessIdentifier, out bridgeHandler)) delayTask = asyncDelayer.Delay(TimeSpan.FromMilliseconds(100), cancellationToken); await delayTask; @@ -525,9 +532,9 @@ namespace Tgstation.Server.Host.Components if (bridgeHandler == null) lock (bridgeHandlers) - if (!bridgeHandlers.TryGetValue(parameters.AccessIdentifier, out bridgeHandler)) + if (!bridgeHandlers.TryGetValue(accessIdentifier, out bridgeHandler)) { - logger.LogWarning("Received invalid bridge request with access identifier: {accessIdentifier}", parameters.AccessIdentifier); + logger.LogWarning("Received invalid bridge request with access identifier: {accessIdentifier}", accessIdentifier); return null; } @@ -540,6 +547,9 @@ namespace Tgstation.Server.Host.Components ArgumentNullException.ThrowIfNull(bridgeHandler); var accessIdentifier = bridgeHandler.DMApiParameters.AccessIdentifier; + if (accessIdentifier == null) + throw new InvalidOperationException("Attempted bridge registration with null AccessIdentifier!"); + lock (bridgeHandlers) { bridgeHandlers.Add(accessIdentifier, bridgeHandler); diff --git a/src/Tgstation.Server.Host/Components/Interop/DMApiParameters.cs b/src/Tgstation.Server.Host/Components/Interop/DMApiParameters.cs index 55954dd38d..2a31c9efbc 100644 --- a/src/Tgstation.Server.Host/Components/Interop/DMApiParameters.cs +++ b/src/Tgstation.Server.Host/Components/Interop/DMApiParameters.cs @@ -1,7 +1,5 @@ using System.ComponentModel.DataAnnotations; -#nullable disable - namespace Tgstation.Server.Host.Components.Interop { /// @@ -13,6 +11,6 @@ namespace Tgstation.Server.Host.Components.Interop /// Used to identify and authenticate the DreamDaemon instance. /// [Required] - public string AccessIdentifier { get; set; } + public string? AccessIdentifier { get; set; } } } From b6cb32c54a1367116a834921e5a8907a911c1ada Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 23 Dec 2023 10:31:04 -0500 Subject: [PATCH 375/425] Nullify `DMApiResponse` --- .../Components/Interop/DMApiResponse.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Interop/DMApiResponse.cs b/src/Tgstation.Server.Host/Components/Interop/DMApiResponse.cs index 1196d8aa6f..e6c7502063 100644 --- a/src/Tgstation.Server.Host/Components/Interop/DMApiResponse.cs +++ b/src/Tgstation.Server.Host/Components/Interop/DMApiResponse.cs @@ -1,6 +1,4 @@ -#nullable disable - -namespace Tgstation.Server.Host.Components.Interop +namespace Tgstation.Server.Host.Components.Interop { /// /// Common base for interop responses. @@ -10,6 +8,6 @@ namespace Tgstation.Server.Host.Components.Interop /// /// Any errors in the client's parameters. /// - public string ErrorMessage { get; set; } + public string? ErrorMessage { get; set; } } } From 047618c4c46fd94a56e7f40735c8adb1263a168b Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 23 Dec 2023 10:31:19 -0500 Subject: [PATCH 376/425] Nullify `IMissingPayloadsCommunication` --- .../Components/Interop/IMissingPayloadsCommunication.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Interop/IMissingPayloadsCommunication.cs b/src/Tgstation.Server.Host/Components/Interop/IMissingPayloadsCommunication.cs index 77c3ebff3f..7adf7d9cce 100644 --- a/src/Tgstation.Server.Host/Components/Interop/IMissingPayloadsCommunication.cs +++ b/src/Tgstation.Server.Host/Components/Interop/IMissingPayloadsCommunication.cs @@ -1,7 +1,5 @@ using System.Collections.Generic; -#nullable disable - namespace Tgstation.Server.Host.Components.Interop { /// @@ -12,6 +10,6 @@ namespace Tgstation.Server.Host.Components.Interop /// /// The s missing from a chunked request. /// - IReadOnlyCollection MissingChunks { get; set; } + IReadOnlyCollection? MissingChunks { get; set; } } } From ffbf0f5ba77b1eecedc0bcce71692740693c2cc0 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 23 Dec 2023 10:34:49 -0500 Subject: [PATCH 377/425] Nullify `MessageContent` --- .../Chat/Providers/DiscordProvider.cs | 18 +++++++++++++++++- .../Components/Interop/MessageContent.cs | 8 +++----- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Chat/Providers/DiscordProvider.cs b/src/Tgstation.Server.Host/Components/Chat/Providers/DiscordProvider.cs index 02914f87d7..6f7ad59c5a 100644 --- a/src/Tgstation.Server.Host/Components/Chat/Providers/DiscordProvider.cs +++ b/src/Tgstation.Server.Host/Components/Chat/Providers/DiscordProvider.cs @@ -218,6 +218,22 @@ namespace Tgstation.Server.Host.Components.Chat.Providers var channelsClient = serviceProvider.GetRequiredService(); async ValueTask SendToChannel(Snowflake channelId) { + if (message.Text == null) + { + Logger.LogWarning( + "Failed to send to channel {channelId}: Message was null!", + channelId); + + await channelsClient.CreateMessageAsync( + channelId, + "TGS: Could not send message to Discord. Message was `null`!", + messageReference: replyToReference, + allowedMentions: allowedMentions, + ct: cancellationToken); + + return; + } + var result = await channelsClient.CreateMessageAsync( channelId, message.Text, @@ -940,7 +956,7 @@ namespace Tgstation.Server.Host.Components.Chat.Providers /// The to convert. /// The parameter for sending a single . #pragma warning disable CA1502 - Optional> ConvertEmbed(ChatEmbed embed) + Optional> ConvertEmbed(ChatEmbed? embed) { if (embed == null) return default; diff --git a/src/Tgstation.Server.Host/Components/Interop/MessageContent.cs b/src/Tgstation.Server.Host/Components/Interop/MessageContent.cs index 73e2980906..6b04fb10ae 100644 --- a/src/Tgstation.Server.Host/Components/Interop/MessageContent.cs +++ b/src/Tgstation.Server.Host/Components/Interop/MessageContent.cs @@ -1,6 +1,4 @@ -#nullable disable - -namespace Tgstation.Server.Host.Components.Interop +namespace Tgstation.Server.Host.Components.Interop { /// /// Represents a message to send to a chat provider. @@ -10,11 +8,11 @@ namespace Tgstation.Server.Host.Components.Interop /// /// The message . /// - public string Text { get; set; } + public string? Text { get; set; } /// /// The . /// - public ChatEmbed Embed { get; set; } + public ChatEmbed? Embed { get; set; } } } From c4da6df175cd090e0cd395a5fa52ffc8b9106920 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 23 Dec 2023 10:35:06 -0500 Subject: [PATCH 378/425] Simplify a null check --- src/Tgstation.Server.Host/Components/InstanceManager.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/InstanceManager.cs b/src/Tgstation.Server.Host/Components/InstanceManager.cs index cc0dd09972..613b9d7800 100644 --- a/src/Tgstation.Server.Host/Components/InstanceManager.cs +++ b/src/Tgstation.Server.Host/Components/InstanceManager.cs @@ -546,10 +546,8 @@ namespace Tgstation.Server.Host.Components { ArgumentNullException.ThrowIfNull(bridgeHandler); - var accessIdentifier = bridgeHandler.DMApiParameters.AccessIdentifier; - if (accessIdentifier == null) - throw new InvalidOperationException("Attempted bridge registration with null AccessIdentifier!"); - + var accessIdentifier = bridgeHandler.DMApiParameters.AccessIdentifier + ?? throw new InvalidOperationException("Attempted bridge registration with null AccessIdentifier!"); lock (bridgeHandlers) { bridgeHandlers.Add(accessIdentifier, bridgeHandler); From a4258d137e4a28da8bb741124ffcb2eb33a09178 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 23 Dec 2023 11:02:14 -0500 Subject: [PATCH 379/425] Rework `DMApiParameters.AccessIdentifier` to be properly non-nullble --- .../Interop/Bridge/BridgeParameters.cs | 9 ++++++++ .../Components/Interop/DMApiParameters.cs | 23 +++++++++++++++++-- .../Interop/Topic/TopicParameters.cs | 1 + .../Components/Session/ReattachInformation.cs | 3 +-- .../Components/Session/SessionPersistor.cs | 5 ++-- .../Controllers/BridgeController.cs | 4 ++-- .../Models/ReattachInformation.cs | 20 +++++++++++++++- .../Models/ReattachInformationBase.cs | 15 ++++++++++-- .../Live/Instance/TestBridgeHandler.cs | 13 +++++++---- 9 files changed, 76 insertions(+), 17 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Interop/Bridge/BridgeParameters.cs b/src/Tgstation.Server.Host/Components/Interop/Bridge/BridgeParameters.cs index e633a4c240..1240bc81cb 100644 --- a/src/Tgstation.Server.Host/Components/Interop/Bridge/BridgeParameters.cs +++ b/src/Tgstation.Server.Host/Components/Interop/Bridge/BridgeParameters.cs @@ -50,5 +50,14 @@ namespace Tgstation.Server.Host.Components.Interop.Bridge /// The port that should be used to send world topics, if not the default. /// public ushort? TopicPort { get; set; } + + /// + /// Initializes a new instance of the class. + /// + /// The access identifier for the . + public BridgeParameters(string accessIdentifier) + : base(accessIdentifier) + { + } } } diff --git a/src/Tgstation.Server.Host/Components/Interop/DMApiParameters.cs b/src/Tgstation.Server.Host/Components/Interop/DMApiParameters.cs index 2a31c9efbc..64b774aeb5 100644 --- a/src/Tgstation.Server.Host/Components/Interop/DMApiParameters.cs +++ b/src/Tgstation.Server.Host/Components/Interop/DMApiParameters.cs @@ -1,4 +1,5 @@ -using System.ComponentModel.DataAnnotations; +using System; +using System.ComponentModel.DataAnnotations; namespace Tgstation.Server.Host.Components.Interop { @@ -11,6 +12,24 @@ namespace Tgstation.Server.Host.Components.Interop /// Used to identify and authenticate the DreamDaemon instance. /// [Required] - public string? AccessIdentifier { get; set; } + public string AccessIdentifier { get; set; } + + /// + /// Initializes a new instance of the class. + /// + /// The value of . + public DMApiParameters(string accessIdentifier) + { + AccessIdentifier = accessIdentifier ?? throw new ArgumentNullException(nameof(accessIdentifier)); + } + + /// + /// Initializes a new instance of the class. + /// + /// For use by EFCore only. + protected DMApiParameters() + { + AccessIdentifier = null!; + } } } diff --git a/src/Tgstation.Server.Host/Components/Interop/Topic/TopicParameters.cs b/src/Tgstation.Server.Host/Components/Interop/Topic/TopicParameters.cs index f84a404289..bdc8405b02 100644 --- a/src/Tgstation.Server.Host/Components/Interop/Topic/TopicParameters.cs +++ b/src/Tgstation.Server.Host/Components/Interop/Topic/TopicParameters.cs @@ -188,6 +188,7 @@ namespace Tgstation.Server.Host.Components.Interop.Topic /// /// The value of . protected TopicParameters(TopicCommandType commandType) + : base(String.Empty) // access identifier gets set before send { CommandType = commandType; } diff --git a/src/Tgstation.Server.Host/Components/Session/ReattachInformation.cs b/src/Tgstation.Server.Host/Components/Session/ReattachInformation.cs index 3ddeff51d7..31aa0834b7 100644 --- a/src/Tgstation.Server.Host/Components/Session/ReattachInformation.cs +++ b/src/Tgstation.Server.Host/Components/Session/ReattachInformation.cs @@ -74,13 +74,12 @@ namespace Tgstation.Server.Host.Components.Session RuntimeInformation runtimeInformation, string accessIdentifier, ushort port) + : base(accessIdentifier) { Dmb = dmb ?? throw new ArgumentNullException(nameof(dmb)); ProcessId = process?.Id ?? throw new ArgumentNullException(nameof(process)); RuntimeInformation = runtimeInformation ?? throw new ArgumentNullException(nameof(runtimeInformation)); - AccessIdentifier = accessIdentifier ?? throw new ArgumentNullException(nameof(accessIdentifier)); - LaunchSecurityLevel = runtimeInformation.SecurityLevel; LaunchVisibility = runtimeInformation.Visibility; Port = port; diff --git a/src/Tgstation.Server.Host/Components/Session/SessionPersistor.cs b/src/Tgstation.Server.Host/Components/Session/SessionPersistor.cs index 7eebd9a2af..2cd093c3ee 100644 --- a/src/Tgstation.Server.Host/Components/Session/SessionPersistor.cs +++ b/src/Tgstation.Server.Host/Components/Session/SessionPersistor.cs @@ -75,9 +75,8 @@ namespace Tgstation.Server.Host.Components.Session await ClearImpl(db, false, cancellationToken); - var dbReattachInfo = new Models.ReattachInformation + var dbReattachInfo = new Models.ReattachInformation(reattachInformation.AccessIdentifier) { - AccessIdentifier = reattachInformation.AccessIdentifier, CompileJobId = reattachInformation.Dmb.CompileJob.Id.Value, InitialCompileJobId = reattachInformation.InitialDmb?.CompileJob.Id.Value, Port = reattachInformation.Port, @@ -103,7 +102,7 @@ namespace Tgstation.Server.Host.Components.Session logger.LogTrace("Updating reattach information: {info}...", reattachInformation); - var dbReattachInfo = new Models.ReattachInformation + var dbReattachInfo = new Models.ReattachInformation(String.Empty) { Id = reattachInformation.Id.Value, }; diff --git a/src/Tgstation.Server.Host/Controllers/BridgeController.cs b/src/Tgstation.Server.Host/Controllers/BridgeController.cs index c4d33be706..4b1a1fac3e 100644 --- a/src/Tgstation.Server.Host/Controllers/BridgeController.cs +++ b/src/Tgstation.Server.Host/Controllers/BridgeController.cs @@ -97,10 +97,10 @@ namespace Tgstation.Server.Host.Controllers using (LogContext.PushProperty(SerilogContextHelper.BridgeRequestIterationContextProperty, Interlocked.Increment(ref requestsProcessed))) { - var request = new BridgeParameters(); + BridgeParameters? request; try { - JsonConvert.PopulateObject(data, request, DMApiConstants.SerializerSettings); + request = JsonConvert.DeserializeObject(data, DMApiConstants.SerializerSettings); } catch (Exception ex) { diff --git a/src/Tgstation.Server.Host/Models/ReattachInformation.cs b/src/Tgstation.Server.Host/Models/ReattachInformation.cs index 9454e4acf6..49360cf3e5 100644 --- a/src/Tgstation.Server.Host/Models/ReattachInformation.cs +++ b/src/Tgstation.Server.Host/Models/ReattachInformation.cs @@ -1,4 +1,5 @@ -using System.ComponentModel.DataAnnotations; +using System; +using System.ComponentModel.DataAnnotations; namespace Tgstation.Server.Host.Models { @@ -27,5 +28,22 @@ namespace Tgstation.Server.Host.Models /// The of . /// public long? InitialCompileJobId { get; set; } + + /// + /// Initializes a new instance of the class. + /// + [Obsolete("For use by EFCore only", true)] + public ReattachInformation() + { + } + + /// + /// Initializes a new instance of the class. + /// + /// The access identifier for the . + public ReattachInformation(string accessIdentifier) + : base(accessIdentifier) + { + } } } diff --git a/src/Tgstation.Server.Host/Models/ReattachInformationBase.cs b/src/Tgstation.Server.Host/Models/ReattachInformationBase.cs index 3d3d4411cb..fc6d07a8f3 100644 --- a/src/Tgstation.Server.Host/Models/ReattachInformationBase.cs +++ b/src/Tgstation.Server.Host/Models/ReattachInformationBase.cs @@ -49,19 +49,30 @@ namespace Tgstation.Server.Host.Models /// /// Initializes a new instance of the class. /// + /// For use by EFCore only. protected ReattachInformationBase() { } + /// + /// Initializes a new instance of the class. + /// + /// The access identifier for the . + protected ReattachInformationBase(string accessIdentifier) + : base(accessIdentifier) + { + } + /// /// Initializes a new instance of the class. /// /// The to copy values from. protected ReattachInformationBase(ReattachInformationBase copy) + : base(copy == null + ? throw new ArgumentNullException(nameof(copy)) + : copy.AccessIdentifier) { - ArgumentNullException.ThrowIfNull(copy); Id = copy.Id; - AccessIdentifier = copy.AccessIdentifier; Port = copy.Port; TopicPort = copy.TopicPort; ProcessId = copy.ProcessId; diff --git a/tests/Tgstation.Server.Tests/Live/Instance/TestBridgeHandler.cs b/tests/Tgstation.Server.Tests/Live/Instance/TestBridgeHandler.cs index 4276067b19..e00421e295 100644 --- a/tests/Tgstation.Server.Tests/Live/Instance/TestBridgeHandler.cs +++ b/tests/Tgstation.Server.Tests/Live/Instance/TestBridgeHandler.cs @@ -15,17 +15,20 @@ namespace Tgstation.Server.Tests.Live.Instance { sealed class TestBridgeHandler : Chunker, IBridgeHandler { - class DMApiParametersImpl : DMApiParameters { } + class DMApiParametersImpl : DMApiParameters + { + public DMApiParametersImpl(string accessIdentifier) + : base(accessIdentifier) + { + } + } class BridgeResponseHack : BridgeResponse { public string IntegrationHack { get; set; } } - public DMApiParameters DMApiParameters => new DMApiParametersImpl - { - AccessIdentifier = accessIdentifier - }; + public DMApiParameters DMApiParameters => new DMApiParametersImpl(accessIdentifier); long lastBridgeRequestSize = 0; From 0f655f14d752d33732264aaf4b7540405c5014b9 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 23 Dec 2023 11:03:28 -0500 Subject: [PATCH 380/425] Nullify `DefaultGitRemoteFeatures` --- .../Components/Repository/DefaultGitRemoteFeatures.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Repository/DefaultGitRemoteFeatures.cs b/src/Tgstation.Server.Host/Components/Repository/DefaultGitRemoteFeatures.cs index c5909b7b84..05d9408a67 100644 --- a/src/Tgstation.Server.Host/Components/Repository/DefaultGitRemoteFeatures.cs +++ b/src/Tgstation.Server.Host/Components/Repository/DefaultGitRemoteFeatures.cs @@ -4,8 +4,6 @@ using System.Threading.Tasks; using Tgstation.Server.Api.Models; -#nullable disable - namespace Tgstation.Server.Host.Components.Repository { /// @@ -23,10 +21,10 @@ namespace Tgstation.Server.Host.Components.Repository public RemoteGitProvider? RemoteGitProvider => Api.Models.RemoteGitProvider.Unknown; /// - public string RemoteRepositoryOwner => null; + public string? RemoteRepositoryOwner => null; /// - public string RemoteRepositoryName => null; + public string? RemoteRepositoryName => null; /// public ValueTask GetTestMerge( From a1f4ed4ab4de0bf11f3cee65b903bac9ca17ff7a Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 23 Dec 2023 11:04:18 -0500 Subject: [PATCH 381/425] Nullify `GitHubRemoteFeatures` --- .../Components/Repository/GitHubRemoteFeatures.cs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Repository/GitHubRemoteFeatures.cs b/src/Tgstation.Server.Host/Components/Repository/GitHubRemoteFeatures.cs index 2aa9cb3312..609862d9ba 100644 --- a/src/Tgstation.Server.Host/Components/Repository/GitHubRemoteFeatures.cs +++ b/src/Tgstation.Server.Host/Components/Repository/GitHubRemoteFeatures.cs @@ -9,8 +9,6 @@ using Tgstation.Server.Api.Models; using Tgstation.Server.Api.Models.Internal; using Tgstation.Server.Host.Utils.GitHub; -#nullable disable - namespace Tgstation.Server.Host.Components.Repository { /// @@ -67,9 +65,9 @@ namespace Tgstation.Server.Host.Components.Repository ? gitHubServiceFactory.CreateService(repositorySettings.AccessToken) : gitHubServiceFactory.CreateService(); - PullRequest pr = null; - ApiException exception = null; - string errorMessage = null; + PullRequest? pr = null; + ApiException? exception = null; + string? errorMessage = null; try { pr = await gitHubService.GetPullRequest(RemoteRepositoryOwner, RemoteRepositoryName, parameters.Number, cancellationToken); From fc7c8b2c6314eb0f9db9675b0bcf24176dc13ad7 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 23 Dec 2023 11:04:44 -0500 Subject: [PATCH 382/425] Nullify `GitLabRemoteFeatures` --- .../Components/Repository/GitLabRemoteFeatures.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Repository/GitLabRemoteFeatures.cs b/src/Tgstation.Server.Host/Components/Repository/GitLabRemoteFeatures.cs index 1f34ceeacb..def1adbaaf 100644 --- a/src/Tgstation.Server.Host/Components/Repository/GitLabRemoteFeatures.cs +++ b/src/Tgstation.Server.Host/Components/Repository/GitLabRemoteFeatures.cs @@ -8,8 +8,6 @@ using Microsoft.Extensions.Logging; using Tgstation.Server.Api.Models; using Tgstation.Server.Api.Models.Internal; -#nullable disable - namespace Tgstation.Server.Host.Components.Repository { /// From 1d43e7a8517ebc2e53ce6c3a156d91eeef77926d Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 23 Dec 2023 11:05:36 -0500 Subject: [PATCH 383/425] Nullify `GitRemoteFeaturesBase` --- .../Components/Repository/GitRemoteFeaturesBase.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Repository/GitRemoteFeaturesBase.cs b/src/Tgstation.Server.Host/Components/Repository/GitRemoteFeaturesBase.cs index b0adfdb298..ffbf99fa81 100644 --- a/src/Tgstation.Server.Host/Components/Repository/GitRemoteFeaturesBase.cs +++ b/src/Tgstation.Server.Host/Components/Repository/GitRemoteFeaturesBase.cs @@ -8,8 +8,6 @@ using Microsoft.Extensions.Logging; using Tgstation.Server.Api.Models; using Tgstation.Server.Api.Models.Internal; -#nullable disable - namespace Tgstation.Server.Host.Components.Repository { /// @@ -64,7 +62,7 @@ namespace Tgstation.Server.Host.Components.Repository ArgumentNullException.ThrowIfNull(parameters); ArgumentNullException.ThrowIfNull(repositorySettings); - Models.TestMerge result; + Models.TestMerge? result; lock (cachedLookups) if (cachedLookups.TryGetValue(parameters, out result)) Logger.LogTrace("Using cache for test merge #{0}", parameters.Number); From e536b0238be7f6b66677e24582369b91156902b2 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 23 Dec 2023 11:07:20 -0500 Subject: [PATCH 384/425] Cleanup `GitRemoteFeaturesBase` - Fix logging templates. - Deduplicate constructor code. --- .../Components/Repository/GitHubRemoteFeatures.cs | 13 ------------- .../Components/Repository/GitLabRemoteFeatures.cs | 10 ---------- .../Repository/GitRemoteFeaturesBase.cs | 15 ++++++++++----- 3 files changed, 10 insertions(+), 28 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Repository/GitHubRemoteFeatures.cs b/src/Tgstation.Server.Host/Components/Repository/GitHubRemoteFeatures.cs index 609862d9ba..7a21ebde2b 100644 --- a/src/Tgstation.Server.Host/Components/Repository/GitHubRemoteFeatures.cs +++ b/src/Tgstation.Server.Host/Components/Repository/GitHubRemoteFeatures.cs @@ -25,12 +25,6 @@ namespace Tgstation.Server.Host.Components.Repository /// public override RemoteGitProvider? RemoteGitProvider => Api.Models.RemoteGitProvider.GitHub; - /// - public override string RemoteRepositoryOwner { get; } - - /// - public override string RemoteRepositoryName { get; } - /// /// The for the . /// @@ -46,13 +40,6 @@ namespace Tgstation.Server.Host.Components.Repository : base(logger, remoteUrl) { this.gitHubServiceFactory = gitHubServiceFactory ?? throw new ArgumentNullException(nameof(gitHubServiceFactory)); - - ArgumentNullException.ThrowIfNull(remoteUrl); - - RemoteRepositoryOwner = remoteUrl.Segments[1].TrimEnd('/'); - RemoteRepositoryName = remoteUrl.Segments[2].TrimEnd('/'); - if (RemoteRepositoryName.EndsWith(".git", StringComparison.OrdinalIgnoreCase)) - RemoteRepositoryName = RemoteRepositoryName[0..^4]; } /// diff --git a/src/Tgstation.Server.Host/Components/Repository/GitLabRemoteFeatures.cs b/src/Tgstation.Server.Host/Components/Repository/GitLabRemoteFeatures.cs index def1adbaaf..9e468b06e6 100644 --- a/src/Tgstation.Server.Host/Components/Repository/GitLabRemoteFeatures.cs +++ b/src/Tgstation.Server.Host/Components/Repository/GitLabRemoteFeatures.cs @@ -30,12 +30,6 @@ namespace Tgstation.Server.Host.Components.Repository /// public override RemoteGitProvider? RemoteGitProvider => Api.Models.RemoteGitProvider.GitLab; - /// - public override string RemoteRepositoryOwner { get; } - - /// - public override string RemoteRepositoryName { get; } - /// /// Initializes a new instance of the class. /// @@ -44,10 +38,6 @@ namespace Tgstation.Server.Host.Components.Repository public GitLabRemoteFeatures(ILogger logger, Uri remoteUrl) : base(logger, remoteUrl) { - RemoteRepositoryOwner = remoteUrl.Segments[1].TrimEnd('/'); - RemoteRepositoryName = remoteUrl.Segments[2].TrimEnd('/'); - if (RemoteRepositoryName.EndsWith(".git", StringComparison.OrdinalIgnoreCase)) - RemoteRepositoryName = RemoteRepositoryName[0..^4]; } /// diff --git a/src/Tgstation.Server.Host/Components/Repository/GitRemoteFeaturesBase.cs b/src/Tgstation.Server.Host/Components/Repository/GitRemoteFeaturesBase.cs index ffbf99fa81..d42e928792 100644 --- a/src/Tgstation.Server.Host/Components/Repository/GitRemoteFeaturesBase.cs +++ b/src/Tgstation.Server.Host/Components/Repository/GitRemoteFeaturesBase.cs @@ -25,10 +25,10 @@ namespace Tgstation.Server.Host.Components.Repository public abstract RemoteGitProvider? RemoteGitProvider { get; } /// - public abstract string RemoteRepositoryOwner { get; } + public string RemoteRepositoryOwner { get; } /// - public abstract string RemoteRepositoryName { get; } + public string RemoteRepositoryName { get; } /// /// The for the . @@ -50,6 +50,11 @@ namespace Tgstation.Server.Host.Components.Repository Logger = logger ?? throw new ArgumentNullException(nameof(logger)); ArgumentNullException.ThrowIfNull(remoteUrl); + RemoteRepositoryOwner = remoteUrl.Segments[1].TrimEnd('/'); + RemoteRepositoryName = remoteUrl.Segments[2].TrimEnd('/'); + if (RemoteRepositoryName.EndsWith(".git", StringComparison.OrdinalIgnoreCase)) + RemoteRepositoryName = RemoteRepositoryName[0..^4]; + cachedLookups = new Dictionary(); } @@ -65,15 +70,15 @@ namespace Tgstation.Server.Host.Components.Repository Models.TestMerge? result; lock (cachedLookups) if (cachedLookups.TryGetValue(parameters, out result)) - Logger.LogTrace("Using cache for test merge #{0}", parameters.Number); + Logger.LogTrace("Using cache for test merge #{testMergeNumber}", parameters.Number); if (result == null) { - Logger.LogTrace("Retrieving metadata for test merge #{0}...", parameters.Number); + Logger.LogTrace("Retrieving metadata for test merge #{testMergeNumber}...", parameters.Number); result = await GetTestMergeImpl(parameters, repositorySettings, cancellationToken); lock (cachedLookups) if (!cachedLookups.TryAdd(parameters, result)) - Logger.LogError("Race condition on adding test merge #{0}!", parameters.Number); + Logger.LogError("Race condition on adding test merge #{testMergeNumber}!", parameters.Number); } return result; From 9a0ec666123aa7825a0091470c3c4ce121d8327d Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 23 Dec 2023 11:08:17 -0500 Subject: [PATCH 385/425] Nullify `GitRemoteFeaturesFactory` Also cleanup logging --- .../Components/Repository/GitRemoteFeaturesFactory.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Repository/GitRemoteFeaturesFactory.cs b/src/Tgstation.Server.Host/Components/Repository/GitRemoteFeaturesFactory.cs index 2c7c222071..70694d0b94 100644 --- a/src/Tgstation.Server.Host/Components/Repository/GitRemoteFeaturesFactory.cs +++ b/src/Tgstation.Server.Host/Components/Repository/GitRemoteFeaturesFactory.cs @@ -5,8 +5,6 @@ using Microsoft.Extensions.Logging; using Tgstation.Server.Api.Models; using Tgstation.Server.Host.Utils.GitHub; -#nullable disable - namespace Tgstation.Server.Host.Components.Repository { /// @@ -80,7 +78,7 @@ namespace Tgstation.Server.Host.Components.Repository case "GIT.GITLAB.COM": return RemoteGitProvider.GitLab; default: - logger.LogTrace("Unknown git remote: {0}", origin); + logger.LogDebug("Unknown git remote: {origin}", origin); return RemoteGitProvider.Unknown; } } From 73c309178319c26e5e4f0f53791b80231ef2e5d8 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 23 Dec 2023 11:08:40 -0500 Subject: [PATCH 386/425] Nullify `ICredentialsProvider` --- .../Components/Repository/ICredentialsProvider.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Repository/ICredentialsProvider.cs b/src/Tgstation.Server.Host/Components/Repository/ICredentialsProvider.cs index d120754a5e..1324c35320 100644 --- a/src/Tgstation.Server.Host/Components/Repository/ICredentialsProvider.cs +++ b/src/Tgstation.Server.Host/Components/Repository/ICredentialsProvider.cs @@ -3,8 +3,6 @@ using LibGit2Sharp.Handlers; using Tgstation.Server.Host.Jobs; -#nullable disable - namespace Tgstation.Server.Host.Components.Repository { /// @@ -18,7 +16,7 @@ namespace Tgstation.Server.Host.Components.Repository /// The optional username to use in the . /// The optional password to use in the . /// A new . - CredentialsHandler GenerateCredentialsHandler(string username, string password); + CredentialsHandler GenerateCredentialsHandler(string? username, string? password); /// /// Rethrow the authentication failure message as a if it is one. From f826a1beafbe9581ba1058f1242f5eea84e61e86 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 23 Dec 2023 11:08:53 -0500 Subject: [PATCH 387/425] Nullify `IGitRemoteAdditionalInformation` --- .../Components/Repository/IGitRemoteAdditionalInformation.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Repository/IGitRemoteAdditionalInformation.cs b/src/Tgstation.Server.Host/Components/Repository/IGitRemoteAdditionalInformation.cs index a933a85ad1..ffead020f9 100644 --- a/src/Tgstation.Server.Host/Components/Repository/IGitRemoteAdditionalInformation.cs +++ b/src/Tgstation.Server.Host/Components/Repository/IGitRemoteAdditionalInformation.cs @@ -4,8 +4,6 @@ using System.Threading.Tasks; using Tgstation.Server.Api.Models; using Tgstation.Server.Api.Models.Internal; -#nullable disable - namespace Tgstation.Server.Host.Components.Repository { /// From 4d7991b2ddc319b3ae592e14746c6ab64e95f7ea Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 23 Dec 2023 11:09:14 -0500 Subject: [PATCH 388/425] Nullify `IGitRemoteFeaturesFactory` --- .../Components/Repository/IGitRemoteFeaturesFactory.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Repository/IGitRemoteFeaturesFactory.cs b/src/Tgstation.Server.Host/Components/Repository/IGitRemoteFeaturesFactory.cs index dd4ee7de3a..42a55e6285 100644 --- a/src/Tgstation.Server.Host/Components/Repository/IGitRemoteFeaturesFactory.cs +++ b/src/Tgstation.Server.Host/Components/Repository/IGitRemoteFeaturesFactory.cs @@ -2,8 +2,6 @@ using Tgstation.Server.Api.Models; -#nullable disable - namespace Tgstation.Server.Host.Components.Repository { /// From 992b1710f8e4e99a8654671570c49c528dbd9603 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 23 Dec 2023 11:09:30 -0500 Subject: [PATCH 389/425] Nullify `ILibGit2Commands` --- .../Components/Repository/ILibGit2Commands.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Repository/ILibGit2Commands.cs b/src/Tgstation.Server.Host/Components/Repository/ILibGit2Commands.cs index e4fc821ec4..6c0ab0da49 100644 --- a/src/Tgstation.Server.Host/Components/Repository/ILibGit2Commands.cs +++ b/src/Tgstation.Server.Host/Components/Repository/ILibGit2Commands.cs @@ -2,8 +2,6 @@ using LibGit2Sharp; -#nullable disable - namespace Tgstation.Server.Host.Components.Repository { /// From 24615ba010fe938f8cc41da4c2be1ad02c26e907 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 23 Dec 2023 11:09:45 -0500 Subject: [PATCH 390/425] Nullify `ILibGit2RepositoryFactory` --- .../Components/Repository/ILibGit2RepositoryFactory.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Repository/ILibGit2RepositoryFactory.cs b/src/Tgstation.Server.Host/Components/Repository/ILibGit2RepositoryFactory.cs index b69df2783f..34b8c56669 100644 --- a/src/Tgstation.Server.Host/Components/Repository/ILibGit2RepositoryFactory.cs +++ b/src/Tgstation.Server.Host/Components/Repository/ILibGit2RepositoryFactory.cs @@ -4,8 +4,6 @@ using System.Threading.Tasks; using LibGit2Sharp; -#nullable disable - namespace Tgstation.Server.Host.Components.Repository { /// From 9e761240a3d1cf87bbc165a009348ca081f69b0c Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 23 Dec 2023 11:33:57 -0500 Subject: [PATCH 391/425] Nullify `IRepository` --- .../Components/Instance.cs | 8 ++-- .../Components/Repository/IRepository.cs | 42 +++++++++---------- 2 files changed, 24 insertions(+), 26 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Instance.cs b/src/Tgstation.Server.Host/Components/Instance.cs index 38932c5277..0973cd9322 100644 --- a/src/Tgstation.Server.Host/Components/Instance.cs +++ b/src/Tgstation.Server.Host/Components/Instance.cs @@ -392,8 +392,8 @@ namespace Tgstation.Server.Host.Components var result = await repo.MergeOrigin( NextProgressReporter("Merge Origin"), - repositorySettings.CommitterName, - repositorySettings.CommitterEmail, + repositorySettings.CommitterName!, + repositorySettings.CommitterEmail!, true, cancellationToken); @@ -456,8 +456,8 @@ namespace Tgstation.Server.Host.Components NextProgressReporter("Synchronize"), repositorySettings.AccessUser, repositorySettings.AccessToken, - repositorySettings.CommitterName, - repositorySettings.CommitterEmail, + repositorySettings.CommitterName!, + repositorySettings.CommitterEmail!, shouldSyncTracked, true, cancellationToken); diff --git a/src/Tgstation.Server.Host/Components/Repository/IRepository.cs b/src/Tgstation.Server.Host/Components/Repository/IRepository.cs index ed858ab492..795e264609 100644 --- a/src/Tgstation.Server.Host/Components/Repository/IRepository.cs +++ b/src/Tgstation.Server.Host/Components/Repository/IRepository.cs @@ -5,8 +5,6 @@ using System.Threading.Tasks; using Tgstation.Server.Api.Models; using Tgstation.Server.Host.Jobs; -#nullable disable - namespace Tgstation.Server.Host.Components.Repository { /// @@ -46,18 +44,18 @@ namespace Tgstation.Server.Host.Components.Repository /// Checks out a given . /// /// The sha or reference to checkout. - /// The username used for fetching from submodule repositories. - /// The password used for fetching from submodule repositories. + /// The optional username used for fetching from submodule repositories. + /// The optional password used for fetching from submodule repositories. /// If a submodule update should be attempted after the merge. /// The optional to report progress of the operation. /// The for the operation. /// A representing the running operation. ValueTask CheckoutObject( string committish, - string username, - string password, + string? username, + string? password, bool updateSubmodules, - JobProgressReporter progressReporter, + JobProgressReporter? progressReporter, CancellationToken cancellationToken); /// @@ -66,8 +64,8 @@ namespace Tgstation.Server.Host.Components.Repository /// The of the pull request. /// The name of the merge committer. /// The e-mail of the merge committer. - /// The username used to fetch from the origin and submodule repositories. - /// The password used to fetch from the origin and submodule repositories. + /// The optional username used to fetch from the origin and submodule repositories. + /// The optional password used to fetch from the origin and submodule repositories. /// If a submodule update should be attempted after the merge. /// The to report progress of the operation. /// The for the operation. @@ -76,8 +74,8 @@ namespace Tgstation.Server.Host.Components.Repository TestMergeParameters testMergeParameters, string committerName, string committerEmail, - string username, - string password, + string? username, + string? password, bool updateSubmodules, JobProgressReporter progressReporter, CancellationToken cancellationToken); @@ -86,15 +84,15 @@ namespace Tgstation.Server.Host.Components.Repository /// Fetch commits from the origin repository. /// /// The optional to report progress of the operation. - /// The username to fetch from the origin repository. - /// The password to fetch from the origin repository. + /// The optional username to fetch from the origin repository. + /// The optional password to fetch from the origin repository. /// If any events created should be marked as part of the deployment pipeline. /// The for the operation. /// A representing the running operation. ValueTask FetchOrigin( - JobProgressReporter progressReporter, - string username, - string password, + JobProgressReporter? progressReporter, + string? username, + string? password, bool deploymentPipeline, CancellationToken cancellationToken); @@ -102,16 +100,16 @@ namespace Tgstation.Server.Host.Components.Repository /// Requires the current HEAD to be a tracked reference. Hard resets the reference to what it tracks on the origin repository. /// /// The to report progress of the operation. - /// The username used for fetching from submodule repositories. - /// The password used for fetching from submodule repositories. + /// The optional username used for fetching from submodule repositories. + /// The optional password used for fetching from submodule repositories. /// If a submodule update should be attempted after the merge. /// If any events created should be marked as part of the deployment pipeline. /// The for the operation. /// A resulting in the SHA of the new HEAD. ValueTask ResetToOrigin( JobProgressReporter progressReporter, - string username, - string password, + string? username, + string? password, bool updateSubmodules, bool deploymentPipeline, CancellationToken cancellationToken); @@ -155,8 +153,8 @@ namespace Tgstation.Server.Host.Components.Repository /// A resulting in if commits were pushed to the tracked origin reference, otherwise. ValueTask Sychronize( JobProgressReporter progressReporter, - string username, - string password, + string? username, + string? password, string committerName, string committerEmail, bool synchronizeTrackedBranch, From 9aaad784ac9bc81789338f6df704e19f742905b9 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 23 Dec 2023 11:36:50 -0500 Subject: [PATCH 392/425] Nullify `IRepositoryManager` --- .../Components/Engine/OpenDreamInstaller.cs | 2 +- .../Components/Instance.cs | 3 +++ .../Repository/IRepositoryManager.cs | 20 +++++++++---------- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Engine/OpenDreamInstaller.cs b/src/Tgstation.Server.Host/Components/Engine/OpenDreamInstaller.cs index 5244816ead..a2b74e1445 100644 --- a/src/Tgstation.Server.Host/Components/Engine/OpenDreamInstaller.cs +++ b/src/Tgstation.Server.Host/Components/Engine/OpenDreamInstaller.cs @@ -159,7 +159,7 @@ namespace Tgstation.Server.Host.Components.Engine Logger.LogTrace("OD repo seems to already exist, attempting load and fetch..."); repo = await repositoryManager.LoadRepository(cancellationToken); - await repo.FetchOrigin( + await repo!.FetchOrigin( progressSection1, null, null, diff --git a/src/Tgstation.Server.Host/Components/Instance.cs b/src/Tgstation.Server.Host/Components/Instance.cs index 0973cd9322..0e448251b0 100644 --- a/src/Tgstation.Server.Host/Components/Instance.cs +++ b/src/Tgstation.Server.Host/Components/Instance.cs @@ -514,6 +514,9 @@ namespace Tgstation.Server.Host.Components Job compileProcessJob; using (var repo = await RepositoryManager.LoadRepository(cancellationToken)) { + if (repo == null) + throw new JobException(Api.Models.ErrorCode.RepoMissing); + var deploySha = repo.Head; if (deploySha == null) { diff --git a/src/Tgstation.Server.Host/Components/Repository/IRepositoryManager.cs b/src/Tgstation.Server.Host/Components/Repository/IRepositoryManager.cs index 090e3cad82..596301611a 100644 --- a/src/Tgstation.Server.Host/Components/Repository/IRepositoryManager.cs +++ b/src/Tgstation.Server.Host/Components/Repository/IRepositoryManager.cs @@ -4,8 +4,6 @@ using System.Threading.Tasks; using Tgstation.Server.Host.Jobs; -#nullable disable - namespace Tgstation.Server.Host.Components.Repository { /// @@ -28,25 +26,25 @@ namespace Tgstation.Server.Host.Components.Repository /// /// The for the operation. /// A resulting in the loaded if it exists, otherwise. - ValueTask LoadRepository(CancellationToken cancellationToken); + ValueTask LoadRepository(CancellationToken cancellationToken); /// /// Clone the repository at . /// /// The of the remote repository to clone. - /// The branch to clone. - /// The username to clone from . - /// The password to clone from . + /// The optional branch to clone. + /// The optional username to clone from . + /// The optional password to clone from . /// The optional for progress of the clone. /// If submodules should be recusively cloned and initialized. /// The for the operation. /// A resulting i the newly cloned , if one already exists. - ValueTask CloneRepository( + ValueTask CloneRepository( Uri url, - string initialBranch, - string username, - string password, - JobProgressReporter progressReporter, + string? initialBranch, + string? username, + string? password, + JobProgressReporter? progressReporter, bool recurseSubmodules, CancellationToken cancellationToken); From 98a0ece919005745cd62e3f5d04f080d0b711b5f Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 23 Dec 2023 11:37:02 -0500 Subject: [PATCH 393/425] Nullify `IRepositoryManagerFactory` --- .../Components/Repository/IRepositoryManagerFactory.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Repository/IRepositoryManagerFactory.cs b/src/Tgstation.Server.Host/Components/Repository/IRepositoryManagerFactory.cs index 049ad396de..0e8c54c70e 100644 --- a/src/Tgstation.Server.Host/Components/Repository/IRepositoryManagerFactory.cs +++ b/src/Tgstation.Server.Host/Components/Repository/IRepositoryManagerFactory.cs @@ -1,8 +1,6 @@ using Tgstation.Server.Host.Components.Events; using Tgstation.Server.Host.IO; -#nullable disable - namespace Tgstation.Server.Host.Components.Repository { /// From 4683242bb9861500e15689b4e37656ab4be585cf Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 23 Dec 2023 11:37:17 -0500 Subject: [PATCH 394/425] Nullify `LibGit2Commands` --- .../Components/Repository/LibGit2Commands.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Repository/LibGit2Commands.cs b/src/Tgstation.Server.Host/Components/Repository/LibGit2Commands.cs index b70dc7b156..ec5c37a880 100644 --- a/src/Tgstation.Server.Host/Components/Repository/LibGit2Commands.cs +++ b/src/Tgstation.Server.Host/Components/Repository/LibGit2Commands.cs @@ -3,8 +3,6 @@ using System.Collections.Generic; using LibGit2Sharp; -#nullable disable - namespace Tgstation.Server.Host.Components.Repository { /// From fdc25c6c37597812f0729de0929a99773b48753c Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 23 Dec 2023 11:37:47 -0500 Subject: [PATCH 395/425] Nullify `LibGit2RepositoryFactory` --- .../Components/Repository/LibGit2RepositoryFactory.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Repository/LibGit2RepositoryFactory.cs b/src/Tgstation.Server.Host/Components/Repository/LibGit2RepositoryFactory.cs index e47d1a553f..418758ebe7 100644 --- a/src/Tgstation.Server.Host/Components/Repository/LibGit2RepositoryFactory.cs +++ b/src/Tgstation.Server.Host/Components/Repository/LibGit2RepositoryFactory.cs @@ -10,8 +10,6 @@ using Tgstation.Server.Api.Models; using Tgstation.Server.Host.IO; using Tgstation.Server.Host.Jobs; -#nullable disable - namespace Tgstation.Server.Host.Components.Repository { /// @@ -82,7 +80,7 @@ namespace Tgstation.Server.Host.Components.Repository TaskScheduler.Current); /// - public CredentialsHandler GenerateCredentialsHandler(string username, string password) => (a, b, supportedCredentialTypes) => + public CredentialsHandler GenerateCredentialsHandler(string? username, string? password) => (a, b, supportedCredentialTypes) => { var hasCreds = username != null; var supportsUserPass = supportedCredentialTypes.HasFlag(SupportedCredentialTypes.UsernamePassword); From 3f758bb560cf379271f4ddcf6e4a298950047006 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 23 Dec 2023 11:43:42 -0500 Subject: [PATCH 396/425] Correct naming of `Synchronize` function --- src/Tgstation.Server.Host/Components/Instance.cs | 2 +- .../Components/Repository/IRepository.cs | 2 +- .../Components/Repository/Repository.cs | 2 +- .../Components/Repository/RepositoryUpdateService.cs | 6 +++--- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Instance.cs b/src/Tgstation.Server.Host/Components/Instance.cs index 0e448251b0..a8b9a40721 100644 --- a/src/Tgstation.Server.Host/Components/Instance.cs +++ b/src/Tgstation.Server.Host/Components/Instance.cs @@ -452,7 +452,7 @@ namespace Tgstation.Server.Host.Components // synch if necessary if (repositorySettings.AutoUpdatesSynchronize!.Value && startSha != repo.Head && (shouldSyncTracked || repositorySettings.PushTestMergeCommits!.Value)) { - var pushedOrigin = await repo.Sychronize( + var pushedOrigin = await repo.Synchronize( NextProgressReporter("Synchronize"), repositorySettings.AccessUser, repositorySettings.AccessToken, diff --git a/src/Tgstation.Server.Host/Components/Repository/IRepository.cs b/src/Tgstation.Server.Host/Components/Repository/IRepository.cs index 795e264609..65bcd1d61e 100644 --- a/src/Tgstation.Server.Host/Components/Repository/IRepository.cs +++ b/src/Tgstation.Server.Host/Components/Repository/IRepository.cs @@ -151,7 +151,7 @@ namespace Tgstation.Server.Host.Components.Repository /// If any events created should be marked as part of the deployment pipeline. /// The for the operation. /// A resulting in if commits were pushed to the tracked origin reference, otherwise. - ValueTask Sychronize( + ValueTask Synchronize( JobProgressReporter progressReporter, string? username, string? password, diff --git a/src/Tgstation.Server.Host/Components/Repository/Repository.cs b/src/Tgstation.Server.Host/Components/Repository/Repository.cs index c083dfdde6..8b44031766 100644 --- a/src/Tgstation.Server.Host/Components/Repository/Repository.cs +++ b/src/Tgstation.Server.Host/Components/Repository/Repository.cs @@ -613,7 +613,7 @@ namespace Tgstation.Server.Host.Components.Repository } /// - public async ValueTask Sychronize( + public async ValueTask Synchronize( JobProgressReporter progressReporter, string username, string password, diff --git a/src/Tgstation.Server.Host/Components/Repository/RepositoryUpdateService.cs b/src/Tgstation.Server.Host/Components/Repository/RepositoryUpdateService.cs index 130718f9e5..4da69c51af 100644 --- a/src/Tgstation.Server.Host/Components/Repository/RepositoryUpdateService.cs +++ b/src/Tgstation.Server.Host/Components/Repository/RepositoryUpdateService.cs @@ -271,7 +271,7 @@ namespace Tgstation.Server.Host.Components.Repository await UpdateRevInfo(); if (fastForward.Value) { - await repo.Sychronize( + await repo.Synchronize( NextProgressReporter("Sychronize"), currentModel.AccessUser, currentModel.AccessToken, @@ -330,7 +330,7 @@ namespace Tgstation.Server.Host.Components.Repository updateSubmodules, false, cancellationToken); - await repo.Sychronize( + await repo.Synchronize( NextProgressReporter("Synchronize"), currentModel.AccessUser, currentModel.AccessToken, @@ -545,7 +545,7 @@ namespace Tgstation.Server.Host.Components.Repository var currentHead = repo.Head; if (currentModel.PushTestMergeCommits.Value && (startSha != currentHead || (postUpdateSha != null && postUpdateSha != currentHead))) { - await repo.Sychronize( + await repo.Synchronize( NextProgressReporter("Synchronize"), currentModel.AccessUser, currentModel.AccessToken, From 0b3b41dca70a4d8e996a71aa634b4b17cbe43bbd Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 23 Dec 2023 11:44:15 -0500 Subject: [PATCH 397/425] Nullify `TestMergeResult` --- .../Components/Repository/TestMergeResult.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Repository/TestMergeResult.cs b/src/Tgstation.Server.Host/Components/Repository/TestMergeResult.cs index c722590e30..2505a491d8 100644 --- a/src/Tgstation.Server.Host/Components/Repository/TestMergeResult.cs +++ b/src/Tgstation.Server.Host/Components/Repository/TestMergeResult.cs @@ -2,8 +2,6 @@ using LibGit2Sharp; -#nullable disable - namespace Tgstation.Server.Host.Components.Repository { /// @@ -19,6 +17,6 @@ namespace Tgstation.Server.Host.Components.Repository /// /// List of conflicting file paths relative to the repository root. Only present if is . /// - public IReadOnlyList ConflictingFiles { get; init; } + public IReadOnlyList? ConflictingFiles { get; init; } } } From 695cc4645f6371260f5251e60d6624b1ed6287c0 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 23 Dec 2023 11:44:33 -0500 Subject: [PATCH 398/425] Nullify `RepostoryManagerFactory` --- .../Components/Repository/RepostoryManagerFactory.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Repository/RepostoryManagerFactory.cs b/src/Tgstation.Server.Host/Components/Repository/RepostoryManagerFactory.cs index 140b79f03c..cba66ff69a 100644 --- a/src/Tgstation.Server.Host/Components/Repository/RepostoryManagerFactory.cs +++ b/src/Tgstation.Server.Host/Components/Repository/RepostoryManagerFactory.cs @@ -9,8 +9,6 @@ using Tgstation.Server.Host.Components.Events; using Tgstation.Server.Host.Configuration; using Tgstation.Server.Host.IO; -#nullable disable - namespace Tgstation.Server.Host.Components.Repository { /// From 874f16da4b56045f9ed0010cdc20d69b76249d65 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 23 Dec 2023 11:53:19 -0500 Subject: [PATCH 399/425] Nullify `RepositoryUpdateService` --- .../Repository/RepositoryUpdateService.cs | 137 +++++++++--------- 1 file changed, 72 insertions(+), 65 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Repository/RepositoryUpdateService.cs b/src/Tgstation.Server.Host/Components/Repository/RepositoryUpdateService.cs index 4da69c51af..a7aca78c4b 100644 --- a/src/Tgstation.Server.Host/Components/Repository/RepositoryUpdateService.cs +++ b/src/Tgstation.Server.Host/Components/Repository/RepositoryUpdateService.cs @@ -15,8 +15,6 @@ using Tgstation.Server.Host.Database; using Tgstation.Server.Host.Jobs; using Tgstation.Server.Host.Models; -#nullable disable - namespace Tgstation.Server.Host.Components.Repository { /// @@ -87,16 +85,18 @@ namespace Tgstation.Server.Host.Components.Repository IDatabaseContext databaseContext, ILogger logger, Models.Instance instance, - string lastOriginCommitSha, - Action revInfoSink, + string? lastOriginCommitSha, + Action? revInfoSink, CancellationToken cancellationToken) { var repoSha = repository.Head; IQueryable ApplyQuery(IQueryable query) => query - .Where(x => x.CommitSha == repoSha && x.Instance.Id == instance.Id) + .Where(x => x.CommitSha == repoSha && x.InstanceId == instance.Id) .Include(x => x.CompileJobs) - .Include(x => x.ActiveTestMerges).ThenInclude(x => x.TestMerge).ThenInclude(x => x.MergedBy); + .Include(x => x.ActiveTestMerges!) + .ThenInclude(x => x.TestMerge) + .ThenInclude(x => x.MergedBy); var revisionInfo = await ApplyQuery(databaseContext.RevisionInformations).FirstOrDefaultAsync(cancellationToken); @@ -105,7 +105,7 @@ namespace Tgstation.Server.Host.Components.Repository revisionInfo = databaseContext .RevisionInformations .Local - .Where(x => x.CommitSha == repoSha && x.Instance.Id == instance.Id) + .Where(x => x.CommitSha == repoSha && x.InstanceId == instance.Id) .FirstOrDefault(); var needsDbUpdate = revisionInfo == default; @@ -125,7 +125,7 @@ namespace Tgstation.Server.Host.Components.Repository databaseContext.RevisionInformations.Add(revisionInfo); } - revisionInfo.OriginCommitSha ??= lastOriginCommitSha; + revisionInfo!.OriginCommitSha ??= lastOriginCommitSha; if (revisionInfo.OriginCommitSha == null) { revisionInfo.OriginCommitSha = repoSha; @@ -147,13 +147,15 @@ namespace Tgstation.Server.Host.Components.Repository /// A representing the running operation. #pragma warning disable CA1502, CA1506 // TODO: Decomplexify public async ValueTask RepositoryUpdateJob( - IInstanceCore instance, + IInstanceCore? instance, IDatabaseContextFactory databaseContextFactory, Job job, JobProgressReporter progressReporter, CancellationToken cancellationToken) #pragma warning restore CA1502, CA1506 { + ArgumentNullException.ThrowIfNull(instance); + _ = job; // shuts up an IDE warning var repoManager = instance.RepositoryManager; @@ -162,23 +164,23 @@ namespace Tgstation.Server.Host.Components.Repository var startReference = repo.Reference; var startSha = repo.Head; - string postUpdateSha = null; + string? postUpdateSha = null; var newTestMerges = model.NewTestMerges != null && model.NewTestMerges.Count > 0; if (newTestMerges && repo.RemoteGitProvider == RemoteGitProvider.Unknown) throw new JobException(ErrorCode.RepoUnsupportedTestMergeRemote); - var committerName = currentModel.ShowTestMergeCommitters.Value + var committerName = (currentModel.ShowTestMergeCommitters!.Value ? initiatingUser.Name - : currentModel.CommitterName; + : currentModel.CommitterName)!; var hardResettingToOriginReference = model.UpdateFromOrigin == true && model.Reference != null; var numSteps = (model.NewTestMerges?.Count ?? 0) + (model.UpdateFromOrigin == true ? 1 : 0) + (!modelHasShaOrReference ? 2 : (hardResettingToOriginReference ? 3 : 1)); var progressFactor = 1.0 / numSteps; - JobProgressReporter NextProgressReporter(string stage) + JobProgressReporter NextProgressReporter(string? stage) { return progressReporter.CreateSection(stage, progressFactor); } @@ -186,19 +188,19 @@ namespace Tgstation.Server.Host.Components.Repository progressReporter.ReportProgress(0); // get a base line for where we are - Models.RevisionInformation lastRevisionInfo = null; + Models.RevisionInformation? lastRevisionInfo = null; var attachedInstance = new Models.Instance { Id = instanceId, }; - ValueTask CallLoadRevInfo(Models.TestMerge testMergeToAdd = null, string lastOriginCommitSha = null) => databaseContextFactory + ValueTask CallLoadRevInfo(Models.TestMerge? testMergeToAdd = null, string? lastOriginCommitSha = null) => databaseContextFactory .UseContext( async databaseContext => { databaseContext.Instances.Attach(attachedInstance); - var previousRevInfo = lastRevisionInfo; + var previousRevInfo = lastRevisionInfo!; var needsUpdate = await LoadRevisionInformation( repo, databaseContext, @@ -225,10 +227,11 @@ namespace Tgstation.Server.Host.Components.Repository testMergeToAdd.MergedBy = mergedBy; testMergeToAdd.MergedAt = DateTimeOffset.UtcNow; - foreach (var activeTestMerge in previousRevInfo.ActiveTestMerges) - lastRevisionInfo.ActiveTestMerges.Add(activeTestMerge); + var activeTestMerges = lastRevisionInfo!.ActiveTestMerges!; + foreach (var activeTestMerge in previousRevInfo.ActiveTestMerges!) + activeTestMerges.Add(activeTestMerge); - lastRevisionInfo.ActiveTestMerges.Add(new RevInfoTestMerge(testMergeToAdd, lastRevisionInfo)); + activeTestMerges.Add(new RevInfoTestMerge(testMergeToAdd, lastRevisionInfo)); lastRevisionInfo.PrimaryTestMerge = testMergeToAdd; needsUpdate = true; @@ -241,7 +244,7 @@ namespace Tgstation.Server.Host.Components.Repository await CallLoadRevInfo(); // apply new rev info, tracking applied test merges - ValueTask UpdateRevInfo(Models.TestMerge testMergeToAdd = null) => CallLoadRevInfo(testMergeToAdd, lastRevisionInfo.OriginCommitSha); + ValueTask UpdateRevInfo(Models.TestMerge? testMergeToAdd = null) => CallLoadRevInfo(testMergeToAdd, lastRevisionInfo!.OriginCommitSha); try { @@ -262,12 +265,12 @@ namespace Tgstation.Server.Host.Components.Repository var fastForward = await repo.MergeOrigin( NextProgressReporter("Merge Origin"), committerName, - currentModel.CommitterEmail, + currentModel.CommitterEmail!, false, cancellationToken); if (!fastForward.HasValue) throw new JobException(ErrorCode.RepoMergeConflict); - lastRevisionInfo.OriginCommitSha = await repo.GetOriginSha(cancellationToken); + lastRevisionInfo!.OriginCommitSha = await repo.GetOriginSha(cancellationToken); await UpdateRevInfo(); if (fastForward.Value) { @@ -275,8 +278,8 @@ namespace Tgstation.Server.Host.Components.Repository NextProgressReporter("Sychronize"), currentModel.AccessUser, currentModel.AccessToken, - currentModel.CommitterName, - currentModel.CommitterEmail, + currentModel.CommitterName!, + currentModel.CommitterEmail!, true, false, cancellationToken); @@ -287,7 +290,7 @@ namespace Tgstation.Server.Host.Components.Repository } } - var updateSubmodules = currentModel.UpdateSubmodules.Value; + var updateSubmodules = currentModel.UpdateSubmodules!.Value; // checkout/hard reset if (modelHasShaOrReference) @@ -301,7 +304,7 @@ namespace Tgstation.Server.Host.Components.Repository if (validCheckoutSha || validCheckoutReference) { - var committish = model.CheckoutSha ?? model.Reference; + var committish = model.CheckoutSha ?? model.Reference!; var isSha = await repo.IsSha(committish, cancellationToken); if ((isSha && model.Reference != null) || (!isSha && model.CheckoutSha != null)) @@ -334,8 +337,8 @@ namespace Tgstation.Server.Host.Components.Repository NextProgressReporter("Synchronize"), currentModel.AccessUser, currentModel.AccessToken, - currentModel.CommitterName, - currentModel.CommitterEmail, + currentModel.CommitterName!, + currentModel.CommitterEmail!, true, false, cancellationToken); @@ -343,7 +346,7 @@ namespace Tgstation.Server.Host.Components.Repository // repo head is on origin so force this // will update the db if necessary - lastRevisionInfo.OriginCommitSha = repo.Head; + lastRevisionInfo!.OriginCommitSha = repo.Head; } } @@ -354,19 +357,20 @@ namespace Tgstation.Server.Host.Components.Repository throw new JobException(ErrorCode.RepoTestMergeInvalidRemote); // bit of sanitization - foreach (var newTestMergeWithoutTargetCommitSha in model.NewTestMerges.Where(x => String.IsNullOrWhiteSpace(x.TargetCommitSha))) + var newTestMergeModels = model.NewTestMerges!; + foreach (var newTestMergeWithoutTargetCommitSha in newTestMergeModels.Where(x => String.IsNullOrWhiteSpace(x.TargetCommitSha))) newTestMergeWithoutTargetCommitSha.TargetCommitSha = null; var repoOwner = repo.RemoteRepositoryOwner; var repoName = repo.RemoteRepositoryName; // optimization: if we've already merged these exact same commits in this fashion before, just find the rev info for it and check it out - Models.RevisionInformation revInfoWereLookingFor = null; + Models.RevisionInformation? revInfoWereLookingFor = null; bool needToApplyRemainingPrs = true; - if (lastRevisionInfo.OriginCommitSha == lastRevisionInfo.CommitSha) + if (lastRevisionInfo!.OriginCommitSha == lastRevisionInfo.CommitSha) { bool cantSearch = false; - foreach (var newTestMerge in model.NewTestMerges) + foreach (var newTestMerge in newTestMergeModels) { if (newTestMerge.TargetCommitSha != null) #pragma warning disable CA1308 // Normalize strings to uppercase @@ -390,56 +394,58 @@ namespace Tgstation.Server.Host.Components.Repository if (!cantSearch) { - List dbPull = null; + List? dbPull = null; await databaseContextFactory.UseContext( async databaseContext => dbPull = await databaseContext.RevisionInformations .AsQueryable() - .Where(x => x.Instance.Id == instanceId - && x.OriginCommitSha == lastRevisionInfo.OriginCommitSha - && x.ActiveTestMerges.Count <= model.NewTestMerges.Count - && x.ActiveTestMerges.Count > 0) - .Include(x => x.ActiveTestMerges) - .ThenInclude(x => x.TestMerge) + .Where(x => x.InstanceId == instanceId + && x.OriginCommitSha == lastRevisionInfo.OriginCommitSha + && x.ActiveTestMerges!.Count <= newTestMergeModels.Count + && x.ActiveTestMerges!.Count > 0) + .Include(x => x.ActiveTestMerges!) + .ThenInclude(x => x.TestMerge) .ToListAsync(cancellationToken)); // split here cause this bit has to be done locally - revInfoWereLookingFor = dbPull - .Where(x => x.ActiveTestMerges.Count == model.NewTestMerges.Count - && x.ActiveTestMerges.Select(y => y.TestMerge) - .All(y => model.NewTestMerges.Any(z => - y.Number == z.Number - && y.TargetCommitSha.StartsWith(z.TargetCommitSha, StringComparison.Ordinal) - && (y.Comment?.Trim().ToUpperInvariant() == z.Comment?.Trim().ToUpperInvariant() || z.Comment == null)))) + revInfoWereLookingFor = dbPull! + .Where(x => x.ActiveTestMerges!.Count == newTestMergeModels.Count + && x.ActiveTestMerges + .Select(y => y.TestMerge) + .All(y => newTestMergeModels + .Any(z => + y.Number == z.Number + && y.TargetCommitSha!.StartsWith(z.TargetCommitSha!, StringComparison.Ordinal) + && (y.Comment?.Trim().ToUpperInvariant() == z.Comment?.Trim().ToUpperInvariant() || z.Comment == null)))) .FirstOrDefault(); - if (revInfoWereLookingFor == default && model.NewTestMerges.Count > 1) + if (revInfoWereLookingFor == default && newTestMergeModels.Count > 1) { // okay try to add at least SOME prs we've seen before - var listedNewTestMerges = model.NewTestMerges.ToList(); + var listedNewTestMerges = newTestMergeModels.ToList(); var appliedTestMergeIds = new List(); - Models.RevisionInformation lastGoodRevInfo = null; + Models.RevisionInformation? lastGoodRevInfo = null; do { foreach (var newTestMergeParameters in listedNewTestMerges) { - revInfoWereLookingFor = dbPull + revInfoWereLookingFor = dbPull! .Where(testRevInfo => { if (testRevInfo.PrimaryTestMerge == null) return false; - var testMergeMatch = model.NewTestMerges.Any(testTestMerge => + var testMergeMatch = newTestMergeModels.Any(testTestMerge => { var numberMatch = testRevInfo.PrimaryTestMerge.Number == testTestMerge.Number; if (!numberMatch) return false; - var shaMatch = testRevInfo.PrimaryTestMerge.TargetCommitSha.StartsWith( - testTestMerge.TargetCommitSha, + var shaMatch = testRevInfo.PrimaryTestMerge.TargetCommitSha!.StartsWith( + testTestMerge.TargetCommitSha!, StringComparison.Ordinal); if (!shaMatch) return false; @@ -452,7 +458,7 @@ namespace Tgstation.Server.Host.Components.Repository return false; var previousTestMergesMatch = testRevInfo - .ActiveTestMerges + .ActiveTestMerges! .Select(previousRevInfoTestMerge => previousRevInfoTestMerge.TestMerge) .All(previousTestMerge => appliedTestMergeIds.Contains(previousTestMerge.Id)); @@ -463,7 +469,7 @@ namespace Tgstation.Server.Host.Components.Repository if (revInfoWereLookingFor != null) { lastGoodRevInfo = revInfoWereLookingFor; - appliedTestMergeIds.Add(revInfoWereLookingFor.PrimaryTestMerge.Id); + appliedTestMergeIds.Add(revInfoWereLookingFor.PrimaryTestMerge!.Id); listedNewTestMerges.Remove(newTestMergeParameters); break; } @@ -484,16 +490,17 @@ namespace Tgstation.Server.Host.Components.Repository if (revInfoWereLookingFor != null) { // goteem - logger.LogDebug("Reusing existing SHA {sha}...", revInfoWereLookingFor.CommitSha); - await repo.ResetToSha(revInfoWereLookingFor.CommitSha, NextProgressReporter($"Reset to {revInfoWereLookingFor.CommitSha[..7]}"), cancellationToken); + var commitSha = revInfoWereLookingFor.CommitSha!; + logger.LogDebug("Reusing existing SHA {sha}...", commitSha); + await repo.ResetToSha(commitSha, NextProgressReporter($"Reset to {commitSha[..7]}"), cancellationToken); lastRevisionInfo = revInfoWereLookingFor; } if (needToApplyRemainingPrs) { - foreach (var newTestMerge in model.NewTestMerges) + foreach (var newTestMerge in newTestMergeModels) { - if (lastRevisionInfo.ActiveTestMerges.Any(x => x.TestMerge.Number == newTestMerge.Number)) + if (lastRevisionInfo.ActiveTestMerges!.Any(x => x.TestMerge.Number == newTestMerge.Number)) throw new JobException(ErrorCode.RepoDuplicateTestMerge); var fullTestMergeTask = repo.GetTestMerge(newTestMerge, currentModel, cancellationToken); @@ -501,7 +508,7 @@ namespace Tgstation.Server.Host.Components.Repository var mergeResult = await repo.AddTestMerge( newTestMerge, committerName, - currentModel.CommitterEmail, + currentModel.CommitterEmail!, currentModel.AccessUser, currentModel.AccessToken, updateSubmodules, @@ -512,7 +519,7 @@ namespace Tgstation.Server.Host.Components.Repository throw new JobException( ErrorCode.RepoTestMergeConflict, new JobException( - $"Test Merge #{newTestMerge.Number} at {newTestMerge.TargetCommitSha[..7]} conflicted! Conflicting files:{Environment.NewLine}{String.Join(Environment.NewLine, mergeResult.ConflictingFiles.Select(file => $"\t- /{file}"))}")); + $"Test Merge #{newTestMerge.Number} at {newTestMerge.TargetCommitSha![..7]} conflicted! Conflicting files:{Environment.NewLine}{String.Join(Environment.NewLine, mergeResult.ConflictingFiles!.Select(file => $"\t- /{file}"))}")); Models.TestMerge fullTestMerge; try @@ -543,14 +550,14 @@ namespace Tgstation.Server.Host.Components.Repository } var currentHead = repo.Head; - if (currentModel.PushTestMergeCommits.Value && (startSha != currentHead || (postUpdateSha != null && postUpdateSha != currentHead))) + if (currentModel.PushTestMergeCommits!.Value && (startSha != currentHead || (postUpdateSha != null && postUpdateSha != currentHead))) { await repo.Synchronize( NextProgressReporter("Synchronize"), currentModel.AccessUser, currentModel.AccessToken, - currentModel.CommitterName, - currentModel.CommitterEmail, + currentModel.CommitterName!, + currentModel.CommitterEmail!, false, false, cancellationToken); From 0a3de43ccce9c85b5a993c051a45813896ee17aa Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 23 Dec 2023 11:54:30 -0500 Subject: [PATCH 400/425] Nullify `RepositoryManager` --- .../Components/Repository/RepositoryManager.cs | 14 ++++++-------- .../Extensions/FetchOptionsExtensions.cs | 4 ++-- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Repository/RepositoryManager.cs b/src/Tgstation.Server.Host/Components/Repository/RepositoryManager.cs index d733b1e506..727d171e4e 100644 --- a/src/Tgstation.Server.Host/Components/Repository/RepositoryManager.cs +++ b/src/Tgstation.Server.Host/Components/Repository/RepositoryManager.cs @@ -14,8 +14,6 @@ using Tgstation.Server.Host.IO; using Tgstation.Server.Host.Jobs; using Tgstation.Server.Host.Utils; -#nullable disable - namespace Tgstation.Server.Host.Components.Repository { /// @@ -120,12 +118,12 @@ namespace Tgstation.Server.Host.Components.Repository } /// - public async ValueTask CloneRepository( + public async ValueTask CloneRepository( Uri url, - string initialBranch, - string username, - string password, - JobProgressReporter progressReporter, + string? initialBranch, + string? username, + string? password, + JobProgressReporter? progressReporter, bool recurseSubmodules, CancellationToken cancellationToken) { @@ -210,7 +208,7 @@ namespace Tgstation.Server.Host.Components.Repository } /// - public async ValueTask LoadRepository(CancellationToken cancellationToken) + public async ValueTask LoadRepository(CancellationToken cancellationToken) { logger.LogTrace("Begin LoadRepository..."); lock (semaphore) diff --git a/src/Tgstation.Server.Host/Extensions/FetchOptionsExtensions.cs b/src/Tgstation.Server.Host/Extensions/FetchOptionsExtensions.cs index e1b47d644a..6d71a68edf 100644 --- a/src/Tgstation.Server.Host/Extensions/FetchOptionsExtensions.cs +++ b/src/Tgstation.Server.Host/Extensions/FetchOptionsExtensions.cs @@ -27,7 +27,7 @@ namespace Tgstation.Server.Host.Extensions public static FetchOptions Hydrate( this FetchOptions fetchOptions, ILogger logger, - JobProgressReporter progressReporter, + JobProgressReporter? progressReporter, CredentialsHandler credentialsHandler, CancellationToken cancellationToken) { @@ -63,7 +63,7 @@ namespace Tgstation.Server.Host.Extensions /// The optional of the operation. /// The for the operation. /// A new based on . - static TransferProgressHandler TransferProgressHandler(ILogger logger, JobProgressReporter progressReporter, CancellationToken cancellationToken) => transferProgress => + static TransferProgressHandler TransferProgressHandler(ILogger logger, JobProgressReporter? progressReporter, CancellationToken cancellationToken) => transferProgress => { double? percentage; var totalObjectsToProcess = transferProgress.TotalObjects * 2; From 4a950aad630397310c59b4c7014661f3301788f2 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 23 Dec 2023 11:57:04 -0500 Subject: [PATCH 401/425] Nullify `Repository` --- .../Components/Repository/Repository.cs | 64 +++++++++---------- 1 file changed, 31 insertions(+), 33 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Repository/Repository.cs b/src/Tgstation.Server.Host/Components/Repository/Repository.cs index 8b44031766..5518c1a44d 100644 --- a/src/Tgstation.Server.Host/Components/Repository/Repository.cs +++ b/src/Tgstation.Server.Host/Components/Repository/Repository.cs @@ -19,8 +19,6 @@ using Tgstation.Server.Host.IO; using Tgstation.Server.Host.Jobs; using Tgstation.Server.Host.Utils; -#nullable disable - namespace Tgstation.Server.Host.Components.Repository { /// @@ -56,10 +54,10 @@ namespace Tgstation.Server.Host.Components.Repository public RemoteGitProvider? RemoteGitProvider => gitRemoteFeatures.RemoteGitProvider; /// - public string RemoteRepositoryOwner => gitRemoteFeatures.RemoteRepositoryOwner; + public string? RemoteRepositoryOwner => gitRemoteFeatures.RemoteRepositoryOwner; /// - public string RemoteRepositoryName => gitRemoteFeatures.RemoteRepositoryName; + public string? RemoteRepositoryName => gitRemoteFeatures.RemoteRepositoryName; /// public bool Tracking => Reference != null && libGitRepo.Head.IsTracking; @@ -164,8 +162,8 @@ namespace Tgstation.Server.Host.Components.Repository TestMergeParameters testMergeParameters, string committerName, string committerEmail, - string username, - string password, + string? username, + string? password, bool updateSubmodules, JobProgressReporter progressReporter, CancellationToken cancellationToken) @@ -204,12 +202,12 @@ namespace Tgstation.Server.Host.Components.Repository var originalCommit = libGitRepo.Head; - MergeResult result = null; + MergeResult? result = null; var progressFactor = 1.0 / (updateSubmodules ? 3 : 2); var sig = new Signature(new Identity(committerName, committerEmail), DateTimeOffset.UtcNow); - List conflictedPaths = null; + List? conflictedPaths = null; await Task.Factory.StartNew( () => { @@ -293,17 +291,17 @@ namespace Tgstation.Server.Host.Components.Repository DefaultIOManager.BlockingTaskCreationOptions, TaskScheduler.Current); - if (result.Status == MergeStatus.Conflicts) + if (result!.Status == MergeStatus.Conflicts) { var arguments = new List { originalCommit.Tip.Sha, - testMergeParameters.TargetCommitSha, + testMergeParameters.TargetCommitSha!, originalCommit.FriendlyName ?? UnknownReference, testMergeBranchName, }; - arguments.AddRange(conflictedPaths); + arguments.AddRange(conflictedPaths!); await eventConsumer.HandleEvent( EventType.RepoMergeConflict, @@ -342,10 +340,10 @@ namespace Tgstation.Server.Host.Components.Repository await eventConsumer.HandleEvent( EventType.RepoAddTestMerge, - new List + new List { testMergeParameters.Number.ToString(CultureInfo.InvariantCulture), - testMergeParameters.TargetCommitSha, + testMergeParameters.TargetCommitSha!, testMergeParameters.Comment, }, false, @@ -361,10 +359,10 @@ namespace Tgstation.Server.Host.Components.Repository /// public async ValueTask CheckoutObject( string committish, - string username, - string password, + string? username, + string? password, bool updateSubmodules, - JobProgressReporter progressReporter, + JobProgressReporter? progressReporter, CancellationToken cancellationToken) { ArgumentNullException.ThrowIfNull(committish); @@ -395,9 +393,9 @@ namespace Tgstation.Server.Host.Components.Repository /// public async ValueTask FetchOrigin( - JobProgressReporter progressReporter, - string username, - string password, + JobProgressReporter? progressReporter, + string? username, + string? password, bool deploymentPipeline, CancellationToken cancellationToken) { @@ -445,8 +443,8 @@ namespace Tgstation.Server.Host.Components.Repository /// public async ValueTask ResetToOrigin( JobProgressReporter progressReporter, - string username, - string password, + string? username, + string? password, bool updateSubmodules, bool deploymentPipeline, CancellationToken cancellationToken) @@ -543,8 +541,8 @@ namespace Tgstation.Server.Host.Components.Repository { ArgumentNullException.ThrowIfNull(progressReporter); - MergeResult result = null; - Branch trackedBranch = null; + MergeResult? result = null; + Branch? trackedBranch = null; var oldHead = libGitRepo.Head; var oldTip = oldHead.Tip; @@ -593,14 +591,14 @@ namespace Tgstation.Server.Host.Components.Repository DefaultIOManager.BlockingTaskCreationOptions, TaskScheduler.Current); - if (result.Status == MergeStatus.Conflicts) + if (result!.Status == MergeStatus.Conflicts) { await eventConsumer.HandleEvent( EventType.RepoMergeConflict, new List { oldTip.Sha, - trackedBranch.Tip.Sha, + trackedBranch!.Tip.Sha, oldHead.FriendlyName ?? UnknownReference, trackedBranch.FriendlyName, }, @@ -615,8 +613,8 @@ namespace Tgstation.Server.Host.Components.Repository /// public async ValueTask Synchronize( JobProgressReporter progressReporter, - string username, - string password, + string? username, + string? password, string committerName, string committerEmail, bool synchronizeTrackedBranch, @@ -858,7 +856,7 @@ namespace Tgstation.Server.Host.Components.Repository /// The committish to checkout. /// The optional for the operation. /// The for the operation. - void RawCheckout(string committish, JobProgressReporter progressReporter, CancellationToken cancellationToken) + void RawCheckout(string committish, JobProgressReporter? progressReporter, CancellationToken cancellationToken) { logger.LogTrace("Checkout: {committish}", committish); @@ -993,15 +991,15 @@ namespace Tgstation.Server.Host.Components.Repository /// Recusively update all s in the . /// /// Optional of the operation. - /// The username for the . - /// The password for the . + /// The optional username for the . + /// The optional password for the . /// If any events created should be marked as part of the deployment pipeline. /// The for the operation. /// A representing the running operation. async ValueTask UpdateSubmodules( - JobProgressReporter progressReporter, - string username, - string password, + JobProgressReporter? progressReporter, + string? username, + string? password, bool deploymentPipeline, CancellationToken cancellationToken) { From 46c4114c24ea79472ddc15245143433af8abbdf0 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 23 Dec 2023 12:05:22 -0500 Subject: [PATCH 402/425] Nullify `CombinedTopicResponse` --- .../Components/Session/CombinedTopicResponse.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Session/CombinedTopicResponse.cs b/src/Tgstation.Server.Host/Components/Session/CombinedTopicResponse.cs index 2b7a09b174..d98fa10efd 100644 --- a/src/Tgstation.Server.Host/Components/Session/CombinedTopicResponse.cs +++ b/src/Tgstation.Server.Host/Components/Session/CombinedTopicResponse.cs @@ -2,8 +2,6 @@ using Tgstation.Server.Host.Components.Interop.Topic; -#nullable disable - namespace Tgstation.Server.Host.Components.Session { /// @@ -19,14 +17,14 @@ namespace Tgstation.Server.Host.Components.Session /// /// The interop , if any. /// - public TopicResponse InteropResponse { get; } + public TopicResponse? InteropResponse { get; } /// /// Initializes a new instance of the class. /// /// The value of . /// The optional value of . - public CombinedTopicResponse(global::Byond.TopicSender.TopicResponse byondTopicResponse, TopicResponse interopResponse) + public CombinedTopicResponse(global::Byond.TopicSender.TopicResponse byondTopicResponse, TopicResponse? interopResponse) { ByondTopicResponse = byondTopicResponse ?? throw new ArgumentNullException(nameof(byondTopicResponse)); InteropResponse = interopResponse; From 16d50692fa3808e68414bf528774aad55b243a01 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 23 Dec 2023 12:06:45 -0500 Subject: [PATCH 403/425] Nullify `ISessionController` --- .../Components/Session/CombinedTopicResponse.cs | 8 ++++---- .../Components/Session/ISessionController.cs | 6 ++---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Session/CombinedTopicResponse.cs b/src/Tgstation.Server.Host/Components/Session/CombinedTopicResponse.cs index d98fa10efd..ad22b6204b 100644 --- a/src/Tgstation.Server.Host/Components/Session/CombinedTopicResponse.cs +++ b/src/Tgstation.Server.Host/Components/Session/CombinedTopicResponse.cs @@ -5,14 +5,14 @@ using Tgstation.Server.Host.Components.Interop.Topic; namespace Tgstation.Server.Host.Components.Session { /// - /// Combines a with a . + /// Combines a with a . /// sealed class CombinedTopicResponse { /// - /// The raw . + /// The raw . /// - public global::Byond.TopicSender.TopicResponse ByondTopicResponse { get; } + public Byond.TopicSender.TopicResponse ByondTopicResponse { get; } /// /// The interop , if any. @@ -24,7 +24,7 @@ namespace Tgstation.Server.Host.Components.Session /// /// The value of . /// The optional value of . - public CombinedTopicResponse(global::Byond.TopicSender.TopicResponse byondTopicResponse, TopicResponse? interopResponse) + public CombinedTopicResponse(Byond.TopicSender.TopicResponse byondTopicResponse, TopicResponse? interopResponse) { ByondTopicResponse = byondTopicResponse ?? throw new ArgumentNullException(nameof(byondTopicResponse)); InteropResponse = interopResponse; diff --git a/src/Tgstation.Server.Host/Components/Session/ISessionController.cs b/src/Tgstation.Server.Host/Components/Session/ISessionController.cs index d42190c78f..ccdaa448c4 100644 --- a/src/Tgstation.Server.Host/Components/Session/ISessionController.cs +++ b/src/Tgstation.Server.Host/Components/Session/ISessionController.cs @@ -7,8 +7,6 @@ using Tgstation.Server.Host.Components.Deployment; using Tgstation.Server.Host.Components.Interop.Topic; using Tgstation.Server.Host.System; -#nullable disable - namespace Tgstation.Server.Host.Components.Session { /// @@ -34,7 +32,7 @@ namespace Tgstation.Server.Host.Components.Session /// /// The DMAPI . /// - Version DMApiVersion { get; } + Version? DMApiVersion { get; } /// /// Gets the associated with the . @@ -98,7 +96,7 @@ namespace Tgstation.Server.Host.Components.Session /// The to send. /// The for the operation. /// A resulting in the of /world/Topic(). - ValueTask SendCommand(TopicParameters parameters, CancellationToken cancellationToken); + ValueTask SendCommand(TopicParameters parameters, CancellationToken cancellationToken); /// /// Attempts to change the current to . From b81ecda0754fc89a05424d5e64782590e21dc131 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 23 Dec 2023 12:07:10 -0500 Subject: [PATCH 404/425] Nullify `ISessionControllerFactory` --- .../Components/Session/ISessionControllerFactory.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Session/ISessionControllerFactory.cs b/src/Tgstation.Server.Host/Components/Session/ISessionControllerFactory.cs index 34f58c8cc0..c6d1a634ff 100644 --- a/src/Tgstation.Server.Host/Components/Session/ISessionControllerFactory.cs +++ b/src/Tgstation.Server.Host/Components/Session/ISessionControllerFactory.cs @@ -5,8 +5,6 @@ using Tgstation.Server.Api.Models.Internal; using Tgstation.Server.Host.Components.Deployment; using Tgstation.Server.Host.Components.Engine; -#nullable disable - namespace Tgstation.Server.Host.Components.Session { /// @@ -18,14 +16,14 @@ namespace Tgstation.Server.Host.Components.Session /// Create a from a freshly launch DreamDaemon instance. /// /// The to use. - /// The current if any. + /// The current . if any. /// The to use. will be updated with the minumum required security level for the launch. /// If the should only validate the DMAPI then exit. /// The for the operation. /// A resulting in a new . ValueTask LaunchNew( IDmbProvider dmbProvider, - IEngineExecutableLock currentByondLock, + IEngineExecutableLock? currentByondLock, DreamDaemonLaunchParameters launchParameters, bool apiValidate, CancellationToken cancellationToken); From dd1588f8841b8607226a76220c299ffe326b1569 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 23 Dec 2023 12:07:30 -0500 Subject: [PATCH 405/425] Nullify `ISessionPersistor` --- .../Components/Session/ISessionPersistor.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Session/ISessionPersistor.cs b/src/Tgstation.Server.Host/Components/Session/ISessionPersistor.cs index 597208530e..9d3806c317 100644 --- a/src/Tgstation.Server.Host/Components/Session/ISessionPersistor.cs +++ b/src/Tgstation.Server.Host/Components/Session/ISessionPersistor.cs @@ -1,8 +1,6 @@ using System.Threading; using System.Threading.Tasks; -#nullable disable - namespace Tgstation.Server.Host.Components.Session { /// @@ -31,7 +29,7 @@ namespace Tgstation.Server.Host.Components.Session /// /// The for the operation. /// A resulting in the stored if any. - ValueTask Load(CancellationToken cancellationToken); + ValueTask Load(CancellationToken cancellationToken); /// /// Clear any stored . From 835ec189c6fda8e2ac5bca6d978c96962e99b161 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 23 Dec 2023 12:07:43 -0500 Subject: [PATCH 406/425] Nullify `ITopicClientFactory` --- .../Components/Session/ITopicClientFactory.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Session/ITopicClientFactory.cs b/src/Tgstation.Server.Host/Components/Session/ITopicClientFactory.cs index 7f60ace9d0..c4be5235a1 100644 --- a/src/Tgstation.Server.Host/Components/Session/ITopicClientFactory.cs +++ b/src/Tgstation.Server.Host/Components/Session/ITopicClientFactory.cs @@ -2,8 +2,6 @@ using Byond.TopicSender; -#nullable disable - namespace Tgstation.Server.Host.Components.Session { /// From f8e4af3be5e96fc3beee4fd49defbdd576d3b854 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 23 Dec 2023 12:08:12 -0500 Subject: [PATCH 407/425] Nullify `LaunchResult` --- .../Components/Session/LaunchResult.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Session/LaunchResult.cs b/src/Tgstation.Server.Host/Components/Session/LaunchResult.cs index de536ce83e..eb44b6e55f 100644 --- a/src/Tgstation.Server.Host/Components/Session/LaunchResult.cs +++ b/src/Tgstation.Server.Host/Components/Session/LaunchResult.cs @@ -1,8 +1,6 @@ using System; using System.Globalization; -#nullable disable - namespace Tgstation.Server.Host.Components.Session { /// @@ -13,12 +11,12 @@ namespace Tgstation.Server.Host.Components.Session /// /// The time it took for to return or the initial bridge request to process. If the startup timed out. /// - public TimeSpan? StartupTime { get; set; } + public TimeSpan? StartupTime { get; init; } /// /// The if it exited. /// - public int? ExitCode { get; set; } + public int? ExitCode { get; init; } /// public override string ToString() => String.Format(CultureInfo.InvariantCulture, "Exit Code: {0}, Time {1}ms", ExitCode, StartupTime?.TotalMilliseconds); From e655767d31a2e6ce3bf5f47ad0a7db4175efe82f Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 23 Dec 2023 20:55:21 -0500 Subject: [PATCH 408/425] Use `FrozenDictionary` where appropriate --- .../Components/Engine/DelegatingEngineInstaller.cs | 8 ++++---- src/Tgstation.Server.Host/Core/Application.cs | 6 ++++-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Engine/DelegatingEngineInstaller.cs b/src/Tgstation.Server.Host/Components/Engine/DelegatingEngineInstaller.cs index c7c5363a95..1157dff565 100644 --- a/src/Tgstation.Server.Host/Components/Engine/DelegatingEngineInstaller.cs +++ b/src/Tgstation.Server.Host/Components/Engine/DelegatingEngineInstaller.cs @@ -1,5 +1,5 @@ using System; -using System.Collections.Generic; +using System.Collections.Frozen; using System.Linq; using System.Threading; using System.Threading.Tasks; @@ -15,15 +15,15 @@ namespace Tgstation.Server.Host.Components.Engine sealed class DelegatingEngineInstaller : IEngineInstaller { /// - /// The mapping s to their appropriate . + /// The mapping s to their appropriate . /// - readonly IReadOnlyDictionary delegatedInstallers; + readonly FrozenDictionary delegatedInstallers; /// /// Initializes a new instance of the class. /// /// The value of . - public DelegatingEngineInstaller(IReadOnlyDictionary delegatedInstallers) + public DelegatingEngineInstaller(FrozenDictionary delegatedInstallers) { this.delegatedInstallers = delegatedInstallers ?? throw new ArgumentNullException(nameof(delegatedInstallers)); } diff --git a/src/Tgstation.Server.Host/Core/Application.cs b/src/Tgstation.Server.Host/Core/Application.cs index 202b098d7c..3b80d9da38 100644 --- a/src/Tgstation.Server.Host/Core/Application.cs +++ b/src/Tgstation.Server.Host/Core/Application.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Frozen; using System.Collections.Generic; using System.Globalization; using System.Threading.Tasks; @@ -380,12 +381,13 @@ namespace Tgstation.Server.Host.Core openDreamRepositoryDirectory), new NoopEventConsumer())); - services.AddSingleton>( + services.AddSingleton( serviceProvider => new Dictionary { { EngineType.Byond, serviceProvider.GetRequiredService() }, { EngineType.OpenDream, serviceProvider.GetRequiredService() }, - }); + } + .ToFrozenDictionary()); services.AddSingleton(); if (postSetupServices.InternalConfiguration.UsingSystemD) From 6a9e7358a5b3d34474712b8a8687fe219e4eb527 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 23 Dec 2023 20:56:44 -0500 Subject: [PATCH 409/425] Switch to named logging placeholder --- tests/Tgstation.Server.Tests/Live/DummyChatProviderFactory.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Tgstation.Server.Tests/Live/DummyChatProviderFactory.cs b/tests/Tgstation.Server.Tests/Live/DummyChatProviderFactory.cs index dec859f6af..fe6746cb73 100644 --- a/tests/Tgstation.Server.Tests/Live/DummyChatProviderFactory.cs +++ b/tests/Tgstation.Server.Tests/Live/DummyChatProviderFactory.cs @@ -55,7 +55,7 @@ namespace Tgstation.Server.Tests.Live ? new Random().Next() : 22475; - logger.LogInformation("Random seed: {0}", randomSeed); + logger.LogInformation("Random seed: {randomSeed}", randomSeed); var baseRng = new Random(randomSeed); seededRng = new Dictionary{ From e1f9d1e59d4d49e18aa02d4ac496da53be69183c Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 23 Dec 2023 20:58:50 -0500 Subject: [PATCH 410/425] Nullify `ReattachInformation` --- .../Components/Session/ReattachInformation.cs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Session/ReattachInformation.cs b/src/Tgstation.Server.Host/Components/Session/ReattachInformation.cs index 31aa0834b7..df2ce141d4 100644 --- a/src/Tgstation.Server.Host/Components/Session/ReattachInformation.cs +++ b/src/Tgstation.Server.Host/Components/Session/ReattachInformation.cs @@ -5,8 +5,6 @@ using Tgstation.Server.Host.Components.Interop.Bridge; using Tgstation.Server.Host.Models; using Tgstation.Server.Host.System; -#nullable disable - namespace Tgstation.Server.Host.Components.Session { /// @@ -22,12 +20,12 @@ namespace Tgstation.Server.Host.Components.Session /// /// The initially used to launch DreamDaemon. Should be a different than . Should not be set if persisting the initial isn't necessary. /// - public IDmbProvider InitialDmb { get; set; } + public IDmbProvider? InitialDmb { get; set; } /// /// The for the DMAPI. /// - public RuntimeInformation RuntimeInformation { get; private set; } + public RuntimeInformation? RuntimeInformation { get; private set; } /// /// The which indicates when topic requests should timeout. @@ -49,7 +47,7 @@ namespace Tgstation.Server.Host.Components.Session public ReattachInformation( Models.ReattachInformation copy, IDmbProvider dmb, - IDmbProvider initialDmb, + IDmbProvider? initialDmb, TimeSpan topicRequestTimeout) : base(copy) { From 47ac4229ae3a81d6b1c680f0e7f4221b8ad50165 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 23 Dec 2023 21:17:35 -0500 Subject: [PATCH 411/425] Nullify `SessionController` --- .../Components/Interop/Chunker.cs | 14 +++-- .../Components/Session/SessionController.cs | 60 ++++++++++--------- 2 files changed, 41 insertions(+), 33 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Interop/Chunker.cs b/src/Tgstation.Server.Host/Components/Interop/Chunker.cs index c95d97b9e6..e13cfd00ba 100644 --- a/src/Tgstation.Server.Host/Components/Interop/Chunker.cs +++ b/src/Tgstation.Server.Host/Components/Interop/Chunker.cs @@ -64,11 +64,12 @@ namespace Tgstation.Server.Host.Components.Interop /// The . /// The for the operation. /// A resulting in the for the chunked request. - protected async ValueTask ProcessChunk( - Func> completionCallback, - Func chunkErrorCallback, - ChunkData chunk, + protected async ValueTask ProcessChunk( + Func> completionCallback, + Func chunkErrorCallback, + ChunkData? chunk, CancellationToken cancellationToken) + where TCommunication : class where TResponse : IMissingPayloadsCommunication, new() { if (chunk == null) @@ -140,9 +141,12 @@ namespace Tgstation.Server.Host.Components.Interop catch (Exception ex) { Logger.LogDebug(ex, "Bad chunked communication for payload {payloadId}!", requestInfo.PayloadId); - return chunkErrorCallback("Chunked request completed with bad JSON!"); + completedCommunication = null; } + if (completedCommunication == null) + return chunkErrorCallback("Chunked request completed with bad JSON!"); + return await completionCallback(completedCommunication, cancellationToken); } } diff --git a/src/Tgstation.Server.Host/Components/Session/SessionController.cs b/src/Tgstation.Server.Host/Components/Session/SessionController.cs index 9fbd96cca9..ad9bdf1728 100644 --- a/src/Tgstation.Server.Host/Components/Session/SessionController.cs +++ b/src/Tgstation.Server.Host/Components/Session/SessionController.cs @@ -16,6 +16,7 @@ using Tgstation.Server.Api.Models; using Tgstation.Server.Api.Models.Internal; using Tgstation.Server.Common.Extensions; using Tgstation.Server.Host.Components.Chat; +using Tgstation.Server.Host.Components.Chat.Commands; using Tgstation.Server.Host.Components.Deployment; using Tgstation.Server.Host.Components.Engine; using Tgstation.Server.Host.Components.Interop; @@ -25,8 +26,6 @@ using Tgstation.Server.Host.Extensions; using Tgstation.Server.Host.System; using Tgstation.Server.Host.Utils; -#nullable disable - namespace Tgstation.Server.Host.Components.Session { /// @@ -61,7 +60,7 @@ namespace Tgstation.Server.Host.Components.Session public RebootState RebootState => ReattachInformation.RebootState; /// - public Version DMApiVersion { get; private set; } + public Version? DMApiVersion { get; private set; } /// public bool TerminationWasRequested { get; private set; } @@ -123,7 +122,7 @@ namespace Tgstation.Server.Host.Components.Session /// /// The for the . /// - readonly IBridgeRegistration bridgeRegistration; + readonly IBridgeRegistration? bridgeRegistration; /// /// The for the . @@ -198,7 +197,7 @@ namespace Tgstation.Server.Host.Components.Session /// /// for shutting down the server if it is taking too long after validation. /// - volatile Task postValidationShutdownTask; + volatile Task? postValidationShutdownTask; /// /// The number of currently active calls to from TgsReboot(). @@ -374,7 +373,7 @@ namespace Tgstation.Server.Host.Components.Session } /// - public async ValueTask ProcessBridgeRequest(BridgeParameters parameters, CancellationToken cancellationToken) + public async ValueTask ProcessBridgeRequest(BridgeParameters parameters, CancellationToken cancellationToken) { ArgumentNullException.ThrowIfNull(parameters); @@ -406,7 +405,7 @@ namespace Tgstation.Server.Host.Components.Session } /// - public ValueTask SendCommand(TopicParameters parameters, CancellationToken cancellationToken) + public ValueTask SendCommand(TopicParameters parameters, CancellationToken cancellationToken) => SendCommand(parameters, false, cancellationToken); /// @@ -453,7 +452,10 @@ namespace Tgstation.Server.Host.Components.Session /// public async ValueTask InstanceRenamed(string newInstanceName, CancellationToken cancellationToken) { - ReattachInformation.RuntimeInformation.InstanceName = newInstanceName; + var runtimeInformation = ReattachInformation.RuntimeInformation; + if (runtimeInformation != null) + runtimeInformation.InstanceName = newInstanceName; + await SendCommand( TopicParameters.CreateInstanceRenamedTopicParameters(newInstanceName), cancellationToken); @@ -519,7 +521,7 @@ namespace Tgstation.Server.Host.Components.Session var reattachResponse = await SendCommand( new TopicParameters( assemblyInformationProvider.Version, - ReattachInformation.RuntimeInformation.ServerPort), + ReattachInformation.RuntimeInformation!.ServerPort), true, reattachTopicCts.Token); @@ -533,7 +535,7 @@ namespace Tgstation.Server.Host.Components.Session ? LogLevel.Warning : LogLevel.Debug, "DMAPI Interop v{interopVersion} isn't returning the TGS custom commands list. Functionality added in v5.2.0.", - CompileJob.DMApiVersion.Semver()); + CompileJob.DMApiVersion!.Semver()); } } @@ -581,7 +583,7 @@ namespace Tgstation.Server.Host.Components.Session /// The for the operation. /// A resulting in the for the request or if the request could not be dispatched. #pragma warning disable CA1502 // TODO: Decomplexify - async ValueTask ProcessBridgeCommand(BridgeParameters parameters, CancellationToken cancellationToken) + async ValueTask ProcessBridgeCommand(BridgeParameters parameters, CancellationToken cancellationToken) { var response = new BridgeResponse(); switch (parameters.CommandType) @@ -645,7 +647,7 @@ namespace Tgstation.Server.Host.Components.Session // TODO: When OD figures out how to unite port and topic_port, set an upper version bound on OD for this check if (DMApiVersion.Major != DMApiConstants.InteropVersion.Major - || (EngineVersion.Engine.Value == EngineType.OpenDream && DMApiVersion < new Version(5, 7))) + || (EngineVersion.Engine == EngineType.OpenDream && DMApiVersion < new Version(5, 7))) { apiValidationStatus = ApiValidationStatus.Incompatible; return BridgeError("Incompatible dmApiVersion!"); @@ -670,10 +672,11 @@ namespace Tgstation.Server.Host.Components.Session Logger.LogTrace("ApiValidationStatus set to {apiValidationStatus}", apiValidationStatus); + // we create new runtime info here because of potential .Dmb changes (i think. i forget...) response.RuntimeInformation = new RuntimeInformation( chatTrackingContext, ReattachInformation.Dmb, - ReattachInformation.RuntimeInformation.ServerVersion, + ReattachInformation.RuntimeInformation!.ServerVersion, ReattachInformation.RuntimeInformation.InstanceName, ReattachInformation.RuntimeInformation.SecurityLevel, ReattachInformation.RuntimeInformation.Visibility, @@ -688,7 +691,7 @@ namespace Tgstation.Server.Host.Components.Session } // Load custom commands - chatTrackingContext.CustomCommands = parameters.CustomCommands; + chatTrackingContext.CustomCommands = parameters.CustomCommands ?? Array.Empty(); chatTrackingContext.Active = true; Interlocked.Exchange(ref startupTcs, new TaskCompletionSource()).SetResult(); break; @@ -738,7 +741,7 @@ namespace Tgstation.Server.Host.Components.Session /// The to send. /// The for the operation. /// A resulting in the of the topic request. - async ValueTask SendTopicRequest(TopicParameters parameters, CancellationToken cancellationToken) + async ValueTask SendTopicRequest(TopicParameters parameters, CancellationToken cancellationToken) { parameters.AccessIdentifier = ReattachInformation.AccessIdentifier; @@ -764,14 +767,14 @@ namespace Tgstation.Server.Host.Components.Session var payloadId = NextPayloadId; // AccessIdentifer is just noise in a chunked request - parameters.AccessIdentifier = null; + parameters.AccessIdentifier = null!; GenerateQueryString(parameters, out json); // yes, this straight up ignores unicode, precalculating it is useless when we don't // even know if the UTF8 bytes of the url encoded chunk will fit the window until we do said encoding var fullPayloadSize = (uint)json.Length; - List chunkQueryStrings = null; + List? chunkQueryStrings = null; for (var chunkCount = 2; chunkQueryStrings == null; ++chunkCount) { var standardChunkSize = fullPayloadSize / chunkCount; @@ -817,7 +820,7 @@ namespace Tgstation.Server.Host.Components.Session Logger.LogTrace("Chunking topic request ({totalChunks} total)...", chunkQueryStrings.Count); - CombinedTopicResponse combinedResponse = null; + CombinedTopicResponse? combinedResponse = null; bool LogRequestIssue(bool possiblyFromCompletedRequest) { if (combinedResponse?.InteropResponse == null || combinedResponse.InteropResponse.ErrorMessage != null) @@ -841,11 +844,12 @@ namespace Tgstation.Server.Host.Components.Session return null; } - while ((combinedResponse.InteropResponse.MissingChunks?.Count ?? 0) > 0) + while ((combinedResponse?.InteropResponse?.MissingChunks?.Count ?? 0) > 0) { Logger.LogWarning("DD is still missing some chunks of topic request P{payloadId}! Sending missing chunks...", payloadId); - var lastIndex = combinedResponse.InteropResponse.MissingChunks.Last(); - foreach (var missingChunkIndex in combinedResponse.InteropResponse.MissingChunks) + var missingChunks = combinedResponse!.InteropResponse!.MissingChunks!; + var lastIndex = missingChunks.Last(); + foreach (var missingChunkIndex in missingChunks) { var chunkCommandString = chunkQueryStrings[(int)missingChunkIndex]; combinedResponse = await SendRawTopic(chunkCommandString, topicPriority, cancellationToken); @@ -881,7 +885,7 @@ namespace Tgstation.Server.Host.Components.Session /// If this is a priority message. If so, the topic will make 5 attempts to send unless BYOND reboots or exits. /// The for the operation. /// A resulting in the of the topic request. - async ValueTask SendRawTopic(string queryString, bool priority, CancellationToken cancellationToken) + async ValueTask SendRawTopic(string queryString, bool priority, CancellationToken cancellationToken) { if (disposed) { @@ -891,7 +895,7 @@ namespace Tgstation.Server.Host.Components.Session } var targetPort = ReattachInformation.TopicPort ?? ReattachInformation.Port; - Byond.TopicSender.TopicResponse byondResponse; + Byond.TopicSender.TopicResponse? byondResponse; using (await TopicSendSemaphore.Lock(cancellationToken)) byondResponse = await byondTopicSender.SendWithOptionalPriority( asyncDelayer, @@ -913,7 +917,7 @@ namespace Tgstation.Server.Host.Components.Session var topicReturn = byondResponse.StringData; - TopicResponse interopResponse = null; + TopicResponse? interopResponse = null; if (topicReturn != null) try { @@ -934,7 +938,7 @@ namespace Tgstation.Server.Host.Components.Session /// If waiting for the should be bypassed. /// The for the operation. /// A resulting in the of /world/Topic(). - async ValueTask SendCommand(TopicParameters parameters, bool bypassLaunchResult, CancellationToken cancellationToken) + async ValueTask SendCommand(TopicParameters parameters, bool bypassLaunchResult, CancellationToken cancellationToken) { ArgumentNullException.ThrowIfNull(parameters); @@ -996,7 +1000,7 @@ namespace Tgstation.Server.Host.Components.Session } } - TopicResponse fullResponse = null; + TopicResponse? fullResponse = null; var lifetimeWatchingTask = CancelIfLifetimeElapses(); try { @@ -1014,14 +1018,14 @@ namespace Tgstation.Server.Host.Components.Session { Logger.LogTrace("Topic response is chunked..."); - ChunkData nextChunk = combinedResponse.InteropResponse.Chunk; + ChunkData? nextChunk = combinedResponse.InteropResponse.Chunk; do { var nextRequest = await ProcessChunk( (completedResponse, _) => { fullResponse = completedResponse; - return ValueTask.FromResult(null); + return ValueTask.FromResult(null); }, error => { From a47017d3189eef5918c71d85d7bcbafa143e9a14 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 23 Dec 2023 22:06:23 -0500 Subject: [PATCH 412/425] Nullify `SessionControllerFactory` --- .../Session/ISessionControllerFactory.cs | 2 +- .../Session/SessionControllerFactory.cs | 42 +++++++++---------- 2 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Session/ISessionControllerFactory.cs b/src/Tgstation.Server.Host/Components/Session/ISessionControllerFactory.cs index c6d1a634ff..7058d3f4e4 100644 --- a/src/Tgstation.Server.Host/Components/Session/ISessionControllerFactory.cs +++ b/src/Tgstation.Server.Host/Components/Session/ISessionControllerFactory.cs @@ -34,7 +34,7 @@ namespace Tgstation.Server.Host.Components.Session /// The to use. /// The for the operation. /// A resulting in a new on success or on failure to reattach. - ValueTask Reattach( + ValueTask Reattach( ReattachInformation reattachInformation, CancellationToken cancellationToken); } diff --git a/src/Tgstation.Server.Host/Components/Session/SessionControllerFactory.cs b/src/Tgstation.Server.Host/Components/Session/SessionControllerFactory.cs index 79abda99a8..70bed0f5ba 100644 --- a/src/Tgstation.Server.Host/Components/Session/SessionControllerFactory.cs +++ b/src/Tgstation.Server.Host/Components/Session/SessionControllerFactory.cs @@ -26,8 +26,6 @@ using Tgstation.Server.Host.Security; using Tgstation.Server.Host.System; using Tgstation.Server.Host.Utils; -#nullable disable - namespace Tgstation.Server.Host.Components.Session { /// @@ -227,7 +225,7 @@ namespace Tgstation.Server.Host.Components.Session #pragma warning disable CA1506 // TODO: Decomplexify public async ValueTask LaunchNew( IDmbProvider dmbProvider, - IEngineExecutableLock currentByondLock, + IEngineExecutableLock? currentByondLock, DreamDaemonLaunchParameters launchParameters, bool apiValidate, CancellationToken cancellationToken) @@ -270,17 +268,17 @@ namespace Tgstation.Server.Host.Components.Session dmbProvider.CompileJob.Id); // mad this isn't abstracted but whatever - var engineType = dmbProvider.EngineVersion.Engine.Value; + var engineType = dmbProvider.EngineVersion.Engine!.Value; if (engineType == EngineType.Byond) await CheckPagerIsNotRunning(); await PortBindTest(launchParameters.Port.Value, engineType, cancellationToken); - string outputFilePath = null; + string? outputFilePath = null; var preserveLogFile = true; var hasStandardOutput = engineLock.HasStandardOutput; - if (launchParameters.LogOutput.Value) + if (launchParameters.LogOutput!.Value) { var now = DateTimeOffset.UtcNow; var dateDirectory = diagnosticsIOManager.ConcatPath(DreamDaemonLogsPath, now.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture)); @@ -322,8 +320,8 @@ namespace Tgstation.Server.Host.Components.Session var runtimeInformation = CreateRuntimeInformation( dmbProvider, chatTrackingContext, - launchParameters.SecurityLevel.Value, - launchParameters.Visibility.Value, + launchParameters.SecurityLevel!.Value, + launchParameters.Visibility!.Value, apiValidate); var reattachInformation = new ReattachInformation( @@ -335,7 +333,7 @@ namespace Tgstation.Server.Host.Components.Session var byondTopicSender = topicClientFactory.CreateTopicClient( TimeSpan.FromMilliseconds( - launchParameters.TopicRequestTimeout.Value)); + launchParameters.TopicRequestTimeout!.Value)); var sessionController = new SessionController( reattachInformation, @@ -387,7 +385,7 @@ namespace Tgstation.Server.Host.Components.Session #pragma warning restore CA1506 /// - public async ValueTask Reattach( + public async ValueTask Reattach( ReattachInformation reattachInformation, CancellationToken cancellationToken) { @@ -452,19 +450,21 @@ namespace Tgstation.Server.Host.Components.Session } catch { - chatTrackingContext.Dispose(); + chatTrackingContext?.Dispose(); throw; } } catch { - await process.DisposeAsync(); + if (process != null) + await process.DisposeAsync(); + throw; } } catch { - engineLock.Dispose(); + engineLock?.Dispose(); throw; } } @@ -476,7 +476,7 @@ namespace Tgstation.Server.Host.Components.Session /// The . /// The . /// The secure string to use for the session. - /// The full path to log DreamDaemon output to. + /// The optional full path to log DreamDaemon output to. /// If we are only validating the DMAPI then exiting. /// The for the operation. /// A resulting in the DreamDaemon . @@ -485,7 +485,7 @@ namespace Tgstation.Server.Host.Components.Session IEngineExecutableLock engineLock, DreamDaemonLaunchParameters launchParameters, string accessIdentifier, - string logFilePath, + string? logFilePath, bool apiValidate, CancellationToken cancellationToken) { @@ -557,19 +557,19 @@ namespace Tgstation.Server.Host.Components.Session /// If , will be deleted. /// The for the operation. /// A representing the running operation. - async ValueTask LogDDOutput(IProcess process, string outputFilePath, bool cliSupported, bool preserveFile, CancellationToken cancellationToken) + async ValueTask LogDDOutput(IProcess process, string? outputFilePath, bool cliSupported, bool preserveFile, CancellationToken cancellationToken) { try { - string ddOutput = null; + string? ddOutput = null; if (cliSupported) - ddOutput = await process.GetCombinedOutput(cancellationToken); + ddOutput = (await process.GetCombinedOutput(cancellationToken))!; if (ddOutput == null) try { var dreamDaemonLogBytes = await gameIOManager.ReadAllBytes( - outputFilePath, + outputFilePath!, cancellationToken); ddOutput = Encoding.UTF8.GetString(dreamDaemonLogBytes); @@ -580,7 +580,7 @@ namespace Tgstation.Server.Host.Components.Session try { logger.LogTrace("Deleting temporary log file {path}...", outputFilePath); - await gameIOManager.DeleteFile(outputFilePath, cancellationToken); + await gameIOManager.DeleteFile(outputFilePath!, cancellationToken); } catch (Exception ex) { @@ -620,7 +620,7 @@ namespace Tgstation.Server.Host.Components.Session chatTrackingContext, dmbProvider, assemblyInformationProvider.Version, - instance.Name, + instance.Name!, securityLevel, visibility, serverPortProvider.HttpApiPort, From 071de7b466e18d2d10e611e90b27c50fa3afc286 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 23 Dec 2023 22:08:30 -0500 Subject: [PATCH 413/425] Nullify `SessionPersistor` --- .../Components/Session/SessionPersistor.cs | 29 +++++++++---------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Session/SessionPersistor.cs b/src/Tgstation.Server.Host/Components/Session/SessionPersistor.cs index 2cd093c3ee..a916ea792b 100644 --- a/src/Tgstation.Server.Host/Components/Session/SessionPersistor.cs +++ b/src/Tgstation.Server.Host/Components/Session/SessionPersistor.cs @@ -8,12 +8,11 @@ using Microsoft.Extensions.Logging; using Tgstation.Server.Host.Components.Deployment; using Tgstation.Server.Host.Database; +using Tgstation.Server.Host.Models; using Tgstation.Server.Host.System; using Z.EntityFramework.Plus; -#nullable disable - namespace Tgstation.Server.Host.Components.Session { /// @@ -77,8 +76,8 @@ namespace Tgstation.Server.Host.Components.Session var dbReattachInfo = new Models.ReattachInformation(reattachInformation.AccessIdentifier) { - CompileJobId = reattachInformation.Dmb.CompileJob.Id.Value, - InitialCompileJobId = reattachInformation.InitialDmb?.CompileJob.Id.Value, + CompileJobId = reattachInformation.Dmb.CompileJob.Require(x => x.Id), + InitialCompileJobId = reattachInformation.InitialDmb?.CompileJob.Require(x => x.Id), Port = reattachInformation.Port, ProcessId = reattachInformation.ProcessId, RebootState = reattachInformation.RebootState, @@ -89,7 +88,7 @@ namespace Tgstation.Server.Host.Components.Session db.ReattachInformations.Add(dbReattachInfo); await db.Save(cancellationToken); - reattachInformation.Id = dbReattachInfo.Id.Value; + reattachInformation.Id = dbReattachInfo.Id!.Value; logger.LogDebug("Saved reattach information: {info}", reattachInformation); }); @@ -110,8 +109,8 @@ namespace Tgstation.Server.Host.Components.Session db.ReattachInformations.Attach(dbReattachInfo); dbReattachInfo.AccessIdentifier = reattachInformation.AccessIdentifier; - dbReattachInfo.CompileJobId = reattachInformation.Dmb.CompileJob.Id.Value; - dbReattachInfo.InitialCompileJobId = reattachInformation.InitialDmb?.CompileJob.Id.Value; + dbReattachInfo.CompileJobId = reattachInformation.Dmb.CompileJob.Require(x => x.Id); + dbReattachInfo.InitialCompileJobId = reattachInformation.InitialDmb?.CompileJob.Require(x => x.Id); dbReattachInfo.Port = reattachInformation.Port; dbReattachInfo.ProcessId = reattachInformation.ProcessId; dbReattachInfo.RebootState = reattachInformation.RebootState; @@ -124,9 +123,9 @@ namespace Tgstation.Server.Host.Components.Session }); /// - public async ValueTask Load(CancellationToken cancellationToken) + public async ValueTask Load(CancellationToken cancellationToken) { - Models.ReattachInformation result = null; + Models.ReattachInformation? result = null; TimeSpan? topicTimeout = null; async ValueTask KillProcess(Models.ReattachInformation reattachInfo) @@ -160,19 +159,19 @@ namespace Tgstation.Server.Host.Components.Session var dbReattachInfos = await db .ReattachInformations .AsQueryable() - .Where(x => x.CompileJob.Job.Instance.Id == metadata.Id) + .Where(x => x.CompileJob!.Job.Instance!.Id == metadata.Id) .Include(x => x.CompileJob) .Include(x => x.InitialCompileJob) .ToListAsync(cancellationToken); result = dbReattachInfos.FirstOrDefault(); - if (result == default) + if (result == null) return; var timeoutMilliseconds = await db .Instances .AsQueryable() .Where(x => x.Id == metadata.Id) - .Select(x => x.DreamDaemonSettings.TopicRequestTimeout) + .Select(x => x.DreamDaemonSettings!.TopicRequestTimeout) .FirstOrDefaultAsync(cancellationToken); if (timeoutMilliseconds == default) @@ -207,7 +206,7 @@ namespace Tgstation.Server.Host.Components.Session return null; } - var dmb = await dmbFactory.FromCompileJob(result.CompileJob, cancellationToken); + var dmb = await dmbFactory.FromCompileJob(result!.CompileJob!, cancellationToken); if (dmb == null) { logger.LogError("Unable to reattach! Could not load .dmb!"); @@ -225,7 +224,7 @@ namespace Tgstation.Server.Host.Components.Session return null; } - IDmbProvider initialDmb = null; + IDmbProvider? initialDmb = null; if (result.InitialCompileJob != null) { logger.LogTrace("Loading initial compile job..."); @@ -266,7 +265,7 @@ namespace Tgstation.Server.Host.Components.Session var baseQuery = databaseContext .ReattachInformations .AsQueryable() - .Where(x => x.CompileJob.Job.Instance.Id == metadata.Id); + .Where(x => x.CompileJob!.Job.Instance!.Id == metadata.Id); if (instant) await baseQuery From 3c62327d1d87d9684dbb1d7f2cfb8912530f9f9a Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 23 Dec 2023 22:08:56 -0500 Subject: [PATCH 414/425] Nullify `TopicClientFactory` --- .../Components/Session/TopicClientFactory.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Session/TopicClientFactory.cs b/src/Tgstation.Server.Host/Components/Session/TopicClientFactory.cs index dc51016b29..3ed153a641 100644 --- a/src/Tgstation.Server.Host/Components/Session/TopicClientFactory.cs +++ b/src/Tgstation.Server.Host/Components/Session/TopicClientFactory.cs @@ -4,8 +4,6 @@ using Byond.TopicSender; using Microsoft.Extensions.Logging; -#nullable disable - namespace Tgstation.Server.Host.Components.Session { /// @@ -14,7 +12,7 @@ namespace Tgstation.Server.Host.Components.Session /// /// The for created s. /// - readonly ILogger logger; + readonly ILogger? logger; /// /// Initializes a new instance of the class. From c40720df8093173d65b7671ad5110bf2cfdd77ca Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 23 Dec 2023 22:24:36 -0500 Subject: [PATCH 415/425] Cleanup a `JobsHubTests` assert --- tests/Tgstation.Server.Tests/Live/Instance/JobsHubTests.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/Tgstation.Server.Tests/Live/Instance/JobsHubTests.cs b/tests/Tgstation.Server.Tests/Live/Instance/JobsHubTests.cs index 84985b6a9b..b3149556e5 100644 --- a/tests/Tgstation.Server.Tests/Live/Instance/JobsHubTests.cs +++ b/tests/Tgstation.Server.Tests/Live/Instance/JobsHubTests.cs @@ -44,7 +44,7 @@ namespace Tgstation.Server.Tests.Live.Instance finishTcs = new TaskCompletionSource(); seenJobs = new ConcurrentDictionary(); - permlessSeenJobs = new HashSet(); + permlessSeenJobs = []; } public Task ReceiveJobUpdate(JobResponse job, CancellationToken cancellationToken) @@ -199,7 +199,7 @@ namespace Tgstation.Server.Tests.Live.Instance } static DateTimeOffset PerformDBTruncation(DateTimeOffset original) - => new DateTimeOffset( + => new( original.Ticks - (original.Ticks % TimeSpan.TicksPerSecond), original.Offset); @@ -234,7 +234,7 @@ namespace Tgstation.Server.Tests.Live.Instance Assert.IsTrue(accountedJobs <= seenJobs.Count); Assert.AreNotEqual(0, permlessSeenJobs.Count); Assert.IsTrue(permlessSeenJobs.Count < seenJobs.Count); - Assert.IsTrue(permlessSeenJobs.All(id => seenJobs.ContainsKey(id))); + Assert.IsTrue(permlessSeenJobs.All(id => seenJobs.ContainsKey(id)), $"Saw permless job(s) that wasn't seen:{Environment.NewLine}{JobListFormatter(permlessSeenJobs.Where(id => !seenJobs.ContainsKey(id)).Select(id => allJobs.First(x => x.Id == id)))}"); await using var conn3 = (HubConnection)await permedUser.SubscribeToJobUpdates( this, From 9a3c0aaf82db43baf6a5076194658b9045c2ba31 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 23 Dec 2023 23:36:02 -0500 Subject: [PATCH 416/425] Nullify `AdvancedWatchdog` --- .../Components/Watchdog/AdvancedWatchdog.cs | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Watchdog/AdvancedWatchdog.cs b/src/Tgstation.Server.Host/Components/Watchdog/AdvancedWatchdog.cs index 0b08ed062b..3698367f1f 100644 --- a/src/Tgstation.Server.Host/Components/Watchdog/AdvancedWatchdog.cs +++ b/src/Tgstation.Server.Host/Components/Watchdog/AdvancedWatchdog.cs @@ -18,8 +18,6 @@ using Tgstation.Server.Host.IO; using Tgstation.Server.Host.Jobs; using Tgstation.Server.Host.Utils; -#nullable disable - namespace Tgstation.Server.Host.Components.Watchdog { /// @@ -30,7 +28,7 @@ namespace Tgstation.Server.Host.Components.Watchdog /// /// The for . /// - protected SwappableDmbProvider ActiveSwappable { get; private set; } + protected SwappableDmbProvider? ActiveSwappable { get; private set; } /// /// The for the . @@ -45,12 +43,12 @@ namespace Tgstation.Server.Host.Components.Watchdog /// /// The active for . /// - SwappableDmbProvider pendingSwappable; + SwappableDmbProvider? pendingSwappable; /// /// The representing the cleanup of an unused . /// - volatile TaskCompletionSource deploymentCleanupGate; + volatile TaskCompletionSource? deploymentCleanupGate; /// /// Initializes a new instance of the class. @@ -178,7 +176,7 @@ namespace Tgstation.Server.Host.Components.Watchdog var localDeploymentCleanupGate = new TaskCompletionSource(); async Task CleanupLingeringDeployment() { - var lingeringDeploymentExpirySeconds = ActiveLaunchParameters.StartupTimeout.Value; + var lingeringDeploymentExpirySeconds = ActiveLaunchParameters.StartupTimeout!.Value; Logger.LogDebug( "Holding old deployment {compileJobId} for up to {expiry} seconds...", currentCompileJobId, @@ -262,7 +260,7 @@ namespace Tgstation.Server.Host.Components.Watchdog return; } - SwappableDmbProvider swappableProvider = null; + SwappableDmbProvider? swappableProvider = null; try { swappableProvider = CreateSwappableDmbProvider(compileJobProvider); @@ -350,9 +348,9 @@ namespace Tgstation.Server.Host.Components.Watchdog /// if swapping is possible, otherwise. bool CanUseSwappableDmbProvider(IDmbProvider dmbProvider) { - if (dmbProvider.EngineVersion.Engine.Value != EngineType.Byond) + if (dmbProvider.EngineVersion.Engine != EngineType.Byond) { - Logger.LogDebug("Not using SwappableDmbProvider for engine type {engineType}", dmbProvider.EngineVersion.Engine.Value); + Logger.LogDebug("Not using SwappableDmbProvider for engine type {engineType}", dmbProvider.EngineVersion.Engine); return false; } @@ -366,7 +364,7 @@ namespace Tgstation.Server.Host.Components.Watchdog /// A representing the running operation. async ValueTask InitialLink(CancellationToken cancellationToken) { - await ActiveSwappable.FinishActivationPreparation(cancellationToken); + await ActiveSwappable!.FinishActivationPreparation(cancellationToken); Logger.LogTrace("Linking compile job..."); await ActiveSwappable.MakeActive(cancellationToken); } From b1878d697a4d87065f139a60a7099208d0bbf93e Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 23 Dec 2023 23:37:14 -0500 Subject: [PATCH 417/425] Nullify `IWatchdog` --- src/Tgstation.Server.Host/Components/Watchdog/IWatchdog.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Watchdog/IWatchdog.cs b/src/Tgstation.Server.Host/Components/Watchdog/IWatchdog.cs index 8699c17c6c..96c6c9ccf9 100644 --- a/src/Tgstation.Server.Host/Components/Watchdog/IWatchdog.cs +++ b/src/Tgstation.Server.Host/Components/Watchdog/IWatchdog.cs @@ -7,8 +7,6 @@ using Tgstation.Server.Api.Models.Internal; using Tgstation.Server.Host.Components.Events; using Tgstation.Server.Host.Components.Session; -#nullable disable - namespace Tgstation.Server.Host.Components.Watchdog { /// @@ -34,7 +32,7 @@ namespace Tgstation.Server.Host.Components.Watchdog /// /// Retrieves the currently running on the server. /// - Models.CompileJob ActiveCompileJob { get; } + Models.CompileJob? ActiveCompileJob { get; } /// /// The to be applied. @@ -45,7 +43,7 @@ namespace Tgstation.Server.Host.Components.Watchdog /// The the active server is using. /// /// This may not be the exact same as but still be associated with the same session. - DreamDaemonLaunchParameters LastLaunchParameters { get; } + DreamDaemonLaunchParameters? LastLaunchParameters { get; } /// /// The of the active server. From c37d3ef7cbb78b4af997a24e23df5811415fc7cf Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 23 Dec 2023 23:38:14 -0500 Subject: [PATCH 418/425] Nullify `IWatchdogFactory` --- src/Tgstation.Server.Host/Components/InstanceFactory.cs | 2 +- .../Components/Watchdog/IWatchdogFactory.cs | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/InstanceFactory.cs b/src/Tgstation.Server.Host/Components/InstanceFactory.cs index 7f621333e8..2b24bcb6cb 100644 --- a/src/Tgstation.Server.Host/Components/InstanceFactory.cs +++ b/src/Tgstation.Server.Host/Components/InstanceFactory.cs @@ -324,7 +324,7 @@ namespace Tgstation.Server.Host.Components configuration, // watchdog doesn't need itself as an event consumer remoteDeploymentManagerFactory, metadata, - metadata.DreamDaemonSettings); + metadata.DreamDaemonSettings!); try { eventConsumer.SetWatchdog(watchdog); diff --git a/src/Tgstation.Server.Host/Components/Watchdog/IWatchdogFactory.cs b/src/Tgstation.Server.Host/Components/Watchdog/IWatchdogFactory.cs index eff60cf711..308cd3db54 100644 --- a/src/Tgstation.Server.Host/Components/Watchdog/IWatchdogFactory.cs +++ b/src/Tgstation.Server.Host/Components/Watchdog/IWatchdogFactory.cs @@ -6,8 +6,6 @@ using Tgstation.Server.Host.Components.Events; using Tgstation.Server.Host.Components.Session; using Tgstation.Server.Host.IO; -#nullable disable - namespace Tgstation.Server.Host.Components.Watchdog { /// From 1f8d24835b5a5b54e891d1108336bfe2dbe9eb8e Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 23 Dec 2023 23:38:53 -0500 Subject: [PATCH 419/425] Nullify `PosixWatchdog` --- src/Tgstation.Server.Host/Components/Watchdog/PosixWatchdog.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Watchdog/PosixWatchdog.cs b/src/Tgstation.Server.Host/Components/Watchdog/PosixWatchdog.cs index 7b142d6b54..27874178af 100644 --- a/src/Tgstation.Server.Host/Components/Watchdog/PosixWatchdog.cs +++ b/src/Tgstation.Server.Host/Components/Watchdog/PosixWatchdog.cs @@ -17,8 +17,6 @@ using Tgstation.Server.Host.IO; using Tgstation.Server.Host.Jobs; using Tgstation.Server.Host.Utils; -#nullable disable - namespace Tgstation.Server.Host.Components.Watchdog { /// From 2b0eefca238bc30fbfb710d762abbabb3d2ae0b6 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 23 Dec 2023 23:39:13 -0500 Subject: [PATCH 420/425] Nullify `PosixWatchdogFactory` --- .../Components/Watchdog/PosixWatchdogFactory.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Watchdog/PosixWatchdogFactory.cs b/src/Tgstation.Server.Host/Components/Watchdog/PosixWatchdogFactory.cs index 491f0ff362..1d0d140bc0 100644 --- a/src/Tgstation.Server.Host/Components/Watchdog/PosixWatchdogFactory.cs +++ b/src/Tgstation.Server.Host/Components/Watchdog/PosixWatchdogFactory.cs @@ -16,8 +16,6 @@ using Tgstation.Server.Host.IO; using Tgstation.Server.Host.Jobs; using Tgstation.Server.Host.Utils; -#nullable disable - namespace Tgstation.Server.Host.Components.Watchdog { /// From 418b627b44970f633bba00a5d7c531fd04206021 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 23 Dec 2023 23:39:29 -0500 Subject: [PATCH 421/425] Nullify `WatchdogFactory` --- .../Components/Watchdog/WatchdogFactory.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Watchdog/WatchdogFactory.cs b/src/Tgstation.Server.Host/Components/Watchdog/WatchdogFactory.cs index 868155d3dc..e9a37ecb2b 100644 --- a/src/Tgstation.Server.Host/Components/Watchdog/WatchdogFactory.cs +++ b/src/Tgstation.Server.Host/Components/Watchdog/WatchdogFactory.cs @@ -15,8 +15,6 @@ using Tgstation.Server.Host.IO; using Tgstation.Server.Host.Jobs; using Tgstation.Server.Host.Utils; -#nullable disable - namespace Tgstation.Server.Host.Components.Watchdog { /// From 26a1e618761da2af60cc346404293ff9503dba5f Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 23 Dec 2023 23:39:51 -0500 Subject: [PATCH 422/425] Nullify `WindowsWatchdogFactory` --- .../Components/Watchdog/WindowsWatchdogFactory.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Watchdog/WindowsWatchdogFactory.cs b/src/Tgstation.Server.Host/Components/Watchdog/WindowsWatchdogFactory.cs index cd78148c37..89ed6b145d 100644 --- a/src/Tgstation.Server.Host/Components/Watchdog/WindowsWatchdogFactory.cs +++ b/src/Tgstation.Server.Host/Components/Watchdog/WindowsWatchdogFactory.cs @@ -15,8 +15,6 @@ using Tgstation.Server.Host.IO; using Tgstation.Server.Host.Jobs; using Tgstation.Server.Host.Utils; -#nullable disable - namespace Tgstation.Server.Host.Components.Watchdog { /// From a7caf35a6b0e7e6ce1e19ef73d8d77c2f8ca0b9b Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 23 Dec 2023 23:40:15 -0500 Subject: [PATCH 423/425] Nullify `WindowsWatchdog` --- .../Components/Watchdog/WindowsWatchdog.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Watchdog/WindowsWatchdog.cs b/src/Tgstation.Server.Host/Components/Watchdog/WindowsWatchdog.cs index 98a8d0da46..4fb87385c9 100644 --- a/src/Tgstation.Server.Host/Components/Watchdog/WindowsWatchdog.cs +++ b/src/Tgstation.Server.Host/Components/Watchdog/WindowsWatchdog.cs @@ -15,8 +15,6 @@ using Tgstation.Server.Host.IO; using Tgstation.Server.Host.Jobs; using Tgstation.Server.Host.Utils; -#nullable disable - namespace Tgstation.Server.Host.Components.Watchdog { /// @@ -83,9 +81,9 @@ namespace Tgstation.Server.Host.Components.Watchdog /// protected override async ValueTask ApplyInitialDmb(CancellationToken cancellationToken) { - if (Server.EngineVersion.Engine.Value != EngineType.Byond) + if (Server.EngineVersion.Engine != EngineType.Byond) { - Logger.LogTrace("Not setting InitialDmb for engine type {engineType}", Server.EngineVersion.Engine.Value); + Logger.LogTrace("Not setting InitialDmb for engine type {engineType}", Server.EngineVersion.Engine); return; } From 9db05f82ec577d2031421a7c1f5615b7387ece2c Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 23 Dec 2023 23:45:14 -0500 Subject: [PATCH 424/425] Nullify `BasicWatchdog` --- .../Components/Watchdog/AdvancedWatchdog.cs | 11 ++++--- .../Components/Watchdog/BasicWatchdog.cs | 33 ++++++++----------- .../Components/Watchdog/WindowsWatchdog.cs | 2 +- 3 files changed, 21 insertions(+), 25 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Watchdog/AdvancedWatchdog.cs b/src/Tgstation.Server.Host/Components/Watchdog/AdvancedWatchdog.cs index 3698367f1f..347048921d 100644 --- a/src/Tgstation.Server.Host/Components/Watchdog/AdvancedWatchdog.cs +++ b/src/Tgstation.Server.Host/Components/Watchdog/AdvancedWatchdog.cs @@ -141,11 +141,12 @@ namespace Tgstation.Server.Host.Components.Watchdog ValueTask RunPrequel() => BeforeApplyDmb(pendingSwappable.CompileJob, cancellationToken); var needToSwap = !pendingSwappable.Swapped; + var controller = Server!; if (needToSwap) { // IMPORTANT: THE SESSIONCONTROLLER SHOULD STILL BE PROCESSING THE BRIDGE REQUEST SO WE KNOW DD IS SLEEPING // OTHERWISE, IT COULD RETURN TO /world/Reboot() TOO EARLY AND LOAD THE WRONG .DMB - if (!Server.ProcessingRebootBridgeRequest) + if (!controller.ProcessingRebootBridgeRequest) { // integration test logging will catch this Logger.LogError( @@ -168,7 +169,7 @@ namespace Tgstation.Server.Host.Components.Watchdog if (needToSwap) await PerformDmbSwap(pendingSwappable, cancellationToken); - var currentCompileJobId = Server.ReattachInformation.Dmb.CompileJob.Id; + var currentCompileJobId = controller.ReattachInformation.Dmb.CompileJob.Id; await DrainDeploymentCleanupTasks(false); @@ -209,7 +210,7 @@ namespace Tgstation.Server.Host.Components.Watchdog lock (deploymentCleanupTasks) { - lingeringDeployment = Server.ReplaceDmbProvider(pendingSwappable); + lingeringDeployment = controller.ReplaceDmbProvider(pendingSwappable); deploymentCleanupTasks.Add( CleanupLingeringDeployment()); } @@ -217,7 +218,7 @@ namespace Tgstation.Server.Host.Components.Watchdog ActiveSwappable = pendingSwappable; pendingSwappable = null; - await SessionPersistor.Update(Server.ReattachInformation, cancellationToken); + await SessionPersistor.Update(controller.ReattachInformation, cancellationToken); await updateTask; } else @@ -382,7 +383,7 @@ namespace Tgstation.Server.Host.Components.Watchdog await newProvider.FinishActivationPreparation(cancellationToken); var suspended = false; - var server = Server; + var server = Server!; try { server.SuspendProcess(); diff --git a/src/Tgstation.Server.Host/Components/Watchdog/BasicWatchdog.cs b/src/Tgstation.Server.Host/Components/Watchdog/BasicWatchdog.cs index d9f37a6f55..37b9bed41c 100644 --- a/src/Tgstation.Server.Host/Components/Watchdog/BasicWatchdog.cs +++ b/src/Tgstation.Server.Host/Components/Watchdog/BasicWatchdog.cs @@ -17,8 +17,6 @@ using Tgstation.Server.Host.IO; using Tgstation.Server.Host.Jobs; using Tgstation.Server.Host.Utils; -#nullable disable - namespace Tgstation.Server.Host.Components.Watchdog { /// @@ -35,7 +33,7 @@ namespace Tgstation.Server.Host.Components.Watchdog /// /// The single . /// - protected ISessionController Server { get; private set; } + protected ISessionController? Server { get; private set; } /// /// If the server is set to gracefully reboot due to a pending dmb or settings change. @@ -111,16 +109,17 @@ namespace Tgstation.Server.Host.Components.Watchdog /// protected override async ValueTask HandleMonitorWakeup(MonitorActivationReason reason, CancellationToken cancellationToken) { + var controller = Server!; switch (reason) { case MonitorActivationReason.ActiveServerCrashed: - var eventType = Server.TerminationWasRequested + var eventType = controller.TerminationWasRequested ? EventType.WorldEndProcess : EventType.WatchdogCrash; await HandleEventImpl(eventType, Enumerable.Empty(), false, cancellationToken); - var exitWord = Server.TerminationWasRequested ? "exited" : "crashed"; - if (Server.RebootState == Session.RebootState.Shutdown) + var exitWord = controller.TerminationWasRequested ? "exited" : "crashed"; + if (controller.RebootState == Session.RebootState.Shutdown) { // the time for graceful shutdown is now Chat.QueueWatchdogMessage( @@ -138,7 +137,7 @@ namespace Tgstation.Server.Host.Components.Watchdog exitWord)); return MonitorAction.Restart; case MonitorActivationReason.ActiveServerRebooted: - var rebootState = Server.RebootState; + var rebootState = controller.RebootState; if (gracefulRebootRequired && rebootState == Session.RebootState.Normal) { Logger.LogError("Watchdog reached normal reboot state with gracefulRebootRequired set!"); @@ -146,7 +145,7 @@ namespace Tgstation.Server.Host.Components.Watchdog } gracefulRebootRequired = false; - Server.ResetRebootState(); + controller.ResetRebootState(); var eventTask = HandleEventImpl(EventType.WorldReboot, Enumerable.Empty(), false, cancellationToken); try @@ -172,7 +171,7 @@ namespace Tgstation.Server.Host.Components.Watchdog } case MonitorActivationReason.ActiveLaunchParametersUpdated: - await Server.SetRebootState(Session.RebootState.Restart, cancellationToken); + await controller.SetRebootState(Session.RebootState.Restart, cancellationToken); gracefulRebootRequired = true; break; case MonitorActivationReason.NewDmbAvailable: @@ -204,7 +203,7 @@ namespace Tgstation.Server.Host.Components.Watchdog } /// - protected sealed override ISessionController GetActiveController() => Server; + protected sealed override ISessionController? GetActiveController() => Server; /// protected override async ValueTask InitController( @@ -222,15 +221,14 @@ namespace Tgstation.Server.Host.Components.Watchdog // start the alpha server task, either by launch a new process or attaching to an existing one // The tasks returned are mainly for writing interop files to the directories among other things and should generally never fail // The tasks pertaining to server startup times are in the ISessionControllers - ValueTask serverLaunchTask; if (!reattachInProgress) { - Logger.LogTrace("Initializing controller with CompileJob {compileJobId}...", dmbToUse.CompileJob.Id); + Logger.LogTrace("Initializing controller with CompileJob {compileJobId}...", dmbToUse!.CompileJob.Id); await BeforeApplyDmb(dmbToUse.CompileJob, cancellationToken); dmbToUse = await PrepServerForLaunch(dmbToUse, cancellationToken); await eventTask; - serverLaunchTask = SessionControllerFactory.LaunchNew( + Server = await SessionControllerFactory.LaunchNew( dmbToUse, null, ActiveLaunchParameters, @@ -240,12 +238,9 @@ namespace Tgstation.Server.Host.Components.Watchdog else { await eventTask; - serverLaunchTask = SessionControllerFactory.Reattach(reattachInfo, cancellationToken); + Server = await SessionControllerFactory.Reattach(reattachInfo!, cancellationToken); } - // retrieve the session controller - Server = await serverLaunchTask; - // possiblity of null servers due to failed reattaches if (Server == null) { @@ -293,7 +288,7 @@ namespace Tgstation.Server.Host.Components.Watchdog /// The for the operation. /// A representing the running operation. protected virtual ValueTask SessionStartupPersist(CancellationToken cancellationToken) - => SessionPersistor.Save(Server.ReattachInformation, cancellationToken); + => SessionPersistor.Save(Server!.ReattachInformation, cancellationToken); /// /// Handler for when the is . @@ -311,7 +306,7 @@ namespace Tgstation.Server.Host.Components.Watchdog protected virtual async ValueTask HandleNewDmbAvailable(CancellationToken cancellationToken) { gracefulRebootRequired = true; - if (Server.CompileJob.DMApiVersion == null) + if (Server!.CompileJob.DMApiVersion == null) { Chat.QueueWatchdogMessage( "A new deployment has been made but cannot be applied automatically as the currently running server has no DMAPI. Please manually reboot the server to apply the update."); diff --git a/src/Tgstation.Server.Host/Components/Watchdog/WindowsWatchdog.cs b/src/Tgstation.Server.Host/Components/Watchdog/WindowsWatchdog.cs index 4fb87385c9..e75ba74511 100644 --- a/src/Tgstation.Server.Host/Components/Watchdog/WindowsWatchdog.cs +++ b/src/Tgstation.Server.Host/Components/Watchdog/WindowsWatchdog.cs @@ -81,7 +81,7 @@ namespace Tgstation.Server.Host.Components.Watchdog /// protected override async ValueTask ApplyInitialDmb(CancellationToken cancellationToken) { - if (Server.EngineVersion.Engine != EngineType.Byond) + if (Server!.EngineVersion.Engine != EngineType.Byond) { Logger.LogTrace("Not setting InitialDmb for engine type {engineType}", Server.EngineVersion.Engine); return; From 7b458a67da0016e8075ec1d646c9eae58ce2a297 Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Sat, 23 Dec 2023 23:55:25 -0500 Subject: [PATCH 425/425] Nullify `WatchdogBase` --- .../Components/Watchdog/AdvancedWatchdog.cs | 4 +- .../Components/Watchdog/BasicWatchdog.cs | 2 +- .../Components/Watchdog/WatchdogBase.cs | 131 +++++++++++------- 3 files changed, 84 insertions(+), 53 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Watchdog/AdvancedWatchdog.cs b/src/Tgstation.Server.Host/Components/Watchdog/AdvancedWatchdog.cs index 347048921d..884541e9fb 100644 --- a/src/Tgstation.Server.Host/Components/Watchdog/AdvancedWatchdog.cs +++ b/src/Tgstation.Server.Host/Components/Watchdog/AdvancedWatchdog.cs @@ -233,7 +233,7 @@ namespace Tgstation.Server.Host.Components.Watchdog IDmbProvider compileJobProvider = DmbFactory.LockNextDmb(1); bool canSeamlesslySwap = CanUseSwappableDmbProvider(compileJobProvider); if (canSeamlesslySwap) - if (compileJobProvider.CompileJob.EngineVersion != ActiveCompileJob.EngineVersion) + if (compileJobProvider.CompileJob.EngineVersion != ActiveCompileJob!.EngineVersion) { // have to do a graceful restart Logger.LogDebug( @@ -265,7 +265,7 @@ namespace Tgstation.Server.Host.Components.Watchdog try { swappableProvider = CreateSwappableDmbProvider(compileJobProvider); - if (ActiveCompileJob.DMApiVersion == null) + if (ActiveCompileJob!.DMApiVersion == null) { Logger.LogWarning("Active compile job has no DMAPI! Commencing immediate .dmb swap. Note this behavior is known to be buggy in some DM code contexts. See https://github.com/tgstation/tgstation-server/issues/1550"); await PerformDmbSwap(swappableProvider, cancellationToken); diff --git a/src/Tgstation.Server.Host/Components/Watchdog/BasicWatchdog.cs b/src/Tgstation.Server.Host/Components/Watchdog/BasicWatchdog.cs index 37b9bed41c..10b6a7b19c 100644 --- a/src/Tgstation.Server.Host/Components/Watchdog/BasicWatchdog.cs +++ b/src/Tgstation.Server.Host/Components/Watchdog/BasicWatchdog.cs @@ -208,7 +208,7 @@ namespace Tgstation.Server.Host.Components.Watchdog /// protected override async ValueTask InitController( ValueTask eventTask, - ReattachInformation reattachInfo, + ReattachInformation? reattachInfo, CancellationToken cancellationToken) { // don't need a new dmb if reattaching diff --git a/src/Tgstation.Server.Host/Components/Watchdog/WatchdogBase.cs b/src/Tgstation.Server.Host/Components/Watchdog/WatchdogBase.cs index 0750f006d6..e922322995 100644 --- a/src/Tgstation.Server.Host/Components/Watchdog/WatchdogBase.cs +++ b/src/Tgstation.Server.Host/Components/Watchdog/WatchdogBase.cs @@ -27,8 +27,6 @@ using Tgstation.Server.Host.IO; using Tgstation.Server.Host.Jobs; using Tgstation.Server.Host.Utils; -#nullable disable - namespace Tgstation.Server.Host.Components.Watchdog { /// @@ -58,10 +56,10 @@ namespace Tgstation.Server.Host.Components.Watchdog public DreamDaemonLaunchParameters ActiveLaunchParameters { get; protected set; } /// - public DreamDaemonLaunchParameters LastLaunchParameters { get; protected set; } + public DreamDaemonLaunchParameters? LastLaunchParameters { get; protected set; } /// - public Models.CompileJob ActiveCompileJob => GetActiveController()?.CompileJob; + public Models.CompileJob? ActiveCompileJob => GetActiveController()?.CompileJob; /// public abstract RebootState? RebootState { get; } @@ -154,12 +152,12 @@ namespace Tgstation.Server.Host.Components.Watchdog /// /// The for the monitor loop. /// - CancellationTokenSource monitorCts; + CancellationTokenSource? monitorCts; /// /// The running the monitor loop. /// - Task monitorTask; + Task? monitorTask; /// /// Backing field for . @@ -395,7 +393,7 @@ namespace Tgstation.Server.Host.Components.Watchdog job, async (core, databaseContextFactory, paramJob, progressFunction, ct) => { - if (core.Watchdog != this) + if (core?.Watchdog != this) throw new InvalidOperationException(Instance.DifferentCoreExceptionMessage); using (await SemaphoreSlimContext.Lock(synchronizationSemaphore, ct)) @@ -418,7 +416,7 @@ namespace Tgstation.Server.Host.Components.Watchdog } /// - public async ValueTask HandleRestart(Version updateVersion, bool handlerMayDelayShutdownWithExtremelyLongRunningTasks, CancellationToken cancellationToken) + public async ValueTask HandleRestart(Version? updateVersion, bool handlerMayDelayShutdownWithExtremelyLongRunningTasks, CancellationToken cancellationToken) { if (handlerMayDelayShutdownWithExtremelyLongRunningTasks) { @@ -427,7 +425,7 @@ namespace Tgstation.Server.Host.Components.Watchdog if (Status != WatchdogStatus.Offline) { Logger.LogDebug("Waiting for server to gracefully shut down."); - await monitorTask.WaitAsync(cancellationToken); + await monitorTask!.WaitAsync(cancellationToken); } else Logger.LogTrace("Graceful shutdown requested but server is already offline."); @@ -490,7 +488,7 @@ namespace Tgstation.Server.Host.Components.Watchdog } /// - async ValueTask IEventConsumer.HandleEvent(EventType eventType, IEnumerable parameters, bool deploymentPipeline, CancellationToken cancellationToken) + async ValueTask IEventConsumer.HandleEvent(EventType eventType, IEnumerable parameters, bool deploymentPipeline, CancellationToken cancellationToken) { ArgumentNullException.ThrowIfNull(parameters); @@ -516,7 +514,7 @@ namespace Tgstation.Server.Host.Components.Watchdog /// to use, if any. /// The for the operation. /// A representing the running operation. - protected abstract ValueTask InitController(ValueTask eventTask, ReattachInformation reattachInfo, CancellationToken cancellationToken); + protected abstract ValueTask InitController(ValueTask eventTask, ReattachInformation? reattachInfo, CancellationToken cancellationToken); /// /// Launches the watchdog. @@ -531,7 +529,7 @@ namespace Tgstation.Server.Host.Components.Watchdog bool startMonitor, bool announce, bool announceFailure, - ReattachInformation reattachInfo, + ReattachInformation? reattachInfo, CancellationToken cancellationToken) { Logger.LogTrace("Begin LaunchImplNoLock"); @@ -612,7 +610,7 @@ namespace Tgstation.Server.Host.Components.Watchdog if (monitorTask == null) return false; var wasRunning = !monitorTask.IsCompleted; - monitorCts.Cancel(); + monitorCts!.Cancel(); await monitorTask; Logger.LogTrace("Stopped Monitor"); monitorCts.Dispose(); @@ -640,7 +638,7 @@ namespace Tgstation.Server.Host.Components.Watchdog if (!launchResult.StartupTime.HasValue) throw new JobException( ErrorCode.WatchdogStartupTimeout, - new JobException($"{serverName} timed out on startup: {ActiveLaunchParameters.StartupTimeout.Value}s")); + new JobException($"{serverName} timed out on startup: {ActiveLaunchParameters.StartupTimeout!.Value}s")); } /// @@ -685,8 +683,8 @@ namespace Tgstation.Server.Host.Components.Watchdog /// /// Get the active . /// - /// The active . - protected abstract ISessionController GetActiveController(); + /// The active , if any. + protected abstract ISessionController? GetActiveController(); /// /// Handles the actions to take when the monitor has to "wake up". @@ -718,9 +716,9 @@ namespace Tgstation.Server.Host.Components.Watchdog var eventTask = eventConsumer.HandleEvent( EventType.DeploymentActivation, - new List + new List { - GameIOManager.ResolvePath(newCompileJob.DirectoryName.ToString()), + GameIOManager.ResolvePath(newCompileJob.DirectoryName!.Value.ToString()), }, false, cancellationToken); @@ -845,13 +843,14 @@ namespace Tgstation.Server.Host.Components.Watchdog try { MonitorAction nextAction = MonitorAction.Continue; - Task activeServerLifetime = null, + Task? activeServerLifetime = null, activeServerReboot = null, activeServerStartup = null, serverPrimed = null, activeLaunchParametersChanged = null, - newDmbAvailable = null; - ISessionController lastController = null; + newDmbAvailable = null, + healthCheck = null; + ISessionController? lastController = null; var ranInitialDmbCheck = false; for (ulong iteration = 1; nextAction != MonitorAction.Exit; ++iteration) using (LogContext.PushProperty(SerilogContextHelper.WatchdogMonitorIterationContextProperty, iteration)) @@ -867,7 +866,7 @@ namespace Tgstation.Server.Host.Components.Watchdog void UpdateMonitoredTasks() { var sameController = lastController == controller; - void TryUpdateTask(ref Task oldTask, Func newTaskFactory) + void TryUpdateTask(ref Task? oldTask, Func newTaskFactory) { if (sameController && oldTask?.IsCompleted == true) return; @@ -875,7 +874,7 @@ namespace Tgstation.Server.Host.Components.Watchdog oldTask = newTaskFactory(); } - controller.RebootGate = nextMonitorWakeupTcs.Task; + controller!.RebootGate = nextMonitorWakeupTcs.Task; TryUpdateTask(ref activeServerLifetime, () => controller.Lifetime); TryUpdateTask(ref activeServerReboot, () => controller.OnReboot); @@ -898,28 +897,36 @@ namespace Tgstation.Server.Host.Components.Watchdog }); } - UpdateMonitoredTasks(); + if (controller != null) + { + UpdateMonitoredTasks(); - var healthCheckSeconds = ActiveLaunchParameters.HealthCheckSeconds.Value; - var healthCheck = healthCheckSeconds == 0 - || !controller.DMApiAvailable - ? Extensions.TaskExtensions.InfiniteTask - : Task.Delay( - TimeSpan.FromSeconds(healthCheckSeconds), - cancellationToken); + var healthCheckSeconds = ActiveLaunchParameters.HealthCheckSeconds!.Value; + healthCheck = healthCheckSeconds == 0 + || !controller.DMApiAvailable + ? Extensions.TaskExtensions.InfiniteTask + : Task.Delay( + TimeSpan.FromSeconds(healthCheckSeconds), + cancellationToken); - // cancel waiting if requested - var toWaitOn = Task.WhenAny( - activeServerLifetime, - activeServerReboot, - activeServerStartup, - healthCheck, - newDmbAvailable, - activeLaunchParametersChanged, - serverPrimed); + // cancel waiting if requested + var toWaitOn = Task.WhenAny( + activeServerLifetime!, + activeServerReboot!, + activeServerStartup!, + healthCheck, + newDmbAvailable!, + activeLaunchParametersChanged!, + serverPrimed!); - // wait for something to happen - await toWaitOn.WaitAsync(cancellationToken); + // wait for something to happen + await toWaitOn.WaitAsync(cancellationToken); + } + else + { + Logger.LogError("Controller was null on monitor wakeup! Attempting restart..."); + nextAction = MonitorAction.Restart; // excuse me wtf? + } cancellationToken.ThrowIfCancellationRequested(); Logger.LogTrace("Monitor activated"); @@ -928,7 +935,7 @@ namespace Tgstation.Server.Host.Components.Watchdog using (await SemaphoreSlimContext.Lock(synchronizationSemaphore, cancellationToken)) { // Set this sooner so chat sends don't hold us up - if (activeServerLifetime.IsCompleted) + if (activeServerLifetime!.IsCompleted) Status = WatchdogStatus.Restoring; // multiple things may have happened, handle them one at a time @@ -936,7 +943,7 @@ namespace Tgstation.Server.Host.Components.Watchdog { MonitorActivationReason activationReason = default; // this will always be assigned before being used - bool CheckActivationReason(ref Task task, MonitorActivationReason testActivationReason) + bool CheckActivationReason(ref Task? task, MonitorActivationReason testActivationReason) { var taskCompleted = task?.IsCompleted == true; task = null; @@ -1027,7 +1034,10 @@ namespace Tgstation.Server.Host.Components.Watchdog { Logger.LogTrace("Detaching server..."); var controller = GetActiveController(); - await controller.Release(); + if (controller != null) + await controller.Release(); + else + Logger.LogError("Controller was null on monitor shutdown!"); } } @@ -1091,6 +1101,9 @@ namespace Tgstation.Server.Host.Components.Watchdog { Logger.LogTrace("Sending health check to active server..."); var activeServer = GetActiveController(); + if (activeServer == null) + return MonitorAction.Restart; // uhhhh??? + var response = await activeServer.SendCommand(new TopicParameters(), cancellationToken); var shouldShutdown = activeServer.RebootState == Session.RebootState.Shutdown; @@ -1130,7 +1143,7 @@ namespace Tgstation.Server.Host.Components.Watchdog actionTaken, StringComparison.Ordinal)); - if (ActiveLaunchParameters.DumpOnHealthCheckRestart.Value) + if (ActiveLaunchParameters.DumpOnHealthCheckRestart!.Value) { Logger.LogDebug("DumpOnHealthCheckRestart enabled."); try @@ -1166,13 +1179,30 @@ namespace Tgstation.Server.Host.Components.Watchdog /// Handle any in a given topic . /// /// The . - void HandleChatResponses(TopicResponse result) + void HandleChatResponses(TopicResponse? result) { if (result?.ChatResponses != null) - foreach (var response in result.ChatResponses) + { + var warnedMissingChannelIds = false; + foreach (var response in result.ChatResponses + .Where(response => + { + if (response.ChannelIds == null) + { + if (!warnedMissingChannelIds) + { + Logger.LogWarning("DMAPI response contains null channelIds!"); + warnedMissingChannelIds = true; + } + + return false; + } + + return true; + })) Chat.QueueMessage( response, - response.ChannelIds + response.ChannelIds! .Select(channelIdString => { if (UInt64.TryParse(channelIdString, out var channelId)) @@ -1183,7 +1213,8 @@ namespace Tgstation.Server.Host.Components.Watchdog return null; }) .Where(nullableChannelId => nullableChannelId.HasValue) - .Select(nullableChannelId => nullableChannelId.Value)); + .Select(nullableChannelId => nullableChannelId!.Value)); + } } ///