Make use of C# 14 features

This commit is contained in:
Tyrrrz 2025-11-16 20:29:39 +02:00
parent 380dd6d511
commit fbbac2afaa
25 changed files with 337 additions and 287 deletions

View file

@ -4,7 +4,9 @@ namespace DiscordChatExporter.Cli.Tests.Utils.Extensions;
internal static class StringExtensions internal static class StringExtensions
{ {
public static string ReplaceWhiteSpace(this string str, string replacement = " ") extension(string str)
{
public string ReplaceWhiteSpace(string replacement = " ")
{ {
var buffer = new StringBuilder(str.Length); var buffer = new StringBuilder(str.Length);
@ -14,3 +16,4 @@ internal static class StringExtensions
return buffer.ToString(); return buffer.ToString();
} }
} }
}

View file

@ -7,7 +7,9 @@ namespace DiscordChatExporter.Cli.Utils.Extensions;
internal static class ConsoleExtensions internal static class ConsoleExtensions
{ {
public static IAnsiConsole CreateAnsiConsole(this IConsole console) => extension(IConsole console)
{
public IAnsiConsole CreateAnsiConsole() =>
AnsiConsole.Create( AnsiConsole.Create(
new AnsiConsoleSettings new AnsiConsoleSettings
{ {
@ -17,10 +19,10 @@ internal static class ConsoleExtensions
} }
); );
public static Status CreateStatusTicker(this IConsole console) => public Status CreateStatusTicker() =>
console.CreateAnsiConsole().Status().AutoRefresh(true); console.CreateAnsiConsole().Status().AutoRefresh(true);
public static Progress CreateProgressTicker(this IConsole console) => public Progress CreateProgressTicker() =>
console console
.CreateAnsiConsole() .CreateAnsiConsole()
.Progress() .Progress()
@ -32,6 +34,7 @@ internal static class ConsoleExtensions
new ProgressBarColumn(), new ProgressBarColumn(),
new PercentageColumn() new PercentageColumn()
); );
}
public static async ValueTask StartTaskAsync( public static async ValueTask StartTaskAsync(
this ProgressContext context, this ProgressContext context,

View file

@ -13,18 +13,19 @@ public enum RateLimitPreference
public static class RateLimitPreferenceExtensions public static class RateLimitPreferenceExtensions
{ {
internal static bool IsRespectedFor( extension(RateLimitPreference rateLimitPreference)
this RateLimitPreference rateLimitPreference, {
TokenKind tokenKind internal bool IsRespectedFor(TokenKind tokenKind) =>
) =>
tokenKind switch tokenKind switch
{ {
TokenKind.User => (rateLimitPreference & RateLimitPreference.RespectForUserTokens) != 0, TokenKind.User => (rateLimitPreference & RateLimitPreference.RespectForUserTokens)
TokenKind.Bot => (rateLimitPreference & RateLimitPreference.RespectForBotTokens) != 0, != 0,
TokenKind.Bot => (rateLimitPreference & RateLimitPreference.RespectForBotTokens)
!= 0,
_ => throw new ArgumentOutOfRangeException(nameof(tokenKind)), _ => throw new ArgumentOutOfRangeException(nameof(tokenKind)),
}; };
public static string GetDisplayName(this RateLimitPreference rateLimitPreference) => public string GetDisplayName() =>
rateLimitPreference switch rateLimitPreference switch
{ {
RateLimitPreference.IgnoreAll => "Always ignore", RateLimitPreference.IgnoreAll => "Always ignore",
@ -34,3 +35,4 @@ public static class RateLimitPreferenceExtensions
_ => throw new ArgumentOutOfRangeException(nameof(rateLimitPreference)), _ => throw new ArgumentOutOfRangeException(nameof(rateLimitPreference)),
}; };
} }
}

View file

@ -103,7 +103,7 @@ internal partial class ExportAssetDownloader
fileExtension = ""; fileExtension = "";
} }
return PathEx.EscapeFileName( return Path.EscapeFileName(
fileNameWithoutExtension.Truncate(42) + '-' + urlHash + fileExtension fileNameWithoutExtension.Truncate(42) + '-' + urlHash + fileExtension
); );
} }

View file

