diff --git a/DiscordChatExporter.Cli/DiscordChatExporter.Cli.csproj b/DiscordChatExporter.Cli/DiscordChatExporter.Cli.csproj
index db538f38..9dd13ac2 100644
--- a/DiscordChatExporter.Cli/DiscordChatExporter.Cli.csproj
+++ b/DiscordChatExporter.Cli/DiscordChatExporter.Cli.csproj
@@ -13,7 +13,7 @@
-
+
diff --git a/DiscordChatExporter.Cli/Verbs/ExportChannelVerb.cs b/DiscordChatExporter.Cli/Verbs/ExportChannelVerb.cs
index 00c7a36e..1dc7c572 100644
--- a/DiscordChatExporter.Cli/Verbs/ExportChannelVerb.cs
+++ b/DiscordChatExporter.Cli/Verbs/ExportChannelVerb.cs
@@ -24,7 +24,7 @@ namespace DiscordChatExporter.Cli.Verbs
var exportService = Container.Instance.Get();
// Configure settings
- if (!Options.DateFormat.EmptyIfNull().IsWhiteSpace())
+ if (!Options.DateFormat.IsNullOrWhiteSpace())
settingsService.DateFormat = Options.DateFormat;
// Track progress
@@ -37,7 +37,7 @@ namespace DiscordChatExporter.Cli.Verbs
// Generate file path if not set or is a directory
var filePath = Options.OutputPath;
- if (filePath.EmptyIfNull().IsWhiteSpace() || ExportHelper.IsDirectoryPath(filePath))
+ if (filePath.IsNullOrWhiteSpace() || ExportHelper.IsDirectoryPath(filePath))
{
// Generate default file name
var fileName = ExportHelper.GetDefaultExportFileName(Options.ExportFormat, chatLog.Guild,
diff --git a/DiscordChatExporter.Cli/Verbs/ExportDirectMessagesVerb.cs b/DiscordChatExporter.Cli/Verbs/ExportDirectMessagesVerb.cs
index 61e89464..1dd844f8 100644
--- a/DiscordChatExporter.Cli/Verbs/ExportDirectMessagesVerb.cs
+++ b/DiscordChatExporter.Cli/Verbs/ExportDirectMessagesVerb.cs
@@ -27,7 +27,7 @@ namespace DiscordChatExporter.Cli.Verbs
var exportService = Container.Instance.Get();
// Configure settings
- if (!Options.DateFormat.EmptyIfNull().IsWhiteSpace())
+ if (!Options.DateFormat.IsNullOrWhiteSpace())
settingsService.DateFormat = Options.DateFormat;
// Get channels
diff --git a/DiscordChatExporter.Cli/Verbs/ExportGuildVerb.cs b/DiscordChatExporter.Cli/Verbs/ExportGuildVerb.cs
index c7eef821..f271debd 100644
--- a/DiscordChatExporter.Cli/Verbs/ExportGuildVerb.cs
+++ b/DiscordChatExporter.Cli/Verbs/ExportGuildVerb.cs
@@ -28,7 +28,7 @@ namespace DiscordChatExporter.Cli.Verbs
var exportService = Container.Instance.Get();
// Configure settings
- if (!Options.DateFormat.EmptyIfNull().IsWhiteSpace())
+ if (!Options.DateFormat.IsNullOrWhiteSpace())
settingsService.DateFormat = Options.DateFormat;
// Get channels
diff --git a/DiscordChatExporter.Core.Markdown/DiscordChatExporter.Core.Markdown.csproj b/DiscordChatExporter.Core.Markdown/DiscordChatExporter.Core.Markdown.csproj
index 03f624f8..20446bcc 100644
--- a/DiscordChatExporter.Core.Markdown/DiscordChatExporter.Core.Markdown.csproj
+++ b/DiscordChatExporter.Core.Markdown/DiscordChatExporter.Core.Markdown.csproj
@@ -5,7 +5,7 @@
-
+
\ No newline at end of file
diff --git a/DiscordChatExporter.Core.Markdown/MarkdownParser.cs b/DiscordChatExporter.Core.Markdown/MarkdownParser.cs
index e9e6a295..ce7dc139 100644
--- a/DiscordChatExporter.Core.Markdown/MarkdownParser.cs
+++ b/DiscordChatExporter.Core.Markdown/MarkdownParser.cs
@@ -113,7 +113,7 @@ namespace DiscordChatExporter.Core.Markdown
// Capture <:lul:123456> or
private static readonly IMatcher CustomEmojiNodeMatcher = new RegexMatcher(
new Regex("<(a)?:(.+?):(\\d+?)>", DefaultRegexOptions),
- m => new EmojiNode(m.Value, m.Groups[3].Value, m.Groups[2].Value, !m.Groups[1].Value.IsEmpty()));
+ m => new EmojiNode(m.Value, m.Groups[3].Value, m.Groups[2].Value, !m.Groups[1].Value.IsNullOrWhiteSpace()));
/* Links */
diff --git a/DiscordChatExporter.Core.Markdown/Nodes/EmojiNode.cs b/DiscordChatExporter.Core.Markdown/Nodes/EmojiNode.cs
index f372c4a5..86cef1d5 100644
--- a/DiscordChatExporter.Core.Markdown/Nodes/EmojiNode.cs
+++ b/DiscordChatExporter.Core.Markdown/Nodes/EmojiNode.cs
@@ -1,4 +1,6 @@
-namespace DiscordChatExporter.Core.Markdown.Nodes
+using Tyrrrz.Extensions;
+
+namespace DiscordChatExporter.Core.Markdown.Nodes
{
public class EmojiNode : Node
{
@@ -8,7 +10,7 @@
public bool IsAnimated { get; }
- public bool IsCustomEmoji => Id != null;
+ public bool IsCustomEmoji => !Id.IsNullOrWhiteSpace();
public EmojiNode(string source, string id, string name, bool isAnimated)
: base(source)
diff --git a/DiscordChatExporter.Core.Models/DiscordChatExporter.Core.Models.csproj b/DiscordChatExporter.Core.Models/DiscordChatExporter.Core.Models.csproj
index 03f624f8..20446bcc 100644
--- a/DiscordChatExporter.Core.Models/DiscordChatExporter.Core.Models.csproj
+++ b/DiscordChatExporter.Core.Models/DiscordChatExporter.Core.Models.csproj
@@ -5,7 +5,7 @@
-
+
\ No newline at end of file
diff --git a/DiscordChatExporter.Core.Models/Emoji.cs b/DiscordChatExporter.Core.Models/Emoji.cs
index b976e1fb..9de011f1 100644
--- a/DiscordChatExporter.Core.Models/Emoji.cs
+++ b/DiscordChatExporter.Core.Models/Emoji.cs
@@ -40,7 +40,7 @@ namespace DiscordChatExporter.Core.Models
public static string GetImageUrl(string id, string name, bool isAnimated)
{
// Custom emoji
- if (id != null)
+ if (!id.IsNullOrWhiteSpace())
{
// Animated
if (isAnimated)
diff --git a/DiscordChatExporter.Core.Models/Guild.cs b/DiscordChatExporter.Core.Models/Guild.cs
index cb70a19f..2fb93c13 100644
--- a/DiscordChatExporter.Core.Models/Guild.cs
+++ b/DiscordChatExporter.Core.Models/Guild.cs
@@ -1,4 +1,6 @@
-namespace DiscordChatExporter.Core.Models
+using Tyrrrz.Extensions;
+
+namespace DiscordChatExporter.Core.Models
{
// https://discordapp.com/developers/docs/resources/guild#guild-object
@@ -28,7 +30,7 @@
{
public static string GetIconUrl(string id, string iconHash)
{
- return iconHash != null
+ return !iconHash.IsNullOrWhiteSpace()
? $"https://cdn.discordapp.com/icons/{id}/{iconHash}.png"
: "https://cdn.discordapp.com/embed/avatars/0.png";
}
diff --git a/DiscordChatExporter.Core.Models/User.cs b/DiscordChatExporter.Core.Models/User.cs
index 2a5154cf..c239ef46 100644
--- a/DiscordChatExporter.Core.Models/User.cs
+++ b/DiscordChatExporter.Core.Models/User.cs
@@ -1,4 +1,5 @@
using System;
+using Tyrrrz.Extensions;
namespace DiscordChatExporter.Core.Models
{
@@ -39,7 +40,7 @@ namespace DiscordChatExporter.Core.Models
public static string GetAvatarUrl(string id, int discriminator, string avatarHash)
{
// Custom avatar
- if (avatarHash != null)
+ if (!avatarHash.IsNullOrWhiteSpace())
{
// Animated
if (avatarHash.StartsWith("a_", StringComparison.Ordinal))
diff --git a/DiscordChatExporter.Core.Rendering/HtmlChatLogRenderer.cs b/DiscordChatExporter.Core.Rendering/HtmlChatLogRenderer.cs
index a2daa023..331c2b26 100644
--- a/DiscordChatExporter.Core.Rendering/HtmlChatLogRenderer.cs
+++ b/DiscordChatExporter.Core.Rendering/HtmlChatLogRenderer.cs
@@ -92,7 +92,7 @@ namespace DiscordChatExporter.Core.Rendering
if (node is MultilineCodeBlockNode multilineCodeBlockNode)
{
// Set language class for syntax highlighting
- var languageCssClass = multilineCodeBlockNode.Language != null
+ var languageCssClass = !multilineCodeBlockNode.Language.IsNullOrWhiteSpace()
? "language-" + multilineCodeBlockNode.Language
: null;
diff --git a/DiscordChatExporter.Core.Services/DataService.Parsers.cs b/DiscordChatExporter.Core.Services/DataService.Parsers.cs
index 5b4cac40..1d8cea41 100644
--- a/DiscordChatExporter.Core.Services/DataService.Parsers.cs
+++ b/DiscordChatExporter.Core.Services/DataService.Parsers.cs
@@ -41,14 +41,14 @@ namespace DiscordChatExporter.Core.Services
var guildId = json["guild_id"]?.Value();
// If the guild ID is blank, it's direct messages
- if (guildId == null)
+ if (guildId.IsNullOrWhiteSpace())
guildId = Guild.DirectMessages.Id;
// Try to extract name
var name = json["name"]?.Value();
// If the name is blank, it's direct messages
- if (name == null)
+ if (name.IsNullOrWhiteSpace())
name = json["recipients"].Select(ParseUser).Select(u => u.Name).JoinToString(", ");
return new Channel(id, parentId, guildId, name, topic, type);
diff --git a/DiscordChatExporter.Core.Services/DataService.cs b/DiscordChatExporter.Core.Services/DataService.cs
index cec862e1..c6d0f3b2 100644
--- a/DiscordChatExporter.Core.Services/DataService.cs
+++ b/DiscordChatExporter.Core.Services/DataService.cs
@@ -48,7 +48,7 @@ namespace DiscordChatExporter.Core.Services
var value = parameter.SubstringAfter("=");
// Skip empty values
- if (value.IsEmpty())
+ if (value.IsNullOrWhiteSpace())
continue;
request.RequestUri = request.RequestUri.SetQueryParameter(key, value);
diff --git a/DiscordChatExporter.Core.Services/DiscordChatExporter.Core.Services.csproj b/DiscordChatExporter.Core.Services/DiscordChatExporter.Core.Services.csproj
index 42a5f6f5..ffa8a484 100644
--- a/DiscordChatExporter.Core.Services/DiscordChatExporter.Core.Services.csproj
+++ b/DiscordChatExporter.Core.Services/DiscordChatExporter.Core.Services.csproj
@@ -8,7 +8,7 @@
-
+
diff --git a/DiscordChatExporter.Core.Services/ExportService.cs b/DiscordChatExporter.Core.Services/ExportService.cs
index 85d544df..5c4b70c9 100644
--- a/DiscordChatExporter.Core.Services/ExportService.cs
+++ b/DiscordChatExporter.Core.Services/ExportService.cs
@@ -38,7 +38,7 @@ namespace DiscordChatExporter.Core.Services
{
// Create output directory
var dirPath = Path.GetDirectoryName(filePath);
- if (!dirPath.EmptyIfNull().IsWhiteSpace())
+ if (!dirPath.IsNullOrWhiteSpace())
Directory.CreateDirectory(dirPath);
// Render chat log to output file
@@ -74,7 +74,7 @@ namespace DiscordChatExporter.Core.Services
var partitionFilePath = $"{fileNameWithoutExt} [{partitionNumber} of {partitions.Length}]{fileExt}";
// Compose full file path
- if (!dirPath.EmptyIfNull().IsWhiteSpace())
+ if (!dirPath.IsNullOrWhiteSpace())
partitionFilePath = Path.Combine(dirPath, partitionFilePath);
// Export
diff --git a/DiscordChatExporter.Core.Services/Helpers/ExportHelper.cs b/DiscordChatExporter.Core.Services/Helpers/ExportHelper.cs
index 9ea3bbba..142b70d9 100644
--- a/DiscordChatExporter.Core.Services/Helpers/ExportHelper.cs
+++ b/DiscordChatExporter.Core.Services/Helpers/ExportHelper.cs
@@ -3,6 +3,7 @@ using System.IO;
using System.Linq;
using System.Text;
using DiscordChatExporter.Core.Models;
+using Tyrrrz.Extensions;
namespace DiscordChatExporter.Core.Services.Helpers
{
@@ -11,7 +12,7 @@ namespace DiscordChatExporter.Core.Services.Helpers
public static bool IsDirectoryPath(string path) =>
path.Last() == Path.DirectorySeparatorChar ||
path.Last() == Path.AltDirectorySeparatorChar ||
- Path.GetExtension(path) == null;
+ (Path.GetExtension(path).IsNullOrWhiteSpace() && !File.Exists(path));
public static string GetDefaultExportFileName(ExportFormat format, Guild guild, Channel channel,
DateTimeOffset? after = null, DateTimeOffset? before = null)
diff --git a/DiscordChatExporter.Gui/DiscordChatExporter.Gui.csproj b/DiscordChatExporter.Gui/DiscordChatExporter.Gui.csproj
index 805d860e..56d7cde2 100644
--- a/DiscordChatExporter.Gui/DiscordChatExporter.Gui.csproj
+++ b/DiscordChatExporter.Gui/DiscordChatExporter.Gui.csproj
@@ -148,7 +148,7 @@
2.0.20525
- 1.6.0
+ 1.6.1
diff --git a/DiscordChatExporter.Gui/ViewModels/Dialogs/ExportSetupViewModel.cs b/DiscordChatExporter.Gui/ViewModels/Dialogs/ExportSetupViewModel.cs
index 4858d497..bd0df609 100644
--- a/DiscordChatExporter.Gui/ViewModels/Dialogs/ExportSetupViewModel.cs
+++ b/DiscordChatExporter.Gui/ViewModels/Dialogs/ExportSetupViewModel.cs
@@ -6,6 +6,7 @@ using DiscordChatExporter.Core.Services;
using DiscordChatExporter.Core.Services.Helpers;
using DiscordChatExporter.Gui.ViewModels.Components;
using DiscordChatExporter.Gui.ViewModels.Framework;
+using Tyrrrz.Extensions;
namespace DiscordChatExporter.Gui.ViewModels.Dialogs
{
@@ -84,7 +85,7 @@ namespace DiscordChatExporter.Gui.ViewModels.Dialogs
}
// If canceled - return
- if (OutputPath == null)
+ if (OutputPath.IsNullOrWhiteSpace())
return;
// Close dialog
diff --git a/DiscordChatExporter.Gui/ViewModels/RootViewModel.cs b/DiscordChatExporter.Gui/ViewModels/RootViewModel.cs
index e5b24083..f1e24752 100644
--- a/DiscordChatExporter.Gui/ViewModels/RootViewModel.cs
+++ b/DiscordChatExporter.Gui/ViewModels/RootViewModel.cs
@@ -122,7 +122,7 @@ namespace DiscordChatExporter.Gui.ViewModels
await _dialogManager.ShowDialogAsync(dialog);
}
- public bool CanPopulateGuildsAndChannels => !IsBusy && !TokenValue.EmptyIfNull().IsWhiteSpace();
+ public bool CanPopulateGuildsAndChannels => !IsBusy && !TokenValue.IsNullOrWhiteSpace();
public async void PopulateGuildsAndChannels()
{
@@ -235,7 +235,7 @@ namespace DiscordChatExporter.Gui.ViewModels
}
}
- public bool CanExportChannels => !IsBusy && SelectedChannels.EmptyIfNull().Any();
+ public bool CanExportChannels => !IsBusy && !SelectedChannels.IsNullOrEmpty();
public async void ExportChannels()
{