diff --git a/DiscordChatExporter.Cli/Commands/ExportCommandBase.cs b/DiscordChatExporter.Cli/Commands/ExportCommandBase.cs
index ddc5648..33b2941 100644
--- a/DiscordChatExporter.Cli/Commands/ExportCommandBase.cs
+++ b/DiscordChatExporter.Cli/Commands/ExportCommandBase.cs
@@ -7,7 +7,6 @@ using CliFx.Utilities;
using DiscordChatExporter.Core.Models;
using DiscordChatExporter.Core.Services;
using DiscordChatExporter.Core.Services.Helpers;
-using Tyrrrz.Extensions;
namespace DiscordChatExporter.Cli.Commands
{
@@ -22,7 +21,7 @@ namespace DiscordChatExporter.Cli.Commands
public ExportFormat ExportFormat { get; set; } = ExportFormat.HtmlDark;
[CommandOption("output", 'o', Description = "Output file or directory path.")]
- public string OutputPath { get; set; }
+ public string? OutputPath { get; set; }
[CommandOption("after",Description = "Limit to messages sent after this date.")]
public DateTimeOffset? After { get; set; }
@@ -34,7 +33,7 @@ namespace DiscordChatExporter.Cli.Commands
public int? PartitionLimit { get; set; }
[CommandOption("dateformat", Description = "Date format used in output.")]
- public string DateFormat { get; set; }
+ public string? DateFormat { get; set; }
protected ExportCommandBase(SettingsService settingsService, DataService dataService, ExportService exportService)
: base(dataService)
@@ -46,8 +45,8 @@ namespace DiscordChatExporter.Cli.Commands
protected async Task ExportChannelAsync(IConsole console, Channel channel)
{
// Configure settings
- if (!DateFormat.IsNullOrWhiteSpace())
- SettingsService.DateFormat = DateFormat;
+ if (!string.IsNullOrWhiteSpace(DateFormat))
+ SettingsService.DateFormat = DateFormat!;
console.Output.Write($"Exporting channel [{channel.Name}]... ");
var progress = console.CreateProgressTicker();
@@ -57,7 +56,7 @@ namespace DiscordChatExporter.Cli.Commands
// Generate file path if not set or is a directory
var filePath = OutputPath;
- if (filePath.IsNullOrWhiteSpace() || ExportHelper.IsDirectoryPath(filePath))
+ if (string.IsNullOrWhiteSpace(filePath) || ExportHelper.IsDirectoryPath(filePath))
{
// Generate default file name
var fileName = ExportHelper.GetDefaultExportFileName(ExportFormat, chatLog.Guild,
diff --git a/DiscordChatExporter.Cli/DiscordChatExporter.Cli.csproj b/DiscordChatExporter.Cli/DiscordChatExporter.Cli.csproj
index d4a63d9..b7f7b22 100644
--- a/DiscordChatExporter.Cli/DiscordChatExporter.Cli.csproj
+++ b/DiscordChatExporter.Cli/DiscordChatExporter.Cli.csproj
@@ -6,13 +6,14 @@
2.15
Tyrrrz
Copyright (c) Alexey Golub
+ enable
..\favicon.ico
-
+
diff --git a/DiscordChatExporter.Core.Markdown/DiscordChatExporter.Core.Markdown.csproj b/DiscordChatExporter.Core.Markdown/DiscordChatExporter.Core.Markdown.csproj
index 5f4a3f5..70a6a23 100644
--- a/DiscordChatExporter.Core.Markdown/DiscordChatExporter.Core.Markdown.csproj
+++ b/DiscordChatExporter.Core.Markdown/DiscordChatExporter.Core.Markdown.csproj
@@ -2,10 +2,11 @@
netcoreapp3.0
+ enable
-
+
\ No newline at end of file
diff --git a/DiscordChatExporter.Core.Markdown/Internal/AggregateMatcher.cs b/DiscordChatExporter.Core.Markdown/Internal/AggregateMatcher.cs
index ee54096..fe02d9f 100644
--- a/DiscordChatExporter.Core.Markdown/Internal/AggregateMatcher.cs
+++ b/DiscordChatExporter.Core.Markdown/Internal/AggregateMatcher.cs
@@ -16,9 +16,9 @@ namespace DiscordChatExporter.Core.Markdown.Internal
{
}
- public ParsedMatch Match(StringPart stringPart)
+ public ParsedMatch? Match(StringPart stringPart)
{
- ParsedMatch earliestMatch = null;
+ ParsedMatch? earliestMatch = null;
// Try to match the input with each matcher and get the match with the lowest start index
foreach (var matcher in _matchers)
diff --git a/DiscordChatExporter.Core.Markdown/Internal/IMatcher.cs b/DiscordChatExporter.Core.Markdown/Internal/IMatcher.cs
index b6c8905..e61e6af 100644
--- a/DiscordChatExporter.Core.Markdown/Internal/IMatcher.cs
+++ b/DiscordChatExporter.Core.Markdown/Internal/IMatcher.cs
@@ -2,6 +2,6 @@
{
internal interface IMatcher
{
- ParsedMatch Match(StringPart stringPart);
+ ParsedMatch? Match(StringPart stringPart);
}
}
\ No newline at end of file
diff --git a/DiscordChatExporter.Core.Markdown/Internal/RegexMatcher.cs b/DiscordChatExporter.Core.Markdown/Internal/RegexMatcher.cs
index ee7cf32..a35d92f 100644
--- a/DiscordChatExporter.Core.Markdown/Internal/RegexMatcher.cs
+++ b/DiscordChatExporter.Core.Markdown/Internal/RegexMatcher.cs
@@ -1,8 +1,4 @@
using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Linq.Expressions;
-using System.Reflection;
using System.Text.RegularExpressions;
namespace DiscordChatExporter.Core.Markdown.Internal
@@ -23,7 +19,7 @@ namespace DiscordChatExporter.Core.Markdown.Internal
{
}
- public ParsedMatch Match(StringPart stringPart)
+ public ParsedMatch? Match(StringPart stringPart)
{
var match = _regex.Match(stringPart.Target, stringPart.StartIndex, stringPart.Length);
if (!match.Success)
diff --git a/DiscordChatExporter.Core.Markdown/Internal/StringMatcher.cs b/DiscordChatExporter.Core.Markdown/Internal/StringMatcher.cs
index fbf4290..2722ce5 100644
--- a/DiscordChatExporter.Core.Markdown/Internal/StringMatcher.cs
+++ b/DiscordChatExporter.Core.Markdown/Internal/StringMatcher.cs
@@ -20,7 +20,7 @@ namespace DiscordChatExporter.Core.Markdown.Internal
{
}
- public ParsedMatch Match(StringPart stringPart)
+ public ParsedMatch? Match(StringPart stringPart)
{
var index = stringPart.Target.IndexOf(_needle, stringPart.StartIndex, stringPart.Length, _comparison);
diff --git a/DiscordChatExporter.Core.Markdown/MarkdownParser.cs b/DiscordChatExporter.Core.Markdown/MarkdownParser.cs
index 31de461..45a0dfc 100644
--- a/DiscordChatExporter.Core.Markdown/MarkdownParser.cs
+++ b/DiscordChatExporter.Core.Markdown/MarkdownParser.cs
@@ -3,7 +3,6 @@ using System.Linq;
using System.Text.RegularExpressions;
using DiscordChatExporter.Core.Markdown.Internal;
using DiscordChatExporter.Core.Markdown.Nodes;
-using Tyrrrz.Extensions;
namespace DiscordChatExporter.Core.Markdown
{
@@ -125,7 +124,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.Groups[3].Value, m.Groups[2].Value, !m.Groups[1].Value.IsNullOrWhiteSpace()));
+ m => new EmojiNode(m.Groups[3].Value, m.Groups[2].Value, !string.IsNullOrWhiteSpace(m.Groups[1].Value)));
/* Links */
diff --git a/DiscordChatExporter.Core.Markdown/Nodes/EmojiNode.cs b/DiscordChatExporter.Core.Markdown/Nodes/EmojiNode.cs
index 798411b..0aa2bd1 100644
--- a/DiscordChatExporter.Core.Markdown/Nodes/EmojiNode.cs
+++ b/DiscordChatExporter.Core.Markdown/Nodes/EmojiNode.cs
@@ -1,18 +1,16 @@
-using Tyrrrz.Extensions;
-
-namespace DiscordChatExporter.Core.Markdown.Nodes
+namespace DiscordChatExporter.Core.Markdown.Nodes
{
public class EmojiNode : Node
{
- public string Id { get; }
+ public string? Id { get; }
public string Name { get; }
public bool IsAnimated { get; }
- public bool IsCustomEmoji => !Id.IsNullOrWhiteSpace();
+ public bool IsCustomEmoji => !string.IsNullOrWhiteSpace(Id);
- public EmojiNode(string id, string name, bool isAnimated)
+ public EmojiNode(string? id, string name, bool isAnimated)
{
Id = id;
Name = name;
diff --git a/DiscordChatExporter.Core.Models/Channel.cs b/DiscordChatExporter.Core.Models/Channel.cs
index 513970d..34b8d91 100644
--- a/DiscordChatExporter.Core.Models/Channel.cs
+++ b/DiscordChatExporter.Core.Models/Channel.cs
@@ -6,17 +6,17 @@
{
public string Id { get; }
- public string ParentId { get; }
+ public string? ParentId { get; }
- public string GuildId { get; }
+ public string? GuildId { get; }
public string Name { get; }
- public string Topic { get; }
+ public string? Topic { get; }
public ChannelType Type { get; }
- public Channel(string id, string parentId, string guildId, string name, string topic, ChannelType type)
+ public Channel(string id, string? parentId, string? guildId, string name, string? topic, ChannelType type)
{
Id = id;
ParentId = parentId;
diff --git a/DiscordChatExporter.Core.Models/DiscordChatExporter.Core.Models.csproj b/DiscordChatExporter.Core.Models/DiscordChatExporter.Core.Models.csproj
index 5f4a3f5..70a6a23 100644
--- a/DiscordChatExporter.Core.Models/DiscordChatExporter.Core.Models.csproj
+++ b/DiscordChatExporter.Core.Models/DiscordChatExporter.Core.Models.csproj
@@ -2,10 +2,11 @@
netcoreapp3.0
+ enable
-
+
\ No newline at end of file
diff --git a/DiscordChatExporter.Core.Models/Embed.cs b/DiscordChatExporter.Core.Models/Embed.cs
index 5246ccd..8cf4434 100644
--- a/DiscordChatExporter.Core.Models/Embed.cs
+++ b/DiscordChatExporter.Core.Models/Embed.cs
@@ -8,28 +8,29 @@ namespace DiscordChatExporter.Core.Models
public class Embed
{
- public string Title { get; }
+ public string? Title { get; }
- public string Url { get; }
+ public string? Url { get; }
public DateTimeOffset? Timestamp { get; }
+ // TODO: this should be nullable and default color should be set in CSS
public Color Color { get; }
- public EmbedAuthor Author { get; }
+ public EmbedAuthor? Author { get; }
- public string Description { get; }
+ public string? Description { get; }
public IReadOnlyList Fields { get; }
- public EmbedImage Thumbnail { get; }
+ public EmbedImage? Thumbnail { get; }
- public EmbedImage Image { get; }
+ public EmbedImage? Image { get; }
- public EmbedFooter Footer { get; }
+ public EmbedFooter? Footer { get; }
- public Embed(string title, string url, DateTimeOffset? timestamp, Color color, EmbedAuthor author, string description,
- IReadOnlyList fields, EmbedImage thumbnail, EmbedImage image, EmbedFooter footer)
+ public Embed(string? title, string? url, DateTimeOffset? timestamp, Color color, EmbedAuthor? author, string? description,
+ IReadOnlyList fields, EmbedImage? thumbnail, EmbedImage? image, EmbedFooter? footer)
{
Title = title;
Url = url;
@@ -43,6 +44,6 @@ namespace DiscordChatExporter.Core.Models
Footer = footer;
}
- public override string ToString() => Title;
+ public override string ToString() => Title ?? "";
}
}
\ No newline at end of file
diff --git a/DiscordChatExporter.Core.Models/EmbedAuthor.cs b/DiscordChatExporter.Core.Models/EmbedAuthor.cs
index b4496a3..659eb28 100644
--- a/DiscordChatExporter.Core.Models/EmbedAuthor.cs
+++ b/DiscordChatExporter.Core.Models/EmbedAuthor.cs
@@ -4,19 +4,19 @@ namespace DiscordChatExporter.Core.Models
public class EmbedAuthor
{
- public string Name { get; }
+ public string? Name { get; }
- public string Url { get; }
+ public string? Url { get; }
- public string IconUrl { get; }
+ public string? IconUrl { get; }
- public EmbedAuthor(string name, string url, string iconUrl)
+ public EmbedAuthor(string? name, string? url, string? iconUrl)
{
Name = name;
Url = url;
IconUrl = iconUrl;
}
- public override string ToString() => Name;
+ public override string ToString() => Name ?? "";
}
}
\ No newline at end of file
diff --git a/DiscordChatExporter.Core.Models/EmbedFooter.cs b/DiscordChatExporter.Core.Models/EmbedFooter.cs
index 38229d1..4c10025 100644
--- a/DiscordChatExporter.Core.Models/EmbedFooter.cs
+++ b/DiscordChatExporter.Core.Models/EmbedFooter.cs
@@ -6,9 +6,9 @@ namespace DiscordChatExporter.Core.Models
{
public string Text { get; }
- public string IconUrl { get; }
+ public string? IconUrl { get; }
- public EmbedFooter(string text, string iconUrl)
+ public EmbedFooter(string text, string? iconUrl)
{
Text = text;
IconUrl = iconUrl;
diff --git a/DiscordChatExporter.Core.Models/EmbedImage.cs b/DiscordChatExporter.Core.Models/EmbedImage.cs
index 3382788..c438f90 100644
--- a/DiscordChatExporter.Core.Models/EmbedImage.cs
+++ b/DiscordChatExporter.Core.Models/EmbedImage.cs
@@ -4,13 +4,13 @@ namespace DiscordChatExporter.Core.Models
public class EmbedImage
{
- public string Url { get; }
+ public string? Url { get; }
public int? Width { get; }
public int? Height { get; }
- public EmbedImage(string url, int? width, int? height)
+ public EmbedImage(string? url, int? width, int? height)
{
Url = url;
Height = height;
diff --git a/DiscordChatExporter.Core.Models/Emoji.cs b/DiscordChatExporter.Core.Models/Emoji.cs
index 9de011f..19af4e4 100644
--- a/DiscordChatExporter.Core.Models/Emoji.cs
+++ b/DiscordChatExporter.Core.Models/Emoji.cs
@@ -8,7 +8,7 @@ namespace DiscordChatExporter.Core.Models
public partial class Emoji
{
- public string Id { get; }
+ public string? Id { get; }
public string Name { get; }
@@ -16,7 +16,7 @@ namespace DiscordChatExporter.Core.Models
public string ImageUrl { get; }
- public Emoji(string id, string name, bool isAnimated)
+ public Emoji(string? id, string name, bool isAnimated)
{
Id = id;
Name = name;
@@ -37,10 +37,10 @@ namespace DiscordChatExporter.Core.Models
private static string GetTwemojiName(string emoji) =>
GetCodePoints(emoji).Select(i => i.ToString("x")).JoinToString("-");
- public static string GetImageUrl(string id, string name, bool isAnimated)
+ public static string GetImageUrl(string? id, string name, bool isAnimated)
{
// Custom emoji
- if (!id.IsNullOrWhiteSpace())
+ if (!string.IsNullOrWhiteSpace(id))
{
// Animated
if (isAnimated)
diff --git a/DiscordChatExporter.Core.Models/Guild.cs b/DiscordChatExporter.Core.Models/Guild.cs
index 2fb93c1..97c7b9f 100644
--- a/DiscordChatExporter.Core.Models/Guild.cs
+++ b/DiscordChatExporter.Core.Models/Guild.cs
@@ -1,8 +1,6 @@
-using Tyrrrz.Extensions;
-
-namespace DiscordChatExporter.Core.Models
+namespace DiscordChatExporter.Core.Models
{
- // https://discordapp.com/developers/docs/resources/guild#guild-object
+ // https://discordapp.string.IsNullOrWhiteSpace(com/developers/docs/resources/guild#guild-object
public partial class Guild
{
@@ -10,11 +8,11 @@ namespace DiscordChatExporter.Core.Models
public string Name { get; }
- public string IconHash { get; }
+ public string? IconHash { get; }
public string IconUrl { get; }
- public Guild(string id, string name, string iconHash)
+ public Guild(string id, string name, string? iconHash)
{
Id = id;
Name = name;
@@ -28,9 +26,9 @@ namespace DiscordChatExporter.Core.Models
public partial class Guild
{
- public static string GetIconUrl(string id, string iconHash)
+ public static string GetIconUrl(string id, string? iconHash)
{
- return !iconHash.IsNullOrWhiteSpace()
+ return !string.IsNullOrWhiteSpace(iconHash)
? $"https://cdn.discordapp.com/icons/{id}/{iconHash}.png"
: "https://cdn.discordapp.com/embed/avatars/0.png";
}
diff --git a/DiscordChatExporter.Core.Models/Message.cs b/DiscordChatExporter.Core.Models/Message.cs
index cb64974..7fe2135 100644
--- a/DiscordChatExporter.Core.Models/Message.cs
+++ b/DiscordChatExporter.Core.Models/Message.cs
@@ -19,7 +19,7 @@ namespace DiscordChatExporter.Core.Models
public DateTimeOffset? EditedTimestamp { get; }
- public string Content { get; }
+ public string? Content { get; }
public IReadOnlyList Attachments { get; }
@@ -32,7 +32,7 @@ namespace DiscordChatExporter.Core.Models
public bool IsPinned { get; }
public Message(string id, string channelId, MessageType type, User author, DateTimeOffset timestamp,
- DateTimeOffset? editedTimestamp, string content, IReadOnlyList attachments,
+ DateTimeOffset? editedTimestamp, string? content, IReadOnlyList attachments,
IReadOnlyList