@ -13,7 +13,9 @@ public enum ExportFormat
public static class ExportFormatExtensions public static class ExportFormatExtensions
{ {
public static string GetFileExtension(this ExportFormat format) => extension(ExportFormat format)
{
public string GetFileExtension() =>
format switch format switch
{ {
ExportFormat.PlainText => "txt", ExportFormat.PlainText => "txt",
@ -24,7 +26,7 @@ public static class ExportFormatExtensions
_ => throw new ArgumentOutOfRangeException(nameof(format)), _ => throw new ArgumentOutOfRangeException(nameof(format)),
}; };
public static string GetDisplayName(this ExportFormat format) => public string GetDisplayName() =>
format switch format switch
{ {
ExportFormat.PlainText => "TXT", ExportFormat.PlainText => "TXT",
@ -35,3 +37,4 @@ public static class ExportFormatExtensions
_ => throw new ArgumentOutOfRangeException(nameof(format)), _ => throw new ArgumentOutOfRangeException(nameof(format)),
}; };
} }
}

View file

@ -7,7 +7,6 @@ using DiscordChatExporter.Core.Discord;
using DiscordChatExporter.Core.Discord.Data; using DiscordChatExporter.Core.Discord.Data;
using DiscordChatExporter.Core.Exporting.Filtering; using DiscordChatExporter.Core.Exporting.Filtering;
using DiscordChatExporter.Core.Exporting.Partitioning; using DiscordChatExporter.Core.Exporting.Partitioning;
using DiscordChatExporter.Core.Utils;
using DiscordChatExporter.Core.Utils.Extensions; using DiscordChatExporter.Core.Utils.Extensions;
namespace DiscordChatExporter.Core.Exporting; namespace DiscordChatExporter.Core.Exporting;
@ -145,7 +144,7 @@ public partial class ExportRequest
// File extension // File extension
buffer.Append('.').Append(format.GetFileExtension()); buffer.Append('.').Append(format.GetFileExtension());
return PathEx.EscapeFileName(buffer.ToString()); return Path.EscapeFileName(buffer.ToString());
} }
private static string FormatPath( private static string FormatPath(
@ -159,7 +158,7 @@ public partial class ExportRequest
path, path,
"%.", "%.",
m => m =>
PathEx.EscapeFileName( Path.EscapeFileName(
m.Value switch m.Value switch
{ {
"%g" => guild.Id.ToString(), "%g" => guild.Id.ToString(),

View file

@ -6,9 +6,9 @@ namespace DiscordChatExporter.Core.Utils.Extensions;
public static class AsyncCollectionExtensions public static class AsyncCollectionExtensions
{ {
private static async ValueTask<IReadOnlyList<T>> CollectAsync<T>( extension<T>(IAsyncEnumerable<T> asyncEnumerable)
this IAsyncEnumerable<T> asyncEnumerable {
) private async ValueTask<IReadOnlyList<T>> CollectAsync()
{ {
var list = new List<T>(); var list = new List<T>();
@ -18,7 +18,7 @@ public static class AsyncCollectionExtensions
return list; return list;
} }
public static ValueTaskAwaiter<IReadOnlyList<T>> GetAwaiter<T>( public ValueTaskAwaiter<IReadOnlyList<T>> GetAwaiter() =>
this IAsyncEnumerable<T> asyncEnumerable asyncEnumerable.CollectAsync().GetAwaiter();
) => asyncEnumerable.CollectAsync().GetAwaiter(); }
} }

View file

@ -5,7 +5,9 @@ namespace DiscordChatExporter.Core.Utils.Extensions;
public static class BinaryExtensions public static class BinaryExtensions
{ {
public static string ToHex(this byte[] data, bool isUpperCase = true) extension(byte[] data)
{
public string ToHex(bool isUpperCase = true)
{ {
var buffer = new StringBuilder(2 * data.Length); var buffer = new StringBuilder(2 * data.Length);
@ -17,3 +19,4 @@ public static class BinaryExtensions
return buffer.ToString(); return buffer.ToString();
} }
} }
}

View file

@ -4,20 +4,28 @@ namespace DiscordChatExporter.Core.Utils.Extensions;
public static class CollectionExtensions public static class CollectionExtensions
{ {
public static IEnumerable<T> ToSingletonEnumerable<T>(this T obj) extension<T>(T obj)
{
public IEnumerable<T> ToSingletonEnumerable()
{ {
yield return obj; yield return obj;
} }
}
public static IEnumerable<(T value, int index)> WithIndex<T>(this IEnumerable<T> source) extension<T>(IEnumerable<T> source)
{
public IEnumerable<(T value, int index)> WithIndex()
{ {
var i = 0; var i = 0;
foreach (var o in source) foreach (var o in source)
yield return (o, i++); yield return (o, i++);
} }
}
public static IEnumerable<T> WhereNotNull<T>(this IEnumerable<T?> source) extension<T>(IEnumerable<T?> source)
where T : class where T : class
{
public IEnumerable<T> WhereNotNull()
{ {
foreach (var o in source) foreach (var o in source)
{ {
@ -26,3 +34,4 @@ public static class CollectionExtensions
} }
} }
} }
}

View file

@ -4,11 +4,14 @@ namespace DiscordChatExporter.Core.Utils.Extensions;
public static class ColorExtensions public static class ColorExtensions
{ {
public static Color WithAlpha(this Color color, int alpha) => Color.FromArgb(alpha, color); extension(Color color)
{
public Color WithAlpha(int alpha) => Color.FromArgb(alpha, color);
public static Color ResetAlpha(this Color color) => color.WithAlpha(255); public Color ResetAlpha() => color.WithAlpha(255);
public static int ToRgb(this Color color) => color.ToArgb() & 0xffffff; public int ToRgb() => color.ToArgb() & 0xffffff;
public static string ToHex(this Color color) => $"#{color.R:X2}{color.G:X2}{color.B:X2}"; public string ToHex() => $"#{color.R:X2}{color.G:X2}{color.B:X2}";
}
} }

View file

@ -5,7 +5,9 @@ namespace DiscordChatExporter.Core.Utils.Extensions;
public static class ExceptionExtensions public static class ExceptionExtensions
{ {
private static void PopulateChildren(this Exception exception, ICollection<Exception> children) extension(Exception exception)
{
private void PopulateChildren(ICollection<Exception> children)
{ {
if (exception is AggregateException aggregateException) if (exception is AggregateException aggregateException)
{ {
@ -22,10 +24,11 @@ public static class ExceptionExtensions
} }
} }
public static IReadOnlyList<Exception> GetSelfAndChildren(this Exception exception) public IReadOnlyList<Exception> GetSelfAndChildren()
{ {
var children = new List<Exception> { exception }; var children = new List<Exception> { exception };
PopulateChildren(exception, children); PopulateChildren(exception, children);
return children; return children;
} }
} }
}

View file

@ -5,12 +5,17 @@ namespace DiscordChatExporter.Core.Utils.Extensions;
public static class GenericExtensions public static class GenericExtensions
{ {
public static TOut Pipe<TIn, TOut>(this TIn input, Func<TIn, TOut> transform) => extension<TIn>(TIn input)
transform(input); {
public TOut Pipe<TOut>(Func<TIn, TOut> transform) => transform(input);
public static T? NullIf<T>(this T value, Func<T, bool> predicate) }
where T : struct => !predicate(value) ? value : null;
extension<T>(T value)
public static T? NullIfDefault<T>(this T value) where T : struct
where T : struct => value.NullIf(v => EqualityComparer<T>.Default.Equals(v, default)); {
public T? NullIf(Func<T, bool> predicate) => !predicate(value) ? value : null;
public T? NullIfDefault() =>
value.NullIf(v => EqualityComparer<T>.Default.Equals(v, default));
}
} }

View file

@ -4,6 +4,9 @@ namespace DiscordChatExporter.Core.Utils.Extensions;
public static class HttpExtensions public static class HttpExtensions
{ {
public static string? TryGetValue(this HttpHeaders headers, string name) => extension(HttpHeaders headers)
{
public string? TryGetValue(string name) =>
headers.TryGetValues(name, out var values) ? string.Concat(values) : null; headers.TryGetValues(name, out var values) ? string.Concat(values) : null;
} }
}

View file

@ -0,0 +1,29 @@
using System;
using System.IO;
using System.Text;
namespace DiscordChatExporter.Core.Utils.Extensions;
public static class PathExtensions
{
extension(Path)
{
public static string EscapeFileName(string path)
{
var buffer = new StringBuilder(path.Length);
foreach (var c in path)
buffer.Append(!Path.GetInvalidFileNameChars().Contains(c) ? c : '_');
// File names cannot end with a dot on Windows
// https://github.com/Tyrrrz/DiscordChatExporter/issues/977
if (OperatingSystem.IsWindows())
{
while (buffer.Length > 0 && buffer[^1] == '.')
buffer.Remove(buffer.Length - 1, 1);
}
return buffer.ToString();
}
}
}

View file

@ -5,13 +5,13 @@ namespace DiscordChatExporter.Core.Utils.Extensions;
public static class StringExtensions public static class StringExtensions
{ {
public static string? NullIfWhiteSpace(this string str) => extension(string str)
!string.IsNullOrWhiteSpace(str) ? str : null; {
public string? NullIfWhiteSpace() => !string.IsNullOrWhiteSpace(str) ? str : null;
public static string Truncate(this string str, int charCount) => public string Truncate(int charCount) => str.Length > charCount ? str[..charCount] : str;
str.Length > charCount ? str[..charCount] : str;
public static string ToSpaceSeparatedWords(this string str) public string ToSpaceSeparatedWords()
{ {
var builder = new StringBuilder(str.Length * 2); var builder = new StringBuilder(str.Length * 2);
@ -26,9 +26,14 @@ public static class StringExtensions
return builder.ToString(); return builder.ToString();
} }
public static T? ParseEnumOrNull<T>(this string str, bool ignoreCase = true) public T? ParseEnumOrNull<T>(bool ignoreCase = true)
where T : struct, Enum => Enum.TryParse<T>(str, ignoreCase, out var result) ? result : null; where T : struct, Enum =>
Enum.TryParse<T>(str, ignoreCase, out var result) ? result : null;
}
public static StringBuilder AppendIfNotEmpty(this StringBuilder builder, char value) => extension(StringBuilder builder)
{
public StringBuilder AppendIfNotEmpty(char value) =>
builder.Length > 0 ? builder.Append(value) : builder; builder.Length > 0 ? builder.Append(value) : builder;
} }
}

View file

@ -7,13 +7,15 @@ namespace DiscordChatExporter.Core.Utils.Extensions;
public static class SuperpowerExtensions public static class SuperpowerExtensions
{ {
public static TextParser<T> Token<T>(this TextParser<T> parser) => extension<T>(TextParser<T> parser)
{
public TextParser<T> Token() =>
parser.Between(Character.WhiteSpace.IgnoreMany(), Character.WhiteSpace.IgnoreMany()); parser.Between(Character.WhiteSpace.IgnoreMany(), Character.WhiteSpace.IgnoreMany());
// Only used for debugging while writing Superpower parsers. // Only used for debugging while writing Superpower parsers.
// From https://twitter.com/nblumhardt/status/1389349059786264578 // From https://twitter.com/nblumhardt/status/1389349059786264578
[ExcludeFromCodeCoverage] [ExcludeFromCodeCoverage]
public static TextParser<T> Log<T>(this TextParser<T> parser, string description) => public TextParser<T> Log(string description) =>
i => i =>
{ {
Console.WriteLine($"Trying {description} ->"); Console.WriteLine($"Trying {description} ->");
@ -22,3 +24,4 @@ public static class SuperpowerExtensions
return r; return r;
}; };
} }
}

View file

@ -4,7 +4,9 @@ namespace DiscordChatExporter.Core.Utils.Extensions;
public static class TimeSpanExtensions public static class TimeSpanExtensions
{ {
public static TimeSpan Clamp(this TimeSpan value, TimeSpan min, TimeSpan max) extension(TimeSpan value)
{
public TimeSpan Clamp(TimeSpan min, TimeSpan max)
{ {
if (value < min) if (value < min)
return min; return min;
@ -15,3 +17,4 @@ public static class TimeSpanExtensions
return value; return value;
} }
} }
}

View file

@ -1,32 +0,0 @@
using System;
using System.Collections.Frozen;
using System.IO;
using System.Text;
namespace DiscordChatExporter.Core.Utils;
public static class PathEx
{
private static readonly FrozenSet<char> InvalidFileNameChars =
[
.. Path.GetInvalidFileNameChars(),
];
public static string EscapeFileName(string path)
{
var buffer = new StringBuilder(path.Length);
foreach (var c in path)
buffer.Append(!InvalidFileNameChars.Contains(c) ? c : '_');
// File names cannot end with a dot on Windows
// https://github.com/Tyrrrz/DiscordChatExporter/issues/977
if (OperatingSystem.IsWindows())
{
while (buffer.Length > 0 && buffer[^1] == '.')
buffer.Remove(buffer.Length - 1, 1);
}
return buffer.ToString();
}
}

View file

@ -6,16 +6,18 @@ namespace DiscordChatExporter.Gui.Utils.Extensions;
internal static class AvaloniaExtensions internal static class AvaloniaExtensions
{ {
public static Window? TryGetMainWindow(this IApplicationLifetime lifetime) => extension(IApplicationLifetime lifetime)
{
public Window? TryGetMainWindow() =>
lifetime is IClassicDesktopStyleApplicationLifetime desktopLifetime lifetime is IClassicDesktopStyleApplicationLifetime desktopLifetime
? desktopLifetime.MainWindow ? desktopLifetime.MainWindow
: null; : null;
public static TopLevel? TryGetTopLevel(this IApplicationLifetime lifetime) => public TopLevel? TryGetTopLevel() =>
lifetime.TryGetMainWindow() lifetime.TryGetMainWindow()
?? (lifetime as ISingleViewApplicationLifetime)?.MainView?.GetVisualRoot() as TopLevel; ?? (lifetime as ISingleViewApplicationLifetime)?.MainView?.GetVisualRoot() as TopLevel;
public static bool TryShutdown(this IApplicationLifetime lifetime, int exitCode = 0) public bool TryShutdown(int exitCode = 0)
{ {
if (lifetime is IClassicDesktopStyleApplicationLifetime desktopLifetime) if (lifetime is IClassicDesktopStyleApplicationLifetime desktopLifetime)
{ {
@ -31,3 +33,4 @@ internal static class AvaloniaExtensions
return false; return false;
} }
} }
}

View file

@ -6,7 +6,9 @@ namespace DiscordChatExporter.Gui.Utils.Extensions;
internal static class DisposableExtensions internal static class DisposableExtensions
{ {
public static void DisposeAll(this IEnumerable<IDisposable> disposables) extension(IEnumerable<IDisposable> disposables)
{
public void DisposeAll()
{ {
var exceptions = default(List<Exception>); var exceptions = default(List<Exception>);
@ -26,3 +28,4 @@ internal static class DisposableExtensions
throw new AggregateException(exceptions); throw new AggregateException(exceptions);
} }
} }
}

View file

@ -7,13 +7,14 @@ namespace DiscordChatExporter.Gui.Utils.Extensions;
internal static class NotifyPropertyChangedExtensions internal static class NotifyPropertyChangedExtensions
{ {
public static IDisposable WatchProperty<TOwner, TProperty>( extension<TOwner>(TOwner owner)
this TOwner owner, where TOwner : INotifyPropertyChanged
{
public IDisposable WatchProperty<TProperty>(
Expression<Func<TOwner, TProperty>> propertyExpression, Expression<Func<TOwner, TProperty>> propertyExpression,
Action callback, Action callback,
bool watchInitialValue = false bool watchInitialValue = false
) )
where TOwner : INotifyPropertyChanged
{ {
var memberExpression = propertyExpression.Body as MemberExpression; var memberExpression = propertyExpression.Body as MemberExpression;
if (memberExpression?.Member is not PropertyInfo property) if (memberExpression?.Member is not PropertyInfo property)
@ -38,12 +39,7 @@ internal static class NotifyPropertyChangedExtensions
return Disposable.Create(() => owner.PropertyChanged -= OnPropertyChanged); return Disposable.Create(() => owner.PropertyChanged -= OnPropertyChanged);
} }
public static IDisposable WatchAllProperties<TOwner>( public IDisposable WatchAllProperties(Action callback, bool watchInitialValues = false)
this TOwner owner,
Action callback,
bool watchInitialValues = false
)
where TOwner : INotifyPropertyChanged
{ {
void OnPropertyChanged(object? sender, PropertyChangedEventArgs args) => callback(); void OnPropertyChanged(object? sender, PropertyChangedEventArgs args) => callback();
owner.PropertyChanged += OnPropertyChanged; owner.PropertyChanged += OnPropertyChanged;
@ -54,3 +50,4 @@ internal static class NotifyPropertyChangedExtensions
return Disposable.Create(() => owner.PropertyChanged -= OnPropertyChanged); return Disposable.Create(() => owner.PropertyChanged -= OnPropertyChanged);
} }
} }
}

View file

@ -0,0 +1,17 @@
using System.Diagnostics;
namespace DiscordChatExporter.Gui.Utils.Extensions;
internal static class ProcessExtensions
{
extension(Process)
{
public static void StartShellExecute(string path)
{
using var process = new Process();
process.StartInfo = new ProcessStartInfo { FileName = path, UseShellExecute = true };
process.Start();
}
}
}

View file

@ -1,14 +0,0 @@
using System.Diagnostics;
namespace DiscordChatExporter.Gui.Utils;
internal static class ProcessEx
{
public static void StartShellExecute(string path)
{
using var process = new Process();
process.StartInfo = new ProcessStartInfo { FileName = path, UseShellExecute = true };
process.Start();
}
}

View file

@ -1,6 +1,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Linq; using System.Linq;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -102,7 +103,7 @@ public partial class DashboardViewModel : ViewModelBase
await _dialogManager.ShowDialogAsync(_viewModelManager.CreateSettingsViewModel()); await _dialogManager.ShowDialogAsync(_viewModelManager.CreateSettingsViewModel());
[RelayCommand] [RelayCommand]
private void ShowHelp() => ProcessEx.StartShellExecute(Program.ProjectDocumentationUrl); private void ShowHelp() => Process.StartShellExecute(Program.ProjectDocumentationUrl);
private bool CanPullGuilds() => !IsBusy && !string.IsNullOrWhiteSpace(Token); private bool CanPullGuilds() => !IsBusy && !string.IsNullOrWhiteSpace(Token);
@ -322,11 +323,11 @@ public partial class DashboardViewModel : ViewModelBase
} }
[RelayCommand] [RelayCommand]
private void OpenDiscord() => ProcessEx.StartShellExecute("https://discord.com/app"); private void OpenDiscord() => Process.StartShellExecute("https://discord.com/app");
[RelayCommand] [RelayCommand]
private void OpenDiscordDeveloperPortal() => private void OpenDiscordDeveloperPortal() =>
ProcessEx.StartShellExecute("https://discord.com/developers/applications"); Process.StartShellExecute("https://discord.com/developers/applications");
protected override void Dispose(bool disposing) protected override void Dispose(bool disposing)
{ {

View file

@ -5,7 +5,6 @@ using Avalonia;
using CommunityToolkit.Mvvm.Input; using CommunityToolkit.Mvvm.Input;
using DiscordChatExporter.Gui.Framework; using DiscordChatExporter.Gui.Framework;
using DiscordChatExporter.Gui.Services; using DiscordChatExporter.Gui.Services;
using DiscordChatExporter.Gui.Utils;
using DiscordChatExporter.Gui.Utils.Extensions; using DiscordChatExporter.Gui.Utils.Extensions;
using DiscordChatExporter.Gui.ViewModels.Components; using DiscordChatExporter.Gui.ViewModels.Components;
@ -44,7 +43,7 @@ public partial class MainViewModel(
settingsService.Save(); settingsService.Save();
if (await dialogManager.ShowDialogAsync(dialog) == true) if (await dialogManager.ShowDialogAsync(dialog) == true)
ProcessEx.StartShellExecute("https://tyrrrz.me/ukraine?source=discordchatexporter"); Process.StartShellExecute("https://tyrrrz.me/ukraine?source=discordchatexporter");
} }
private async Task ShowDevelopmentBuildMessageAsync() private async Task ShowDevelopmentBuildMessageAsync()
@ -70,7 +69,7 @@ public partial class MainViewModel(
); );
if (await dialogManager.ShowDialogAsync(dialog) == true) if (await dialogManager.ShowDialogAsync(dialog) == true)
ProcessEx.StartShellExecute(Program.ProjectReleasesUrl); Process.StartShellExecute(Program.ProjectReleasesUrl);
} }
private async Task CheckForUpdatesAsync() private async Task CheckForUpdatesAsync()