diff --git a/DiscordChatExporter.Cli/Commands/ExportChannelCommand.cs b/DiscordChatExporter.Cli/Commands/ExportChannelCommand.cs index dc86bbe..dda10f5 100644 --- a/DiscordChatExporter.Cli/Commands/ExportChannelCommand.cs +++ b/DiscordChatExporter.Cli/Commands/ExportChannelCommand.cs @@ -1,6 +1,6 @@ using System.Threading.Tasks; +using CliFx; using CliFx.Attributes; -using CliFx.Services; using DiscordChatExporter.Core.Services; namespace DiscordChatExporter.Cli.Commands @@ -16,6 +16,6 @@ namespace DiscordChatExporter.Cli.Commands { } - public override async Task ExecuteAsync(IConsole console) => await ExportAsync(console, ChannelId); + public override async ValueTask ExecuteAsync(IConsole console) => await ExportAsync(console, ChannelId); } } \ No newline at end of file diff --git a/DiscordChatExporter.Cli/Commands/ExportCommandBase.cs b/DiscordChatExporter.Cli/Commands/ExportCommandBase.cs index 35a3e89..161bc6e 100644 --- a/DiscordChatExporter.Cli/Commands/ExportCommandBase.cs +++ b/DiscordChatExporter.Cli/Commands/ExportCommandBase.cs @@ -1,8 +1,8 @@ using System; using System.IO; using System.Threading.Tasks; +using CliFx; using CliFx.Attributes; -using CliFx.Services; using CliFx.Utilities; using DiscordChatExporter.Core.Models; using DiscordChatExporter.Core.Services; @@ -40,7 +40,7 @@ namespace DiscordChatExporter.Cli.Commands ExportService = exportService; } - protected async Task ExportAsync(IConsole console, Guild guild, Channel channel) + protected async ValueTask ExportAsync(IConsole console, Guild guild, Channel channel) { if (!string.IsNullOrWhiteSpace(DateFormat)) SettingsService.DateFormat = DateFormat; @@ -56,13 +56,13 @@ namespace DiscordChatExporter.Cli.Commands console.Output.WriteLine(); } - protected async Task ExportAsync(IConsole console, Channel channel) + protected async ValueTask ExportAsync(IConsole console, Channel channel) { var guild = await DataService.GetGuildAsync(GetToken(), channel.GuildId); await ExportAsync(console, guild, channel); } - protected async Task ExportAsync(IConsole console, string channelId) + protected async ValueTask ExportAsync(IConsole console, string channelId) { var channel = await DataService.GetChannelAsync(GetToken(), channelId); await ExportAsync(console, channel); diff --git a/DiscordChatExporter.Cli/Commands/ExportDirectMessagesCommand.cs b/DiscordChatExporter.Cli/Commands/ExportDirectMessagesCommand.cs index 8bc9bdf..673ac41 100644 --- a/DiscordChatExporter.Cli/Commands/ExportDirectMessagesCommand.cs +++ b/DiscordChatExporter.Cli/Commands/ExportDirectMessagesCommand.cs @@ -1,8 +1,8 @@ using System.Linq; using System.Net; using System.Threading.Tasks; +using CliFx; using CliFx.Attributes; -using CliFx.Services; using DiscordChatExporter.Core.Models.Exceptions; using DiscordChatExporter.Core.Services; using DiscordChatExporter.Core.Services.Exceptions; @@ -17,7 +17,7 @@ namespace DiscordChatExporter.Cli.Commands { } - public override async Task ExecuteAsync(IConsole console) + public override async ValueTask ExecuteAsync(IConsole console) { // Get channels var channels = await DataService.GetDirectMessageChannelsAsync(GetToken()); diff --git a/DiscordChatExporter.Cli/Commands/ExportGuildCommand.cs b/DiscordChatExporter.Cli/Commands/ExportGuildCommand.cs index 586266c..ead8a3a 100644 --- a/DiscordChatExporter.Cli/Commands/ExportGuildCommand.cs +++ b/DiscordChatExporter.Cli/Commands/ExportGuildCommand.cs @@ -1,8 +1,8 @@ using System.Linq; using System.Net; using System.Threading.Tasks; +using CliFx; using CliFx.Attributes; -using CliFx.Services; using DiscordChatExporter.Core.Models; using DiscordChatExporter.Core.Models.Exceptions; using DiscordChatExporter.Core.Services; @@ -21,7 +21,7 @@ namespace DiscordChatExporter.Cli.Commands { } - public override async Task ExecuteAsync(IConsole console) + public override async ValueTask ExecuteAsync(IConsole console) { // Get channels var channels = await DataService.GetGuildChannelsAsync(GetToken(), GuildId); diff --git a/DiscordChatExporter.Cli/Commands/GetChannelsCommand.cs b/DiscordChatExporter.Cli/Commands/GetChannelsCommand.cs index 74e29d8..1c246ac 100644 --- a/DiscordChatExporter.Cli/Commands/GetChannelsCommand.cs +++ b/DiscordChatExporter.Cli/Commands/GetChannelsCommand.cs @@ -1,7 +1,7 @@ using System.Linq; using System.Threading.Tasks; +using CliFx; using CliFx.Attributes; -using CliFx.Services; using DiscordChatExporter.Core.Models; using DiscordChatExporter.Core.Services; @@ -18,7 +18,7 @@ namespace DiscordChatExporter.Cli.Commands { } - public override async Task ExecuteAsync(IConsole console) + public override async ValueTask ExecuteAsync(IConsole console) { // Get channels var channels = await DataService.GetGuildChannelsAsync(GetToken(), GuildId); diff --git a/DiscordChatExporter.Cli/Commands/GetDirectMessageChannelsCommand.cs b/DiscordChatExporter.Cli/Commands/GetDirectMessageChannelsCommand.cs index eeb0a43..1ae59c4 100644 --- a/DiscordChatExporter.Cli/Commands/GetDirectMessageChannelsCommand.cs +++ b/DiscordChatExporter.Cli/Commands/GetDirectMessageChannelsCommand.cs @@ -1,7 +1,7 @@ using System.Linq; using System.Threading.Tasks; +using CliFx; using CliFx.Attributes; -using CliFx.Services; using DiscordChatExporter.Core.Services; namespace DiscordChatExporter.Cli.Commands @@ -14,7 +14,7 @@ namespace DiscordChatExporter.Cli.Commands { } - public override async Task ExecuteAsync(IConsole console) + public override async ValueTask ExecuteAsync(IConsole console) { // Get channels var channels = await DataService.GetDirectMessageChannelsAsync(GetToken()); diff --git a/DiscordChatExporter.Cli/Commands/GetGuildsCommand.cs b/DiscordChatExporter.Cli/Commands/GetGuildsCommand.cs index b8c6a92..cc4c552 100644 --- a/DiscordChatExporter.Cli/Commands/GetGuildsCommand.cs +++ b/DiscordChatExporter.Cli/Commands/GetGuildsCommand.cs @@ -1,7 +1,7 @@ using System.Linq; using System.Threading.Tasks; +using CliFx; using CliFx.Attributes; -using CliFx.Services; using DiscordChatExporter.Core.Services; namespace DiscordChatExporter.Cli.Commands @@ -14,7 +14,7 @@ namespace DiscordChatExporter.Cli.Commands { } - public override async Task ExecuteAsync(IConsole console) + public override async ValueTask ExecuteAsync(IConsole console) { // Get guilds var guilds = await DataService.GetUserGuildsAsync(GetToken()); diff --git a/DiscordChatExporter.Cli/Commands/GuideCommand.cs b/DiscordChatExporter.Cli/Commands/GuideCommand.cs index 45a16ad..658b4e5 100644 --- a/DiscordChatExporter.Cli/Commands/GuideCommand.cs +++ b/DiscordChatExporter.Cli/Commands/GuideCommand.cs @@ -2,14 +2,13 @@ using System.Threading.Tasks; using CliFx; using CliFx.Attributes; -using CliFx.Services; namespace DiscordChatExporter.Cli.Commands { [Command("guide", Description = "Explains how to obtain token, guild or channel ID.")] public class GuideCommand : ICommand { - public Task ExecuteAsync(IConsole console) + public ValueTask ExecuteAsync(IConsole console) { console.WithForegroundColor(ConsoleColor.White, () => console.Output.WriteLine("To get user token:")); console.Output.WriteLine(" 1. Open Discord"); @@ -48,7 +47,7 @@ namespace DiscordChatExporter.Cli.Commands console.Output.WriteLine("If you still have unanswered questions, check out the wiki:"); console.Output.WriteLine("https://github.com/Tyrrrz/DiscordChatExporter/wiki"); - return Task.CompletedTask; + return default; } } } \ No newline at end of file diff --git a/DiscordChatExporter.Cli/Commands/TokenCommandBase.cs b/DiscordChatExporter.Cli/Commands/TokenCommandBase.cs index d746736..8dacf99 100644 --- a/DiscordChatExporter.Cli/Commands/TokenCommandBase.cs +++ b/DiscordChatExporter.Cli/Commands/TokenCommandBase.cs @@ -1,7 +1,6 @@ using System.Threading.Tasks; using CliFx; using CliFx.Attributes; -using CliFx.Services; using DiscordChatExporter.Core.Models; using DiscordChatExporter.Core.Services; @@ -24,6 +23,6 @@ namespace DiscordChatExporter.Cli.Commands protected AuthToken GetToken() => new AuthToken(IsBotToken ? AuthTokenType.Bot : AuthTokenType.User, TokenValue); - public abstract Task ExecuteAsync(IConsole console); + public abstract ValueTask ExecuteAsync(IConsole console); } } \ No newline at end of file diff --git a/DiscordChatExporter.Cli/DiscordChatExporter.Cli.csproj b/DiscordChatExporter.Cli/DiscordChatExporter.Cli.csproj index 87fd5de..539f641 100644 --- a/DiscordChatExporter.Cli/DiscordChatExporter.Cli.csproj +++ b/DiscordChatExporter.Cli/DiscordChatExporter.Cli.csproj @@ -7,8 +7,8 @@ - - + + diff --git a/DiscordChatExporter.Cli/Program.cs b/DiscordChatExporter.Cli/Program.cs index 6fcb8ef..16841ff 100644 --- a/DiscordChatExporter.Cli/Program.cs +++ b/DiscordChatExporter.Cli/Program.cs @@ -30,13 +30,13 @@ namespace DiscordChatExporter.Cli return services.BuildServiceProvider(); } - public static Task Main(string[] args) + public static async Task Main(string[] args) { var serviceProvider = ConfigureServices(); - return new CliApplicationBuilder() + return await new CliApplicationBuilder() .AddCommandsFromThisAssembly() - .UseCommandFactory(schema => (ICommand) serviceProvider.GetService(schema.Type)) + .UseTypeActivator(serviceProvider.GetService) .Build() .RunAsync(args); } diff --git a/DiscordChatExporter.Gui/DiscordChatExporter.Gui.csproj b/DiscordChatExporter.Gui/DiscordChatExporter.Gui.csproj index 366e3de..b7933d4 100644 --- a/DiscordChatExporter.Gui/DiscordChatExporter.Gui.csproj +++ b/DiscordChatExporter.Gui/DiscordChatExporter.Gui.csproj @@ -16,11 +16,11 @@ - + - +