From 182f24846b31237348fb781ff040f0c84c261cd0 Mon Sep 17 00:00:00 2001 From: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com> Date: Thu, 11 Jan 2024 22:21:53 +0200 Subject: [PATCH] Use new array syntax --- .../Infra/ExportWrapper.cs | 2 +- .../Specs/DateRangeSpecs.cs | 21 ++++++++----------- .../Specs/FilterSpecs.cs | 10 ++++----- .../Specs/HtmlGroupingSpecs.cs | 2 +- .../Specs/PartitioningSpecs.cs | 4 ++-- .../Specs/SelfContainedSpecs.cs | 2 +- DiscordChatExporter.Core/Markdown/LinkNode.cs | 2 +- 7 files changed, 20 insertions(+), 23 deletions(-) diff --git a/DiscordChatExporter.Cli.Tests/Infra/ExportWrapper.cs b/DiscordChatExporter.Cli.Tests/Infra/ExportWrapper.cs index e7febfc..d0a389f 100644 --- a/DiscordChatExporter.Cli.Tests/Infra/ExportWrapper.cs +++ b/DiscordChatExporter.Cli.Tests/Infra/ExportWrapper.cs @@ -57,7 +57,7 @@ public static class ExportWrapper await new ExportChannelsCommand { Token = Secrets.DiscordToken, - ChannelIds = new[] { channelId }, + ChannelIds = [channelId], ExportFormat = format, OutputPath = filePath, Locale = "en-US", diff --git a/DiscordChatExporter.Cli.Tests/Specs/DateRangeSpecs.cs b/DiscordChatExporter.Cli.Tests/Specs/DateRangeSpecs.cs index af9fcb8..7257711 100644 --- a/DiscordChatExporter.Cli.Tests/Specs/DateRangeSpecs.cs +++ b/DiscordChatExporter.Cli.Tests/Specs/DateRangeSpecs.cs @@ -27,7 +27,7 @@ public class DateRangeSpecs await new ExportChannelsCommand { Token = Secrets.DiscordToken, - ChannelIds = new[] { ChannelIds.DateRangeTestCases }, + ChannelIds = [ChannelIds.DateRangeTestCases], ExportFormat = ExportFormat.Json, OutputPath = file.Path, After = Snowflake.FromDate(after) @@ -45,14 +45,13 @@ public class DateRangeSpecs timestamps .Should() .BeEquivalentTo( - new[] - { + [ new DateTimeOffset(2021, 07, 24, 13, 49, 13, TimeSpan.Zero), new DateTimeOffset(2021, 07, 24, 14, 52, 38, TimeSpan.Zero), new DateTimeOffset(2021, 07, 24, 14, 52, 39, TimeSpan.Zero), new DateTimeOffset(2021, 07, 24, 14, 52, 40, TimeSpan.Zero), new DateTimeOffset(2021, 09, 08, 14, 26, 35, TimeSpan.Zero) - }, + ], o => o.Using( ctx => @@ -74,7 +73,7 @@ public class DateRangeSpecs await new ExportChannelsCommand { Token = Secrets.DiscordToken, - ChannelIds = new[] { ChannelIds.DateRangeTestCases }, + ChannelIds = [ChannelIds.DateRangeTestCases], ExportFormat = ExportFormat.Json, OutputPath = file.Path, Before = Snowflake.FromDate(before) @@ -92,12 +91,11 @@ public class DateRangeSpecs timestamps .Should() .BeEquivalentTo( - new[] - { + [ new DateTimeOffset(2021, 07, 19, 13, 34, 18, TimeSpan.Zero), new DateTimeOffset(2021, 07, 19, 15, 58, 48, TimeSpan.Zero), new DateTimeOffset(2021, 07, 19, 17, 23, 58, TimeSpan.Zero) - }, + ], o => o.Using( ctx => @@ -120,7 +118,7 @@ public class DateRangeSpecs await new ExportChannelsCommand { Token = Secrets.DiscordToken, - ChannelIds = new[] { ChannelIds.DateRangeTestCases }, + ChannelIds = [ChannelIds.DateRangeTestCases], ExportFormat = ExportFormat.Json, OutputPath = file.Path, Before = Snowflake.FromDate(before), @@ -139,13 +137,12 @@ public class DateRangeSpecs timestamps .Should() .BeEquivalentTo( - new[] - { + [ new DateTimeOffset(2021, 07, 24, 13, 49, 13, TimeSpan.Zero), new DateTimeOffset(2021, 07, 24, 14, 52, 38, TimeSpan.Zero), new DateTimeOffset(2021, 07, 24, 14, 52, 39, TimeSpan.Zero), new DateTimeOffset(2021, 07, 24, 14, 52, 40, TimeSpan.Zero) - }, + ], o => o.Using( ctx => diff --git a/DiscordChatExporter.Cli.Tests/Specs/FilterSpecs.cs b/DiscordChatExporter.Cli.Tests/Specs/FilterSpecs.cs index d22099e..d5b7675 100644 --- a/DiscordChatExporter.Cli.Tests/Specs/FilterSpecs.cs +++ b/DiscordChatExporter.Cli.Tests/Specs/FilterSpecs.cs @@ -25,7 +25,7 @@ public class FilterSpecs await new ExportChannelsCommand { Token = Secrets.DiscordToken, - ChannelIds = new[] { ChannelIds.FilterTestCases }, + ChannelIds = [ChannelIds.FilterTestCases], ExportFormat = ExportFormat.Json, OutputPath = file.Path, MessageFilter = MessageFilter.Parse("some text") @@ -50,7 +50,7 @@ public class FilterSpecs await new ExportChannelsCommand { Token = Secrets.DiscordToken, - ChannelIds = new[] { ChannelIds.FilterTestCases }, + ChannelIds = [ChannelIds.FilterTestCases], ExportFormat = ExportFormat.Json, OutputPath = file.Path, MessageFilter = MessageFilter.Parse("from:Tyrrrz") @@ -75,7 +75,7 @@ public class FilterSpecs await new ExportChannelsCommand { Token = Secrets.DiscordToken, - ChannelIds = new[] { ChannelIds.FilterTestCases }, + ChannelIds = [ChannelIds.FilterTestCases], ExportFormat = ExportFormat.Json, OutputPath = file.Path, MessageFilter = MessageFilter.Parse("has:image") @@ -100,7 +100,7 @@ public class FilterSpecs await new ExportChannelsCommand { Token = Secrets.DiscordToken, - ChannelIds = new[] { ChannelIds.FilterTestCases }, + ChannelIds = [ChannelIds.FilterTestCases], ExportFormat = ExportFormat.Json, OutputPath = file.Path, MessageFilter = MessageFilter.Parse("has:pin") @@ -125,7 +125,7 @@ public class FilterSpecs await new ExportChannelsCommand { Token = Secrets.DiscordToken, - ChannelIds = new[] { ChannelIds.FilterTestCases }, + ChannelIds = [ChannelIds.FilterTestCases], ExportFormat = ExportFormat.Json, OutputPath = file.Path, MessageFilter = MessageFilter.Parse("mentions:Tyrrrz") diff --git a/DiscordChatExporter.Cli.Tests/Specs/HtmlGroupingSpecs.cs b/DiscordChatExporter.Cli.Tests/Specs/HtmlGroupingSpecs.cs index 769ef91..8ccb64a 100644 --- a/DiscordChatExporter.Cli.Tests/Specs/HtmlGroupingSpecs.cs +++ b/DiscordChatExporter.Cli.Tests/Specs/HtmlGroupingSpecs.cs @@ -26,7 +26,7 @@ public class HtmlGroupingSpecs await new ExportChannelsCommand { Token = Secrets.DiscordToken, - ChannelIds = new[] { ChannelIds.GroupingTestCases }, + ChannelIds = [ChannelIds.GroupingTestCases], ExportFormat = ExportFormat.HtmlDark, OutputPath = file.Path }.ExecuteAsync(new FakeConsole()); diff --git a/DiscordChatExporter.Cli.Tests/Specs/PartitioningSpecs.cs b/DiscordChatExporter.Cli.Tests/Specs/PartitioningSpecs.cs index e9f02fe..e245f91 100644 --- a/DiscordChatExporter.Cli.Tests/Specs/PartitioningSpecs.cs +++ b/DiscordChatExporter.Cli.Tests/Specs/PartitioningSpecs.cs @@ -24,7 +24,7 @@ public class PartitioningSpecs await new ExportChannelsCommand { Token = Secrets.DiscordToken, - ChannelIds = new[] { ChannelIds.DateRangeTestCases }, + ChannelIds = [ChannelIds.DateRangeTestCases], ExportFormat = ExportFormat.HtmlDark, OutputPath = filePath, PartitionLimit = PartitionLimit.Parse("3") @@ -45,7 +45,7 @@ public class PartitioningSpecs await new ExportChannelsCommand { Token = Secrets.DiscordToken, - ChannelIds = new[] { ChannelIds.DateRangeTestCases }, + ChannelIds = [ChannelIds.DateRangeTestCases], ExportFormat = ExportFormat.HtmlDark, OutputPath = filePath, PartitionLimit = PartitionLimit.Parse("1kb") diff --git a/DiscordChatExporter.Cli.Tests/Specs/SelfContainedSpecs.cs b/DiscordChatExporter.Cli.Tests/Specs/SelfContainedSpecs.cs index 94c0e1b..8699e92 100644 --- a/DiscordChatExporter.Cli.Tests/Specs/SelfContainedSpecs.cs +++ b/DiscordChatExporter.Cli.Tests/Specs/SelfContainedSpecs.cs @@ -24,7 +24,7 @@ public class SelfContainedSpecs await new ExportChannelsCommand { Token = Secrets.DiscordToken, - ChannelIds = new[] { ChannelIds.SelfContainedTestCases }, + ChannelIds = [ChannelIds.SelfContainedTestCases], ExportFormat = ExportFormat.HtmlDark, OutputPath = filePath, ShouldDownloadAssets = true diff --git a/DiscordChatExporter.Core/Markdown/LinkNode.cs b/DiscordChatExporter.Core/Markdown/LinkNode.cs index fc8714b..4f9d7e4 100644 --- a/DiscordChatExporter.Core/Markdown/LinkNode.cs +++ b/DiscordChatExporter.Core/Markdown/LinkNode.cs @@ -8,5 +8,5 @@ internal record LinkNode(string Url, IReadOnlyList Children) IContainerNode { public LinkNode(string url) - : this(url, new[] { new TextNode(url) }) { } + : this(url, [new TextNode(url)]) { } }