From 73e2e0624b0fa56bff6f17f0db3e46b5b4fbc2b8 Mon Sep 17 00:00:00 2001 From: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com> Date: Sat, 10 Aug 2024 22:28:07 +0300 Subject: [PATCH] Use a few new APIs --- DiscordChatExporter.Core/Exporting/HtmlMessageWriter.cs | 2 +- DiscordChatExporter.Core/Utils/PathEx.cs | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/DiscordChatExporter.Core/Exporting/HtmlMessageWriter.cs b/DiscordChatExporter.Core/Exporting/HtmlMessageWriter.cs index 5d071b49..1747afd2 100644 --- a/DiscordChatExporter.Core/Exporting/HtmlMessageWriter.cs +++ b/DiscordChatExporter.Core/Exporting/HtmlMessageWriter.cs @@ -15,7 +15,7 @@ internal class HtmlMessageWriter(Stream stream, ExportContext context, string th private readonly TextWriter _writer = new StreamWriter(stream); private readonly HtmlMinifier _minifier = new(); - private readonly List _messageGroup = new(); + private readonly List _messageGroup = []; private bool CanJoinGroup(Message message) { diff --git a/DiscordChatExporter.Core/Utils/PathEx.cs b/DiscordChatExporter.Core/Utils/PathEx.cs index c85b54aa..26195a3a 100644 --- a/DiscordChatExporter.Core/Utils/PathEx.cs +++ b/DiscordChatExporter.Core/Utils/PathEx.cs @@ -1,6 +1,6 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.IO; -using System.Runtime.InteropServices; using System.Text; namespace DiscordChatExporter.Core.Utils; @@ -8,7 +8,7 @@ namespace DiscordChatExporter.Core.Utils; public static class PathEx { private static readonly HashSet InvalidFileNameChars = - new(Path.GetInvalidFileNameChars()); + [..Path.GetInvalidFileNameChars()]; public static string EscapeFileName(string path) { @@ -19,7 +19,7 @@ public static class PathEx // File names cannot end with a dot on Windows // https://github.com/Tyrrrz/DiscordChatExporter/issues/977 - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) + if (OperatingSystem.IsWindows()) { while (buffer.Length > 0 && buffer[^1] == '.') buffer.Remove(buffer.Length - 1, 1);