From ea84843b4feba8b2e4fb6830fd82d14331e302fb Mon Sep 17 00:00:00 2001 From: Poker Date: Wed, 15 Nov 2023 19:49:32 +0800 Subject: [PATCH] refactor --- .editorconfig | 1 - .gitattributes | 1 - README.en.md | 18 ++--- README.md | 4 +- .../CardControl/CardControlAutomationPeer.cs | 15 ++-- .../PersonView/PersonView.xaml.cs | 2 +- src/Pixeval.Controls/Pixeval.Controls.csproj | 4 +- .../PixevalBadge/PixevalBadge.xaml.cs | 2 +- .../ISupportCustomTitleBarDragRegion.cs | 1 - .../Windowing/WindowFactory.cs | 2 +- .../ZoomableImage/ZoomableImage.xaml.cs | 2 +- src/Pixeval.CoreApi/Engine/ICancellable.cs | 1 - .../Engine/ICompletionCallback.cs | 1 - src/Pixeval.CoreApi/Engine/IEngineHandle.cs | 5 +- .../Engine/INotifyCompletion.cs | 1 - .../Implements/AdaptedComputedFetchEngine.cs | 21 ++--- .../Engine/Implements/BookmarkEngine.cs | 45 +++++------ .../Engine/Implements/FeedEngine.cs | 18 +++-- .../IllegalPrivatePolicyException.cs | 10 +-- .../Exception/IllegalSortOptionException.cs | 10 +-- .../Global/Exception/MakoException.cs | 10 +-- .../Exception/MangaPagesNotFoundException.cs | 10 +-- .../RankingDateOutOfRangeException.cs | 9 +-- .../Global/IMakoClientSupport.cs | 1 - src/Pixeval.CoreApi/MakoClient.Engines.cs | 2 +- src/Pixeval.CoreApi/MakoClient.Properties.cs | 6 +- src/Pixeval.CoreApi/MakoClient.cs | 42 +++++----- src/Pixeval.CoreApi/Model/Illustration.cs | 1 - src/Pixeval.CoreApi/Model/TrendingTag.cs | 1 - src/Pixeval.CoreApi/Net/MakoApiKind.cs | 5 +- src/Pixeval.CoreApi/Net/MakoHttpOptions.cs | 1 - .../Net/PixivApiHttpMessageHandler.cs | 4 +- .../SettingsEntryGenerator.cs | 8 +- src/Pixeval.Utilities/Enumerates.cs | 8 +- src/Pixeval.Utilities/ObservableHashSet.cs | 12 +-- src/Pixeval.Utilities/SharedRef.cs | 2 +- .../Threading/CancellationHandle.cs | 10 +-- .../Threading/ReenterableAwaiter.cs | 2 +- .../Threading/ReenterableAwaiter{T}.cs | 2 +- src/Pixeval/Activation/ActivationRegistrar.cs | 4 +- src/Pixeval/App.xaml.cs | 2 +- src/Pixeval/AppManagement/AppContext.cs | 12 +-- src/Pixeval/AppManagement/AppSetting.cs | 2 +- src/Pixeval/AppViewModel.cs | 2 +- .../Attributes/DefaultValueAttribute.cs | 1 - src/Pixeval/Attributes/SettingPOCO.cs | 2 +- .../IllustratorView/IllustratorView.cs | 1 - .../IllustratorView/IllustratorViewModel.cs | 5 +- src/Pixeval/Database/DownloadHistoryEntry.cs | 1 - .../DownloadHistoryPersistentManager.cs | 8 +- .../Database/Managers/IPersistentManager.cs | 1 - .../Managers/SimplePersistentManager.cs | 6 +- .../DownloadListPageDeleteTasksDialog.xaml.cs | 1 - ...everseSearchApiKeyNotPresentDialog.xaml.cs | 2 +- .../AnimatedIllustrationDownloadTask.cs | 4 +- src/Pixeval/Download/DownloadManager.cs | 18 ++--- .../DownloadTaskInitializationException.cs | 9 +-- .../Download/IllustrationDownloadTask.cs | 2 +- .../IllustrationDownloadTaskFactory.cs | 4 +- .../IntrinsicIllustrationDownloadTask.cs | 18 ++--- ...ializedAnimatedIllustrationDownloadTask.cs | 4 +- .../Download/MacroParser/CharStream.cs | 48 ++++++------ src/Pixeval/Download/MacroParser/Lexer.cs | 4 +- .../Download/MacroParser/MacroParser.cs | 8 +- .../Download/Macros/IllustrationTitleMacro.cs | 2 +- .../Download/Macros/IllustratorNameMacro.cs | 2 +- .../Download/Macros/SpotlightTitleMacro.cs | 2 +- .../Flyouts/CommentRepliesBlock.xaml.cs | 2 +- src/Pixeval/Flyouts/LoginWebView.xaml.cs | 2 +- .../IllustrationSourceNotFoundException.cs | 9 +-- .../Interop/IDataTransferManagerInterop.cs | 5 +- src/Pixeval/Interop/TaskBar.cs | 5 +- src/Pixeval/LoginProxyException.cs | 8 +- .../Misc/FetchEngineIncrementalSource.cs | 2 +- src/Pixeval/Options/ThumbnailDirection.cs | 1 - src/Pixeval/Options/XRestrictLevel.cs | 1 - .../Pages/Capability/BookmarksPage.xaml.cs | 2 +- .../Pages/Capability/FollowingsPage.xaml.cs | 6 +- .../Pages/Capability/RankingsPage.xaml.cs | 2 +- .../Pages/Capability/RecentPostsPage.xaml.cs | 2 +- .../Capability/RecommendationPage.xaml.cs | 2 +- .../Capability/SearchResultsPage.xaml.cs | 2 +- .../Pages/Download/DownloadListEntry.xaml.cs | 6 +- .../Pages/Download/DownloadListOption.cs | 1 - .../Pages/Download/DownloadListPage.xaml.cs | 3 +- .../Download/DownloadListPageViewModel.cs | 8 +- .../IllustrationViewer/CommentsPage.xaml.cs | 2 +- .../IllustrationInfoPage.xaml.cs | 4 +- .../IllustrationViewerPage.xaml.cs | 2 +- .../IllustrationViewerPageViewModel.cs | 8 +- .../IllustrationVisualizationController.cs | 4 +- .../ImageViewerPageViewModel.cs | 9 +-- .../PixivReplyEmojiListPage.xaml.cs | 2 +- .../PixivReplyEmojiViewModel.cs | 1 - .../PixivReplyStickerListPage.xaml.cs | 2 +- .../RelatedWorksPage.xaml.cs | 2 +- .../IllustratorViewer/IllustratorPage.xaml.cs | 10 +-- src/Pixeval/Pages/Login/LoginPage.xaml.cs | 4 +- src/Pixeval/Pages/Login/LoginPageViewModel.cs | 9 +-- src/Pixeval/Pages/Login/PixivAuthSignature.cs | 6 +- src/Pixeval/Pages/MainPage.xaml.cs | 30 ++++---- src/Pixeval/Pages/MainPageViewModel.cs | 4 +- src/Pixeval/Pages/Misc/AboutPage.xaml.cs | 2 +- .../Pages/Misc/BrowsingHistoryPage.xaml.cs | 2 +- src/Pixeval/Pages/Misc/SettingsPage.xaml | 5 -- src/Pixeval/Pages/Misc/SettingsPage.xaml.cs | 14 ++-- src/Pixeval/Pages/SuggestionStateMachine.cs | 8 +- src/Pixeval/Pixeval.csproj | 4 +- src/Pixeval/UserControls/CommentList.xaml.cs | 4 +- .../IllustrationContainer.xaml.cs | 7 +- .../IllustrationThumbnail.xaml.cs | 8 +- .../IllustrationViewCommandBar.xaml.cs | 8 +- .../IllustrationViewDataProvider.cs | 2 +- .../IllustrationView/IllustrationViewModel.cs | 4 +- .../IllustratorContentViewer.xaml.cs | 8 +- .../IllustratorContentViewerViewModel.cs | 8 +- ...orIllustrationAndMangaBookmarkPage.xaml.cs | 5 +- ...lustrationAndMangaBookmarkPageViewModel.cs | 6 +- .../IllustratorIllustrationPage.xaml.cs | 5 +- .../IllustratorMangaPage.xaml.cs | 5 +- .../IllustratorViewDataProvider.cs | 2 +- .../IllustratorView/IllustratorViewModel.cs | 24 +++--- .../UserControls/PixivReplyBar.xaml.cs | 2 +- .../RecommendIllustratorProfile.xaml.cs | 4 +- .../RecommendIllustratorProfileViewModel.cs | 8 +- .../TokenInput/TokenInput.xaml.cs | 2 +- src/Pixeval/Util/IO/FileCache.cs | 36 ++++----- src/Pixeval/Util/IO/IOHelper.Download.cs | 22 +++--- src/Pixeval/Util/IO/IOHelper.Imaging.cs | 2 +- src/Pixeval/Util/IO/IOHelper.Mako.cs | 2 +- src/Pixeval/Util/IO/IOHelper.cs | 2 +- .../Util/PixivAuthenticationProxyServer.cs | 18 +++-- src/Pixeval/Util/Threading/ThreadingHelper.cs | 13 ++-- .../Util/UI/Animating/IEasingFunction.cs | 4 +- .../Util/UI/Animating/IValueAnimation.cs | 10 +-- .../Util/UI/Animating/ValueAnimations.cs | 4 +- .../Util/UI/ReplyEmojiHelper.Enumerator.cs | 5 +- src/Pixeval/Util/UI/ReplyEmojiHelper.cs | 9 +-- .../Util/UI/ToastNotificationHelper.cs | 8 +- src/Pixeval/Util/UI/UIHelper.PInvoke.cs | 14 ++-- src/Pixeval/Util/UI/UIHelper.cs | 10 +-- src/Pixeval/Util/UI/XamlUICommandHelper.cs | 2 +- src/Pixeval/packages.lock.json | 77 ++++++++++--------- 143 files changed, 473 insertions(+), 555 deletions(-) diff --git a/.editorconfig b/.editorconfig index 18e1e52d..ee3469c6 100644 --- a/.editorconfig +++ b/.editorconfig @@ -226,6 +226,5 @@ dotnet_naming_style.camel_begin_with__.required_prefix = _ dotnet_naming_style.camel_begin_with__.capitalization = camel_case - # ReSharper properties resharper_max_initializer_elements_on_line = 1 diff --git a/.gitattributes b/.gitattributes index 7c23de33..d14a7e03 100644 --- a/.gitattributes +++ b/.gitattributes @@ -38,7 +38,6 @@ *.filters text eol=crlf *.vcxitems text eol=crlf - #*.sln merge=binary #*.csproj merge=binary #*.vbproj merge=binary diff --git a/README.en.md b/README.en.md index 3096a008..3a0f585a 100644 --- a/README.en.md +++ b/README.en.md @@ -30,17 +30,18 @@ --- **The Pixeval that based on WinUI 3 is now WIP, the older version, -which is the WPF version has been deprecated and expecting no more supports from developers, -the WinUI 3 version provides a better user interface, -a more structural codebase and a modern development experience compared to the WPF version. -You can download and compile it yourself if you want to take a glance at the new version, -follow the following steps to compile and run:** - -For more information, see [main page](https://sora.ink/pixeval/) +which is the WPF version has been deprecated and expecting no more supports from developers.** > The WinUI 3 codebase for Pixeval supports only Windows 10 (1809, Build Number 17763) and higher. > You can check this at Settings | System | About | Windows specifications +For more information, see [main page](https://sora.ink/pixeval/) + +**The WinUI 3 version provides a better user interface, +a more structural codebase and a modern development experience compared to the WPF version. +You can download and compile it yourself if you want to take a glance at the new version, +follow the following steps to compile and run:** + ## Prerequisites 1. Install [Visual Studio 2022](https://visualstudio.microsoft.com/vs) (Roslyn 4.x requires VS17.x, i.e. VS2022) @@ -108,10 +109,9 @@ If this project meets your requirements perfectly, welcome the buy me a coffee a ## JetBrains Open Source License -
JetBrains
The Jetbrains™ ReSharper is heavily used during the development of this project. Thank JetBrains s.r.o for providing the [JetBrains Open Source License]((https://www.jetbrains.com/community/opensource/#support)), If you are one of the passionate developers who often put JetBrains products into use, you can try to apply the JetBrains Open Source License from the [official channel](https://www.jetbrains.com/shop/eform/opensource) to help you and your developer teammates to significantly improve the productivities -
\ No newline at end of file + diff --git a/README.md b/README.md index f5d78d2c..be78c632 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ 更多详细信息请前往 [项目主页](https://sora.ink/pixeval) 查看 -**WinUI3版本提供了更好的UI,更好的项目结构以及更好的开发体验,如果你想要了解目前的开发进度,可以通过以下方法来下载并编译该项目** +**WinUI3版本提供了更好的UI,更好的项目结构以及更好的开发体验,如果你想要了解目前的开发进度,可以通过以下方法来下载并编译该项目:** ## 环境要求 @@ -108,4 +108,4 @@
本项目重度依赖于 [JetBrains](https://www.jetbrains.com/?from=ImageSharp) ReSharper,感谢JetBrains s.r.o为本项目提供 [开源许可证](https://www.jetbrains.com/community/opensource/#support),如果你同样对开发充满热情并且经常使用JetBrains s.r.o的产品,你也可以尝试通过JetBrains官方渠道 [申请](https://www.jetbrains.com/shop/eform/opensource) 开源许可证以供核心开发者使用 - \ No newline at end of file + diff --git a/src/Pixeval.Controls/CardControl/CardControlAutomationPeer.cs b/src/Pixeval.Controls/CardControl/CardControlAutomationPeer.cs index 4b052b8e..20e57a0f 100644 --- a/src/Pixeval.Controls/CardControl/CardControlAutomationPeer.cs +++ b/src/Pixeval.Controls/CardControl/CardControlAutomationPeer.cs @@ -25,17 +25,12 @@ namespace Pixeval.Controls; /// /// AutomationPeer for CardControl /// -public class CardControlAutomationPeer : FrameworkElementAutomationPeer +/// +/// Initializes a new instance of the class. +/// +/// CardControl +public class CardControlAutomationPeer(CardControl owner) : FrameworkElementAutomationPeer(owner) { - /// - /// Initializes a new instance of the class. - /// - /// CardControl - public CardControlAutomationPeer(CardControl owner) - : base(owner) - { - } - /// /// Gets the control type for the element that is associated with the UI Automation peer. /// diff --git a/src/Pixeval.Controls/PersonView/PersonView.xaml.cs b/src/Pixeval.Controls/PersonView/PersonView.xaml.cs index 9aef90fd..4061d54b 100644 --- a/src/Pixeval.Controls/PersonView/PersonView.xaml.cs +++ b/src/Pixeval.Controls/PersonView/PersonView.xaml.cs @@ -43,6 +43,6 @@ public partial class PersonView : UserControl private async void ContentContainerOnTapped(object sender, TappedRoutedEventArgs e) { - await Launcher.LaunchUriAsync(PersonProfileNavigateUri); + _ = await Launcher.LaunchUriAsync(PersonProfileNavigateUri); } } diff --git a/src/Pixeval.Controls/Pixeval.Controls.csproj b/src/Pixeval.Controls/Pixeval.Controls.csproj index 54dfd3fa..61228ac0 100644 --- a/src/Pixeval.Controls/Pixeval.Controls.csproj +++ b/src/Pixeval.Controls/Pixeval.Controls.csproj @@ -1,7 +1,7 @@ - net8.0-windows10.0.19041.0 - 10.0.17763.0 + net8.0-windows10.0.22621.0 + 10.0.19041.0 Pixeval.Controls x86;x64;arm64 win-x86;win-x64;win-arm64 diff --git a/src/Pixeval.Controls/PixevalBadge/PixevalBadge.xaml.cs b/src/Pixeval.Controls/PixevalBadge/PixevalBadge.xaml.cs index b9cf8794..3203bfde 100644 --- a/src/Pixeval.Controls/PixevalBadge/PixevalBadge.xaml.cs +++ b/src/Pixeval.Controls/PixevalBadge/PixevalBadge.xaml.cs @@ -48,6 +48,6 @@ public sealed partial class PixevalBadge : UserControl private void GoToState(bool useSmall) { - VisualStateManager.GoToState(this, useSmall ? SmallState : NormalState, true); + _ = VisualStateManager.GoToState(this, useSmall ? SmallState : NormalState, true); } } diff --git a/src/Pixeval.Controls/Windowing/ISupportCustomTitleBarDragRegion.cs b/src/Pixeval.Controls/Windowing/ISupportCustomTitleBarDragRegion.cs index e1254f85..24f41112 100644 --- a/src/Pixeval.Controls/Windowing/ISupportCustomTitleBarDragRegion.cs +++ b/src/Pixeval.Controls/Windowing/ISupportCustomTitleBarDragRegion.cs @@ -18,7 +18,6 @@ // along with this program. If not, see . #endregion - namespace Pixeval.Controls.Windowing; public interface ISupportCustomTitleBarDragRegion diff --git a/src/Pixeval.Controls/Windowing/WindowFactory.cs b/src/Pixeval.Controls/Windowing/WindowFactory.cs index 7ccfdaea..0c4870a9 100644 --- a/src/Pixeval.Controls/Windowing/WindowFactory.cs +++ b/src/Pixeval.Controls/Windowing/WindowFactory.cs @@ -34,7 +34,7 @@ public static class WindowFactory public static EnhancedWindow RootWindow => _forkedWindowsInternal[0]; - private static readonly List _forkedWindowsInternal = new(); + private static readonly List _forkedWindowsInternal = []; public static IReadOnlyList ForkedWindows => _forkedWindowsInternal; diff --git a/src/Pixeval.Controls/ZoomableImage/ZoomableImage.xaml.cs b/src/Pixeval.Controls/ZoomableImage/ZoomableImage.xaml.cs index 2f17d076..4aee20c0 100644 --- a/src/Pixeval.Controls/ZoomableImage/ZoomableImage.xaml.cs +++ b/src/Pixeval.Controls/ZoomableImage/ZoomableImage.xaml.cs @@ -134,7 +134,7 @@ public sealed partial class ZoomableImage : UserControl private bool _timerRunning; private CanvasBitmap? _currentFrame; - private readonly List _frames = new(); + private readonly List _frames = []; private readonly CancellationTokenSource _token = new(); private List? ClonedMsIntervals { get; set; } private ManualResetEvent ManualResetEvent { get; } = new(true); diff --git a/src/Pixeval.CoreApi/Engine/ICancellable.cs b/src/Pixeval.CoreApi/Engine/ICancellable.cs index c16233ee..99b89fe4 100644 --- a/src/Pixeval.CoreApi/Engine/ICancellable.cs +++ b/src/Pixeval.CoreApi/Engine/ICancellable.cs @@ -18,7 +18,6 @@ // along with this program. If not, see . #endregion - namespace Pixeval.CoreApi.Engine; public interface ICancellable diff --git a/src/Pixeval.CoreApi/Engine/ICompletionCallback.cs b/src/Pixeval.CoreApi/Engine/ICompletionCallback.cs index e8b92d0e..a0dfeaa7 100644 --- a/src/Pixeval.CoreApi/Engine/ICompletionCallback.cs +++ b/src/Pixeval.CoreApi/Engine/ICompletionCallback.cs @@ -18,7 +18,6 @@ // along with this program. If not, see . #endregion - namespace Pixeval.CoreApi.Engine; public interface ICompletionCallback diff --git a/src/Pixeval.CoreApi/Engine/IEngineHandle.cs b/src/Pixeval.CoreApi/Engine/IEngineHandle.cs index 10810742..60714b91 100644 --- a/src/Pixeval.CoreApi/Engine/IEngineHandle.cs +++ b/src/Pixeval.CoreApi/Engine/IEngineHandle.cs @@ -1,4 +1,4 @@ -#region Copyright (c) Pixeval/Pixeval.CoreApi +#region Copyright (c) Pixeval/Pixeval.CoreApi // GPL v3 License // // Pixeval/Pixeval.CoreApi @@ -18,7 +18,6 @@ // along with this program. If not, see . #endregion - namespace Pixeval.CoreApi.Engine; /// @@ -29,4 +28,4 @@ namespace Pixeval.CoreApi.Engine; public interface IEngineHandleSource { EngineHandle EngineHandle { get; } -} \ No newline at end of file +} diff --git a/src/Pixeval.CoreApi/Engine/INotifyCompletion.cs b/src/Pixeval.CoreApi/Engine/INotifyCompletion.cs index 20841c77..dde2fd84 100644 --- a/src/Pixeval.CoreApi/Engine/INotifyCompletion.cs +++ b/src/Pixeval.CoreApi/Engine/INotifyCompletion.cs @@ -18,7 +18,6 @@ // along with this program. If not, see . #endregion - namespace Pixeval.CoreApi.Engine; public interface INotifyCompletion diff --git a/src/Pixeval.CoreApi/Engine/Implements/AdaptedComputedFetchEngine.cs b/src/Pixeval.CoreApi/Engine/Implements/AdaptedComputedFetchEngine.cs index f485f712..711e7dbc 100644 --- a/src/Pixeval.CoreApi/Engine/Implements/AdaptedComputedFetchEngine.cs +++ b/src/Pixeval.CoreApi/Engine/Implements/AdaptedComputedFetchEngine.cs @@ -31,20 +31,15 @@ namespace Pixeval.CoreApi.Engine.Implements; /// only supposed to be used by caching systems /// /// The type of the results of the -public class AdaptedComputedFetchEngine : IFetchEngine +/// +/// Creates an that delegates all of its +/// property and methods to +/// +/// +/// The that is going to be delegated +public class AdaptedComputedFetchEngine(IEnumerable outer) : IFetchEngine { - private readonly IEnumerable _outer; - - /// - /// Creates an that delegates all of its - /// property and methods to - /// - /// - /// The that is going to be delegated - public AdaptedComputedFetchEngine(IEnumerable outer) - { - _outer = outer; - } + private readonly IEnumerable _outer = outer; public MakoClient MakoClient => throw new NotSupportedException(); diff --git a/src/Pixeval.CoreApi/Engine/Implements/BookmarkEngine.cs b/src/Pixeval.CoreApi/Engine/Implements/BookmarkEngine.cs index b1eb47cc..01f2e1d3 100644 --- a/src/Pixeval.CoreApi/Engine/Implements/BookmarkEngine.cs +++ b/src/Pixeval.CoreApi/Engine/Implements/BookmarkEngine.cs @@ -1,4 +1,4 @@ -#region Copyright (c) Pixeval/Pixeval.CoreApi +#region Copyright (c) Pixeval/Pixeval.CoreApi // GPL v3 License // // Pixeval/Pixeval.CoreApi @@ -30,31 +30,24 @@ namespace Pixeval.CoreApi.Engine.Implements; /// /// An that fetches the bookmark of a specific user /// -internal class BookmarkEngine : AbstractPixivFetchEngine +/// +/// Creates a +/// +/// The that owns this object +/// Id of the user +/// The privacy option +/// Indicates the target API of the fetch operation +/// +internal class BookmarkEngine( + MakoClient makoClient, + string uid, + PrivacyPolicy privacyPolicy, + TargetFilter targetFilter, + EngineHandle? engineHandle = null) : AbstractPixivFetchEngine(makoClient, engineHandle) { - private readonly PrivacyPolicy _privacyPolicy; - private readonly TargetFilter _targetFilter; - private readonly string _uid; - - /// - /// Creates a - /// - /// The that owns this object - /// Id of the user - /// The privacy option - /// Indicates the target API of the fetch operation - /// - public BookmarkEngine( - MakoClient makoClient, - string uid, - PrivacyPolicy privacyPolicy, - TargetFilter targetFilter, - EngineHandle? engineHandle = null) : base(makoClient, engineHandle) - { - _uid = uid; - _privacyPolicy = privacyPolicy; - _targetFilter = targetFilter; - } + private readonly PrivacyPolicy _privacyPolicy = privacyPolicy; + private readonly TargetFilter _targetFilter = targetFilter; + private readonly string _uid = uid; public override IAsyncEnumerator GetAsyncEnumerator(CancellationToken cancellationToken = new()) { @@ -64,4 +57,4 @@ internal class BookmarkEngine : AbstractPixivFetchEngine + $"&restrict={engine._privacyPolicy.GetDescription()}" + $"&filter={engine._targetFilter.GetDescription()}")!; } -} \ No newline at end of file +} diff --git a/src/Pixeval.CoreApi/Engine/Implements/FeedEngine.cs b/src/Pixeval.CoreApi/Engine/Implements/FeedEngine.cs index cd604c40..69306e68 100644 --- a/src/Pixeval.CoreApi/Engine/Implements/FeedEngine.cs +++ b/src/Pixeval.CoreApi/Engine/Implements/FeedEngine.cs @@ -1,4 +1,4 @@ -#region Copyright (c) Pixeval/Pixeval.CoreApi +#region Copyright (c) Pixeval/Pixeval.CoreApi // GPL v3 License // // Pixeval/Pixeval.CoreApi @@ -33,20 +33,19 @@ using Pixeval.Utilities; namespace Pixeval.CoreApi.Engine.Implements; -internal class FeedEngine(MakoClient makoClient, EngineHandle? engineHandle) : AbstractPixivFetchEngine(makoClient, engineHandle) +internal partial class FeedEngine(MakoClient makoClient, EngineHandle? engineHandle) : AbstractPixivFetchEngine(makoClient, engineHandle) { public override IAsyncEnumerator GetAsyncEnumerator(CancellationToken cancellationToken = new()) { return new UserFeedsAsyncEnumerator(this, MakoApiKind.WebApi)!; } - private class UserFeedsAsyncEnumerator + private partial class UserFeedsAsyncEnumerator (FeedEngine pixivFetchEngine, MakoApiKind apiKind) : AbstractPixivAsyncEnumerator(pixivFetchEngine, apiKind) { private FeedRequestContext? _feedRequestContext; private string? _tt; - public override async ValueTask MoveNextAsync() { if (_feedRequestContext is null) @@ -57,7 +56,7 @@ internal class FeedEngine(MakoClient makoClient, EngineHandle? engineHandle) : A if (TryParsePreloadJsonFromHtml(response, out var result)) { await UpdateAsync(result).ConfigureAwait(false); - _tt = Regex.Match(response, "tt: \"(?.*)\"").Groups["tt"].Value; + _tt = TtRegex().Match(response).Groups["tt"].Value; _feedRequestContext = ExtractRequestContextFromHtml(response); } else @@ -147,7 +146,7 @@ internal class FeedEngine(MakoClient makoClient, EngineHandle? engineHandle) : A private static bool TryExtractPreloadJson(string html, out string json) { - var match = Regex.Match(html, "pixiv\\.stacc\\.env\\.preload\\.stacc \\= (?.*);"); + var match = PreloadRegex().Match(html); if (match.Success) { json = match.Groups["json"].Value; @@ -296,10 +295,15 @@ internal class FeedEngine(MakoClient makoClient, EngineHandle? engineHandle) : A return Result.OfFailure(new MakoNetworkException(url, MakoClient.Configuration.Bypass, e.Message, (int?)e.StatusCode ?? -1)); } } + + [GeneratedRegex("tt: \"(?.*)\"")] + private static partial Regex TtRegex(); + [GeneratedRegex("pixiv\\.stacc\\.env\\.preload\\.stacc \\= (?.*);")] + private static partial Regex PreloadRegex(); } /// /// Required parameters established from multiple tests, I don't know what do they mean /// private record FeedRequestContext(string UnifyToken, string Sid, string Mode, bool IsLastPage); -} \ No newline at end of file +} diff --git a/src/Pixeval.CoreApi/Global/Exception/IllegalPrivatePolicyException.cs b/src/Pixeval.CoreApi/Global/Exception/IllegalPrivatePolicyException.cs index 7f409595..a3b96a90 100644 --- a/src/Pixeval.CoreApi/Global/Exception/IllegalPrivatePolicyException.cs +++ b/src/Pixeval.CoreApi/Global/Exception/IllegalPrivatePolicyException.cs @@ -1,4 +1,4 @@ -#region Copyright (c) Pixeval/Pixeval.CoreApi +#region Copyright (c) Pixeval/Pixeval.CoreApi // GPL v3 License // // Pixeval/Pixeval.CoreApi @@ -18,7 +18,6 @@ // along with this program. If not, see . #endregion -using System.Runtime.Serialization; using Pixeval.CoreApi.Global.Enum; namespace Pixeval.CoreApi.Global.Exception; @@ -34,11 +33,6 @@ public class IllegalPrivatePolicyException : MakoException Uid = uid; } - protected IllegalPrivatePolicyException(SerializationInfo info, StreamingContext context, string uid) : base(info, context) - { - Uid = uid; - } - public IllegalPrivatePolicyException(string? message, string uid) : base(message) { Uid = uid; @@ -50,4 +44,4 @@ public class IllegalPrivatePolicyException : MakoException } public string Uid { get; } -} \ No newline at end of file +} diff --git a/src/Pixeval.CoreApi/Global/Exception/IllegalSortOptionException.cs b/src/Pixeval.CoreApi/Global/Exception/IllegalSortOptionException.cs index 76409d4b..4b6eebc9 100644 --- a/src/Pixeval.CoreApi/Global/Exception/IllegalSortOptionException.cs +++ b/src/Pixeval.CoreApi/Global/Exception/IllegalSortOptionException.cs @@ -1,4 +1,4 @@ -#region Copyright (c) Pixeval/Pixeval.CoreApi +#region Copyright (c) Pixeval/Pixeval.CoreApi // GPL v3 License // // Pixeval/Pixeval.CoreApi @@ -18,8 +18,6 @@ // along with this program. If not, see . #endregion -using System.Runtime.Serialization; - namespace Pixeval.CoreApi.Global.Exception; /// @@ -31,10 +29,6 @@ public class IllegalSortOptionException : MakoException { } - protected IllegalSortOptionException(SerializationInfo info, StreamingContext context) : base(info, context) - { - } - public IllegalSortOptionException(string? message) : base(message) { } @@ -42,4 +36,4 @@ public class IllegalSortOptionException : MakoException public IllegalSortOptionException(string? message, System.Exception? innerException) : base(message, innerException) { } -} \ No newline at end of file +} diff --git a/src/Pixeval.CoreApi/Global/Exception/MakoException.cs b/src/Pixeval.CoreApi/Global/Exception/MakoException.cs index 6aa6098a..020dbe9c 100644 --- a/src/Pixeval.CoreApi/Global/Exception/MakoException.cs +++ b/src/Pixeval.CoreApi/Global/Exception/MakoException.cs @@ -1,4 +1,4 @@ -#region Copyright (c) Pixeval/Pixeval.CoreApi +#region Copyright (c) Pixeval/Pixeval.CoreApi // GPL v3 License // // Pixeval/Pixeval.CoreApi @@ -18,8 +18,6 @@ // along with this program. If not, see . #endregion -using System.Runtime.Serialization; - namespace Pixeval.CoreApi.Global.Exception; public class MakoException : System.Exception @@ -28,10 +26,6 @@ public class MakoException : System.Exception { } - protected MakoException(SerializationInfo info, StreamingContext context) : base(info, context) - { - } - public MakoException(string? message) : base(message) { } @@ -39,4 +33,4 @@ public class MakoException : System.Exception public MakoException(string? message, System.Exception? innerException) : base(message, innerException) { } -} \ No newline at end of file +} diff --git a/src/Pixeval.CoreApi/Global/Exception/MangaPagesNotFoundException.cs b/src/Pixeval.CoreApi/Global/Exception/MangaPagesNotFoundException.cs index dde21a40..e75b1f52 100644 --- a/src/Pixeval.CoreApi/Global/Exception/MangaPagesNotFoundException.cs +++ b/src/Pixeval.CoreApi/Global/Exception/MangaPagesNotFoundException.cs @@ -1,4 +1,4 @@ -#region Copyright (c) Pixeval/Pixeval.CoreApi +#region Copyright (c) Pixeval/Pixeval.CoreApi // GPL v3 License // // Pixeval/Pixeval.CoreApi @@ -18,7 +18,6 @@ // along with this program. If not, see . #endregion -using System.Runtime.Serialization; using Pixeval.CoreApi.Model; namespace Pixeval.CoreApi.Global.Exception; @@ -30,11 +29,6 @@ public class MangaPagesNotFoundException : MakoException Illustration = illustration; } - protected MangaPagesNotFoundException(SerializationInfo info, StreamingContext context, Illustration illustration) : base(info, context) - { - Illustration = illustration; - } - public MangaPagesNotFoundException(string? message, Illustration illustration) : base(message) { Illustration = illustration; @@ -46,4 +40,4 @@ public class MangaPagesNotFoundException : MakoException } public Illustration Illustration { get; } -} \ No newline at end of file +} diff --git a/src/Pixeval.CoreApi/Global/Exception/RankingDateOutOfRangeException.cs b/src/Pixeval.CoreApi/Global/Exception/RankingDateOutOfRangeException.cs index a1848fc3..9bfdc439 100644 --- a/src/Pixeval.CoreApi/Global/Exception/RankingDateOutOfRangeException.cs +++ b/src/Pixeval.CoreApi/Global/Exception/RankingDateOutOfRangeException.cs @@ -1,4 +1,4 @@ -#region Copyright (c) Pixeval/Pixeval.CoreApi +#region Copyright (c) Pixeval/Pixeval.CoreApi // GPL v3 License // // Pixeval/Pixeval.CoreApi @@ -18,7 +18,6 @@ // along with this program. If not, see . #endregion -using System.Runtime.Serialization; namespace Pixeval.CoreApi.Global.Exception; @@ -31,10 +30,6 @@ public class RankingDateOutOfRangeException : MakoException { } - protected RankingDateOutOfRangeException(SerializationInfo info, StreamingContext context) : base(info, context) - { - } - public RankingDateOutOfRangeException(string? message) : base(message) { } @@ -42,4 +37,4 @@ public class RankingDateOutOfRangeException : MakoException public RankingDateOutOfRangeException(string? message, System.Exception? innerException) : base(message, innerException) { } -} \ No newline at end of file +} diff --git a/src/Pixeval.CoreApi/Global/IMakoClientSupport.cs b/src/Pixeval.CoreApi/Global/IMakoClientSupport.cs index 56a2fdf8..59520bc3 100644 --- a/src/Pixeval.CoreApi/Global/IMakoClientSupport.cs +++ b/src/Pixeval.CoreApi/Global/IMakoClientSupport.cs @@ -18,7 +18,6 @@ // along with this program. If not, see . #endregion - namespace Pixeval.CoreApi.Global; /// diff --git a/src/Pixeval.CoreApi/MakoClient.Engines.cs b/src/Pixeval.CoreApi/MakoClient.Engines.cs index c5f90146..a489d6e2 100644 --- a/src/Pixeval.CoreApi/MakoClient.Engines.cs +++ b/src/Pixeval.CoreApi/MakoClient.Engines.cs @@ -312,7 +312,7 @@ public partial class MakoClient public IFetchEngine NovelBookmarks(string uid, PrivacyPolicy privacyPolicy, TargetFilter targetFilter) { EnsureNotCancelled(); - CheckPrivacyPolicy(uid, privacyPolicy); + _ = CheckPrivacyPolicy(uid, privacyPolicy); return new NovelBookmarkEngine(this, uid, privacyPolicy, targetFilter, new EngineHandle(CancelInstance)); } diff --git a/src/Pixeval.CoreApi/MakoClient.Properties.cs b/src/Pixeval.CoreApi/MakoClient.Properties.cs index 345a25b9..ca967685 100644 --- a/src/Pixeval.CoreApi/MakoClient.Properties.cs +++ b/src/Pixeval.CoreApi/MakoClient.Properties.cs @@ -1,4 +1,4 @@ -#region Copyright (c) Pixeval/Pixeval.CoreApi +#region Copyright (c) Pixeval/Pixeval.CoreApi // GPL v3 License // // Pixeval/Pixeval.CoreApi @@ -28,7 +28,7 @@ namespace Pixeval.CoreApi; public partial class MakoClient { - private readonly List _runningInstances = new(); + private readonly List _runningInstances = []; /// /// The globally unique ID of current @@ -47,4 +47,4 @@ public partial class MakoClient internal IContainer MakoServices { get; init; } public bool IsCancelled { get; set; } -} \ No newline at end of file +} diff --git a/src/Pixeval.CoreApi/MakoClient.cs b/src/Pixeval.CoreApi/MakoClient.cs index 081e1aa4..0d8736e4 100644 --- a/src/Pixeval.CoreApi/MakoClient.cs +++ b/src/Pixeval.CoreApi/MakoClient.cs @@ -87,64 +87,64 @@ public partial class MakoClient : ICancellable private IContainer BuildContainer() { var builder = new ContainerBuilder(); - builder.RegisterInstance(this).SingleInstance(); + _ = builder.RegisterInstance(this).SingleInstance(); - builder.RegisterType().SingleInstance(); - builder.RegisterType().SingleInstance(); - builder.RegisterType().SingleInstance(); + _ = builder.RegisterType().SingleInstance(); + _ = builder.RegisterType().SingleInstance(); + _ = builder.RegisterType().SingleInstance(); - builder.RegisterType().SingleInstance(); - builder.RegisterType().SingleInstance(); + _ = builder.RegisterType().SingleInstance(); + _ = builder.RegisterType().SingleInstance(); - builder.Register(static c => new MakoRetryHttpClientHandler(c.Resolve())) + _ = builder.Register(static c => new MakoRetryHttpClientHandler(c.Resolve())) .Keyed(typeof(PixivApiHttpMessageHandler)) .As() .PropertiesAutowired(static (info, _) => info.PropertyType == typeof(MakoClient)) .SingleInstance(); - builder.Register(static c => new MakoRetryHttpClientHandler(c.Resolve())) + _ = builder.Register(static c => new MakoRetryHttpClientHandler(c.Resolve())) .Keyed(typeof(PixivImageHttpMessageHandler)) .As() .PropertiesAutowired(static (info, _) => info.PropertyType == typeof(MakoClient)) .SingleInstance(); - builder.Register(static c => MakoHttpClient.Create(c.ResolveKeyed(typeof(PixivApiHttpMessageHandler)), + _ = builder.Register(static c => MakoHttpClient.Create(c.ResolveKeyed(typeof(PixivApiHttpMessageHandler)), static client => client.BaseAddress = new Uri(MakoHttpOptions.AppApiBaseUrl))) .Keyed(MakoApiKind.AppApi) .As() .SingleInstance(); - builder.Register(static c => MakoHttpClient.Create(c.ResolveKeyed(typeof(PixivApiHttpMessageHandler)), + _ = builder.Register(static c => MakoHttpClient.Create(c.ResolveKeyed(typeof(PixivApiHttpMessageHandler)), static client => client.BaseAddress = new Uri(MakoHttpOptions.WebApiBaseUrl))) .Keyed(MakoApiKind.WebApi) .As() .SingleInstance(); - builder.Register(static c => MakoHttpClient.Create(c.ResolveKeyed(typeof(PixivApiHttpMessageHandler)), + _ = builder.Register(static c => MakoHttpClient.Create(c.ResolveKeyed(typeof(PixivApiHttpMessageHandler)), static client => client.BaseAddress = new Uri(MakoHttpOptions.OAuthBaseUrl))) .Keyed(MakoApiKind.AuthApi) .As() .SingleInstance(); - builder.Register(static c => MakoHttpClient.Create(c.ResolveKeyed(typeof(PixivImageHttpMessageHandler)), + _ = builder.Register(static c => MakoHttpClient.Create(c.ResolveKeyed(typeof(PixivImageHttpMessageHandler)), static client => { - client.DefaultRequestHeaders.TryAddWithoutValidation("Referer", "https://www.pixiv.net"); - client.DefaultRequestHeaders.TryAddWithoutValidation("User-Agent", "PixivIOSApp/5.8.7"); + _ = client.DefaultRequestHeaders.TryAddWithoutValidation("Referer", "https://www.pixiv.net"); + _ = client.DefaultRequestHeaders.TryAddWithoutValidation("User-Agent", "PixivIOSApp/5.8.7"); })) .Keyed(MakoApiKind.ImageApi) .As() .SingleInstance(); - builder.Register(static c => MakoHttpOptions.CreateHttpMessageInvoker(c.Resolve())) + _ = builder.Register(static c => MakoHttpOptions.CreateHttpMessageInvoker(c.Resolve())) .Keyed(typeof(PixivApiNameResolver)) .As() .SingleInstance(); - builder.Register(static c => MakoHttpOptions.CreateHttpMessageInvoker(c.Resolve())) + _ = builder.Register(static c => MakoHttpOptions.CreateHttpMessageInvoker(c.Resolve())) .Keyed(typeof(PixivImageNameResolver)) .As() .SingleInstance(); - builder.Register(static _ => MakoHttpOptions.CreateDirectHttpMessageInvoker()) + _ = builder.Register(static _ => MakoHttpOptions.CreateDirectHttpMessageInvoker()) .Keyed(typeof(LocalMachineNameResolver)) .As() .SingleInstance(); - builder.Register(static c => + _ = builder.Register(static c => { var context = c.Resolve(); // or a System.ObjectDisposedException will thrown because the 'c' cannot be hold return RestService.For(c.ResolveKeyed(MakoApiKind.AppApi), new RefitSettings @@ -153,7 +153,7 @@ public partial class MakoClient : ICancellable }); }); - builder.Register(static c => + _ = builder.Register(static c => { var context = c.Resolve(); // or a System.ObjectDisposedException will thrown because the 'c' cannot be hold return RestService.For(c.ResolveKeyed(MakoApiKind.AuthApi), new RefitSettings @@ -162,7 +162,7 @@ public partial class MakoClient : ICancellable }); }); - builder.Register(static c => + _ = builder.Register(static c => { var context = c.Resolve(); // or a System.ObjectDisposedException will thrown because the 'c' cannot be hold return RestService.For("https://saucenao.com/", new RefitSettings @@ -225,7 +225,7 @@ public partial class MakoClient : ICancellable // removes an instance from the running instances list private void CancelInstance(EngineHandle handle) { - _runningInstances.RemoveAll(instance => instance.EngineHandle == handle); + _ = _runningInstances.RemoveAll(instance => instance.EngineHandle == handle); } // PrivacyPolicy.Private is only allowed when the uid is pointing to yourself diff --git a/src/Pixeval.CoreApi/Model/Illustration.cs b/src/Pixeval.CoreApi/Model/Illustration.cs index 76668118..9221679b 100644 --- a/src/Pixeval.CoreApi/Model/Illustration.cs +++ b/src/Pixeval.CoreApi/Model/Illustration.cs @@ -113,7 +113,6 @@ public record Illustration : IIllustrate return other?.Id == Id; } - public class IllustrationMetaSinglePage { [JsonPropertyName("original_image_url")] diff --git a/src/Pixeval.CoreApi/Model/TrendingTag.cs b/src/Pixeval.CoreApi/Model/TrendingTag.cs index 47a9516a..935c977d 100644 --- a/src/Pixeval.CoreApi/Model/TrendingTag.cs +++ b/src/Pixeval.CoreApi/Model/TrendingTag.cs @@ -18,7 +18,6 @@ // along with this program. If not, see . #endregion - namespace Pixeval.CoreApi.Model; public record TrendingTag(string? Tag, string? Translation, Illustration? Illustration); \ No newline at end of file diff --git a/src/Pixeval.CoreApi/Net/MakoApiKind.cs b/src/Pixeval.CoreApi/Net/MakoApiKind.cs index ed23347a..80c9d542 100644 --- a/src/Pixeval.CoreApi/Net/MakoApiKind.cs +++ b/src/Pixeval.CoreApi/Net/MakoApiKind.cs @@ -1,4 +1,4 @@ -#region Copyright (c) Pixeval/Pixeval.CoreApi +#region Copyright (c) Pixeval/Pixeval.CoreApi // GPL v3 License // // Pixeval/Pixeval.CoreApi @@ -18,7 +18,6 @@ // along with this program. If not, see . #endregion - namespace Pixeval.CoreApi.Net; /// @@ -30,4 +29,4 @@ public enum MakoApiKind WebApi, AuthApi, ImageApi -} \ No newline at end of file +} diff --git a/src/Pixeval.CoreApi/Net/MakoHttpOptions.cs b/src/Pixeval.CoreApi/Net/MakoHttpOptions.cs index a9dead8c..72794611 100644 --- a/src/Pixeval.CoreApi/Net/MakoHttpOptions.cs +++ b/src/Pixeval.CoreApi/Net/MakoHttpOptions.cs @@ -72,7 +72,6 @@ public static class MakoHttpOptions return new HttpMessageInvoker(new SocketsHttpHandler()); } - private static Func> BypassedConnectCallback(INameResolver nameResolver) { return async (context, token) => diff --git a/src/Pixeval.CoreApi/Net/PixivApiHttpMessageHandler.cs b/src/Pixeval.CoreApi/Net/PixivApiHttpMessageHandler.cs index 12f4cfae..8b89fbf9 100644 --- a/src/Pixeval.CoreApi/Net/PixivApiHttpMessageHandler.cs +++ b/src/Pixeval.CoreApi/Net/PixivApiHttpMessageHandler.cs @@ -41,14 +41,14 @@ internal class PixivApiHttpMessageHandler(MakoClient makoClient) : MakoClientSup MakoHttpOptions.UseHttpScheme(request); } - headers.TryAddWithoutValidation("Accept-Language", MakoClient.Configuration.CultureInfo.Name); + _ = headers.TryAddWithoutValidation("Accept-Language", MakoClient.Configuration.CultureInfo.Name); var session = MakoClient.Session; switch (host) { case MakoHttpOptions.WebApiHost: - headers.TryAddWithoutValidation("Cookie", session.Cookie); + _ = headers.TryAddWithoutValidation("Cookie", session.Cookie); break; case MakoHttpOptions.AppApiHost: headers.Authorization = new AuthenticationHeaderValue("Bearer", session.AccessToken); diff --git a/src/Pixeval.SourceGen/SettingsEntryGenerator.cs b/src/Pixeval.SourceGen/SettingsEntryGenerator.cs index 1fc64a07..1b859e7d 100644 --- a/src/Pixeval.SourceGen/SettingsEntryGenerator.cs +++ b/src/Pixeval.SourceGen/SettingsEntryGenerator.cs @@ -30,7 +30,7 @@ namespace Pixeval.SourceGen; [Generator] public class SettingsEntryGenerator : IIncrementalGenerator { - private const string SettingPOCOAttributeFqName = "Pixeval.Attributes.SettingPOCO"; + private const string SettingPocoAttributeFqName = "Pixeval.Attributes.SettingPoco"; private const string SyntheticSettingAttributeFqName = "Pixeval.Attributes.SyntheticSetting"; private const string SettingMetadataAttributeFqName = "Pixeval.Attributes.SettingMetadata"; private const string SettingEntryFqName = "global::Pixeval.SettingEntry"; @@ -42,7 +42,7 @@ public class SettingsEntryGenerator : IIncrementalGenerator transform: static (ctx, _) => { var tds = (TypeDeclarationSyntax)ctx.Node; - (TypeDeclarationSyntax, IEnumerable<(PropertyDeclarationSyntax, AttributeSyntax?)>)? tuple = tds.HasAttribute(ctx.SemanticModel, SettingPOCOAttributeFqName) + (TypeDeclarationSyntax, IEnumerable<(PropertyDeclarationSyntax, AttributeSyntax?)>)? tuple = tds.HasAttribute(ctx.SemanticModel, SettingPocoAttributeFqName) ? (tds, tds.Members.OfType().Where(pds => !pds.HasAttribute(ctx.SemanticModel, SyntheticSettingAttributeFqName) && pds.HasAttribute(ctx.SemanticModel, SettingMetadataAttributeFqName)) .Select(property => (property, property.GetAttribute(ctx.SemanticModel, SettingMetadataAttributeFqName))) .Where(tuple => tuple.Item2 is not null)) @@ -96,8 +96,8 @@ public class SettingsEntryGenerator : IIncrementalGenerator ctx.ReportDiagnostic( Diagnostic.Create(new DiagnosticDescriptor( "PSG0001", - "There should be only one [SettingPOCO] in an assembly", - "There should be only one [SettingPOCO] in an assembly", + "There should be only one [SettingPoco] in an assembly", + "There should be only one [SettingPoco] in an assembly", "SourceGen", DiagnosticSeverity.Error, true), typeDeclarationSyntax.GetLocation())); diff --git a/src/Pixeval.Utilities/Enumerates.cs b/src/Pixeval.Utilities/Enumerates.cs index 7e039dee..8b4b53d4 100644 --- a/src/Pixeval.Utilities/Enumerates.cs +++ b/src/Pixeval.Utilities/Enumerates.cs @@ -137,14 +137,14 @@ public static class Enumerates public static T? FirstOrNull(this IEnumerable enumerable, Func predicate) where T : struct { var matches = enumerable.Where(predicate).Take(1).ToArray(); - return matches.Any() ? matches[0] : null; + return matches.Length is 0 ? null : matches[0]; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static T? FirstOrNull(this IEnumerable enumerable) where T : struct { var matches = enumerable.Take(1).ToArray(); - return matches.Any() ? matches[0] : null; + return matches.Length is 0 ? null : matches[0]; } public static IAsyncEnumerable ToAsyncEnumerable(this IEnumerable source) @@ -183,7 +183,7 @@ public static class Enumerates public static void ReplaceByUpdate(this IList dest, IEnumerable source) { var enumerable = source as T[] ?? source.ToArray(); - if (enumerable.Any()) + if (enumerable.Length != 0) { _ = dest.RemoveAll(x => !enumerable.Contains(x)); enumerable.Where(x => !dest.Contains(x)).ForEach(dest.Add); @@ -197,7 +197,7 @@ public static class Enumerates public static void ReplaceByUpdate(this ISet dest, IEnumerable source) { var enumerable = source as T[] ?? source.ToArray(); - if (enumerable.Any()) + if (enumerable.Length != 0) { dest.ToArray().Where(x => !enumerable.Contains(x)).ForEach(x => dest.Remove(x)); dest.AddRange(enumerable); diff --git a/src/Pixeval.Utilities/ObservableHashSet.cs b/src/Pixeval.Utilities/ObservableHashSet.cs index 6adf88ee..d80004f0 100644 --- a/src/Pixeval.Utilities/ObservableHashSet.cs +++ b/src/Pixeval.Utilities/ObservableHashSet.cs @@ -1,4 +1,4 @@ -#region Copyright (c) Pixeval/Pixeval.Utilities +#region Copyright (c) Pixeval/Pixeval.Utilities // GPL v3 License // // Pixeval/Pixeval.Utilities @@ -117,7 +117,7 @@ public class ObservableHashSet void ICollection.Add(T item) { - Add(item); + _ = Add(item); } /// @@ -183,7 +183,7 @@ public class ObservableHashSet OnCountPropertyChanging(); - _set.Remove(item); + _ = _set.Remove(item); OnCollectionChanged(NotifyCollectionChangedAction.Remove, item); @@ -233,7 +233,7 @@ public class ObservableHashSet OnCountPropertyChanging(); - _set.Add(item); + _ = _set.Add(item); OnCollectionChanged(NotifyCollectionChangedAction.Add, item); @@ -555,5 +555,5 @@ internal static class ObservableHashSetSingletons public static readonly PropertyChangedEventArgs CountPropertyChanged = new("Count"); public static readonly PropertyChangingEventArgs CountPropertyChanging = new("Count"); - public static readonly object[] NoItems = Array.Empty(); -} \ No newline at end of file + public static readonly object[] NoItems = []; +} diff --git a/src/Pixeval.Utilities/SharedRef.cs b/src/Pixeval.Utilities/SharedRef.cs index 43b59143..3b756d97 100644 --- a/src/Pixeval.Utilities/SharedRef.cs +++ b/src/Pixeval.Utilities/SharedRef.cs @@ -5,7 +5,7 @@ namespace Pixeval.Utilities; public class SharedRef { - private readonly HashSet _keys = new(); + private readonly HashSet _keys = []; public T Value { get; init; } diff --git a/src/Pixeval.Utilities/Threading/CancellationHandle.cs b/src/Pixeval.Utilities/Threading/CancellationHandle.cs index fea5023a..3df8cbfc 100644 --- a/src/Pixeval.Utilities/Threading/CancellationHandle.cs +++ b/src/Pixeval.Utilities/Threading/CancellationHandle.cs @@ -48,7 +48,7 @@ public class CancellationHandle if (!IsCancelled) { _onCancellation?.Invoke(); - Interlocked.Increment(ref _isCancelled); + _ = Interlocked.Increment(ref _isCancelled); } } @@ -56,12 +56,12 @@ public class CancellationHandle { if (IsPaused) { - Interlocked.Decrement(ref _paused); + _ = Interlocked.Decrement(ref _paused); } if (IsCancelled) { - Interlocked.Decrement(ref _isCancelled); + _ = Interlocked.Decrement(ref _isCancelled); } } @@ -70,7 +70,7 @@ public class CancellationHandle if (!IsPaused) { _onPause?.Invoke(); - Interlocked.Increment(ref _paused); + _ = Interlocked.Increment(ref _paused); } } @@ -79,7 +79,7 @@ public class CancellationHandle if (IsPaused) { _onResume?.Invoke(); - Interlocked.Decrement(ref _paused); + _ = Interlocked.Decrement(ref _paused); } } diff --git a/src/Pixeval.Utilities/Threading/ReenterableAwaiter.cs b/src/Pixeval.Utilities/Threading/ReenterableAwaiter.cs index aabe474b..c879f610 100644 --- a/src/Pixeval.Utilities/Threading/ReenterableAwaiter.cs +++ b/src/Pixeval.Utilities/Threading/ReenterableAwaiter.cs @@ -93,7 +93,7 @@ public class ReenterableAwaiter(bool initialSignal) : INotifyCompletion } else { - Task.Factory.StartNew(_continuation, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default); + _ = Task.Factory.StartNew(_continuation, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default); } } diff --git a/src/Pixeval.Utilities/Threading/ReenterableAwaiter{T}.cs b/src/Pixeval.Utilities/Threading/ReenterableAwaiter{T}.cs index ff38bc66..8fd16c4d 100644 --- a/src/Pixeval.Utilities/Threading/ReenterableAwaiter{T}.cs +++ b/src/Pixeval.Utilities/Threading/ReenterableAwaiter{T}.cs @@ -97,7 +97,7 @@ public class ReenterableAwaiter(bool initialSignal, TResult resultIniti } else { - Task.Factory.StartNew(_continuation, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default); + _ = Task.Factory.StartNew(_continuation, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default); } } diff --git a/src/Pixeval/Activation/ActivationRegistrar.cs b/src/Pixeval/Activation/ActivationRegistrar.cs index ac697973..22861562 100644 --- a/src/Pixeval/Activation/ActivationRegistrar.cs +++ b/src/Pixeval/Activation/ActivationRegistrar.cs @@ -27,7 +27,7 @@ namespace Pixeval.Activation; public static class ActivationRegistrar { - public static readonly List FeatureHandlers = new(); + public static readonly List FeatureHandlers = []; static ActivationRegistrar() { @@ -39,7 +39,7 @@ public static class ActivationRegistrar if (args is { Kind: ExtendedActivationKind.Protocol, Data: IProtocolActivatedEventArgs { Uri: var activationUri } } && FeatureHandlers.FirstOrDefault(f => f.ActivationFragment == activationUri.Host) is { } handler) { - handler.Execute(activationUri.PathAndQuery[1..]); + _ = handler.Execute(activationUri.PathAndQuery[1..]); } } } diff --git a/src/Pixeval/App.xaml.cs b/src/Pixeval/App.xaml.cs index 1f62491f..ceb34d99 100644 --- a/src/Pixeval/App.xaml.cs +++ b/src/Pixeval/App.xaml.cs @@ -83,7 +83,7 @@ public partial class App public static void ExitWithPushNotification() { - WeakReferenceMessenger.Default.Send(new ApplicationExitingMessage()); + _ = WeakReferenceMessenger.Default.Send(new ApplicationExitingMessage()); CurrentContext.App.Exit(); } } diff --git a/src/Pixeval/AppManagement/AppContext.cs b/src/Pixeval/AppManagement/AppContext.cs index c24ef4c2..2bad6e70 100644 --- a/src/Pixeval/AppManagement/AppContext.cs +++ b/src/Pixeval/AppManagement/AppContext.cs @@ -56,7 +56,7 @@ public static partial class AppContext public static readonly string AppVersion = GitVersionInformation.AssemblySemVer; - private static readonly ApplicationDataContainer SessionContainer; + private static readonly ApplicationDataContainer _sessionContainer; private static SoftwareBitmapSource? _imageNotAvailable; @@ -70,14 +70,14 @@ public static partial class AppContext { if (!ApplicationData.Current.LocalSettings.Containers.ContainsKey(SessionContainerKey)) { - ApplicationData.Current.LocalSettings.CreateContainer(SessionContainerKey, ApplicationDataCreateDisposition.Always); + _ = ApplicationData.Current.LocalSettings.CreateContainer(SessionContainerKey, ApplicationDataCreateDisposition.Always); } // Keys in the RoamingSettings will be synced through the devices of the same user // For more detailed information see https://docs.microsoft.com/en-us/windows/apps/design/app-settings/store-and-retrieve-app-data InitializeConfigurationContainer(); - SessionContainer = ApplicationData.Current.LocalSettings.Containers[SessionContainerKey]; + _sessionContainer = ApplicationData.Current.LocalSettings.Containers[SessionContainerKey]; } public static async Task GetNotAvailableImageAsync() @@ -160,7 +160,7 @@ public static partial class AppContext using var scope = App.AppViewModel.AppServicesScope; var downloadHistoryManager = scope.ServiceProvider.GetRequiredService(); // the HasFlag is not allow in expression tree - downloadHistoryManager.Delete(entry => entry.State == DownloadState.Running || + _ = downloadHistoryManager.Delete(entry => entry.State == DownloadState.Running || entry.State == DownloadState.Queued || entry.State == DownloadState.Created || entry.State == DownloadState.Paused); @@ -201,7 +201,7 @@ public static partial class AppContext { if (App.AppViewModel.MakoClient.Session is { } session) { - var values = SessionContainer.Values; + var values = _sessionContainer.Values; values[nameof(Session.AccessToken)] = session.AccessToken; values[nameof(Session.Account)] = session.Account; values[nameof(Session.AvatarUrl)] = session.AvatarUrl; @@ -219,7 +219,7 @@ public static partial class AppContext { try { - var values = SessionContainer.Values; + var values = _sessionContainer.Values; return new Session { AccessToken = values[nameof(Session.AccessToken)].CastOrThrow(), diff --git a/src/Pixeval/AppManagement/AppSetting.cs b/src/Pixeval/AppManagement/AppSetting.cs index f982db06..dcd28260 100644 --- a/src/Pixeval/AppManagement/AppSetting.cs +++ b/src/Pixeval/AppManagement/AppSetting.cs @@ -33,7 +33,7 @@ using WinUI3Utilities.Attributes; namespace Pixeval.AppManagement; -[GenerateConstructor, SettingPOCO] +[GenerateConstructor, SettingPoco] public partial record AppSetting : IWindowSettings { #pragma warning disable CS8618 diff --git a/src/Pixeval/AppViewModel.cs b/src/Pixeval/AppViewModel.cs index 5e150f59..07e3db92 100644 --- a/src/Pixeval/AppViewModel.cs +++ b/src/Pixeval/AppViewModel.cs @@ -88,7 +88,7 @@ public class AppViewModel(App app) : AutoActivateObservableRecipient, IRecipient public async Task ShowExceptionDialogAsync(Exception e) { - await MessageDialogBuilder.CreateAcknowledgement(CurrentContext.Window, MiscResources.ExceptionEncountered, e.ToString()).ShowAsync(); + _ = await MessageDialogBuilder.CreateAcknowledgement(CurrentContext.Window, MiscResources.ExceptionEncountered, e.ToString()).ShowAsync(); } public async Task InitializeAsync(bool activatedByProtocol) diff --git a/src/Pixeval/Attributes/DefaultValueAttribute.cs b/src/Pixeval/Attributes/DefaultValueAttribute.cs index 200b0ce9..f65a3ca6 100644 --- a/src/Pixeval/Attributes/DefaultValueAttribute.cs +++ b/src/Pixeval/Attributes/DefaultValueAttribute.cs @@ -22,7 +22,6 @@ using System; using System.Reflection; using Pixeval.Misc; - namespace Pixeval.Attributes; [AttributeUsage(AttributeTargets.Property)] diff --git a/src/Pixeval/Attributes/SettingPOCO.cs b/src/Pixeval/Attributes/SettingPOCO.cs index 8c614b8a..07ae825e 100644 --- a/src/Pixeval/Attributes/SettingPOCO.cs +++ b/src/Pixeval/Attributes/SettingPOCO.cs @@ -22,4 +22,4 @@ using System; namespace Pixeval.Attributes; -public class SettingPOCO : Attribute { } \ No newline at end of file +public class SettingPoco : Attribute { } \ No newline at end of file diff --git a/src/Pixeval/Controls/IllustratorView/IllustratorView.cs b/src/Pixeval/Controls/IllustratorView/IllustratorView.cs index d0ca52ad..e5f75454 100644 --- a/src/Pixeval/Controls/IllustratorView/IllustratorView.cs +++ b/src/Pixeval/Controls/IllustratorView/IllustratorView.cs @@ -24,7 +24,6 @@ using Microsoft.UI.Xaml.Input; using Microsoft.UI.Xaml.Media; using WinUI3Utilities.Attributes; - namespace Pixeval.Controls.IllustratorView; [TemplatePart(Name = PartContentContainer, Type = typeof(CardControl))] diff --git a/src/Pixeval/Controls/IllustratorView/IllustratorViewModel.cs b/src/Pixeval/Controls/IllustratorView/IllustratorViewModel.cs index 66b28102..19397f4b 100644 --- a/src/Pixeval/Controls/IllustratorView/IllustratorViewModel.cs +++ b/src/Pixeval/Controls/IllustratorView/IllustratorViewModel.cs @@ -73,7 +73,7 @@ public partial class IllustratorViewModel : ObservableObject, IIllustrationVisua Account = info.Account; Comment = info.Comment; IsFollowed = info.IsFollowed; - Illustrations = new ObservableCollection(); + Illustrations = []; VisualizationController = new IllustrationVisualizationController(this); IsFollowButtonEnabled = true; _ = LoadAvatar(); @@ -81,7 +81,8 @@ public partial class IllustratorViewModel : ObservableObject, IIllustrationVisua public async Task LoadAvatar() { - if (AvatarSource != null) return; + if (AvatarSource != null) + return; AvatarSource = (await App.AppViewModel.MakoClient.DownloadBitmapImageResultAsync(AvatarUrl, 60) .GetOrElseAsync(await AppContext.GetPixivNoProfileImageAsync()))!; } diff --git a/src/Pixeval/Database/DownloadHistoryEntry.cs b/src/Pixeval/Database/DownloadHistoryEntry.cs index 2017f50d..72c5dc2e 100644 --- a/src/Pixeval/Database/DownloadHistoryEntry.cs +++ b/src/Pixeval/Database/DownloadHistoryEntry.cs @@ -29,7 +29,6 @@ public partial class DownloadHistoryEntry : ObservableObject [ObservableProperty] private string? _errorCause; - [ObservableProperty] private DownloadState _state; diff --git a/src/Pixeval/Database/Managers/DownloadHistoryPersistentManager.cs b/src/Pixeval/Database/Managers/DownloadHistoryPersistentManager.cs index b5e2fa7f..d0d03534 100644 --- a/src/Pixeval/Database/Managers/DownloadHistoryPersistentManager.cs +++ b/src/Pixeval/Database/Managers/DownloadHistoryPersistentManager.cs @@ -42,12 +42,12 @@ public class DownloadHistoryPersistentManager(ILiteDatabase collection, int maxi Purge(MaximumRecords); } - Collection.Insert(t); + _ = Collection.Insert(t); t.PropertyChanged += (_, _) => { if (Collection.Find(entry => entry.Destination == t.Destination).Any()) { - Collection.Update(t); + _ = Collection.Update(t); } }; } @@ -88,13 +88,13 @@ public class DownloadHistoryPersistentManager(ILiteDatabase collection, int maxi if (Collection.Count() > limit) { var last = Collection.FindAll().Take(^limit..).Select(e => e.Destination).ToHashSet(); - Delete(e => !last.Contains(e.Destination!)); + _ = Delete(e => !last.Contains(e.Destination!)); } } public void Clear() { - Collection.DeleteAll(); + _ = Collection.DeleteAll(); App.AppViewModel.DownloadManager.ClearTasks(); } diff --git a/src/Pixeval/Database/Managers/IPersistentManager.cs b/src/Pixeval/Database/Managers/IPersistentManager.cs index bcbcffef..dc63f805 100644 --- a/src/Pixeval/Database/Managers/IPersistentManager.cs +++ b/src/Pixeval/Database/Managers/IPersistentManager.cs @@ -45,7 +45,6 @@ public interface IPersistentManager where TEntry : new() int MaximumRecords { get; set; } - int Count { get; } void Insert(TEntry t); diff --git a/src/Pixeval/Database/Managers/SimplePersistentManager.cs b/src/Pixeval/Database/Managers/SimplePersistentManager.cs index b169f213..ea3e887a 100644 --- a/src/Pixeval/Database/Managers/SimplePersistentManager.cs +++ b/src/Pixeval/Database/Managers/SimplePersistentManager.cs @@ -47,7 +47,7 @@ public abstract class SimplePersistentManager(ILiteDatabase db, int maximumRe Purge(MaximumRecords); } - Collection.Insert(t); + _ = Collection.Insert(t); } public IEnumerable Query(Expression> predicate) @@ -86,12 +86,12 @@ public abstract class SimplePersistentManager(ILiteDatabase db, int maximumRe if (Collection.Count() > limit) { var last = Collection.FindAll().Take(^limit..).ToHashSet(); - Delete(e => !last.Contains(e!)); + _ = Delete(e => !last.Contains(e!)); } } public void Clear() { - Collection.DeleteAll(); + _ = Collection.DeleteAll(); } } \ No newline at end of file diff --git a/src/Pixeval/Dialogs/DownloadListPageDeleteTasksDialog.xaml.cs b/src/Pixeval/Dialogs/DownloadListPageDeleteTasksDialog.xaml.cs index 44d00938..0673c526 100644 --- a/src/Pixeval/Dialogs/DownloadListPageDeleteTasksDialog.xaml.cs +++ b/src/Pixeval/Dialogs/DownloadListPageDeleteTasksDialog.xaml.cs @@ -20,7 +20,6 @@ using WinUI3Utilities.Attributes; - namespace Pixeval.Dialogs; [DependencyProperty("DeleteLocalFiles", "false")] diff --git a/src/Pixeval/Dialogs/ReverseSearchApiKeyNotPresentDialog.xaml.cs b/src/Pixeval/Dialogs/ReverseSearchApiKeyNotPresentDialog.xaml.cs index 85349b40..702762ba 100644 --- a/src/Pixeval/Dialogs/ReverseSearchApiKeyNotPresentDialog.xaml.cs +++ b/src/Pixeval/Dialogs/ReverseSearchApiKeyNotPresentDialog.xaml.cs @@ -43,6 +43,6 @@ public sealed partial class ReverseSearchApiKeyNotPresentDialog private void SetApiKeyHyperlinkButton_OnTapped(object sender, TappedRoutedEventArgs e) { Owner?.Hide(); - WeakReferenceMessenger.Default.Send(new NavigateToSettingEntryMessage(SettingEntry.ReverseSearchApiKey)); + _ = WeakReferenceMessenger.Default.Send(new NavigateToSettingEntryMessage(SettingEntry.ReverseSearchApiKey)); } } \ No newline at end of file diff --git a/src/Pixeval/Download/AnimatedIllustrationDownloadTask.cs b/src/Pixeval/Download/AnimatedIllustrationDownloadTask.cs index e99d093d..b2bf821a 100644 --- a/src/Pixeval/Download/AnimatedIllustrationDownloadTask.cs +++ b/src/Pixeval/Download/AnimatedIllustrationDownloadTask.cs @@ -59,8 +59,8 @@ public class AnimatedIllustrationDownloadTask : ObservableDownloadTask, ICustomB { using (stream) { - using var ugoiraStream = await IOHelper.GetStreamFromZipStreamAsync(stream.AsStreamForRead(), _metadata); - await IOHelper.CreateAndWriteToFileAsync(ugoiraStream, Destination); + using var ugoiraStream = await IoHelper.GetStreamFromZipStreamAsync(stream.AsStreamForRead(), _metadata); + await IoHelper.CreateAndWriteToFileAsync(ugoiraStream, Destination); } } diff --git a/src/Pixeval/Download/DownloadManager.cs b/src/Pixeval/Download/DownloadManager.cs index dd714f4b..ee1957d5 100644 --- a/src/Pixeval/Download/DownloadManager.cs +++ b/src/Pixeval/Download/DownloadManager.cs @@ -51,7 +51,7 @@ public class DownloadManager : IDisposable where TDownloadTask : public DownloadManager(int concurrencyDegree, HttpClient? httpClient = null) { _httpClient = httpClient ?? new HttpClient(); - _queuedTasks = new(); + _queuedTasks = []; _taskQuerySet = new HashSet(); _throttle = new(true, true); _downloadTaskChannel = Channel.CreateUnbounded(); @@ -79,7 +79,7 @@ public class DownloadManager : IDisposable where TDownloadTask : return; } - _taskQuerySet.Add(task); + _ = _taskQuerySet.Add(task); _queuedTasks.Add(task); // Start the task only if it is created and is ready-to-run if (task.CurrentState == DownloadState.Created) @@ -102,8 +102,8 @@ public class DownloadManager : IDisposable where TDownloadTask : public void RemoveTask(TDownloadTask task) { - _taskQuerySet.Remove(task); - _queuedTasks.Remove(task); + _ = _taskQuerySet.Remove(task); + _ = _queuedTasks.Remove(task); } public void ClearTasks() @@ -134,7 +134,7 @@ public class DownloadManager : IDisposable where TDownloadTask : private void QueueDownloadTask(TDownloadTask task) { - _downloadTaskChannel.Writer.WriteAsync(task); + _ = _downloadTaskChannel.Writer.WriteAsync(task); } private async Task Download(TDownloadTask task) @@ -161,10 +161,10 @@ public class DownloadManager : IDisposable where TDownloadTask : private async Task DecrementCounterAsync() { - Interlocked.Decrement(ref _workingTasks); + _ = Interlocked.Decrement(ref _workingTasks); await _semaphoreSlim.WaitAsync(); _throttle.SetResult(true); - _semaphoreSlim.Release(); + _ = _semaphoreSlim.Release(); } private async Task DownloadInternal(TDownloadTask task) @@ -187,7 +187,7 @@ public class DownloadManager : IDisposable where TDownloadTask : { using (resultStream) { - await IOHelper.CreateAndWriteToFileAsync(resultStream, task.Destination); + await IoHelper.CreateAndWriteToFileAsync(resultStream, task.Destination); } } } @@ -204,7 +204,7 @@ public class DownloadManager : IDisposable where TDownloadTask : break; case Result.Failure(var exception): Functions.IgnoreException(() => File.Delete(task.Destination)); - if (exception is not OperationCanceledException && exception is not null) + if (exception is not OperationCanceledException and not null) { ThreadingHelper.DispatchTask(() => task.ErrorCause = exception); SetState(task, DownloadState.Error); diff --git a/src/Pixeval/Download/DownloadTaskInitializationException.cs b/src/Pixeval/Download/DownloadTaskInitializationException.cs index 1c7bda98..a3ac21ed 100644 --- a/src/Pixeval/Download/DownloadTaskInitializationException.cs +++ b/src/Pixeval/Download/DownloadTaskInitializationException.cs @@ -1,4 +1,4 @@ -#region Copyright (c) Pixeval/Pixeval +#region Copyright (c) Pixeval/Pixeval // GPL v3 License // // Pixeval/Pixeval @@ -19,7 +19,6 @@ #endregion using System; -using System.Runtime.Serialization; namespace Pixeval.Download; @@ -29,10 +28,6 @@ public class DownloadTaskInitializationException : Exception { } - protected DownloadTaskInitializationException(SerializationInfo info, StreamingContext context) : base(info, context) - { - } - public DownloadTaskInitializationException(string? message) : base(message) { } @@ -40,4 +35,4 @@ public class DownloadTaskInitializationException : Exception public DownloadTaskInitializationException(string? message, Exception? innerException) : base(message, innerException) { } -} \ No newline at end of file +} diff --git a/src/Pixeval/Download/IllustrationDownloadTask.cs b/src/Pixeval/Download/IllustrationDownloadTask.cs index 89cf184b..82622972 100644 --- a/src/Pixeval/Download/IllustrationDownloadTask.cs +++ b/src/Pixeval/Download/IllustrationDownloadTask.cs @@ -64,7 +64,7 @@ public class IllustrationDownloadTask : ObservableDownloadTask, IIllustrationVie { using (stream) { - IOHelper.CreateParentDirectories(Destination); + IoHelper.CreateParentDirectories(Destination); await using var fs = File.Open(Destination, FileMode.Create, FileAccess.ReadWrite, FileShare.None); await stream.AsStreamForRead().CopyToAsync(fs); } diff --git a/src/Pixeval/Download/IllustrationDownloadTaskFactory.cs b/src/Pixeval/Download/IllustrationDownloadTaskFactory.cs index a27c2d99..240b2e42 100644 --- a/src/Pixeval/Download/IllustrationDownloadTaskFactory.cs +++ b/src/Pixeval/Download/IllustrationDownloadTaskFactory.cs @@ -41,11 +41,11 @@ public class IllustrationDownloadTaskFactory : IDownloadTaskFactory(); - var path = IOHelper.NormalizePath(PathParser.Reduce(rawPath, context)); + var path = IoHelper.NormalizePath(PathParser.Reduce(rawPath, context)); if (manager.Collection.Find(entry => entry.Destination == path).Any()) { // delete the original entry - manager.Delete(entry => entry.Destination == path); + _ = manager.Delete(entry => entry.Destination == path); } var task = Functions.Block(() => diff --git a/src/Pixeval/Download/IntrinsicIllustrationDownloadTask.cs b/src/Pixeval/Download/IntrinsicIllustrationDownloadTask.cs index 3275a05d..0bd09bd3 100644 --- a/src/Pixeval/Download/IntrinsicIllustrationDownloadTask.cs +++ b/src/Pixeval/Download/IntrinsicIllustrationDownloadTask.cs @@ -25,22 +25,16 @@ using Pixeval.UserControls.IllustrationView; namespace Pixeval.Download; -public class IntrinsicIllustrationDownloadTask : IllustrationDownloadTask, IIntrinsicDownloadTask +/// +/// The disposal of is not handled +/// +public class IntrinsicIllustrationDownloadTask(DownloadHistoryEntry entry, IllustrationViewModel illustrationViewModel, IRandomAccessStream imageStream) : IllustrationDownloadTask(entry, illustrationViewModel), IIntrinsicDownloadTask { - /// - /// The disposal of is not handled - /// - public IntrinsicIllustrationDownloadTask(DownloadHistoryEntry entry, IllustrationViewModel illustrationViewModel, IRandomAccessStream imageStream) - : base(entry, illustrationViewModel) - { - Stream = imageStream; - } - - public IRandomAccessStream Stream { get; } + public IRandomAccessStream Stream { get; } = imageStream; public override async void DownloadStarting(DownloadStartingEventArgs args) { args.GetDeferral().Complete(false); - await IOHelper.CreateAndWriteToFileAsync(Stream, Destination); + await IoHelper.CreateAndWriteToFileAsync(Stream, Destination); } } \ No newline at end of file diff --git a/src/Pixeval/Download/LazyInitializedAnimatedIllustrationDownloadTask.cs b/src/Pixeval/Download/LazyInitializedAnimatedIllustrationDownloadTask.cs index 07dff200..e139f842 100644 --- a/src/Pixeval/Download/LazyInitializedAnimatedIllustrationDownloadTask.cs +++ b/src/Pixeval/Download/LazyInitializedAnimatedIllustrationDownloadTask.cs @@ -45,8 +45,8 @@ public class LazyInitializedAnimatedIllustrationDownloadTask : AnimatedIllustrat using (stream) { var metadata = await App.AppViewModel.MakoClient.GetUgoiraMetadataAsync(_illustId); - using var ugoiraStream = await IOHelper.GetStreamFromZipStreamAsync(stream.AsStreamForRead(), metadata); - await IOHelper.CreateAndWriteToFileAsync(ugoiraStream, Destination); + using var ugoiraStream = await IoHelper.GetStreamFromZipStreamAsync(stream.AsStreamForRead(), metadata); + await IoHelper.CreateAndWriteToFileAsync(ugoiraStream, Destination); } } diff --git a/src/Pixeval/Download/MacroParser/CharStream.cs b/src/Pixeval/Download/MacroParser/CharStream.cs index aca60325..7dec4e6f 100644 --- a/src/Pixeval/Download/MacroParser/CharStream.cs +++ b/src/Pixeval/Download/MacroParser/CharStream.cs @@ -1,4 +1,4 @@ -#region Copyright (c) Pixeval/Pixeval +#region Copyright (c) Pixeval/Pixeval // GPL v3 License // // Pixeval/Pixeval @@ -29,30 +29,30 @@ namespace Pixeval.Download.MacroParser; public class CharStream : ISeekable { - private readonly Stack markers = new(); - private readonly string text; + private readonly Stack _markers = new(); + private readonly string _text; - private char[] stream; + private char[] _stream; public CharStream(string text) { - stream = text.ToCharArray(); - this.text = text; - markers.Push(0); + _stream = text.ToCharArray(); + this._text = text; + _markers.Push(0); } public int Forward { get; private set; } public void Seek(int pos) { - markers.Pop(); - markers.Push(pos); + _ = _markers.Pop(); + _markers.Push(pos); Forward = pos; } public char Peek() { - return Forward >= stream.Length ? char.MaxValue : stream[Forward]; + return Forward >= _stream.Length ? char.MaxValue : _stream[Forward]; } public void Advance() @@ -67,18 +67,18 @@ public class CharStream : ISeekable public char[] GetWindow() { - return stream[markers.Peek()..Forward]; + return _stream[_markers.Peek()..Forward]; } public void AdvanceMarker() { - markers.Pop(); - markers.Push(Forward); + _ = _markers.Pop(); + _markers.Push(Forward); } public void ResetForward() { - Forward = markers.Peek(); + Forward = _markers.Peek(); } public void Return() @@ -94,25 +94,25 @@ public class CharStream : ISeekable public LineInfo GetCurrentLineInfo() { - if (Forward >= text.Length) + if (Forward >= _text.Length) { return LineInfo.Eof; } - var lines = text[..Forward].Split(Environment.NewLine); + var lines = _text[..Forward].Split(Environment.NewLine); return new LineInfo(lines.Length, lines[^1].Length); } public void Replace(char[] newStream) { - stream = newStream; + _stream = newStream; Forward = 0; - if (markers.Any()) + if (_markers.Any()) { - markers.Clear(); + _markers.Clear(); } - markers.Push(0); + _markers.Push(0); } public char NextChar() @@ -124,7 +124,7 @@ public class CharStream : ISeekable public string GetWindowString() { - return new string(stream[markers.Peek()..Forward]); + return new string(_stream[_markers.Peek()..Forward]); } public void Return(int count) @@ -201,12 +201,12 @@ public class CharStream : ISeekable public void PushMarker() { - markers.Push(Forward); + _markers.Push(Forward); } public int PopMarker() { - return markers.Pop(); + return _markers.Pop(); } public string GetUntilIfAndReturn(Func func) @@ -224,4 +224,4 @@ public class CharStream : ISeekable public int Position = position; } -} \ No newline at end of file +} diff --git a/src/Pixeval/Download/MacroParser/Lexer.cs b/src/Pixeval/Download/MacroParser/Lexer.cs index 62f277e5..d1d5ab3e 100644 --- a/src/Pixeval/Download/MacroParser/Lexer.cs +++ b/src/Pixeval/Download/MacroParser/Lexer.cs @@ -24,11 +24,11 @@ public class Lexer(string rawString) { private readonly CharStream _rawString = new(rawString); - private char _currentChar => _rawString.Peek(); + private char CurrentChar => _rawString.Peek(); public TokenInfo? NextToken() { - switch (_currentChar) + switch (CurrentChar) { case char.MaxValue: return null; diff --git a/src/Pixeval/Download/MacroParser/MacroParser.cs b/src/Pixeval/Download/MacroParser/MacroParser.cs index 50919fef..8e036790 100644 --- a/src/Pixeval/Download/MacroParser/MacroParser.cs +++ b/src/Pixeval/Download/MacroParser/MacroParser.cs @@ -104,12 +104,12 @@ public class MacroParser private Macro Macro() { - EatToken(TokenKind.At); - EatToken(TokenKind.LBrace); + _ = EatToken(TokenKind.At); + _ = EatToken(TokenKind.LBrace); var macroName = PlainText(); _expectContextualColon = true; var node = new Macro(macroName, OptionalMacroParameter()); - EatToken(TokenKind.RBrace); + _ = EatToken(TokenKind.RBrace); return node; } @@ -128,7 +128,7 @@ public class MacroParser throw new MacroParseException(MacroParserResources.UnexpectedTokenFormatted.Format(_currentToken.Position.Start)); } - EatToken(TokenKind.Colon); + _ = EatToken(TokenKind.Colon); return new PlainText($":{EatToken(TokenKind.PlainText).Text}"); } diff --git a/src/Pixeval/Download/Macros/IllustrationTitleMacro.cs b/src/Pixeval/Download/Macros/IllustrationTitleMacro.cs index 35e23d6c..210c3565 100644 --- a/src/Pixeval/Download/Macros/IllustrationTitleMacro.cs +++ b/src/Pixeval/Download/Macros/IllustrationTitleMacro.cs @@ -32,6 +32,6 @@ public class IllustrationTitleMacro : IMacro.ITransducer public string Substitute(IllustrationViewModel context) { - return context.Illustrate.Title?.Let(IOHelper.NormalizePathSegment) ?? MacroParserResources.UnknownIllustrationTitle; + return context.Illustrate.Title?.Let(IoHelper.NormalizePathSegment) ?? MacroParserResources.UnknownIllustrationTitle; } } diff --git a/src/Pixeval/Download/Macros/IllustratorNameMacro.cs b/src/Pixeval/Download/Macros/IllustratorNameMacro.cs index a3fae13c..5e821dd4 100644 --- a/src/Pixeval/Download/Macros/IllustratorNameMacro.cs +++ b/src/Pixeval/Download/Macros/IllustratorNameMacro.cs @@ -32,6 +32,6 @@ public class IllustratorNameMacro : IMacro.ITransducer public string Substitute(IllustrationViewModel context) { - return context.Illustrate.User?.Name?.Let(IOHelper.NormalizePathSegment) ?? MacroParserResources.UnknownArtist; + return context.Illustrate.User?.Name?.Let(IoHelper.NormalizePathSegment) ?? MacroParserResources.UnknownArtist; } } diff --git a/src/Pixeval/Download/Macros/SpotlightTitleMacro.cs b/src/Pixeval/Download/Macros/SpotlightTitleMacro.cs index 323ee67a..d8f008ab 100644 --- a/src/Pixeval/Download/Macros/SpotlightTitleMacro.cs +++ b/src/Pixeval/Download/Macros/SpotlightTitleMacro.cs @@ -32,6 +32,6 @@ public class SpotlightTitleMacro : IMacro.ITransducer public string Substitute(IllustrationViewModel context) { - return context.Illustrate.SpotlightTitle?.Let(IOHelper.NormalizePathSegment) ?? MacroParserResources.UnknownSpotlightTitle; + return context.Illustrate.SpotlightTitle?.Let(IoHelper.NormalizePathSegment) ?? MacroParserResources.UnknownSpotlightTitle; } } diff --git a/src/Pixeval/Flyouts/CommentRepliesBlock.xaml.cs b/src/Pixeval/Flyouts/CommentRepliesBlock.xaml.cs index 354883f6..6377bc28 100644 --- a/src/Pixeval/Flyouts/CommentRepliesBlock.xaml.cs +++ b/src/Pixeval/Flyouts/CommentRepliesBlock.xaml.cs @@ -60,7 +60,7 @@ public sealed partial class CommentRepliesBlock private void CommentList_OnRepliesHyperlinkButtonTapped(object? sender, TappedRoutedEventArgs e) { - ReplyBar.FindDescendant()?.Focus(FocusState.Programmatic); + _ = (ReplyBar.FindDescendant()?.Focus(FocusState.Programmatic)); } private async void ReplyBar_OnSendButtonTapped(object? sender, SendButtonTappedEventArgs e) diff --git a/src/Pixeval/Flyouts/LoginWebView.xaml.cs b/src/Pixeval/Flyouts/LoginWebView.xaml.cs index a83eb57f..15074dfb 100644 --- a/src/Pixeval/Flyouts/LoginWebView.xaml.cs +++ b/src/Pixeval/Flyouts/LoginWebView.xaml.cs @@ -44,6 +44,6 @@ public sealed partial class LoginWebView private async void LoginWebView_OnCoreWebView2Initialized(WebView2 sender, CoreWebView2InitializedEventArgs args) { - await LoginWebView2.CoreWebView2.CallDevToolsProtocolMethodAsync("Security.setIgnoreCertificateErrors", "{ \"ignore\": true }"); + _ = await LoginWebView2.CoreWebView2.CallDevToolsProtocolMethodAsync("Security.setIgnoreCertificateErrors", "{ \"ignore\": true }"); } } diff --git a/src/Pixeval/IllustrationSourceNotFoundException.cs b/src/Pixeval/IllustrationSourceNotFoundException.cs index 1f56c058..dc8e3dd6 100644 --- a/src/Pixeval/IllustrationSourceNotFoundException.cs +++ b/src/Pixeval/IllustrationSourceNotFoundException.cs @@ -1,4 +1,4 @@ -#region Copyright (c) Pixeval/Pixeval +#region Copyright (c) Pixeval/Pixeval // GPL v3 License // // Pixeval/Pixeval @@ -19,7 +19,6 @@ #endregion using System; -using System.Runtime.Serialization; namespace Pixeval; @@ -29,10 +28,6 @@ public class IllustrationSourceNotFoundException : Exception { } - protected IllustrationSourceNotFoundException(SerializationInfo info, StreamingContext context) : base(info, context) - { - } - public IllustrationSourceNotFoundException(string? message) : base(message) { } @@ -40,4 +35,4 @@ public class IllustrationSourceNotFoundException : Exception public IllustrationSourceNotFoundException(string? message, Exception? innerException) : base(message, innerException) { } -} \ No newline at end of file +} diff --git a/src/Pixeval/Interop/IDataTransferManagerInterop.cs b/src/Pixeval/Interop/IDataTransferManagerInterop.cs index 5d65f79a..5132fad8 100644 --- a/src/Pixeval/Interop/IDataTransferManagerInterop.cs +++ b/src/Pixeval/Interop/IDataTransferManagerInterop.cs @@ -20,13 +20,14 @@ using System; using System.Runtime.InteropServices; +using System.Runtime.InteropServices.Marshalling; namespace Pixeval.Interop; -[ComImport] +[GeneratedComInterface] [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] [Guid("3A3DCD6C-3EAB-43DC-BCDE-45671CE800C8")] -public interface IDataTransferManagerInterop +public partial interface IDataTransferManagerInterop { unsafe void GetForWindow(nint appWindow, Guid* riId, [Optional] void** dataTransferManager); diff --git a/src/Pixeval/Interop/TaskBar.cs b/src/Pixeval/Interop/TaskBar.cs index b4cd9b12..9ddf0a37 100644 --- a/src/Pixeval/Interop/TaskBar.cs +++ b/src/Pixeval/Interop/TaskBar.cs @@ -19,6 +19,7 @@ #endregion using System.Runtime.InteropServices; +using System.Runtime.InteropServices.Marshalling; namespace Pixeval.Interop; @@ -32,10 +33,10 @@ public enum TaskBarState Paused = 1 << 3 } -[ComImport] +[GeneratedComInterface] [Guid("ea1afb91-9e28-4b86-90e9-9e9f8a5eefaf")] [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] -public interface ITaskBarList3 +public partial interface ITaskBarList3 { [PreserveSig] void HrInit(); diff --git a/src/Pixeval/LoginProxyException.cs b/src/Pixeval/LoginProxyException.cs index bf927bca..5d6474f7 100644 --- a/src/Pixeval/LoginProxyException.cs +++ b/src/Pixeval/LoginProxyException.cs @@ -1,4 +1,4 @@ -#region Copyright (c) Pixeval/Pixeval +#region Copyright (c) Pixeval/Pixeval // GPL v3 License // // Pixeval/Pixeval @@ -32,10 +32,6 @@ public class LoginProxyException : Exception { } - protected LoginProxyException(SerializationInfo info, StreamingContext context) : base(info, context) - { - } - public LoginProxyException(string? message) : base(message) { } @@ -43,4 +39,4 @@ public class LoginProxyException : Exception public LoginProxyException(string? message, Exception? innerException) : base(message, innerException) { } -} \ No newline at end of file +} diff --git a/src/Pixeval/Misc/FetchEngineIncrementalSource.cs b/src/Pixeval/Misc/FetchEngineIncrementalSource.cs index 5de31f22..61018c61 100644 --- a/src/Pixeval/Misc/FetchEngineIncrementalSource.cs +++ b/src/Pixeval/Misc/FetchEngineIncrementalSource.cs @@ -54,7 +54,7 @@ public abstract class FetchEngineIncrementalSource if (_asyncEnumerator.Current is { } obj && !_yieldedItems.Contains(Identifier(obj))) { result.Add(Select(obj)); - _yieldedItems.Add(Identifier(obj)); + _ = _yieldedItems.Add(Identifier(obj)); i++; _yieldedCounter++; } diff --git a/src/Pixeval/Options/ThumbnailDirection.cs b/src/Pixeval/Options/ThumbnailDirection.cs index 083f9600..b4d26f81 100644 --- a/src/Pixeval/Options/ThumbnailDirection.cs +++ b/src/Pixeval/Options/ThumbnailDirection.cs @@ -20,7 +20,6 @@ using Pixeval.Attributes; - namespace Pixeval.Options; public enum ThumbnailDirection diff --git a/src/Pixeval/Options/XRestrictLevel.cs b/src/Pixeval/Options/XRestrictLevel.cs index 06a6ba5e..7252ebfb 100644 --- a/src/Pixeval/Options/XRestrictLevel.cs +++ b/src/Pixeval/Options/XRestrictLevel.cs @@ -20,7 +20,6 @@ using Pixeval.Attributes; - namespace Pixeval.Options; public enum XRestrictLevel diff --git a/src/Pixeval/Pages/Capability/BookmarksPage.xaml.cs b/src/Pixeval/Pages/Capability/BookmarksPage.xaml.cs index eecb7616..7304af3e 100644 --- a/src/Pixeval/Pages/Capability/BookmarksPage.xaml.cs +++ b/src/Pixeval/Pages/Capability/BookmarksPage.xaml.cs @@ -50,7 +50,7 @@ public sealed partial class BookmarksPage : ISortedIllustrationContainerPageHelp { PrivacyPolicyComboBox.SelectedItem = PrivacyPolicyComboBoxPublicItem; SortOptionComboBox.SelectedItem = MakoHelper.GetAppSettingDefaultSortOptionWrapper(); - WeakReferenceMessenger.Default.TryRegister(this, static (recipient, _) => recipient.IllustrationContainer.ViewModel.DataProvider.FetchEngine?.Cancel()); + _ = WeakReferenceMessenger.Default.TryRegister(this, static (recipient, _) => recipient.IllustrationContainer.ViewModel.DataProvider.FetchEngine?.Cancel()); ChangeSource(); } diff --git a/src/Pixeval/Pages/Capability/FollowingsPage.xaml.cs b/src/Pixeval/Pages/Capability/FollowingsPage.xaml.cs index 32dc6104..516aacef 100644 --- a/src/Pixeval/Pages/Capability/FollowingsPage.xaml.cs +++ b/src/Pixeval/Pages/Capability/FollowingsPage.xaml.cs @@ -62,7 +62,7 @@ public sealed partial class FollowingsPage public override void OnPageActivated(NavigationEventArgs e) { - WeakReferenceMessenger.Default.TryRegister(this, static (recipient, _) => recipient.ViewModel.DataProvider.FetchEngine?.Cancel()); + _ = WeakReferenceMessenger.Default.TryRegister(this, static (recipient, _) => recipient.ViewModel.DataProvider.FetchEngine?.Cancel()); _ = ViewModel.ResetEngineAndFillAsync(App.AppViewModel.MakoClient.Following(App.AppViewModel.PixivUid!, PrivacyPolicy.Public)); } @@ -75,7 +75,7 @@ public sealed partial class FollowingsPage if (IllustratorListView.SelectedIndex is > 0 and var i && i < ViewModel.DataProvider.Source.Count && IllustratorContentViewerFrame is { } frame) { - frame.Navigate(typeof(IllustratorContentViewerPage), ViewModel.DataProvider.Source[i]); + _ = frame.Navigate(typeof(IllustratorContentViewerPage), ViewModel.DataProvider.Source[i]); } } @@ -89,6 +89,6 @@ public sealed partial class FollowingsPage _illustratorListViewLoaded = true; await ThreadingHelper.SpinWaitAsync(() => !ViewModel.DataProvider.Source.Any() && !ViewModel.HasNoItems); IllustratorListView.SelectedIndex = 0; - IllustratorContentViewerFrame.Navigate(typeof(IllustratorContentViewerPage), ViewModel.DataProvider.Source[0]); + _ = IllustratorContentViewerFrame.Navigate(typeof(IllustratorContentViewerPage), ViewModel.DataProvider.Source[0]); } } diff --git a/src/Pixeval/Pages/Capability/RankingsPage.xaml.cs b/src/Pixeval/Pages/Capability/RankingsPage.xaml.cs index 146fe9b9..32a085b3 100644 --- a/src/Pixeval/Pages/Capability/RankingsPage.xaml.cs +++ b/src/Pixeval/Pages/Capability/RankingsPage.xaml.cs @@ -55,7 +55,7 @@ public sealed partial class RankingsPage : ISortedIllustrationContainerPageHelpe SortOptionComboBox.SelectedItem = MakoHelper.GetAppSettingDefaultSortOptionWrapper(); RankOptionComboBox.SelectedItem = LocalizedBoxHelper.Of(RankOption.Day); RankDateTimeCalendarDatePicker.Date = DateTime.Now.AddDays(-2); - WeakReferenceMessenger.Default.TryRegister(this, static (recipient, _) => recipient.IllustrationContainer.ViewModel.DataProvider.FetchEngine?.Cancel()); + _ = WeakReferenceMessenger.Default.TryRegister(this, static (recipient, _) => recipient.IllustrationContainer.ViewModel.DataProvider.FetchEngine?.Cancel()); ChangeSource(); } diff --git a/src/Pixeval/Pages/Capability/RecentPostsPage.xaml.cs b/src/Pixeval/Pages/Capability/RecentPostsPage.xaml.cs index ebac8468..a6f0cd5e 100644 --- a/src/Pixeval/Pages/Capability/RecentPostsPage.xaml.cs +++ b/src/Pixeval/Pages/Capability/RecentPostsPage.xaml.cs @@ -50,7 +50,7 @@ public sealed partial class RecentPostsPage : ISortedIllustrationContainerPageHe { PrivacyPolicyComboBox.SelectedItem = PrivacyPolicyComboBoxPublicItem; SortOptionComboBox.SelectedItem = MakoHelper.GetAppSettingDefaultSortOptionWrapper(); - WeakReferenceMessenger.Default.TryRegister(this, static (recipient, _) => recipient.IllustrationContainer.ViewModel.DataProvider.FetchEngine?.Cancel()); + _ = WeakReferenceMessenger.Default.TryRegister(this, static (recipient, _) => recipient.IllustrationContainer.ViewModel.DataProvider.FetchEngine?.Cancel()); ChangeSource(); } diff --git a/src/Pixeval/Pages/Capability/RecommendationPage.xaml.cs b/src/Pixeval/Pages/Capability/RecommendationPage.xaml.cs index 217ed2c4..d6a6c168 100644 --- a/src/Pixeval/Pages/Capability/RecommendationPage.xaml.cs +++ b/src/Pixeval/Pages/Capability/RecommendationPage.xaml.cs @@ -52,7 +52,7 @@ public sealed partial class RecommendationPage : ISortedIllustrationContainerPag { ModeSelectionComboBox.SelectedItem = ModeSelectionComboBoxIllustComboBoxItem; SortOptionComboBox.SelectedItem = MakoHelper.GetAppSettingDefaultSortOptionWrapper(); - WeakReferenceMessenger.Default.TryRegister(this, static (recipient, _) => recipient.IllustrationContainer.ViewModel.DataProvider.FetchEngine?.Cancel()); + _ = WeakReferenceMessenger.Default.TryRegister(this, static (recipient, _) => recipient.IllustrationContainer.ViewModel.DataProvider.FetchEngine?.Cancel()); ChangeSource(); } diff --git a/src/Pixeval/Pages/Capability/SearchResultsPage.xaml.cs b/src/Pixeval/Pages/Capability/SearchResultsPage.xaml.cs index cfb26f78..2743f49e 100644 --- a/src/Pixeval/Pages/Capability/SearchResultsPage.xaml.cs +++ b/src/Pixeval/Pages/Capability/SearchResultsPage.xaml.cs @@ -50,7 +50,7 @@ public sealed partial class SearchResultsPage : ISortedIllustrationContainerPage { SortOptionComboBox.SelectedItem = MakoHelper.GetAppSettingDefaultSortOptionWrapper(); ChangeSource((IFetchEngine)navigationEventArgs.Parameter); - WeakReferenceMessenger.Default.TryRegister(this, static (recipient, _) => recipient.IllustrationContainer.ViewModel.DataProvider.FetchEngine?.Cancel()); + _ = WeakReferenceMessenger.Default.TryRegister(this, static (recipient, _) => recipient.IllustrationContainer.ViewModel.DataProvider.FetchEngine?.Cancel()); } private void ChangeSource(IFetchEngine engine) diff --git a/src/Pixeval/Pages/Download/DownloadListEntry.xaml.cs b/src/Pixeval/Pages/Download/DownloadListEntry.xaml.cs index 67eb7ed2..9715b56c 100644 --- a/src/Pixeval/Pages/Download/DownloadListEntry.xaml.cs +++ b/src/Pixeval/Pages/Download/DownloadListEntry.xaml.cs @@ -78,7 +78,7 @@ public sealed partial class DownloadListEntry case DownloadState.Error: case DownloadState.Cancelled: case DownloadState.Completed: - await Launcher.LaunchUriAsync(new(ViewModel.DownloadTask.Destination)); + _ = await Launcher.LaunchUriAsync(new(ViewModel.DownloadTask.Destination)); break; case DownloadState.Paused: ViewModel.DownloadTask.CancellationHandle.Resume(); @@ -101,14 +101,14 @@ public sealed partial class DownloadListEntry private async void OpenDownloadLocationItem_OnTapped(object sender, TappedRoutedEventArgs e) { - await Launcher.LaunchFolderPathAsync(Path.GetDirectoryName(ViewModel.DownloadTask.Destination)); + _ = await Launcher.LaunchFolderPathAsync(Path.GetDirectoryName(ViewModel.DownloadTask.Destination)); } private void GoToPageItem_OnTapped(object sender, TappedRoutedEventArgs e) => OpenIllustrationRequested?.Invoke(this, ViewModel); private async void CheckErrorMessageInDetail_OnTapped(object sender, TappedRoutedEventArgs e) { - await MessageDialogBuilder.CreateAcknowledgement(CurrentContext.Window, DownloadListEntryResources.ErrorMessageDialogTitle, ViewModel.DownloadTask.ErrorCause!.ToString()) + _ = await MessageDialogBuilder.CreateAcknowledgement(CurrentContext.Window, DownloadListEntryResources.ErrorMessageDialogTitle, ViewModel.DownloadTask.ErrorCause!.ToString()) .ShowAsync(); } } diff --git a/src/Pixeval/Pages/Download/DownloadListOption.cs b/src/Pixeval/Pages/Download/DownloadListOption.cs index f2b5c044..e22d0a89 100644 --- a/src/Pixeval/Pages/Download/DownloadListOption.cs +++ b/src/Pixeval/Pages/Download/DownloadListOption.cs @@ -20,7 +20,6 @@ using Pixeval.Attributes; - namespace Pixeval.Pages.Download; public enum DownloadListOption diff --git a/src/Pixeval/Pages/Download/DownloadListPage.xaml.cs b/src/Pixeval/Pages/Download/DownloadListPage.xaml.cs index 67244389..69e591a7 100644 --- a/src/Pixeval/Pages/Download/DownloadListPage.xaml.cs +++ b/src/Pixeval/Pages/Download/DownloadListPage.xaml.cs @@ -107,7 +107,7 @@ public sealed partial class DownloadListPage { foreach (var downloadListEntryViewModel in _viewModel.SelectedTasks) { - IOHelper.DeleteAsync(downloadListEntryViewModel.DownloadTask.Destination).Discard(); + IoHelper.DeleteAsync(downloadListEntryViewModel.DownloadTask.Destination).Discard(); } } @@ -170,7 +170,6 @@ public sealed partial class DownloadListPage viewModel.CreateWindowWithPage(_viewModel.DownloadTasks); } - private void DownloadListEntryOnEffectiveViewportChanged(FrameworkElement sender, EffectiveViewportChangedEventArgs args) { var context = sender.GetDataContext(); diff --git a/src/Pixeval/Pages/Download/DownloadListPageViewModel.cs b/src/Pixeval/Pages/Download/DownloadListPageViewModel.cs index 4725a886..e2c700d6 100644 --- a/src/Pixeval/Pages/Download/DownloadListPageViewModel.cs +++ b/src/Pixeval/Pages/Download/DownloadListPageViewModel.cs @@ -56,8 +56,8 @@ public partial class DownloadListPageViewModel : ObservableObject, IDisposable public DownloadListPageViewModel() { - _downloadTasks = new(); - _filteredTasks = new(); + _downloadTasks = []; + _filteredTasks = []; _downloadTasksView = new(_downloadTasks, true); _selectionLabel = DownloadListPageResources.CancelSelectionButtonDefaultLabel; } @@ -104,8 +104,8 @@ public partial class DownloadListPageViewModel : ObservableObject, IDisposable SelectedTasks.ToList().ForEach(task => { App.AppViewModel.DownloadManager.RemoveTask(task.DownloadTask); - DownloadTasks.Remove(task); - manager.Delete(m => m.Destination == task.DownloadTask.Destination); + _ = DownloadTasks.Remove(task); + _ = manager.Delete(m => m.Destination == task.DownloadTask.Destination); }); DownloadTasksView.Refresh(); diff --git a/src/Pixeval/Pages/IllustrationViewer/CommentsPage.xaml.cs b/src/Pixeval/Pages/IllustrationViewer/CommentsPage.xaml.cs index 68c3ca71..1a4a8080 100644 --- a/src/Pixeval/Pages/IllustrationViewer/CommentsPage.xaml.cs +++ b/src/Pixeval/Pages/IllustrationViewer/CommentsPage.xaml.cs @@ -51,7 +51,7 @@ public sealed partial class CommentsPage public override void OnPageActivated(NavigationEventArgs e) { // Dispose current page contents if the parent page (IllustrationViewerPage) is navigating - WeakReferenceMessenger.Default.TryRegister(this, (recipient, _) => + _ = WeakReferenceMessenger.Default.TryRegister(this, (recipient, _) => { recipient.CommentList.Dispose(); WeakReferenceMessenger.Default.UnregisterAll(this); diff --git a/src/Pixeval/Pages/IllustrationViewer/IllustrationInfoPage.xaml.cs b/src/Pixeval/Pages/IllustrationViewer/IllustrationInfoPage.xaml.cs index 70b46813..8b5b5560 100644 --- a/src/Pixeval/Pages/IllustrationViewer/IllustrationInfoPage.xaml.cs +++ b/src/Pixeval/Pages/IllustrationViewer/IllustrationInfoPage.xaml.cs @@ -52,7 +52,7 @@ public sealed partial class IllustrationInfoPage private void IllustrationTagButton_OnTapped(object sender, TappedRoutedEventArgs e) { - WeakReferenceMessenger.Default.Send(new IllustrationTagClickedMessage((string)((Button)sender).Content)); + _ = WeakReferenceMessenger.Default.Send(new IllustrationTagClickedMessage((string)((Button)sender).Content)); } //private async void IllustrationCaptionMarkdownTextBlock_OnLinkClicked(object? sender, LinkClickedEventArgs e) @@ -64,7 +64,7 @@ public sealed partial class IllustrationInfoPage { if (_viewModel.Illustrator is { } userInfo) { - ConnectedAnimationService.GetForCurrentView().PrepareToAnimate("ForwardConnectedAnimation", (UIElement)sender); + _ = ConnectedAnimationService.GetForCurrentView().PrepareToAnimate("ForwardConnectedAnimation", (UIElement)sender); // todo IllustratorPage use Navigate // CurrentContext.Window.Content.To().Navigate(typeof(IllustratorPage), Tuple.Create((UIElement)sender, new IllustratorViewModel(userInfo)), new SlideNavigationTransitionInfo // { diff --git a/src/Pixeval/Pages/IllustrationViewer/IllustrationViewerPage.xaml.cs b/src/Pixeval/Pages/IllustrationViewer/IllustrationViewerPage.xaml.cs index f9ad4ef2..d8c53596 100644 --- a/src/Pixeval/Pages/IllustrationViewer/IllustrationViewerPage.xaml.cs +++ b/src/Pixeval/Pages/IllustrationViewer/IllustrationViewerPage.xaml.cs @@ -115,7 +115,7 @@ public sealed partial class IllustrationViewerPage : ISupportCustomTitleBarDragR } case IllustrationViewerPageViewModel.ShowShare: { - Window.ShowShareUI(); + Window.ShowShareUi(); break; } case nameof(IllustrationViewerPageViewModel.IsInfoPaneOpen): diff --git a/src/Pixeval/Pages/IllustrationViewer/IllustrationViewerPageViewModel.cs b/src/Pixeval/Pages/IllustrationViewer/IllustrationViewerPageViewModel.cs index a0f3bda4..76f5bf4a 100644 --- a/src/Pixeval/Pages/IllustrationViewer/IllustrationViewerPageViewModel.cs +++ b/src/Pixeval/Pages/IllustrationViewer/IllustrationViewerPageViewModel.cs @@ -359,7 +359,7 @@ public partial class IllustrationViewerPageViewModel : DetailedObservableObject, RestoreResolutionCommand.CanExecuteRequested += LoadingCompletedCanExecuteRequested; CopyCommand.CanExecuteRequested += LoadingCompletedCanExecuteRequested; - CopyCommand.ExecuteRequested += async (_, _) => UIHelper.ClipboardSetBitmap(await CurrentImage.OriginalImageStream!.EncodeBitmapStreamAsync(false)); + CopyCommand.ExecuteRequested += async (_, _) => UiHelper.ClipboardSetBitmap(await CurrentImage.OriginalImageStream!.EncodeBitmapStreamAsync(false)); PlayGifCommand.CanExecuteRequested += (_, e) => e.CanExecute = IsUgoira && CurrentImage.LoadingCompletedSuccessfully; PlayGifCommand.ExecuteRequested += PlayGifCommandOnExecuteRequested; @@ -461,13 +461,13 @@ public partial class IllustrationViewerPageViewModel : DetailedObservableObject, GenerateLinkTeachingTip.IsOpen = true; } - UIHelper.ClipboardSetText(MakoHelper.GenerateIllustrationAppUri(CurrentIllustration.Id).ToString()); + UiHelper.ClipboardSetText(MakoHelper.GenerateIllustrationAppUri(CurrentIllustration.Id).ToString()); } private void GenerateWebLinkCommandOnExecuteRequested(XamlUICommand sender, ExecuteRequestedEventArgs args) { var link = MakoHelper.GenerateIllustrationWebUri(CurrentIllustration.Id).ToString(); - UIHelper.ClipboardSetText(link); + UiHelper.ClipboardSetText(link); SnackBarTeachingTip.ShowAndHide(IllustrationViewerPageResources.WebLinkCopiedToClipboardToastTitle); } @@ -484,7 +484,7 @@ public partial class IllustrationViewerPageViewModel : DetailedObservableObject, private async void ShowQrCodeCommandExecuteRequested(XamlUICommand sender, ExecuteRequestedEventArgs args) { - var qrCodeSource = await UIHelper.GenerateQrCodeForUrlAsync(MakoHelper.GenerateIllustrationWebUri(CurrentIllustration.Id).ToString()); + var qrCodeSource = await UiHelper.GenerateQrCodeForUrlAsync(MakoHelper.GenerateIllustrationWebUri(CurrentIllustration.Id).ToString()); ShowQrCodeTeachingTip.HeroContent.To().Source = qrCodeSource; OnPropertyChanged(nameof(ShowQrCode)); diff --git a/src/Pixeval/Pages/IllustrationViewer/IllustrationVisualizationController.cs b/src/Pixeval/Pages/IllustrationViewer/IllustrationVisualizationController.cs index 03da30a9..96b31511 100644 --- a/src/Pixeval/Pages/IllustrationViewer/IllustrationVisualizationController.cs +++ b/src/Pixeval/Pages/IllustrationViewer/IllustrationVisualizationController.cs @@ -40,7 +40,7 @@ public class IllustrationVisualizationController(IIllustrationVisualizer visuali { var collection = new IncrementalLoadingCollection, IllustrationViewModel>(new IllustrationFetchEngineIncrementalSource(FetchEngine!, itemsLimit)); visualizer.Illustrations = collection; - await collection.LoadMoreItemsAsync(20); + _ = await collection.LoadMoreItemsAsync(20); visualizer.Illustrations.CollectionChanged += CollectionChanged; return visualizer.Illustrations.Count > 0; } @@ -48,7 +48,7 @@ public class IllustrationVisualizationController(IIllustrationVisualizer visuali public async Task FillAsync(IFetchEngine? newEngine, int itemsLimit = -1) { FetchEngine = newEngine; - await FillAsync(itemsLimit); + _ = await FillAsync(itemsLimit); } public Task ResetAndFillAsync(IFetchEngine? newEngine, int itemsLimit = -1) diff --git a/src/Pixeval/Pages/IllustrationViewer/ImageViewerPageViewModel.cs b/src/Pixeval/Pages/IllustrationViewer/ImageViewerPageViewModel.cs index b91326f9..d4424ace 100644 --- a/src/Pixeval/Pages/IllustrationViewer/ImageViewerPageViewModel.cs +++ b/src/Pixeval/Pages/IllustrationViewer/ImageViewerPageViewModel.cs @@ -147,7 +147,7 @@ public partial class ImageViewerPageViewModel : ObservableObject, IDisposable { using var scope = App.AppViewModel.AppServicesScope; var manager = scope.ServiceProvider.GetRequiredService(); - manager.Delete(x => x.Id == IllustrationViewerPageViewModel.IllustrationId); + _ = manager.Delete(x => x.Id == IllustrationViewerPageViewModel.IllustrationId); manager.Insert(new() { Id = IllustrationViewModel.Id }); } @@ -158,10 +158,7 @@ public partial class ImageViewerPageViewModel : ObservableObject, IDisposable _disposed = false; const ThumbnailUrlOption option = ThumbnailUrlOption.Medium; _ = IllustrationViewModel.TryLoadThumbnail(this, option).ContinueWith( - _ => - { - OriginalImageSources ??= new[] { IllustrationViewModel.ThumbnailStreams[option] }; - }, + _ => OriginalImageSources ??= [IllustrationViewModel.ThumbnailStreams[option]], TaskScheduler.FromCurrentSynchronizationContext()); AddHistory(); await LoadOriginalImage(); @@ -198,7 +195,7 @@ public partial class ImageViewerPageViewModel : ObservableObject, IDisposable { case Result.Success(var zipStream): AdvancePhase(LoadingPhase.MergingGifFrames); - OriginalImageSources = await IOHelper.GetStreamsFromZipStreamAsync(zipStream); + OriginalImageSources = await IoHelper.GetStreamsFromZipStreamAsync(zipStream); MsIntervals = ugoiraMetadata.UgoiraMetadataInfo.Frames?.Select(x => (int)x.Delay)?.ToList(); break; case Result.Failure(OperationCanceledException): diff --git a/src/Pixeval/Pages/IllustrationViewer/PixivReplyEmojiListPage.xaml.cs b/src/Pixeval/Pages/IllustrationViewer/PixivReplyEmojiListPage.xaml.cs index 642d3e0e..7d059303 100644 --- a/src/Pixeval/Pages/IllustrationViewer/PixivReplyEmojiListPage.xaml.cs +++ b/src/Pixeval/Pages/IllustrationViewer/PixivReplyEmojiListPage.xaml.cs @@ -39,7 +39,7 @@ namespace Pixeval.Pages.IllustrationViewer; public sealed partial class PixivReplyEmojiListPage { - public static ObservableCollection EmojiList = new(); + public static ObservableCollection EmojiList = []; private PixivReplyBar? _replyBar; diff --git a/src/Pixeval/Pages/IllustrationViewer/PixivReplyEmojiViewModel.cs b/src/Pixeval/Pages/IllustrationViewer/PixivReplyEmojiViewModel.cs index fc960a9c..5737656b 100644 --- a/src/Pixeval/Pages/IllustrationViewer/PixivReplyEmojiViewModel.cs +++ b/src/Pixeval/Pages/IllustrationViewer/PixivReplyEmojiViewModel.cs @@ -22,7 +22,6 @@ using Microsoft.UI.Xaml.Media; using Pixeval.Misc; using Windows.Storage.Streams; - namespace Pixeval.Pages.IllustrationViewer; public class PixivReplyEmojiViewModel(PixivReplyEmoji emojiEnumValue, IRandomAccessStream imageStream) diff --git a/src/Pixeval/Pages/IllustrationViewer/PixivReplyStickerListPage.xaml.cs b/src/Pixeval/Pages/IllustrationViewer/PixivReplyStickerListPage.xaml.cs index fd69fda6..f4bb1fd3 100644 --- a/src/Pixeval/Pages/IllustrationViewer/PixivReplyStickerListPage.xaml.cs +++ b/src/Pixeval/Pages/IllustrationViewer/PixivReplyStickerListPage.xaml.cs @@ -37,7 +37,7 @@ namespace Pixeval.Pages.IllustrationViewer; public sealed partial class PixivReplyStickerListPage { - public static readonly ObservableCollection Stickers = new(); + public static readonly ObservableCollection Stickers = []; private EventHandler? _replyBarStickerTappedEventHandler; diff --git a/src/Pixeval/Pages/IllustrationViewer/RelatedWorksPage.xaml.cs b/src/Pixeval/Pages/IllustrationViewer/RelatedWorksPage.xaml.cs index 976110f0..e1ee2b3b 100644 --- a/src/Pixeval/Pages/IllustrationViewer/RelatedWorksPage.xaml.cs +++ b/src/Pixeval/Pages/IllustrationViewer/RelatedWorksPage.xaml.cs @@ -41,7 +41,7 @@ public sealed partial class RelatedWorksPage public override async void OnPageActivated(NavigationEventArgs e) { // Dispose current page contents if the parent page (IllustrationViewerPage) is navigating - WeakReferenceMessenger.Default.TryRegister(this, (recipient, _) => + _ = WeakReferenceMessenger.Default.TryRegister(this, (recipient, _) => { recipient.RelatedWorksIllustrationGrid.ViewModel.Dispose(); WeakReferenceMessenger.Default.UnregisterAll(this); diff --git a/src/Pixeval/Pages/IllustratorViewer/IllustratorPage.xaml.cs b/src/Pixeval/Pages/IllustratorViewer/IllustratorPage.xaml.cs index 8f87b4a1..bb524a59 100644 --- a/src/Pixeval/Pages/IllustratorViewer/IllustratorPage.xaml.cs +++ b/src/Pixeval/Pages/IllustratorViewer/IllustratorPage.xaml.cs @@ -93,8 +93,8 @@ public sealed partial class IllustratorPage switch (navigationEventArgs.Parameter) { case (UIElement sender, IllustratorViewModel viewModel): - WeakReferenceMessenger.Default.Send(new MainPageFrameSetConnectedAnimationTargetMessage(sender)); - ConnectedAnimationService.GetForCurrentView().GetAnimation("ForwardConnectedAnimation")?.TryStart(ProfileImage); + _ = WeakReferenceMessenger.Default.Send(new MainPageFrameSetConnectedAnimationTargetMessage(sender)); + _ = (ConnectedAnimationService.GetForCurrentView().GetAnimation("ForwardConnectedAnimation")?.TryStart(ProfileImage)); _viewModel = viewModel; break; case IllustratorViewModel viewModel1: @@ -102,7 +102,7 @@ public sealed partial class IllustratorPage break; } - WeakReferenceMessenger.Default.TryRegister(this, static (recipient, _) => recipient.ViewModelProvider.ViewModel.DataProvider.FetchEngine?.Cancel()); + _ = WeakReferenceMessenger.Default.TryRegister(this, static (recipient, _) => recipient.ViewModelProvider.ViewModel.DataProvider.FetchEngine?.Cancel()); ChangeSource(); } @@ -217,7 +217,7 @@ public sealed partial class IllustratorPage public void GoBack() { - ConnectedAnimationService.GetForCurrentView().PrepareToAnimate("ForwardConnectedAnimation", ProfileImage); + _ = ConnectedAnimationService.GetForCurrentView().PrepareToAnimate("ForwardConnectedAnimation", ProfileImage); Parent.To().GoBack(new SuppressNavigationTransitionInfo()); } @@ -228,7 +228,7 @@ public sealed partial class IllustratorPage private async void OpenLinkButton_OnTapped(object sender, TappedRoutedEventArgs e) { - await Launcher.LaunchUriAsync(new Uri($"https://www.pixiv.net/users/{_viewModel!.Id}")); + _ = await Launcher.LaunchUriAsync(new Uri($"https://www.pixiv.net/users/{_viewModel!.Id}")); } private async void FollowButton_OnTapped(object sender, TappedRoutedEventArgs e) diff --git a/src/Pixeval/Pages/Login/LoginPage.xaml.cs b/src/Pixeval/Pages/Login/LoginPage.xaml.cs index 5474ca33..ee0ddba8 100644 --- a/src/Pixeval/Pages/Login/LoginPage.xaml.cs +++ b/src/Pixeval/Pages/Login/LoginPage.xaml.cs @@ -61,7 +61,7 @@ public sealed partial class LoginPage } AppContext.SaveContext(); - WeakReferenceMessenger.Default.Send(new LoginCompletedMessage(this, App.AppViewModel.MakoClient.Session)); + _ = WeakReferenceMessenger.Default.Send(new LoginCompletedMessage(this, App.AppViewModel.MakoClient.Session)); } catch (Exception exception) { @@ -101,7 +101,7 @@ public sealed partial class LoginPage LoginPageResources.WebView2InstallationRequiredContent).ShowAsync(); if (dialogResult == ContentDialogResult.Primary) { - await Launcher.LaunchUriAsync(new Uri("https://go.microsoft.com/fwlink/p/?LinkId=2124703")); + _ = await Launcher.LaunchUriAsync(new Uri("https://go.microsoft.com/fwlink/p/?LinkId=2124703")); } App.ExitWithPushNotification(); diff --git a/src/Pixeval/Pages/Login/LoginPageViewModel.cs b/src/Pixeval/Pages/Login/LoginPageViewModel.cs index 8239a44a..d924c2aa 100644 --- a/src/Pixeval/Pages/Login/LoginPageViewModel.cs +++ b/src/Pixeval/Pages/Login/LoginPageViewModel.cs @@ -152,7 +152,7 @@ public partial class LoginPageViewModel : AutoActivateObservableRecipient } else { - await MessageDialogBuilder.CreateAcknowledgement( + _ = await MessageDialogBuilder.CreateAcknowledgement( CurrentContext.Window, LoginPageResources.RefreshingSessionIsNotPresentTitle, LoginPageResources.RefreshingSessionIsNotPresentContent) @@ -188,10 +188,7 @@ public partial class LoginPageViewModel : AutoActivateObservableRecipient await WebView.LoginWebView2.EnsureCoreWebView2Async(); WebView.LoginWebView2.CoreWebView2.AddWebResourceRequestedFilter("*", CoreWebView2WebResourceContext.All); - WebView.LoginWebView2.CoreWebView2.WebResourceRequested += (_, args) => - { - args.Request.Headers.SetHeader("Accept-Language", args.Request.Uri.Contains("recaptcha") ? "zh-cn" : CultureInfo.CurrentUICulture.Name); - }; + WebView.LoginWebView2.CoreWebView2.WebResourceRequested += (_, args) => args.Request.Headers.SetHeader("Accept-Language", args.Request.Uri.Contains("recaptcha") ? "zh-cn" : CultureInfo.CurrentUICulture.Name); var verifier = PixivAuthSignature.GetCodeVerify(); WebView.LoginWebView2.Source = new Uri(PixivAuthSignature.GenerateWebPageUrl(verifier)); @@ -221,7 +218,7 @@ public partial class LoginPageViewModel : AutoActivateObservableRecipient ("grant_type", "authorization_code"), ("include_policy", "true"), ("redirect_uri", "https://app-api.pixiv.net/web/v1/users/auth/pixiv/callback")); - result.EnsureSuccessStatusCode(); + _ = result.EnsureSuccessStatusCode(); var session = (await result.Content.ReadAsStringAsync()).FromJson()!.ToSession() with { Cookie = cookie, diff --git a/src/Pixeval/Pages/Login/PixivAuthSignature.cs b/src/Pixeval/Pages/Login/PixivAuthSignature.cs index 9982e1a7..b563618f 100644 --- a/src/Pixeval/Pages/Login/PixivAuthSignature.cs +++ b/src/Pixeval/Pages/Login/PixivAuthSignature.cs @@ -1,4 +1,4 @@ -#region Copyright (c) Pixeval/Pixeval +#region Copyright (c) Pixeval/Pixeval // GPL v3 License // // Pixeval/Pixeval @@ -33,7 +33,7 @@ public static class PixivAuthSignature private static string ToUrlSafeBase64String(this byte[] bytes) { - return Convert.ToBase64String(bytes).TrimEnd(new[] { '=' }).Replace("+", "-").Replace("/", "_"); + return Convert.ToBase64String(bytes).TrimEnd(['=']).Replace("+", "-").Replace("/", "_"); } public static string GenerateWebPageUrl(string codeVerify, bool signUp = false) @@ -48,4 +48,4 @@ public static class PixivAuthSignature { return SHA256.HashData(Encoding.ASCII.GetBytes(code)).ToUrlSafeBase64String(); } -} \ No newline at end of file +} diff --git a/src/Pixeval/Pages/MainPage.xaml.cs b/src/Pixeval/Pages/MainPage.xaml.cs index 2b2d15c1..f82eac29 100644 --- a/src/Pixeval/Pages/MainPage.xaml.cs +++ b/src/Pixeval/Pages/MainPage.xaml.cs @@ -96,21 +96,21 @@ public sealed partial class MainPage : ISupportCustomTitleBarDragRegion ActivationRegistrar.Dispatch(AppInstance.GetCurrent().GetActivatedEventArgs()); } - WeakReferenceMessenger.Default.TryRegister(this, (_, message) => _connectedAnimationTarget = message.Sender); - WeakReferenceMessenger.Default.TryRegister(this, (_, message) => _illustrationViewerContent = message.IllustrationViewModel); - WeakReferenceMessenger.Default.TryRegister(this, (_, message) => PerformSearch(message.Tag)); - WeakReferenceMessenger.Default.TryRegister(this, (_, message) => + _ = WeakReferenceMessenger.Default.TryRegister(this, (_, message) => _connectedAnimationTarget = message.Sender); + _ = WeakReferenceMessenger.Default.TryRegister(this, (_, message) => _illustrationViewerContent = message.IllustrationViewModel); + _ = WeakReferenceMessenger.Default.TryRegister(this, (_, message) => PerformSearch(message.Tag)); + _ = WeakReferenceMessenger.Default.TryRegister(this, (_1, message) => { MainPageRootNavigationView.SelectedItem = null; - MainPageRootFrame.Navigate(typeof(SearchResultsPage), message.Parameter); + _ = MainPageRootFrame.Navigate(typeof(SearchResultsPage), message.Parameter); }); - WeakReferenceMessenger.Default.TryRegister(this, (_, message) => NavigateToSettingEntryAsync(message.Entry).Discard()); + _ = WeakReferenceMessenger.Default.TryRegister(this, (_, message) => NavigateToSettingEntryAsync(message.Entry).Discard()); // Connected animation to the element located in MainPage if (ConnectedAnimationService.GetForCurrentView().GetAnimation("ForwardConnectedAnimation") is { } animation) { animation.Configuration = new DirectConnectedAnimationConfiguration(); - animation.TryStart(_connectedAnimationTarget ?? this); + _ = animation.TryStart(_connectedAnimationTarget ?? this); _connectedAnimationTarget = null; } @@ -141,7 +141,7 @@ public sealed partial class MainPage : ISupportCustomTitleBarDragRegion private void MainPageRootFrame_OnNavigated(object sender, NavigationEventArgs e) { - WeakReferenceMessenger.Default.Send(new MainPageFrameNavigatingEvent(this)); + _ = WeakReferenceMessenger.Default.Send(new MainPageFrameNavigatingEvent(this)); GCSettings.LargeObjectHeapCompactionMode = GCLargeObjectHeapCompactionMode.CompactOnce; GC.Collect(); } @@ -158,7 +158,7 @@ public sealed partial class MainPage : ISupportCustomTitleBarDragRegion { if (args.QueryText.IsNullOrBlank()) { - MessageDialogBuilder.CreateAcknowledgement(this, + _ = MessageDialogBuilder.CreateAcknowledgement(this, MainPageResources.SearchKeywordCannotBeBlankTitle, MainPageResources.SearchKeywordCannotBeBlankContent); return; @@ -184,8 +184,8 @@ public sealed partial class MainPage : ISupportCustomTitleBarDragRegion switch (type) { case SuggestionType.Settings: - SettingEntry.LazyValues.Value.FirstOrDefault(se => se.GetLocalizedResourceContent() == name) - ?.Let(se => WeakReferenceMessenger.Default.Send(new NavigateToSettingEntryMessage(se))); + _ = (SettingEntry.LazyValues.Value.FirstOrDefault(se => se.GetLocalizedResourceContent() == name) + ?.Let(se => WeakReferenceMessenger.Default.Send(new NavigateToSettingEntryMessage(se)))); break; default: sender.Text = name; @@ -217,7 +217,7 @@ public sealed partial class MainPage : ISupportCustomTitleBarDragRegion var setting = App.AppViewModel.AppSetting; MainPageRootNavigationView.SelectedItem = null; - MainPageRootFrame.Navigate(typeof(SearchResultsPage), App.AppViewModel.MakoClient.Search( + _ = MainPageRootFrame.Navigate(typeof(SearchResultsPage), App.AppViewModel.MakoClient.Search( text, setting.SearchStartingFromPageNumber, setting.PageLimitForKeywordSearch, @@ -242,7 +242,7 @@ public sealed partial class MainPage : ISupportCustomTitleBarDragRegion var position = settingsPage.FindChild(element => element.Tag is SettingEntry e && e == entry) ?.TransformToVisual((UIElement)settingsPage.SettingsPageScrollViewer.Content) .TransformPoint(new Point(0, 0)); - settingsPage.SettingsPageScrollViewer.ChangeView(null, position?.Y, null, false); + _ = settingsPage.SettingsPageScrollViewer.ChangeView(null, position?.Y, null, false); } // The AutoSuggestBox does not have a 'Paste' event, so we check the keyboard event accordingly @@ -275,7 +275,7 @@ public sealed partial class MainPage : ISupportCustomTitleBarDragRegion { if (App.AppViewModel.AppSetting.ReverseSearchApiKey is { Length: > 0 }) { - if (await UIHelper.OpenFileOpenPickerAsync() is { } file) + if (await UiHelper.OpenFileOpenPickerAsync() is { } file) { await using var stream = await file.OpenStreamForReadAsync(); await _viewModel.ReverseSearchAsync(stream); @@ -296,7 +296,7 @@ public sealed partial class MainPage : ISupportCustomTitleBarDragRegion .WithDefaultButton(ContentDialogButton.Primary) .Build(CurrentContext.Window); content.Owner = dialog; - await dialog.ShowAsync(); + _ = await dialog.ShowAsync(); } private void KeywordAutoSuggestBox_OnDragOver(object sender, DragEventArgs e) diff --git a/src/Pixeval/Pages/MainPageViewModel.cs b/src/Pixeval/Pages/MainPageViewModel.cs index e6b2dd30..daca3482 100644 --- a/src/Pixeval/Pages/MainPageViewModel.cs +++ b/src/Pixeval/Pages/MainPageViewModel.cs @@ -108,7 +108,7 @@ public partial class MainPageViewModel : AutoActivateObservableRecipient, IRecip break; case var s: - await MessageDialogBuilder.CreateAcknowledgement( + _ = await MessageDialogBuilder.CreateAcknowledgement( window, MainPageResources.ReverseSearchErrorTitle, s > 0 ? MainPageResources.ReverseSearchServerSideErrorContent : MainPageResources.ReverseSearchClientSideErrorContent) @@ -117,7 +117,7 @@ public partial class MainPageViewModel : AutoActivateObservableRecipient, IRecip } // window.HideProgressRing(); - MessageDialogBuilder.CreateAcknowledgement(window, MainPageResources.ReverseSearchNotFoundTitle, MainPageResources.ReverseSearchNotFoundContent); + _ = MessageDialogBuilder.CreateAcknowledgement(window, MainPageResources.ReverseSearchNotFoundTitle, MainPageResources.ReverseSearchNotFoundContent); } } catch (Exception e) diff --git a/src/Pixeval/Pages/Misc/AboutPage.xaml.cs b/src/Pixeval/Pages/Misc/AboutPage.xaml.cs index 0867def0..be09fbeb 100644 --- a/src/Pixeval/Pages/Misc/AboutPage.xaml.cs +++ b/src/Pixeval/Pages/Misc/AboutPage.xaml.cs @@ -49,6 +49,6 @@ public sealed partial class AboutPage private async void LaunchUri(object sender, TappedRoutedEventArgs e) { - await Launcher.LaunchUriAsync(new Uri(sender.GetTag())); + _ = await Launcher.LaunchUriAsync(new Uri(sender.GetTag())); } } diff --git a/src/Pixeval/Pages/Misc/BrowsingHistoryPage.xaml.cs b/src/Pixeval/Pages/Misc/BrowsingHistoryPage.xaml.cs index f57b45c0..c2e5178c 100644 --- a/src/Pixeval/Pages/Misc/BrowsingHistoryPage.xaml.cs +++ b/src/Pixeval/Pages/Misc/BrowsingHistoryPage.xaml.cs @@ -58,7 +58,7 @@ public sealed partial class BrowsingHistoryPage : ISortedIllustrationContainerPa { SortOptionComboBox.SelectedItem = MakoHelper.GetAppSettingDefaultSortOptionWrapper(); await FetchAndFill(); - WeakReferenceMessenger.Default.TryRegister(this, static (recipient, _) => recipient.IllustrationContainer.ViewModel.DataProvider.FetchEngine?.Cancel()); + _ = WeakReferenceMessenger.Default.TryRegister(this, static (recipient, _) => recipient.IllustrationContainer.ViewModel.DataProvider.FetchEngine?.Cancel()); } private async Task FetchAndFill() diff --git a/src/Pixeval/Pages/Misc/SettingsPage.xaml b/src/Pixeval/Pages/Misc/SettingsPage.xaml index cb0f3313..4febf993 100644 --- a/src/Pixeval/Pages/Misc/SettingsPage.xaml +++ b/src/Pixeval/Pages/Misc/SettingsPage.xaml @@ -117,7 +117,6 @@ - - - - - TestParser = new(); + private static readonly MacroParser _testParser = new(); private SettingsPageViewModel _viewModel; // The previous meta path after user changes the path field, if the path is illegal @@ -53,8 +53,10 @@ public sealed partial class SettingsPage public SettingsPage() { InitializeComponent(); - _viewModel = new SettingsPageViewModel(App.AppViewModel.AppSetting); - _viewModel.SettingsTeachingTip = SettingsTeachingTip; + _viewModel = new SettingsPageViewModel(App.AppViewModel.AppSetting) + { + SettingsTeachingTip = SettingsTeachingTip + }; _previousPath = _viewModel.DefaultDownloadPathMacro; } @@ -82,7 +84,7 @@ public sealed partial class SettingsPage private async void ThemeEntryDescriptionHyperlinkButton_OnTapped(object sender, TappedRoutedEventArgs e) { - await Launcher.LaunchUriAsync(new Uri("ms-settings:themes")); + _ = await Launcher.LaunchUriAsync(new Uri("ms-settings:themes")); } private void ImageMirrorServerTextBox_OnGotFocus(object sender, RoutedEventArgs e) @@ -156,8 +158,8 @@ public sealed partial class SettingsPage try { - TestParser.SetupParsingEnvironment(new Lexer(_viewModel.DefaultDownloadPathMacro)); - TestParser.Parse(); + _testParser.SetupParsingEnvironment(new Lexer(_viewModel.DefaultDownloadPathMacro)); + _ = _testParser.Parse(); } catch (Exception exception) { diff --git a/src/Pixeval/Pages/SuggestionStateMachine.cs b/src/Pixeval/Pages/SuggestionStateMachine.cs index 0a314f43..f42f2698 100644 --- a/src/Pixeval/Pages/SuggestionStateMachine.cs +++ b/src/Pixeval/Pages/SuggestionStateMachine.cs @@ -48,15 +48,15 @@ public class SuggestionStateMachine .SelectAsync(t => new Tag(t.Tag!, t.Translation)) .SelectAsync(SuggestionModel.FromTag), LazyThreadSafetyMode.ExecutionAndPublication); - private static readonly TreeSearcher SettingEntriesTreeSearcher = new(SearcherLogic.Contain, PinIn.CreateDefault()); + private static readonly TreeSearcher _settingEntriesTreeSearcher = new(SearcherLogic.Contain, PinIn.CreateDefault()); - public ObservableCollection Suggestions { get; } = new(); + public ObservableCollection Suggestions { get; } = []; static SuggestionStateMachine() { foreach (var settingsEntry in SettingEntry.LazyValues.Value) { - SettingEntriesTreeSearcher.Put(settingsEntry.GetLocalizedResourceContent()!, settingsEntry); + _settingEntriesTreeSearcher.Put(settingsEntry.GetLocalizedResourceContent()!, settingsEntry); } } @@ -105,7 +105,7 @@ public class SuggestionStateMachine private static IReadOnlySet MatchSettings(string keyword) { - var pinInResult = SettingEntriesTreeSearcher.Search(keyword).ToHashSet(); + var pinInResult = _settingEntriesTreeSearcher.Search(keyword).ToHashSet(); var nonPinInResult = SettingEntry.LazyValues.Value.Where(it => it.GetLocalizedResourceContent()!.Contains(keyword)); pinInResult.AddRange(nonPinInResult); return pinInResult; diff --git a/src/Pixeval/Pixeval.csproj b/src/Pixeval/Pixeval.csproj index 710cfff2..ffbb1b10 100644 --- a/src/Pixeval/Pixeval.csproj +++ b/src/Pixeval/Pixeval.csproj @@ -1,8 +1,8 @@ WinExe - net8.0-windows10.0.19041.0 - 10.0.17763.0 + net8.0-windows10.0.22621.0 + 10.0.19041.0 Pixeval Debug;Release x86;x64;arm64 diff --git a/src/Pixeval/UserControls/CommentList.xaml.cs b/src/Pixeval/UserControls/CommentList.xaml.cs index 4cead840..fe92a515 100644 --- a/src/Pixeval/UserControls/CommentList.xaml.cs +++ b/src/Pixeval/UserControls/CommentList.xaml.cs @@ -51,10 +51,10 @@ public sealed partial class CommentList : IDisposable private void CommentBlock_OnDeleteHyperlinkButtonTapped(object? sender, TappedRoutedEventArgs e) { var viewModel = sender!.GetDataContext(); - App.AppViewModel.MakoClient.DeleteCommentAsync(viewModel.CommentId); + _ = App.AppViewModel.MakoClient.DeleteCommentAsync(viewModel.CommentId); if (ItemsSource is IList list) { - list.Remove(viewModel); + _ = list.Remove(viewModel); } } diff --git a/src/Pixeval/UserControls/IllustrationContainer.xaml.cs b/src/Pixeval/UserControls/IllustrationContainer.xaml.cs index 7d41a5e2..f721f3b6 100644 --- a/src/Pixeval/UserControls/IllustrationContainer.xaml.cs +++ b/src/Pixeval/UserControls/IllustrationContainer.xaml.cs @@ -28,7 +28,6 @@ using Pixeval.UserControls.IllustrationView; using Pixeval.Util.UI; using WinUI3Utilities.Attributes; - namespace Pixeval.UserControls; [DependencyProperty>("PrimaryCommandsSupplements", DependencyPropertyDefaultValue.New)] @@ -44,7 +43,7 @@ public sealed partial class IllustrationContainer public IllustrationContainer() { InitializeComponent(); - CommandBarElements = new ObservableCollection(); + CommandBarElements = []; CommandBarElements.CollectionChanged += (_, args) => { switch (args) @@ -91,11 +90,11 @@ public sealed partial class IllustrationContainer private void IllustrationContainer_OnLoaded(object sender, RoutedEventArgs e) { - IllustrationView.Focus(FocusState.Programmatic); + _ = IllustrationView.Focus(FocusState.Programmatic); } public void ScrollToTop() { - IllustrationView.ScrollViewer.ChangeView(null, 0, null, false); + _ = IllustrationView.ScrollViewer.ChangeView(null, 0, null, false); } } diff --git a/src/Pixeval/UserControls/IllustrationView/IllustrationThumbnail.xaml.cs b/src/Pixeval/UserControls/IllustrationView/IllustrationThumbnail.xaml.cs index 9a4c3090..bcffe4d0 100644 --- a/src/Pixeval/UserControls/IllustrationView/IllustrationThumbnail.xaml.cs +++ b/src/Pixeval/UserControls/IllustrationView/IllustrationThumbnail.xaml.cs @@ -121,23 +121,23 @@ public sealed partial class IllustrationThumbnail : CardControl private void CopyWebLinkContextItemOnTapped(object sender, TappedRoutedEventArgs e) { - UIHelper.ClipboardSetText(MakoHelper.GenerateIllustrationWebUri(sender.GetDataContext().Id).ToString()); + UiHelper.ClipboardSetText(MakoHelper.GenerateIllustrationWebUri(sender.GetDataContext().Id).ToString()); } private void CopyAppLinkContextItemOnTapped(object sender, TappedRoutedEventArgs e) { - UIHelper.ClipboardSetText(MakoHelper.GenerateIllustrationAppUri(sender.GetDataContext().Id).ToString()); + UiHelper.ClipboardSetText(MakoHelper.GenerateIllustrationAppUri(sender.GetDataContext().Id).ToString()); } private async void ShowQrCodeContextItemOnTapped(object sender, TappedRoutedEventArgs e) { - var webQrCodeSource = await UIHelper.GenerateQrCodeAsync(MakoHelper.GenerateIllustrationWebUri(sender.GetDataContext().Id).ToString()); + var webQrCodeSource = await UiHelper.GenerateQrCodeAsync(MakoHelper.GenerateIllustrationWebUri(sender.GetDataContext().Id).ToString()); ShowQrCodeRequested?.Invoke(this, webQrCodeSource); } private async void ShowPixEzQrCodeContextItemOnTapped(object sender, TappedRoutedEventArgs e) { - var pixEzQrCodeSource = await UIHelper.GenerateQrCodeAsync(MakoHelper.GenerateIllustrationPixEzUri(sender.GetDataContext().Id).ToString()); + var pixEzQrCodeSource = await UiHelper.GenerateQrCodeAsync(MakoHelper.GenerateIllustrationPixEzUri(sender.GetDataContext().Id).ToString()); ShowQrCodeRequested?.Invoke(this, pixEzQrCodeSource); } } diff --git a/src/Pixeval/UserControls/IllustrationView/IllustrationViewCommandBar.xaml.cs b/src/Pixeval/UserControls/IllustrationView/IllustrationViewCommandBar.xaml.cs index 3a5b8dd0..3c01daf0 100644 --- a/src/Pixeval/UserControls/IllustrationView/IllustrationViewCommandBar.xaml.cs +++ b/src/Pixeval/UserControls/IllustrationView/IllustrationViewCommandBar.xaml.cs @@ -60,7 +60,7 @@ public sealed partial class IllustrationViewCommandBar var defaultCommands = new List(CommandBar.PrimaryCommands); defaultCommands.AddRange(CommandBar.SecondaryCommands); _defaultCommands = defaultCommands.Where(e => e is AppBarButton).Cast(); - CommandBarElements = new(); + CommandBarElements = []; CommandBarElements.CollectionChanged += (_, args) => { switch (args) @@ -148,7 +148,7 @@ public sealed partial class IllustrationViewCommandBar if (viewModelSelectedIllustrations.Length is var c and > 0) { - MessageDialogBuilder.CreateAcknowledgement(this, + _ = MessageDialogBuilder.CreateAcknowledgement(this, IllustrationViewCommandBarResources.AddAllToBookmarkTitle, IllustrationViewCommandBarResources.AddAllToBookmarkContentFormatted.Format(c)); } @@ -200,7 +200,7 @@ public sealed partial class IllustrationViewCommandBar foreach (var illustrationViewModel in selected) { - await Launcher.LaunchUriAsync(MakoHelper.GenerateIllustrationWebUri(illustrationViewModel.Id)); + _ = await Launcher.LaunchUriAsync(MakoHelper.GenerateIllustrationWebUri(illustrationViewModel.Id)); } } } @@ -254,7 +254,7 @@ public sealed partial class IllustrationViewCommandBar if (o is IllustrationViewModel vm) { var stringTags = vm.Illustrate.Tags?.Select(t => t.Name).WhereNotNull().ToArray() ?? - Array.Empty(); + []; var result = ExamineExcludeTags(stringTags, excludeTags) && ExamineIncludeTags(stringTags, includeTags) && vm.Bookmark >= leastBookmark diff --git a/src/Pixeval/UserControls/IllustrationView/IllustrationViewDataProvider.cs b/src/Pixeval/UserControls/IllustrationView/IllustrationViewDataProvider.cs index 232b0eb5..5c7ad87e 100644 --- a/src/Pixeval/UserControls/IllustrationView/IllustrationViewDataProvider.cs +++ b/src/Pixeval/UserControls/IllustrationView/IllustrationViewDataProvider.cs @@ -122,7 +122,7 @@ public class IllustrationViewDataProvider : DataProvider SelectedIllustrations { get; set; } = new(); + public ObservableCollection SelectedIllustrations { get; set; } = []; public override void DisposeCurrent() { diff --git a/src/Pixeval/UserControls/IllustrationView/IllustrationViewModel.cs b/src/Pixeval/UserControls/IllustrationView/IllustrationViewModel.cs index dfde24bb..36d4de43 100644 --- a/src/Pixeval/UserControls/IllustrationView/IllustrationViewModel.cs +++ b/src/Pixeval/UserControls/IllustrationView/IllustrationViewModel.cs @@ -145,9 +145,9 @@ public class IllustrationViewModel(Illustration illustration) : IllustrateViewMo /// public IReadOnlyDictionary ThumbnailStreams => ThumbnailStreamsRef; - private Dictionary ThumbnailStreamsRef { get; } = new(); + private Dictionary ThumbnailStreamsRef { get; } = []; - private Dictionary> ThumbnailSourcesRef { get; } = new(); + private Dictionary> ThumbnailSourcesRef { get; } = []; private CancellationHandle LoadingThumbnailCancellationHandle { get; } = new(); diff --git a/src/Pixeval/UserControls/IllustratorContentViewer/IllustratorContentViewer.xaml.cs b/src/Pixeval/UserControls/IllustratorContentViewer/IllustratorContentViewer.xaml.cs index 25b2cb0e..0e2b5e91 100644 --- a/src/Pixeval/UserControls/IllustratorContentViewer/IllustratorContentViewer.xaml.cs +++ b/src/Pixeval/UserControls/IllustratorContentViewer/IllustratorContentViewer.xaml.cs @@ -44,12 +44,14 @@ public sealed partial class IllustratorContentViewer : IDisposable ViewModel.ShowExternalCommandBarChanged += (_, b) => { - if (IllustratorContentViewerFrame.Content is IIllustratorContentViewerCommandBarHostSubPage subPage) subPage.ChangeCommandBarVisibility(b); + if (IllustratorContentViewerFrame.Content is IIllustratorContentViewerCommandBarHostSubPage subPage) + subPage.ChangeCommandBarVisibility(b); }; ViewModel.ShowRecommendIllustratorsChanged += (_, b) => { - if (b && !ViewModel.RecommendIllustrators.Any()) ViewModel.LoadRecommendIllustratorsAsync().Discard(); + if (b && !ViewModel.RecommendIllustrators.Any()) + ViewModel.LoadRecommendIllustratorsAsync().Discard(); }; ViewModel.CurrentTab = args.SelectedItemContainer.Tag switch @@ -69,7 +71,7 @@ public sealed partial class IllustratorContentViewer : IDisposable _lastNavigationViewTag = args.SelectedItemContainer.Tag as NavigationViewTag; await ThreadingHelper.SpinWaitAsync(() => IllustratorContentViewerFrame.Content.GetType() != _lastNavigationViewTag!.NavigateTo); - _pageCache.Add((Page)IllustratorContentViewerFrame.Content); + _ = _pageCache.Add((Page)IllustratorContentViewerFrame.Content); } private void NavigationViewAutoSuggestBox_OnTextChanged(AutoSuggestBox sender, AutoSuggestBoxTextChangedEventArgs args) diff --git a/src/Pixeval/UserControls/IllustratorContentViewer/IllustratorContentViewerViewModel.cs b/src/Pixeval/UserControls/IllustratorContentViewer/IllustratorContentViewerViewModel.cs index a140b66a..ad40c3fb 100644 --- a/src/Pixeval/UserControls/IllustratorContentViewer/IllustratorContentViewerViewModel.cs +++ b/src/Pixeval/UserControls/IllustratorContentViewer/IllustratorContentViewerViewModel.cs @@ -58,7 +58,7 @@ public partial class IllustratorContentViewerViewModel : ObservableObject public IllustratorContentViewerViewModel(PixivSingleUserResponse userDetail) { - RecommendIllustrators = new(); + RecommendIllustrators = []; UserDetail = userDetail; InitializeTags(); @@ -174,7 +174,7 @@ public partial class IllustratorContentViewerViewModel : ObservableObject Metrics = new(profile?.TotalFollowUsers ?? 0, profile?.TotalMyPixivUsers ?? 0, profile?.TotalIllusts ?? 0); Premium = profile?.IsPremium ?? false; Following = UserDetail.UserEntity?.IsFollowed ?? false; - ActionMenuFlyoutItems = new(); + ActionMenuFlyoutItems = []; } private async Task SetAvatarAsync() @@ -239,13 +239,13 @@ public partial class IllustratorContentViewerViewModel : ObservableObject private void Follow(bool privately) { Following = true; - App.AppViewModel.MakoClient.PostFollowUserAsync(UserDetail.UserEntity!.Id.ToString(), privately ? PrivacyPolicy.Private : PrivacyPolicy.Public); + _ = App.AppViewModel.MakoClient.PostFollowUserAsync(UserDetail.UserEntity!.Id.ToString(), privately ? PrivacyPolicy.Private : PrivacyPolicy.Public); } private void Unfollow() { Following = false; - App.AppViewModel.MakoClient.RemoveFollowUserAsync(UserDetail.UserEntity!.Id.ToString()); + _ = App.AppViewModel.MakoClient.RemoveFollowUserAsync(UserDetail.UserEntity!.Id.ToString()); } public Visibility GetNavigationViewAutoSuggestBoxVisibility(bool showExternalCommandBar) diff --git a/src/Pixeval/UserControls/IllustratorContentViewer/IllustratorIllustrationAndMangaBookmarkPage.xaml.cs b/src/Pixeval/UserControls/IllustratorContentViewer/IllustratorIllustrationAndMangaBookmarkPage.xaml.cs index 0de6e57b..b13c14e5 100644 --- a/src/Pixeval/UserControls/IllustratorContentViewer/IllustratorIllustrationAndMangaBookmarkPage.xaml.cs +++ b/src/Pixeval/UserControls/IllustratorContentViewer/IllustratorIllustrationAndMangaBookmarkPage.xaml.cs @@ -34,9 +34,10 @@ public sealed partial class IllustratorIllustrationAndMangaBookmarkPage : ISorte public override void OnPageActivated(NavigationEventArgs e) { - if (ActivationCount > 1) return; + if (ActivationCount > 1) + return; - WeakReferenceMessenger.Default.TryRegister(this, static (recipient, _) => recipient.IllustrationContainer.ViewModel.DataProvider.FetchEngine?.Cancel()); + _ = WeakReferenceMessenger.Default.TryRegister(this, static (recipient, _) => recipient.IllustrationContainer.ViewModel.DataProvider.FetchEngine?.Cancel()); if (e.Parameter is string id) { _uid = id; diff --git a/src/Pixeval/UserControls/IllustratorContentViewer/IllustratorIllustrationAndMangaBookmarkPageViewModel.cs b/src/Pixeval/UserControls/IllustratorContentViewer/IllustratorIllustrationAndMangaBookmarkPageViewModel.cs index 12e5d91a..aeb14c9d 100644 --- a/src/Pixeval/UserControls/IllustratorContentViewer/IllustratorIllustrationAndMangaBookmarkPageViewModel.cs +++ b/src/Pixeval/UserControls/IllustratorContentViewer/IllustratorIllustrationAndMangaBookmarkPageViewModel.cs @@ -40,7 +40,7 @@ public class IllustratorIllustrationAndMangaBookmarkPageViewModel : ObservableOb private readonly CancellationTokenSource _bookmarksIdLoadingCancellationTokenSource = new(); - public ObservableCollection UserBookmarkTags { get; } = new(); + public ObservableCollection UserBookmarkTags { get; } = []; public event EventHandler? TagBookmarksIncrementallyLoaded; @@ -66,7 +66,7 @@ public class IllustratorIllustrationAndMangaBookmarkPageViewModel : ObservableOb var token = _bookmarksIdLoadingCancellationTokenSource.Token; var engine = App.AppViewModel.MakoClient.UserTaggedBookmarksId(uid, tag); var counter = 0; - var hashSet = _bookmarkTagIllustrationIdDictionary.GetOrAdd(tag, new HashSet()); + var hashSet = _bookmarkTagIllustrationIdDictionary.GetOrAdd(tag, []); await foreach (var id in engine) { if (token.IsCancellationRequested) @@ -82,7 +82,7 @@ public class IllustratorIllustrationAndMangaBookmarkPageViewModel : ObservableOb TagBookmarksIncrementallyLoaded?.Invoke(this, tag); } - hashSet.Add(id); + _ = hashSet.Add(id); counter++; } diff --git a/src/Pixeval/UserControls/IllustratorContentViewer/IllustratorIllustrationPage.xaml.cs b/src/Pixeval/UserControls/IllustratorContentViewer/IllustratorIllustrationPage.xaml.cs index 5dfeb330..823bd7dc 100644 --- a/src/Pixeval/UserControls/IllustratorContentViewer/IllustratorIllustrationPage.xaml.cs +++ b/src/Pixeval/UserControls/IllustratorContentViewer/IllustratorIllustrationPage.xaml.cs @@ -25,9 +25,10 @@ public sealed partial class IllustratorIllustrationPage : ISortedIllustrationCon public override void OnPageActivated(NavigationEventArgs e) { - if (ActivationCount > 1) return; + if (ActivationCount > 1) + return; - WeakReferenceMessenger.Default.TryRegister(this, static (recipient, _) => recipient.IllustrationContainer.ViewModel.DataProvider.FetchEngine?.Cancel()); + _ = WeakReferenceMessenger.Default.TryRegister(this, static (recipient, _) => recipient.IllustrationContainer.ViewModel.DataProvider.FetchEngine?.Cancel()); if (e.Parameter is string id) { IllustrationContainer.IllustrationView.ViewModel.ResetEngineAndFillAsync(App.AppViewModel.MakoClient.Posts(id)).Discard(); diff --git a/src/Pixeval/UserControls/IllustratorContentViewer/IllustratorMangaPage.xaml.cs b/src/Pixeval/UserControls/IllustratorContentViewer/IllustratorMangaPage.xaml.cs index b25d983e..db2b82fd 100644 --- a/src/Pixeval/UserControls/IllustratorContentViewer/IllustratorMangaPage.xaml.cs +++ b/src/Pixeval/UserControls/IllustratorContentViewer/IllustratorMangaPage.xaml.cs @@ -25,9 +25,10 @@ public sealed partial class IllustratorMangaPage : ISortedIllustrationContainerP public override void OnPageActivated(NavigationEventArgs e) { - if (ActivationCount > 1) return; + if (ActivationCount > 1) + return; - WeakReferenceMessenger.Default.TryRegister(this, static (recipient, _) => recipient.IllustrationContainer.ViewModel.DataProvider.FetchEngine?.Cancel()); + _ = WeakReferenceMessenger.Default.TryRegister(this, static (recipient, _) => recipient.IllustrationContainer.ViewModel.DataProvider.FetchEngine?.Cancel()); if (e.Parameter is string id) { IllustrationContainer.IllustrationView.ViewModel.ResetEngineAndFillAsync(App.AppViewModel.MakoClient.MangaPosts(id, App.AppViewModel.AppSetting.TargetFilter)).Discard(); diff --git a/src/Pixeval/UserControls/IllustratorView/IllustratorViewDataProvider.cs b/src/Pixeval/UserControls/IllustratorView/IllustratorViewDataProvider.cs index 594ef23c..67619f95 100644 --- a/src/Pixeval/UserControls/IllustratorView/IllustratorViewDataProvider.cs +++ b/src/Pixeval/UserControls/IllustratorView/IllustratorViewDataProvider.cs @@ -39,7 +39,7 @@ public class IllustratorViewDataProvider : DataProvider _illustratorsSource; protected set { - SetProperty(ref _illustratorsSource, value); + _ = SetProperty(ref _illustratorsSource, value); View.Source = value; } } diff --git a/src/Pixeval/UserControls/IllustratorView/IllustratorViewModel.cs b/src/Pixeval/UserControls/IllustratorView/IllustratorViewModel.cs index 4a754c99..b20b95a5 100644 --- a/src/Pixeval/UserControls/IllustratorView/IllustratorViewModel.cs +++ b/src/Pixeval/UserControls/IllustratorView/IllustratorViewModel.cs @@ -45,7 +45,7 @@ namespace Pixeval.UserControls.IllustratorView; public sealed partial class IllustratorViewModel : IllustrateViewModel { // Dominant color of the "No Image" image - public static readonly SolidColorBrush DefaultAvatarBorderColorBrush = new(UIHelper.ParseHexColor("#D6DEE5")); + public static readonly SolidColorBrush DefaultAvatarBorderColorBrush = new(UiHelper.ParseHexColor("#D6DEE5")); private readonly TaskCompletionSource _bannerImageTaskCompletionSource; @@ -114,13 +114,13 @@ public sealed partial class IllustratorViewModel : IllustrateViewModel var tasks = await Task.WhenAll(urls.Select(u => client.DownloadAsIRandomAccessStreamAsync(u))); if (tasks is [Result.Success(var first), ..]) { - var dominantColor = await UIHelper.GetDominantColorAsync(first.AsStreamForRead(), false); + var dominantColor = await UiHelper.GetDominantColorAsync(first.AsStreamForRead(), false); AvatarBorderBrush = new SolidColorBrush(dominantColor); } var result = (await Task.WhenAll(tasks.SelectNotNull(r => r.BindAsync(s => s.GetSoftwareBitmapSourceAsync(true))))) .SelectNotNull(res => res.GetOrElse(null)).ToArray(); - _bannerImageTaskCompletionSource.TrySetResult(result); + _ = _bannerImageTaskCompletionSource.TrySetResult(result); return; } @@ -128,15 +128,15 @@ public sealed partial class IllustratorViewModel : IllustrateViewModel if (UserDetail.UserProfile?.BackgroundImageUrl is { } url && await client.DownloadAsIRandomAccessStreamAsync(url) is Result.Success(var stream)) { var managedStream = stream.AsStreamForRead(); - var dominantColor = await UIHelper.GetDominantColorAsync(managedStream, false); + var dominantColor = await UiHelper.GetDominantColorAsync(managedStream, false); AvatarBorderBrush = new SolidColorBrush(dominantColor); var result = Enumerates.ArrayOf(await stream.GetSoftwareBitmapSourceAsync(true)); - _bannerImageTaskCompletionSource.TrySetResult(result); + _ = _bannerImageTaskCompletionSource.TrySetResult(result); return; } AvatarBorderBrush = DefaultAvatarBorderColorBrush; - _bannerImageTaskCompletionSource.TrySetResult(Enumerates.ArrayOf(await AppContext.GetPixivNoProfileImageAsync())); + _ = _bannerImageTaskCompletionSource.TrySetResult(Enumerates.ArrayOf(await AppContext.GetPixivNoProfileImageAsync())); } // private void SetMetrics() @@ -180,13 +180,13 @@ public sealed partial class IllustratorViewModel : IllustrateViewModel private void GenerateLinkCommandOnExecuteRequested(XamlUICommand sender, ExecuteRequestedEventArgs args) { - UIHelper.ClipboardSetText(MakoHelper.GenerateIllustratorAppUri(UserId!).ToString()); + UiHelper.ClipboardSetText(MakoHelper.GenerateIllustratorAppUri(UserId!).ToString()); TeachingTipProperties.ShowAndHide(IllustratorProfileResources.LinkCopiedToClipboard); } private void GenerateWebLinkCommandOnExecuteRequested(XamlUICommand sender, ExecuteRequestedEventArgs args) { - UIHelper.ClipboardSetText(MakoHelper.GenerateIllustratorWebUri(UserId!).ToString()); + UiHelper.ClipboardSetText(MakoHelper.GenerateIllustratorWebUri(UserId!).ToString()); TeachingTipProperties.ShowAndHide(IllustratorProfileResources.LinkCopiedToClipboard); } @@ -208,18 +208,18 @@ public sealed partial class IllustratorViewModel : IllustrateViewModel private void Follow() { IsFollowed = true; - App.AppViewModel.MakoClient.PostFollowUserAsync(UserId!, PrivacyPolicy.Public); + _ = App.AppViewModel.MakoClient.PostFollowUserAsync(UserId!, PrivacyPolicy.Public); } private void Unfollow() { IsFollowed = false; - App.AppViewModel.MakoClient.RemoveFollowUserAsync(UserId!); + _ = App.AppViewModel.MakoClient.RemoveFollowUserAsync(UserId!); } public override void Dispose() { - _bannerImageTaskCompletionSource.Task.ContinueWith(s => s.Dispose()); - BannerImageTask.ContinueWith(i => i.Dispose()); + _ = _bannerImageTaskCompletionSource.Task.ContinueWith(s => s.Dispose()); + _ = BannerImageTask.ContinueWith(i => i.Dispose()); } } diff --git a/src/Pixeval/UserControls/PixivReplyBar.xaml.cs b/src/Pixeval/UserControls/PixivReplyBar.xaml.cs index 504601aa..9cc5a789 100644 --- a/src/Pixeval/UserControls/PixivReplyBar.xaml.cs +++ b/src/Pixeval/UserControls/PixivReplyBar.xaml.cs @@ -64,7 +64,7 @@ public sealed partial class PixivReplyBar ReplyContentRichEditBox.Document.GetText(TextGetOptions.UseObjectText, out var content); if (content.Length is 0 or > 140) { - MessageDialogBuilder.CreateAcknowledgement(this, + _ = MessageDialogBuilder.CreateAcknowledgement(this, PixivReplyBarResources.CommentIsTooShortOrTooLongToastTitle, PixivReplyBarResources.CommentIsTooShortOrTooLongToastContentFormatted.Format(content.Length)); return; diff --git a/src/Pixeval/UserControls/RecommendIllustratorProfile/RecommendIllustratorProfile.xaml.cs b/src/Pixeval/UserControls/RecommendIllustratorProfile/RecommendIllustratorProfile.xaml.cs index 3b25fd4c..466453ce 100644 --- a/src/Pixeval/UserControls/RecommendIllustratorProfile/RecommendIllustratorProfile.xaml.cs +++ b/src/Pixeval/UserControls/RecommendIllustratorProfile/RecommendIllustratorProfile.xaml.cs @@ -22,7 +22,7 @@ public sealed partial class RecommendIllustratorProfile private void RecommendIllustratorProfile_OnLoaded(object sender, RoutedEventArgs e) { - ThreadingHelper.Fork(async () => + _ = ThreadingHelper.Fork(async () => { if (ViewModel.AvatarTask is { } task) { @@ -30,7 +30,7 @@ public sealed partial class RecommendIllustratorProfile AvatarPersonPicture.ProfilePicture = result; } }); - ThreadingHelper.Fork(async () => + _ = ThreadingHelper.Fork(async () => { if (ViewModel.DisplayImagesTask is { } task) { diff --git a/src/Pixeval/UserControls/RecommendIllustratorProfile/RecommendIllustratorProfileViewModel.cs b/src/Pixeval/UserControls/RecommendIllustratorProfile/RecommendIllustratorProfileViewModel.cs index 60f06f16..41d54ee8 100644 --- a/src/Pixeval/UserControls/RecommendIllustratorProfile/RecommendIllustratorProfileViewModel.cs +++ b/src/Pixeval/UserControls/RecommendIllustratorProfile/RecommendIllustratorProfileViewModel.cs @@ -84,23 +84,23 @@ public partial class RecommendIllustratorProfileViewModel : ObservableObject public void Follow() { Followed = true; - App.AppViewModel.MakoClient.PostFollowUserAsync(_userId, PrivacyPolicy.Public); + _ = App.AppViewModel.MakoClient.PostFollowUserAsync(_userId, PrivacyPolicy.Public); } public void Unfollow() { Followed = false; - App.AppViewModel.MakoClient.RemoveFollowUserAsync(_userId); + _ = App.AppViewModel.MakoClient.RemoveFollowUserAsync(_userId); } public SolidColorBrush GetButtonBackground(bool isFollowed) { - return isFollowed ? new SolidColorBrush(UIHelper.ParseHexColor("#525252")) : new SolidColorBrush(UIHelper.ParseHexColor("#0096FA")); + return isFollowed ? new SolidColorBrush(UiHelper.ParseHexColor("#525252")) : new SolidColorBrush(UiHelper.ParseHexColor("#0096FA")); } public SolidColorBrush GetButtonForeground(bool isFollowed) { - return isFollowed ? new SolidColorBrush(UIHelper.ParseHexColor("#DBDBDB")) : new SolidColorBrush(UIHelper.ParseHexColor("#F5F5F5")); + return isFollowed ? new SolidColorBrush(UiHelper.ParseHexColor("#DBDBDB")) : new SolidColorBrush(UiHelper.ParseHexColor("#F5F5F5")); } public string GetFollowButtonText(bool isFollowed) diff --git a/src/Pixeval/UserControls/TokenInput/TokenInput.xaml.cs b/src/Pixeval/UserControls/TokenInput/TokenInput.xaml.cs index 1f313b22..683d0ad5 100644 --- a/src/Pixeval/UserControls/TokenInput/TokenInput.xaml.cs +++ b/src/Pixeval/UserControls/TokenInput/TokenInput.xaml.cs @@ -81,7 +81,7 @@ public sealed partial class TokenInput TokenDeleting?.Invoke(this, arg); if (!arg.Cancel) { - TokenSource.Remove(token); + _ = TokenSource.Remove(token); TokenDeleted?.Invoke(this, token); } } diff --git a/src/Pixeval/Util/IO/FileCache.cs b/src/Pixeval/Util/IO/FileCache.cs index 2e92e598..08d24dac 100644 --- a/src/Pixeval/Util/IO/FileCache.cs +++ b/src/Pixeval/Util/IO/FileCache.cs @@ -56,10 +56,10 @@ public class FileCache private FileCache() { - _supportedKeyTypes = new[] { typeof(int), typeof(uint), typeof(ulong), typeof(long) }; + _supportedKeyTypes = [typeof(int), typeof(uint), typeof(ulong), typeof(long)]; - _index = new Dictionary(); - _expireIndex = new Dictionary(); + _index = []; + _expireIndex = []; _indexLocker = new SemaphoreSlim(1, 1); _expireIndexLocker = new SemaphoreSlim(1, 1); @@ -117,7 +117,7 @@ public class FileCache } finally { - _indexLocker.Release(); + _ = _indexLocker.Release(); } } @@ -211,15 +211,15 @@ public class FileCache { foreach (var k in keys) { - (await _baseDirectory.TryGetItemAsync(HashToGuid(k).ToString("N")))?.DeleteAsync(StorageDeleteOption.PermanentDelete); - _index.Remove(k); + _ = ((await _baseDirectory.TryGetItemAsync(HashToGuid(k).ToString("N")))?.DeleteAsync(StorageDeleteOption.PermanentDelete)); + _ = _index.Remove(k); } await WriteIndexAsync(); } finally { - _indexLocker.Release(); + _ = _indexLocker.Release(); } } @@ -233,7 +233,7 @@ public class FileCache try { - await Task.WhenAll(_index.Select(item => HashToGuid(item.Key)) + _ = await Task.WhenAll(_index.Select(item => HashToGuid(item.Key)) .Select(guid => _baseDirectory.TryGetItemAsync(guid.ToString("N")).AsTask()) .Select(item => item.ContinueWith(t => t.Result?.DeleteAsync()))); _index.Clear(); @@ -241,7 +241,7 @@ public class FileCache } finally { - _indexLocker.Release(); + _ = _indexLocker.Release(); } } @@ -260,7 +260,7 @@ public class FileCache foreach (var (key, _) in expired) { await (await _baseDirectory.TryGetItemAsync(key.ToString("N")))?.DeleteAsync(); - _index.Remove(key); + _ = _index.Remove(key); } await WriteIndexAsync(); @@ -268,7 +268,7 @@ public class FileCache } finally { - _indexLocker.Release(); + _ = _indexLocker.Release(); } } @@ -316,7 +316,7 @@ public class FileCache } finally { - _indexLocker.Release(); + _ = _indexLocker.Release(); } } @@ -334,7 +334,7 @@ public class FileCache ? _expireIndex .Where(x => x.Value >= DateTimeOffset.Now) .ToList() - : new List>(); + : []; if (state.HasFlag(CacheState.Expired)) { @@ -349,7 +349,7 @@ public class FileCache } finally { - _indexLocker.Release(); + _ = _indexLocker.Release(); } } @@ -406,7 +406,7 @@ public class FileCache } finally { - _indexLocker.Release(); + _ = _indexLocker.Release(); } throw new KeyNotFoundException(key.ToString()); @@ -451,7 +451,7 @@ public class FileCache } finally { - _indexLocker.Release(); + _ = _indexLocker.Release(); } } @@ -499,7 +499,7 @@ public class FileCache } finally { - _indexLocker.Release(); + _ = _indexLocker.Release(); } } @@ -546,7 +546,7 @@ public class FileCache } finally { - _expireIndexLocker.Release(); + _ = _expireIndexLocker.Release(); } } diff --git a/src/Pixeval/Util/IO/IOHelper.Download.cs b/src/Pixeval/Util/IO/IOHelper.Download.cs index 3ee3752d..a696caf0 100644 --- a/src/Pixeval/Util/IO/IOHelper.Download.cs +++ b/src/Pixeval/Util/IO/IOHelper.Download.cs @@ -37,7 +37,7 @@ using Pixeval.UserControls.IllustrationView; namespace Pixeval.Util.IO; -public static partial class IOHelper +public static partial class IoHelper { private const int BlockSizeInBytes = 1024; // 1KB @@ -49,7 +49,7 @@ public static partial class IOHelper private const int MaximumSmallBufferPoolSizeInBytes = 24 * 1024 * BlockSizeInBytes; // 24MB - private static readonly RecyclableMemoryStreamManager RecyclableMemoryStreamManager = new( + private static readonly RecyclableMemoryStreamManager _recyclableMemoryStreamManager = new( BlockSizeInBytes, LargeBufferMultipleInBytes, MaxBufferSizeInBytes, @@ -58,7 +58,7 @@ public static partial class IOHelper // To avoid collecting stack trace, which is quite a time-consuming task // and this exception is intended to be used at a massive magnitude - private static readonly OperationCanceledException CancellationMark = new(); + private static readonly OperationCanceledException _cancellationMark = new(); /// /// Attempts to download the content that are located by the argument @@ -105,10 +105,10 @@ public static partial class IOHelper using var response = await httpClient.GetResponseHeader(url); if (response.Content.Headers.ContentLength is { } responseLength) { - response.EnsureSuccessStatusCode(); + _ = response.EnsureSuccessStatusCode(); if (cancellationHandle?.IsCancelled is true) { - return Result.OfFailure(CancellationMark); + return Result.OfFailure(_cancellationMark); } await using var contentStream = await response.Content.ReadAsStreamAsync(); @@ -117,7 +117,7 @@ public static partial class IOHelper // running, so we check the state right after the completion of that statement if (cancellationHandle?.IsCancelled is true) { - return Result.OfFailure(CancellationMark); + return Result.OfFailure(_cancellationMark); } var resultStream = new MemoryStream(); @@ -129,7 +129,7 @@ public static partial class IOHelper if (cancellationHandle?.IsCancelled is true) { await resultStream.DisposeAsync(); - return Result.OfFailure(CancellationMark); + return Result.OfFailure(_cancellationMark); } await resultStream.WriteAsync(buffer, 0, bytesRead); @@ -143,11 +143,11 @@ public static partial class IOHelper } ArrayPool.Shared.Return(buffer, true); - resultStream.Seek(0, SeekOrigin.Begin); + _ = resultStream.Seek(0, SeekOrigin.Begin); return Result.OfSuccess(resultStream); } - return (await httpClient.DownloadByteArrayAsync(url)).Bind(m => (Stream)RecyclableMemoryStreamManager.GetStream(m.Span)); + return (await httpClient.DownloadByteArrayAsync(url)).Bind(m => (Stream)_recyclableMemoryStreamManager.GetStream(m.Span)); } catch (Exception e) { @@ -169,8 +169,8 @@ public static partial class IOHelper public static async Task SaveAsAsync(this IllustrationViewModel viewModel) { IStorageItem? item = viewModel.IsManga - ? await UIHelper.OpenFolderPickerAsync(PickerLocationId.PicturesLibrary) - : await UIHelper.OpenFileSavePickerAsync(viewModel.Id, $"{viewModel.Illustrate.GetImageFormat().RemoveSurrounding(".", string.Empty)} file", viewModel.Illustrate.GetImageFormat()); + ? await UiHelper.OpenFolderPickerAsync(PickerLocationId.PicturesLibrary) + : await UiHelper.OpenFileSavePickerAsync(viewModel.Id, $"{viewModel.Illustrate.GetImageFormat().RemoveSurrounding(".", string.Empty)} file", viewModel.Illustrate.GetImageFormat()); using var scope = App.AppViewModel.AppServicesScope; var factory = scope.ServiceProvider.GetRequiredService>(); diff --git a/src/Pixeval/Util/IO/IOHelper.Imaging.cs b/src/Pixeval/Util/IO/IOHelper.Imaging.cs index 99b4c3f4..7b40ce09 100644 --- a/src/Pixeval/Util/IO/IOHelper.Imaging.cs +++ b/src/Pixeval/Util/IO/IOHelper.Imaging.cs @@ -37,7 +37,7 @@ using SixLabors.ImageSharp.Formats.Webp; namespace Pixeval.Util.IO; -public static partial class IOHelper +public static partial class IoHelper { /// /// Re-encode and decode the image that wrapped in . Note that this function diff --git a/src/Pixeval/Util/IO/IOHelper.Mako.cs b/src/Pixeval/Util/IO/IOHelper.Mako.cs index de9049ab..400b3538 100644 --- a/src/Pixeval/Util/IO/IOHelper.Mako.cs +++ b/src/Pixeval/Util/IO/IOHelper.Mako.cs @@ -26,7 +26,7 @@ using Pixeval.Utilities; namespace Pixeval.Util.IO; -public static partial class IOHelper +public static partial class IoHelper { public static async Task> DownloadSoftwareBitmapSourceResultAsync(this MakoClient client, string url) { diff --git a/src/Pixeval/Util/IO/IOHelper.cs b/src/Pixeval/Util/IO/IOHelper.cs index 95ea8623..7de48b39 100644 --- a/src/Pixeval/Util/IO/IOHelper.cs +++ b/src/Pixeval/Util/IO/IOHelper.cs @@ -40,7 +40,7 @@ using Windows.Storage.Streams; namespace Pixeval.Util.IO; -public static partial class IOHelper +public static partial class IoHelper { public static async Task Sha1Async(this IRandomAccessStream randomAccessStream) { diff --git a/src/Pixeval/Util/PixivAuthenticationProxyServer.cs b/src/Pixeval/Util/PixivAuthenticationProxyServer.cs index 2052ffea..061cef87 100644 --- a/src/Pixeval/Util/PixivAuthenticationProxyServer.cs +++ b/src/Pixeval/Util/PixivAuthenticationProxyServer.cs @@ -1,4 +1,4 @@ -#region Copyright (c) Pixeval/Pixeval +#region Copyright (c) Pixeval/Pixeval // GPL v3 License // // Pixeval/Pixeval @@ -31,7 +31,7 @@ using Pixeval.Utilities; namespace Pixeval.Util; -public class PixivAuthenticationProxyServer : IDisposable +public partial class PixivAuthenticationProxyServer : IDisposable { private readonly X509Certificate2? _certificate; private readonly TcpListener? _tcpListener; @@ -41,7 +41,7 @@ public class PixivAuthenticationProxyServer : IDisposable _certificate = certificate; _tcpListener = tcpListener; _tcpListener.Start(); - _tcpListener.BeginAcceptTcpClient(AcceptTcpClientCallback, _tcpListener); + _ = _tcpListener.BeginAcceptTcpClient(AcceptTcpClientCallback, _tcpListener); } public void Dispose() @@ -74,7 +74,7 @@ public class PixivAuthenticationProxyServer : IDisposable if (result.AsyncState is TcpListener listener) { using var client = listener.EndAcceptTcpClient(result); - listener.BeginAcceptTcpClient(AcceptTcpClientCallback, listener); + _ = listener.BeginAcceptTcpClient(AcceptTcpClientCallback, listener); using (client) { var clientStream = client.GetStream(); @@ -95,11 +95,11 @@ public class PixivAuthenticationProxyServer : IDisposable // use specify certificate to establish the HTTPS connection await clientSsl.AuthenticateAsServerAsync(_certificate!, false, SslProtocols.None, false); // create an HTTP connection to the target IP - var host = Regex.Match(content, "CONNECT (?.+)\\:\\d+").Groups["host"].Value; + var host = HostRegex().Match(content).Groups["host"].Value; var serverSsl = await CreateConnection(await GetTargetIp(host)); var request = Functions.IgnoreExceptionAsync(async () => await clientSsl.CopyToAsync(serverSsl)); var response = Functions.IgnoreExceptionAsync(async () => await serverSsl.CopyToAsync(clientSsl)); - await Task.WhenAny(request, response); + _ = await Task.WhenAny(request, response); serverSsl.Close(); } } @@ -110,7 +110,6 @@ public class PixivAuthenticationProxyServer : IDisposable } } - private static async Task CreateConnection(IPAddress[] ipAddresses) { var client = new TcpClient(); @@ -128,4 +127,7 @@ public class PixivAuthenticationProxyServer : IDisposable throw; } } -} \ No newline at end of file + + [GeneratedRegex("CONNECT (?.+)\\:\\d+")] + private static partial Regex HostRegex(); +} diff --git a/src/Pixeval/Util/Threading/ThreadingHelper.cs b/src/Pixeval/Util/Threading/ThreadingHelper.cs index d2dfca59..d864b158 100644 --- a/src/Pixeval/Util/Threading/ThreadingHelper.cs +++ b/src/Pixeval/Util/Threading/ThreadingHelper.cs @@ -45,14 +45,15 @@ public static class ThreadingHelper // nop } - public static Task ContinueWithFlatten(this Task task, Func> func) + public static Task ContinueWithFlatten(this Task task, Func> func) { return task.ContinueWith(t => func(t.Result)).Unwrap(); } public static void CompareExchange(ref int location1, int value, int comparand) { - while (Interlocked.CompareExchange(ref location1, value, comparand) != comparand) ; + while (Interlocked.CompareExchange(ref location1, value, comparand) != comparand) + ; } // fork a task from current context. @@ -68,7 +69,7 @@ public static class ThreadingHelper public static void DispatchTask(DispatcherQueueHandler action) { - CurrentContext.Window.DispatcherQueue.TryEnqueue(action); + _ = CurrentContext.Window.DispatcherQueue.TryEnqueue(action); } public static Task DispatchSyncTaskAsync(Func func) @@ -89,15 +90,15 @@ public static class ThreadingHelper public static Task EnqueueSyncTaskAsync(this DispatcherQueue dispatcher, Func function, DispatcherQueuePriority priority = DispatcherQueuePriority.Normal) { var taskCompletionSource = new TaskCompletionSource(); - dispatcher.TryEnqueue(priority, () => + _ = dispatcher.TryEnqueue(priority, () => { try { - taskCompletionSource.TrySetResult(function()); + _ = taskCompletionSource.TrySetResult(function()); } catch (Exception e) { - taskCompletionSource.TrySetException(e); + _ = taskCompletionSource.TrySetException(e); } }); return taskCompletionSource.Task; diff --git a/src/Pixeval/Util/UI/Animating/IEasingFunction.cs b/src/Pixeval/Util/UI/Animating/IEasingFunction.cs index cd2bb1bc..8d19000f 100644 --- a/src/Pixeval/Util/UI/Animating/IEasingFunction.cs +++ b/src/Pixeval/Util/UI/Animating/IEasingFunction.cs @@ -22,7 +22,7 @@ using System.Numerics; namespace Pixeval.Util.UI.Animating; -public interface IEasingFunction where V : INumber +public interface IEasingFunction where TV : INumber { - V GetValue(double percentage); + TV GetValue(double percentage); } \ No newline at end of file diff --git a/src/Pixeval/Util/UI/Animating/IValueAnimation.cs b/src/Pixeval/Util/UI/Animating/IValueAnimation.cs index 05cde2fc..d6fb1d87 100644 --- a/src/Pixeval/Util/UI/Animating/IValueAnimation.cs +++ b/src/Pixeval/Util/UI/Animating/IValueAnimation.cs @@ -24,19 +24,19 @@ using System.Threading.Tasks; namespace Pixeval.Util.UI.Animating; -public interface IValueAnimation where V : INumber +public interface IValueAnimation where TV : INumber { TimeSpan Duration { get; } TimeSpan SampleRate { get; } - V From { get; } + TV From { get; } - V To { get; } + TV To { get; } - IEasingFunction? EasingFunction { get; } + IEasingFunction? EasingFunction { get; } - event Action OnValueChanged; + event Action OnValueChanged; event EventHandler OnCompleted; diff --git a/src/Pixeval/Util/UI/Animating/ValueAnimations.cs b/src/Pixeval/Util/UI/Animating/ValueAnimations.cs index 12f57397..d6675f9e 100644 --- a/src/Pixeval/Util/UI/Animating/ValueAnimations.cs +++ b/src/Pixeval/Util/UI/Animating/ValueAnimations.cs @@ -28,13 +28,13 @@ namespace Pixeval.Util.UI.Animating; public static class ValueAnimations { - internal static async IAsyncEnumerable StartAsync(IValueAnimation valueAnimation) where V : INumber + internal static async IAsyncEnumerable StartAsync(IValueAnimation valueAnimation) where TV : INumber { await Task.Yield(); var start = valueAnimation.From; var sampleCount = (int)Math.Ceiling(valueAnimation.Duration.Divide(valueAnimation.SampleRate)); var by = valueAnimation.To - valueAnimation.From; - var delta = by / V.Parse(sampleCount.ToString(), NumberStyles.Integer, null); + var delta = by / TV.Parse(sampleCount.ToString(), NumberStyles.Integer, null); yield return start; var counter = 1; diff --git a/src/Pixeval/Util/UI/ReplyEmojiHelper.Enumerator.cs b/src/Pixeval/Util/UI/ReplyEmojiHelper.Enumerator.cs index 8e0e90b0..3b60b28e 100644 --- a/src/Pixeval/Util/UI/ReplyEmojiHelper.Enumerator.cs +++ b/src/Pixeval/Util/UI/ReplyEmojiHelper.Enumerator.cs @@ -23,7 +23,6 @@ using System.Linq; using System.Text; using Pixeval.Misc; - namespace Pixeval.Util.UI; public static partial class ReplyEmojiHelper @@ -42,7 +41,7 @@ public static partial class ReplyEmojiHelper { while (!table.Keys.Contains(i) && i < content.Length) { - stringBuilder.Append(content[i++]); + _ = stringBuilder.Append(content[i++]); } if (stringBuilder.Length != 0) @@ -55,7 +54,7 @@ public static partial class ReplyEmojiHelper yield break; } - stringBuilder.Clear(); + _ = stringBuilder.Clear(); var (emoji, length) = table[i]; yield return new ReplyContentToken.EmojiToken(emoji); i += length; diff --git a/src/Pixeval/Util/UI/ReplyEmojiHelper.cs b/src/Pixeval/Util/UI/ReplyEmojiHelper.cs index 2c3f24a8..ef91c136 100644 --- a/src/Pixeval/Util/UI/ReplyEmojiHelper.cs +++ b/src/Pixeval/Util/UI/ReplyEmojiHelper.cs @@ -25,12 +25,11 @@ using System.Linq; using System.Text.RegularExpressions; using Pixeval.Misc; - namespace Pixeval.Util.UI; public static partial class ReplyEmojiHelper { - private static readonly IReadOnlyDictionary StringToEmojiTable = BuildQueryTable(); + private static readonly IReadOnlyDictionary _stringToEmojiTable = BuildQueryTable(); private static IReadOnlyDictionary BuildQueryTable() { @@ -56,12 +55,12 @@ public static partial class ReplyEmojiHelper public static PixivReplyEmoji GetReplyEmojiFromPlaceholderKey(string content) { - return StringToEmojiTable[content]; + return _stringToEmojiTable[content]; } public static IReadOnlyDictionary BuildEmojiReplacementIndexTableOfReplyContent(string replyContent) { - return Regex.Matches(replyContent, string.Join("|", StringToEmojiTable.Keys.Select(Regex.Escape))) - .ToImmutableDictionary(m => m.Index, m => (StringToEmojiTable[m.Value], m.Value.Length)); + return Regex.Matches(replyContent, string.Join("|", _stringToEmojiTable.Keys.Select(Regex.Escape))) + .ToImmutableDictionary(m => m.Index, m => (_stringToEmojiTable[m.Value], m.Value.Length)); } } \ No newline at end of file diff --git a/src/Pixeval/Util/UI/ToastNotificationHelper.cs b/src/Pixeval/Util/UI/ToastNotificationHelper.cs index e86b3a8c..1fadd369 100644 --- a/src/Pixeval/Util/UI/ToastNotificationHelper.cs +++ b/src/Pixeval/Util/UI/ToastNotificationHelper.cs @@ -71,11 +71,11 @@ public static class ToastNotificationHelper ["progressValue"] = $"{progress.Normalize(100, 0):#.#}" } }; - ToastNotificationManager.CreateToastNotifier().Update(data, _tag); + _ = ToastNotificationManager.CreateToastNotifier().Update(data, _tag); } } - private static readonly PropertyInfo AppLogoOverrideUriProperty = typeof(ToastContentBuilder).GetProperty("AppLogoOverrideUri", BindingFlags.NonPublic | BindingFlags.Instance)!; + private static readonly PropertyInfo _appLogoOverrideUriProperty = typeof(ToastContentBuilder).GetProperty("AppLogoOverrideUri", BindingFlags.NonPublic | BindingFlags.Instance)!; public static ToastContentBuilder AddInlineImage( this ToastContentBuilder builder, @@ -134,7 +134,7 @@ public static class ToastNotificationHelper appLogoOverrideUri.AddImageQuery = query; } - AppLogoOverrideUriProperty.SetValue(builder, appLogoOverrideUri); + _appLogoOverrideUriProperty.SetValue(builder, appLogoOverrideUri); return builder; } @@ -148,7 +148,7 @@ public static class ToastNotificationHelper contentBuilder?.Invoke(builder); if (logoUri is not null) { - builder.AddAppLogoOverride(logoUri, ToastGenericAppLogoCrop.Default); + _ = builder.AddAppLogoOverride(logoUri, ToastGenericAppLogoCrop.Default); } builder.Show(); diff --git a/src/Pixeval/Util/UI/UIHelper.PInvoke.cs b/src/Pixeval/Util/UI/UIHelper.PInvoke.cs index 2026e870..55ee6524 100644 --- a/src/Pixeval/Util/UI/UIHelper.PInvoke.cs +++ b/src/Pixeval/Util/UI/UIHelper.PInvoke.cs @@ -25,13 +25,13 @@ using Windows.ApplicationModel.DataTransfer; namespace Pixeval.Util.UI; -public static partial class UIHelper +public static partial class UiHelper { // ReSharper disable once SuspiciousTypeConversion.Global - private static readonly ITaskBarList3 TaskBarList3Instance = (ITaskBarList3)new TaskBarInstance(); + private static readonly ITaskBarList3 _taskBarList3Instance = (ITaskBarList3)new TaskBarInstance(); // see https://github.com/microsoft/Windows-classic-samples/blob/main/Samples/ShareSource/wpf/DataTransferManagerHelper.cs - private static readonly Guid RiId = new(0xa5caee9b, 0x8708, 0x49d1, 0x8d, 0x36, 0x67, 0xd2, 0x5a, 0x8d, 0xa0, 0x0c); + private static readonly Guid _riId = new(0xa5caee9b, 0x8708, 0x49d1, 0x8d, 0x36, 0x67, 0xd2, 0x5a, 0x8d, 0xa0, 0x0c); public static bool TaskBarCustomizationSupported => Environment.OSVersion.Version >= new Version(6, 1); @@ -41,7 +41,7 @@ public static partial class UIHelper { if (TaskBarCustomizationSupported) { - TaskBarList3Instance.SetProgressState((nint)window.AppWindow.Id.Value, state); + _taskBarList3Instance.SetProgressState((nint)window.AppWindow.Id.Value, state); } } @@ -49,7 +49,7 @@ public static partial class UIHelper { if (TaskBarCustomizationSupported) { - TaskBarList3Instance.SetProgressValue((nint)window.AppWindow.Id.Value, progressValue, max); + _taskBarList3Instance.SetProgressValue((nint)window.AppWindow.Id.Value, progressValue, max); } } @@ -58,14 +58,14 @@ public static partial class UIHelper { var interop = DataTransferManager.As(); var manager = nint.Zero; - fixed (Guid* id = &RiId) + fixed (Guid* id = &_riId) { interop.GetForWindow((nint)window.AppWindow.Id.Value, id, (void**)&manager); return DataTransferManager.FromAbi(manager); } } - public static void ShowShareUI(this Window window) + public static void ShowShareUi(this Window window) { DataTransferManagerInterop.ShowShareUIForWindow((nint)window.AppWindow.Id.Value); } diff --git a/src/Pixeval/Util/UI/UIHelper.cs b/src/Pixeval/Util/UI/UIHelper.cs index 5a8c14b0..75865ab5 100644 --- a/src/Pixeval/Util/UI/UIHelper.cs +++ b/src/Pixeval/Util/UI/UIHelper.cs @@ -56,7 +56,7 @@ using Point = Windows.Foundation.Point; namespace Pixeval.Util.UI; -public static partial class UIHelper +public static partial class UiHelper { /// /// With higher you will get brighter color and vice-versa. @@ -142,7 +142,7 @@ public static partial class UIHelper { var transform = element.TransformToVisual((UIElement)scrollViewer.Content); var position = transform.TransformPoint(new Point(0, 0)); - scrollViewer.ChangeView(null, position.Y, null, false); + _ = scrollViewer.ChangeView(null, position.Y, null, false); } public static Storyboard CreateStoryboard(params Timeline[] animations) @@ -208,7 +208,7 @@ public static partial class UIHelper { if (sender.SelectedItem is NavigationViewItem { Tag: NavigationViewTag tag }) { - frame.Navigate(tag.NavigateTo, tag.Parameter, transitionInfo ?? new SuppressNavigationTransitionInfo()); + _ = frame.Navigate(tag.NavigateTo, tag.Parameter, transitionInfo ?? new SuppressNavigationTransitionInfo()); } } @@ -300,7 +300,7 @@ public static partial class UIHelper var qrCodeData = qrCodeGen.CreateQrCode(urlPayload, QRCodeGenerator.ECCLevel.Q); var qrCode = new BitmapByteQRCode(qrCodeData); var bytes = qrCode.GetGraphic(20); - return await (await IOHelper.GetRandomAccessStreamFromByteArrayAsync(bytes)).GetSoftwareBitmapSourceAsync(true); + return await (await IoHelper.GetRandomAccessStreamFromByteArrayAsync(bytes)).GetSoftwareBitmapSourceAsync(true); } public static async Task GenerateQrCodeAsync(string content) @@ -309,7 +309,7 @@ public static partial class UIHelper var qrCodeData = qrCodeGen.CreateQrCode(content, QRCodeGenerator.ECCLevel.Q); var qrCode = new BitmapByteQRCode(qrCodeData); var bytes = qrCode.GetGraphic(20); - return await (await IOHelper.GetRandomAccessStreamFromByteArrayAsync(bytes)).GetSoftwareBitmapSourceAsync(true); + return await (await IoHelper.GetRandomAccessStreamFromByteArrayAsync(bytes)).GetSoftwareBitmapSourceAsync(true); } public static IAsyncOperation OpenFolderPickerAsync(PickerLocationId suggestedStartLocation) diff --git a/src/Pixeval/Util/UI/XamlUICommandHelper.cs b/src/Pixeval/Util/UI/XamlUICommandHelper.cs index 1dd1132c..1cb85de9 100644 --- a/src/Pixeval/Util/UI/XamlUICommandHelper.cs +++ b/src/Pixeval/Util/UI/XamlUICommandHelper.cs @@ -24,7 +24,7 @@ using Windows.System; namespace Pixeval.Util.UI; -public static class XamlUICommandHelper +public static class XamlUiCommandHelper { public static XamlUICommand GetCommand(this string label, FontIconSymbols icon) { diff --git a/src/Pixeval/packages.lock.json b/src/Pixeval/packages.lock.json index f390a81a..31a8388d 100644 --- a/src/Pixeval/packages.lock.json +++ b/src/Pixeval/packages.lock.json @@ -1,7 +1,7 @@ { "version": 1, "dependencies": { - "net8.0-windows10.0.19041": { + "net8.0-windows10.0.22621": { "CommunityToolkit.Diagnostics": { "type": "Direct", "requested": "[8.2.2, )", @@ -136,6 +136,15 @@ "Microsoft.Extensions.Options": "8.0.0" } }, + "Microsoft.Graphics.Win2D": { + "type": "Direct", + "requested": "[1.1.0, )", + "resolved": "1.1.0", + "contentHash": "bHHnKtvoIGitm7EiOtENw3J1E9DSDAzJcrNhwve6nMvMoiFwtRnSZRO0mB1t0QYKhaZD6zM9Rq5kvBmiu4nelQ==", + "dependencies": { + "Microsoft.WindowsAppSDK": "1.4.230913002" + } + }, "Microsoft.IO.RecyclableMemoryStream": { "type": "Direct", "requested": "[2.3.2, )", @@ -557,14 +566,6 @@ "resolved": "8.0.0", "contentHash": "bXJEZrW9ny8vjMF1JV253WeLhpEVzFo1lyaZu1vQ4ZxWUlVvknZ/+ftFgVheLubb4eZPSwwxBeqS1JkCOjxd8g==" }, - "Microsoft.Graphics.Win2D": { - "type": "Transitive", - "resolved": "1.0.5.1", - "contentHash": "9DVEVvyQWWz8kqhsFBAx9Zv4KRIAcmxuT7kFpK1Fgh6czSiMB+CQW0DlhZXT44Mtv41FRXG47lhEv+7a2YyiLA==", - "dependencies": { - "Microsoft.WindowsAppSDK": "1.0.4" - } - }, "Microsoft.NETCore.Platforms": { "type": "Transitive", "resolved": "3.1.0", @@ -671,7 +672,6 @@ "CommunityToolkit.Mvvm": "[8.2.2, )", "CommunityToolkit.WinUI.Extensions": "[8.0.230907, )", "CommunityToolkit.WinUI.Triggers": "[8.0.230907, )", - "Microsoft.Graphics.Win2D": "[1.0.5.1, )", "Microsoft.Windows.SDK.BuildTools": "[10.0.22621.2428, )", "Microsoft.WindowsAppSDK": "[1.4.231008000, )", "WinUI3Utilities": "[1.1.4.3, )" @@ -692,7 +692,16 @@ } } }, - "net8.0-windows10.0.19041/win-arm64": { + "net8.0-windows10.0.22621/win-arm64": { + "Microsoft.Graphics.Win2D": { + "type": "Direct", + "requested": "[1.1.0, )", + "resolved": "1.1.0", + "contentHash": "bHHnKtvoIGitm7EiOtENw3J1E9DSDAzJcrNhwve6nMvMoiFwtRnSZRO0mB1t0QYKhaZD6zM9Rq5kvBmiu4nelQ==", + "dependencies": { + "Microsoft.WindowsAppSDK": "1.4.230913002" + } + }, "Microsoft.WindowsAppSDK": { "type": "Direct", "requested": "[1.4.231008000, )", @@ -702,14 +711,6 @@ "Microsoft.Windows.SDK.BuildTools": "10.0.22621.1" } }, - "Microsoft.Graphics.Win2D": { - "type": "Transitive", - "resolved": "1.0.5.1", - "contentHash": "9DVEVvyQWWz8kqhsFBAx9Zv4KRIAcmxuT7kFpK1Fgh6czSiMB+CQW0DlhZXT44Mtv41FRXG47lhEv+7a2YyiLA==", - "dependencies": { - "Microsoft.WindowsAppSDK": "1.0.4" - } - }, "Microsoft.Win32.Registry": { "type": "Transitive", "resolved": "4.7.0", @@ -761,7 +762,16 @@ "contentHash": "yev/k9GHAEGx2Rg3/tU6MQh4HGBXJs70y7j1LaM1i/ER9po+6nnQ6RRqTJn1E7Xu0fbIFK80Nh5EoODxrbxwBQ==" } }, - "net8.0-windows10.0.19041/win-x64": { + "net8.0-windows10.0.22621/win-x64": { + "Microsoft.Graphics.Win2D": { + "type": "Direct", + "requested": "[1.1.0, )", + "resolved": "1.1.0", + "contentHash": "bHHnKtvoIGitm7EiOtENw3J1E9DSDAzJcrNhwve6nMvMoiFwtRnSZRO0mB1t0QYKhaZD6zM9Rq5kvBmiu4nelQ==", + "dependencies": { + "Microsoft.WindowsAppSDK": "1.4.230913002" + } + }, "Microsoft.WindowsAppSDK": { "type": "Direct", "requested": "[1.4.231008000, )", @@ -771,14 +781,6 @@ "Microsoft.Windows.SDK.BuildTools": "10.0.22621.1" } }, - "Microsoft.Graphics.Win2D": { - "type": "Transitive", - "resolved": "1.0.5.1", - "contentHash": "9DVEVvyQWWz8kqhsFBAx9Zv4KRIAcmxuT7kFpK1Fgh6czSiMB+CQW0DlhZXT44Mtv41FRXG47lhEv+7a2YyiLA==", - "dependencies": { - "Microsoft.WindowsAppSDK": "1.0.4" - } - }, "Microsoft.Win32.Registry": { "type": "Transitive", "resolved": "4.7.0", @@ -830,7 +832,16 @@ "contentHash": "yev/k9GHAEGx2Rg3/tU6MQh4HGBXJs70y7j1LaM1i/ER9po+6nnQ6RRqTJn1E7Xu0fbIFK80Nh5EoODxrbxwBQ==" } }, - "net8.0-windows10.0.19041/win-x86": { + "net8.0-windows10.0.22621/win-x86": { + "Microsoft.Graphics.Win2D": { + "type": "Direct", + "requested": "[1.1.0, )", + "resolved": "1.1.0", + "contentHash": "bHHnKtvoIGitm7EiOtENw3J1E9DSDAzJcrNhwve6nMvMoiFwtRnSZRO0mB1t0QYKhaZD6zM9Rq5kvBmiu4nelQ==", + "dependencies": { + "Microsoft.WindowsAppSDK": "1.4.230913002" + } + }, "Microsoft.WindowsAppSDK": { "type": "Direct", "requested": "[1.4.231008000, )", @@ -840,14 +851,6 @@ "Microsoft.Windows.SDK.BuildTools": "10.0.22621.1" } }, - "Microsoft.Graphics.Win2D": { - "type": "Transitive", - "resolved": "1.0.5.1", - "contentHash": "9DVEVvyQWWz8kqhsFBAx9Zv4KRIAcmxuT7kFpK1Fgh6czSiMB+CQW0DlhZXT44Mtv41FRXG47lhEv+7a2YyiLA==", - "dependencies": { - "Microsoft.WindowsAppSDK": "1.0.4" - } - }, "Microsoft.Win32.Registry": { "type": "Transitive", "resolved": "4.7.0",