Skip to content

Commit

Permalink
Merge pull request #26 from hlaueriksson/update
Browse files Browse the repository at this point in the history
Cleanup
  • Loading branch information
hlaueriksson committed Oct 31, 2023
2 parents 73f5af4 + 66472c2 commit 58698a0
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 27 deletions.
2 changes: 2 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions Analyzers.props
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@
</AdditionalFiles>
</ItemGroup>
<ItemGroup>
<PackageReference Update="Microsoft.VisualStudio.Threading.Analyzers" Version="17.1.46">
<PackageReference Include="Microsoft.VisualStudio.Threading.Analyzers" Version="17.7.30">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Update="Roslynator.Analyzers" Version="4.1.0">
<PackageReference Include="Roslynator.Analyzers" Version="4.6.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
11 changes: 2 additions & 9 deletions samples/GEmojiSharp.Sample.BlazorServer/Pages/Error.cshtml.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Diagnostics;
using System.Diagnostics;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;

Expand All @@ -12,16 +12,9 @@ public class ErrorModel : PageModel

public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);

private readonly ILogger<ErrorModel> _logger;

public ErrorModel(ILogger<ErrorModel> logger)
{
_logger = logger;
}

public void OnGet()
{
RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier;
}
}
}
}
3 changes: 1 addition & 2 deletions src/GEmojiSharp.AspNetCore/EmojiExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Linq;
using System.Text.RegularExpressions;

namespace GEmojiSharp.AspNetCore
Expand Down Expand Up @@ -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];
}
}
}
11 changes: 9 additions & 2 deletions src/GEmojiSharp.AspNetCore/HtmlHelpers/HtmlHelperExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,15 @@ public static class HtmlHelperExtensions
/// <param name="htmlHelper">The <see cref="IHtmlHelper"/> instance this method extends.</param>
/// <param name="content">The content.</param>
/// <returns>A new <see cref="IHtmlContent"/> containing the created HTML.</returns>
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());
}

/// <summary>
/// Returns emojified HTML markup for the <paramref name="expression"/>.
Expand Down
3 changes: 1 addition & 2 deletions src/GEmojiSharp.Blazor/EmojiExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Linq;
using System.Text.RegularExpressions;

namespace GEmojiSharp.Blazor
Expand Down Expand Up @@ -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];
}
}
}
10 changes: 5 additions & 5 deletions src/GEmojiSharp.DotnetTool/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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()));
}
Expand Down
6 changes: 3 additions & 3 deletions src/GEmojiSharp.PowerToysRun/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public List<ContextMenuResult> 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)
Expand All @@ -167,7 +167,7 @@ public List<ContextMenuResult> 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())),
},
};
}
Expand Down Expand Up @@ -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;
}
Expand Down
3 changes: 1 addition & 2 deletions src/GEmojiSharp/EmojiExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System;
using System.Collections.Generic;
using System.Linq;

Expand Down Expand Up @@ -107,7 +106,7 @@ public static string Alias(this GEmoji emoji)
/// <returns>The raw Unicode <c>strings</c> of the skin tone variants.</returns>
public static IEnumerable<string> 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
Expand Down

0 comments on commit 58698a0

Please sign in to comment.