From 40b61a2d798288a9cceaa520bb9af74ea07caefb Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Mon, 26 Jun 2023 18:53:50 -0400 Subject: [PATCH] ValueTask ICommand --- .../Components/Chat/Commands/ByondCommand.cs | 8 ++++---- .../Components/Chat/Commands/CustomCommand.cs | 2 +- .../Components/Chat/Commands/ICommand.cs | 4 ++-- .../Components/Chat/Commands/KekCommand.cs | 2 +- .../Components/Chat/Commands/PullRequestsCommand.cs | 2 +- .../Components/Chat/Commands/RevisionCommand.cs | 2 +- .../Components/Chat/Commands/VersionCommand.cs | 2 +- .../Components/Chat/ICustomCommandHandler.cs | 4 ++-- .../Components/Watchdog/WatchdogBase.cs | 2 +- 9 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/Tgstation.Server.Host/Components/Chat/Commands/ByondCommand.cs b/src/Tgstation.Server.Host/Components/Chat/Commands/ByondCommand.cs index e24c20a699..f0c87ef4df 100644 --- a/src/Tgstation.Server.Host/Components/Chat/Commands/ByondCommand.cs +++ b/src/Tgstation.Server.Host/Components/Chat/Commands/ByondCommand.cs @@ -47,19 +47,19 @@ namespace Tgstation.Server.Host.Components.Chat.Commands } /// - public Task Invoke(string arguments, ChatUser user, CancellationToken cancellationToken) + public ValueTask Invoke(string arguments, ChatUser user, CancellationToken cancellationToken) { if (arguments.Split(' ').Any(x => x.ToUpperInvariant() == "--ACTIVE")) - return Task.FromResult(new MessageContent + return ValueTask.FromResult(new MessageContent { Text = byondManager.ActiveVersion == null ? "None!" : String.Format(CultureInfo.InvariantCulture, "{0}.{1}", byondManager.ActiveVersion.Major, byondManager.ActiveVersion.Minor), }); if (watchdog.Status == WatchdogStatus.Offline) - return Task.FromResult(new MessageContent + return ValueTask.FromResult(new MessageContent { Text = "Server offline!", }); - return Task.FromResult(new MessageContent + return ValueTask.FromResult(new MessageContent { Text = watchdog.ActiveCompileJob?.ByondVersion ?? "None!", }); diff --git a/src/Tgstation.Server.Host/Components/Chat/Commands/CustomCommand.cs b/src/Tgstation.Server.Host/Components/Chat/Commands/CustomCommand.cs index 5b3c368d67..617b1dba48 100644 --- a/src/Tgstation.Server.Host/Components/Chat/Commands/CustomCommand.cs +++ b/src/Tgstation.Server.Host/Components/Chat/Commands/CustomCommand.cs @@ -37,7 +37,7 @@ namespace Tgstation.Server.Host.Components.Chat.Commands } /// - public Task Invoke(string arguments, ChatUser user, CancellationToken cancellationToken) + public ValueTask Invoke(string arguments, ChatUser user, CancellationToken cancellationToken) { if (handler == null) throw new InvalidOperationException("SetHandler() has not been called!"); diff --git a/src/Tgstation.Server.Host/Components/Chat/Commands/ICommand.cs b/src/Tgstation.Server.Host/Components/Chat/Commands/ICommand.cs index d66df87476..766f29b6c0 100644 --- a/src/Tgstation.Server.Host/Components/Chat/Commands/ICommand.cs +++ b/src/Tgstation.Server.Host/Components/Chat/Commands/ICommand.cs @@ -31,7 +31,7 @@ namespace Tgstation.Server.Host.Components.Chat.Commands /// The text after with leading whitespace trimmed. /// The who invoked the command. /// The for the operation. - /// A resulting in a to send to the invoker. - Task Invoke(string arguments, ChatUser user, CancellationToken cancellationToken); + /// A resulting in a to send to the invoker. + ValueTask Invoke(string arguments, ChatUser user, CancellationToken cancellationToken); } } diff --git a/src/Tgstation.Server.Host/Components/Chat/Commands/KekCommand.cs b/src/Tgstation.Server.Host/Components/Chat/Commands/KekCommand.cs index cde083b38c..a41278ae0a 100644 --- a/src/Tgstation.Server.Host/Components/Chat/Commands/KekCommand.cs +++ b/src/Tgstation.Server.Host/Components/Chat/Commands/KekCommand.cs @@ -25,7 +25,7 @@ namespace Tgstation.Server.Host.Components.Chat.Commands public bool AdminOnly => false; /// - public Task Invoke(string arguments, ChatUser user, CancellationToken cancellationToken) => Task.FromResult(new MessageContent + public ValueTask Invoke(string arguments, ChatUser user, CancellationToken cancellationToken) => ValueTask.FromResult(new MessageContent { Text = Kek, }); diff --git a/src/Tgstation.Server.Host/Components/Chat/Commands/PullRequestsCommand.cs b/src/Tgstation.Server.Host/Components/Chat/Commands/PullRequestsCommand.cs index 409c989a64..39a99bcac4 100644 --- a/src/Tgstation.Server.Host/Components/Chat/Commands/PullRequestsCommand.cs +++ b/src/Tgstation.Server.Host/Components/Chat/Commands/PullRequestsCommand.cs @@ -79,7 +79,7 @@ namespace Tgstation.Server.Host.Components.Chat.Commands /// // TODO: Decomplexify #pragma warning disable CA1506 - public async Task Invoke(string arguments, ChatUser user, CancellationToken cancellationToken) + public async ValueTask Invoke(string arguments, ChatUser user, CancellationToken cancellationToken) { IEnumerable results = null; var splits = arguments.Split(' '); diff --git a/src/Tgstation.Server.Host/Components/Chat/Commands/RevisionCommand.cs b/src/Tgstation.Server.Host/Components/Chat/Commands/RevisionCommand.cs index c0028964e2..aceff96435 100644 --- a/src/Tgstation.Server.Host/Components/Chat/Commands/RevisionCommand.cs +++ b/src/Tgstation.Server.Host/Components/Chat/Commands/RevisionCommand.cs @@ -47,7 +47,7 @@ namespace Tgstation.Server.Host.Components.Chat.Commands } /// - public async Task Invoke(string arguments, ChatUser user, CancellationToken cancellationToken) + public async ValueTask Invoke(string arguments, ChatUser user, CancellationToken cancellationToken) { string result; if (arguments.Split(' ').Any(x => x.ToUpperInvariant() == "--REPO")) diff --git a/src/Tgstation.Server.Host/Components/Chat/Commands/VersionCommand.cs b/src/Tgstation.Server.Host/Components/Chat/Commands/VersionCommand.cs index 08a7853c77..60e7f9e9a1 100644 --- a/src/Tgstation.Server.Host/Components/Chat/Commands/VersionCommand.cs +++ b/src/Tgstation.Server.Host/Components/Chat/Commands/VersionCommand.cs @@ -36,7 +36,7 @@ namespace Tgstation.Server.Host.Components.Chat.Commands } /// - public Task Invoke(string arguments, ChatUser user, CancellationToken cancellationToken) => Task.FromResult(new MessageContent + public ValueTask Invoke(string arguments, ChatUser user, CancellationToken cancellationToken) => ValueTask.FromResult(new MessageContent { Text = assemblyInformationProvider.VersionString, }); diff --git a/src/Tgstation.Server.Host/Components/Chat/ICustomCommandHandler.cs b/src/Tgstation.Server.Host/Components/Chat/ICustomCommandHandler.cs index e61a890cd8..bf406bb421 100644 --- a/src/Tgstation.Server.Host/Components/Chat/ICustomCommandHandler.cs +++ b/src/Tgstation.Server.Host/Components/Chat/ICustomCommandHandler.cs @@ -17,7 +17,7 @@ namespace Tgstation.Server.Host.Components.Chat /// Everything typed after minus leading spaces. /// The sending . /// The for the operation. - /// A resulting in the text to send back. - Task HandleChatCommand(string commandName, string arguments, ChatUser sender, CancellationToken cancellationToken); + /// A resulting in the text to send back. + ValueTask HandleChatCommand(string commandName, string arguments, ChatUser sender, CancellationToken cancellationToken); } } diff --git a/src/Tgstation.Server.Host/Components/Watchdog/WatchdogBase.cs b/src/Tgstation.Server.Host/Components/Watchdog/WatchdogBase.cs index 6df80546ca..a5eed5deaf 100644 --- a/src/Tgstation.Server.Host/Components/Watchdog/WatchdogBase.cs +++ b/src/Tgstation.Server.Host/Components/Watchdog/WatchdogBase.cs @@ -267,7 +267,7 @@ namespace Tgstation.Server.Host.Components.Watchdog } /// - public async Task HandleChatCommand(string commandName, string arguments, ChatUser sender, CancellationToken cancellationToken) + public async ValueTask HandleChatCommand(string commandName, string arguments, ChatUser sender, CancellationToken cancellationToken) { using (await SemaphoreSlimContext.Lock(synchronizationSemaphore, cancellationToken)) {