From 01693964a8409c22aab035ed724fe95c5860b0b2 Mon Sep 17 00:00:00 2001 From: Henrik Lau Eriksson Date: Tue, 31 Oct 2023 23:21:55 +0100 Subject: [PATCH 1/2] :rotating_light: --- Analyzers.props | 4 ++-- src/GEmojiSharp.DotnetTool/Program.cs | 6 +++--- src/GEmojiSharp/EmojiExtensions.cs | 1 - 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/Analyzers.props b/Analyzers.props index 7631692..c931bb8 100644 --- a/Analyzers.props +++ b/Analyzers.props @@ -12,11 +12,11 @@ - + all runtime; build; native; contentfiles; analyzers - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/GEmojiSharp.DotnetTool/Program.cs b/src/GEmojiSharp.DotnetTool/Program.cs index 57dd891..d80cf61 100644 --- a/src/GEmojiSharp.DotnetTool/Program.cs +++ b/src/GEmojiSharp.DotnetTool/Program.cs @@ -140,19 +140,19 @@ var emojis = Emoji.Find(value); string result; - if (!string.IsNullOrEmpty(format) && format.ToUpperInvariant() == "YAML") + if (!string.IsNullOrEmpty(format) && string.Equals(format, "YAML", StringComparison.OrdinalIgnoreCase)) { var serializer = new YamlDotNet.Serialization.SerializerBuilder().Build(); result = serializer.Serialize(emojis); } - else if (!string.IsNullOrEmpty(format) && format.ToUpperInvariant() == "XML") + else if (!string.IsNullOrEmpty(format) && string.Equals(format, "XML", StringComparison.OrdinalIgnoreCase)) { var serializer = new System.Xml.Serialization.XmlSerializer(emojis.GetType()); var writer = new StringWriter(); serializer.Serialize(System.Xml.XmlWriter.Create(writer, new System.Xml.XmlWriterSettings { Indent = true }), emojis); result = writer.ToString(); } - else if (!string.IsNullOrEmpty(format) && format.ToUpperInvariant() == "TOML") + else if (!string.IsNullOrEmpty(format) && string.Equals(format, "TOML", StringComparison.OrdinalIgnoreCase)) { result = Tomlyn.Toml.FromModel(emojis.ToDictionary(x => x.Alias())); } diff --git a/src/GEmojiSharp/EmojiExtensions.cs b/src/GEmojiSharp/EmojiExtensions.cs index 914004b..5adfe4a 100644 --- a/src/GEmojiSharp/EmojiExtensions.cs +++ b/src/GEmojiSharp/EmojiExtensions.cs @@ -1,4 +1,3 @@ -using System; using System.Collections.Generic; using System.Linq; From 66472c2f9a84bc5f32d9a19c9dfc44cc83db92ce Mon Sep 17 00:00:00 2001 From: Henrik Lau Eriksson Date: Tue, 31 Oct 2023 23:40:53 +0100 Subject: [PATCH 2/2] :rotating_light: --- .editorconfig | 2 ++ .../Pages/Error.cshtml.cs | 11 ++--------- src/GEmojiSharp.AspNetCore/EmojiExtensions.cs | 3 +-- .../HtmlHelpers/HtmlHelperExtensions.cs | 11 +++++++++-- src/GEmojiSharp.Blazor/EmojiExtensions.cs | 3 +-- src/GEmojiSharp.DotnetTool/Program.cs | 4 ++-- src/GEmojiSharp.PowerToysRun/Main.cs | 6 +++--- src/GEmojiSharp/EmojiExtensions.cs | 2 +- 8 files changed, 21 insertions(+), 21 deletions(-) diff --git a/.editorconfig b/.editorconfig index 447bc59..5247680 100644 --- a/.editorconfig +++ b/.editorconfig @@ -181,6 +181,8 @@ dotnet_diagnostic.SA1501.severity = none dotnet_diagnostic.SA1503.severity = none dotnet_diagnostic.SA1623.severity = none dotnet_diagnostic.SA1633.severity = none +dotnet_diagnostic.IDE1006.severity = none +dotnet_diagnostic.SYSLIB1045.severity = none [src/GEmojiSharp.DotnetTool/Program.cs] dotnet_diagnostic.CA1812.severity = none diff --git a/samples/GEmojiSharp.Sample.BlazorServer/Pages/Error.cshtml.cs b/samples/GEmojiSharp.Sample.BlazorServer/Pages/Error.cshtml.cs index 48887e3..8b6d4e5 100644 --- a/samples/GEmojiSharp.Sample.BlazorServer/Pages/Error.cshtml.cs +++ b/samples/GEmojiSharp.Sample.BlazorServer/Pages/Error.cshtml.cs @@ -1,4 +1,4 @@ -using System.Diagnostics; +using System.Diagnostics; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc.RazorPages; @@ -12,16 +12,9 @@ public class ErrorModel : PageModel public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); - private readonly ILogger _logger; - - public ErrorModel(ILogger logger) - { - _logger = logger; - } - public void OnGet() { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier; } } -} \ No newline at end of file +} diff --git a/src/GEmojiSharp.AspNetCore/EmojiExtensions.cs b/src/GEmojiSharp.AspNetCore/EmojiExtensions.cs index e18d14c..470e011 100644 --- a/src/GEmojiSharp.AspNetCore/EmojiExtensions.cs +++ b/src/GEmojiSharp.AspNetCore/EmojiExtensions.cs @@ -1,5 +1,4 @@ using System; -using System.Linq; using System.Text.RegularExpressions; namespace GEmojiSharp.AspNetCore @@ -72,7 +71,7 @@ private static string Raw(this string alias) private static string Alias(this GEmoji emoji) { - return emoji.Aliases.First(); + return emoji.Aliases[0]; } } } diff --git a/src/GEmojiSharp.AspNetCore/HtmlHelpers/HtmlHelperExtensions.cs b/src/GEmojiSharp.AspNetCore/HtmlHelpers/HtmlHelperExtensions.cs index 520a393..9f26da5 100644 --- a/src/GEmojiSharp.AspNetCore/HtmlHelpers/HtmlHelperExtensions.cs +++ b/src/GEmojiSharp.AspNetCore/HtmlHelpers/HtmlHelperExtensions.cs @@ -16,8 +16,15 @@ public static class HtmlHelperExtensions /// The instance this method extends. /// The content. /// A new containing the created HTML. - public static IHtmlContent Emoji(this IHtmlHelper htmlHelper, string content) => - new HtmlString(content.MarkupContent()); + public static IHtmlContent Emoji(this IHtmlHelper htmlHelper, string content) + { + if (htmlHelper == null) + { + throw new ArgumentNullException(nameof(htmlHelper)); + } + + return new HtmlString(content.MarkupContent()); + } /// /// Returns emojified HTML markup for the . diff --git a/src/GEmojiSharp.Blazor/EmojiExtensions.cs b/src/GEmojiSharp.Blazor/EmojiExtensions.cs index 2bcdfe9..2f1e291 100644 --- a/src/GEmojiSharp.Blazor/EmojiExtensions.cs +++ b/src/GEmojiSharp.Blazor/EmojiExtensions.cs @@ -1,5 +1,4 @@ using System; -using System.Linq; using System.Text.RegularExpressions; namespace GEmojiSharp.Blazor @@ -72,7 +71,7 @@ private static string Raw(this string alias) private static string Alias(this GEmoji emoji) { - return emoji.Aliases.First(); + return emoji.Aliases[0]; } } } diff --git a/src/GEmojiSharp.DotnetTool/Program.cs b/src/GEmojiSharp.DotnetTool/Program.cs index d80cf61..bbea866 100644 --- a/src/GEmojiSharp.DotnetTool/Program.cs +++ b/src/GEmojiSharp.DotnetTool/Program.cs @@ -40,7 +40,7 @@ } if (copy) - ClipboardService.SetText(string.Join(string.Empty, emojis.Select(e => skinTones && e.HasSkinTones ? e.Raw + string.Join(string.Empty, e.RawSkinToneVariants()) : e.Raw))); + ClipboardService.SetText(string.Concat(emojis.Select(e => skinTones && e.HasSkinTones ? e.Raw + string.Concat(e.RawSkinToneVariants()) : e.Raw))); }, argument, skinTonesOption, @@ -70,7 +70,7 @@ } if (copy) - ClipboardService.SetText(string.Join(string.Empty, emojis.SelectMany(x => x.Aliases).Select(x => x.PadAlias()))); + ClipboardService.SetText(string.Concat(emojis.SelectMany(x => x.Aliases).Select(x => x.PadAlias()))); }, argument, copyOption); diff --git a/src/GEmojiSharp.PowerToysRun/Main.cs b/src/GEmojiSharp.PowerToysRun/Main.cs index 25d250e..a8d6d35 100644 --- a/src/GEmojiSharp.PowerToysRun/Main.cs +++ b/src/GEmojiSharp.PowerToysRun/Main.cs @@ -150,7 +150,7 @@ public List LoadContextMenus(Result selectedResult) Glyph = "\xF413", // F413 => Symbol: CopyTo AcceleratorKey = Key.C, AcceleratorModifiers = ModifierKeys.Control, - Action = _ => CopyToClipboard(string.Join(string.Empty, emoji.Aliases.Select(x => x.PadAlias()))), + Action = _ => CopyToClipboard(string.Concat(emoji.Aliases.Select(x => x.PadAlias()))), }; if (emoji.HasSkinTones) @@ -167,7 +167,7 @@ public List LoadContextMenus(Result selectedResult) Glyph = "\xE748", // E748 => Symbol: SwitchUser AcceleratorKey = Key.Enter, AcceleratorModifiers = ModifierKeys.Control, - Action = _ => CopyToClipboard(emoji.Raw + string.Join(string.Empty, emoji.RawSkinToneVariants())), + Action = _ => CopyToClipboard(emoji.Raw + string.Concat(emoji.RawSkinToneVariants())), }, }; } @@ -232,7 +232,7 @@ protected virtual void Dispose(bool disposing) return; } - if (Context != null && Context.API != null) + if (Context?.API != null) { Context.API.ThemeChanged -= OnThemeChanged; } diff --git a/src/GEmojiSharp/EmojiExtensions.cs b/src/GEmojiSharp/EmojiExtensions.cs index 5adfe4a..6a36eef 100644 --- a/src/GEmojiSharp/EmojiExtensions.cs +++ b/src/GEmojiSharp/EmojiExtensions.cs @@ -106,7 +106,7 @@ public static string Alias(this GEmoji emoji) /// The raw Unicode strings of the skin tone variants. public static IEnumerable RawSkinToneVariants(this GEmoji emoji) { - if (emoji == null || !emoji.HasSkinTones) yield break; + if (emoji?.HasSkinTones != true) yield break; var rawNormalized = string.Concat(emoji.Raw.Where(x => x != '\ufe0f')); // strip VARIATION_SELECTOR_16 var idx = rawNormalized.IndexOf('\u200d'); // detect zero-width joiner