diff --git a/src/Snap.Hutao/Snap.Hutao.Test/BaseClassLibrary/TypeReflectionTest.cs b/src/Snap.Hutao/Snap.Hutao.Test/BaseClassLibrary/TypeReflectionTest.cs index 42020e6d..668fc70a 100644 --- a/src/Snap.Hutao/Snap.Hutao.Test/BaseClassLibrary/TypeReflectionTest.cs +++ b/src/Snap.Hutao/Snap.Hutao.Test/BaseClassLibrary/TypeReflectionTest.cs @@ -1,5 +1,4 @@ -using Microsoft.VisualStudio.TestTools.UnitTesting; -using System; +using System; namespace Snap.Hutao.Test.BaseClassLibrary; diff --git a/src/Snap.Hutao/Snap.Hutao.Test/BaseClassLibrary/UnsafeAccessorTest.cs b/src/Snap.Hutao/Snap.Hutao.Test/BaseClassLibrary/UnsafeAccessorTest.cs index 28c7c74f..0019bdc8 100644 --- a/src/Snap.Hutao/Snap.Hutao.Test/BaseClassLibrary/UnsafeAccessorTest.cs +++ b/src/Snap.Hutao/Snap.Hutao.Test/BaseClassLibrary/UnsafeAccessorTest.cs @@ -16,7 +16,7 @@ public class UnsafeAccessorTest [UnsafeAccessor(UnsafeAccessorKind.Method, Name = "get_TestProperty")] private static extern int InternalGetInterfaceProperty(ITestInterface instance); - interface ITestInterface + internal interface ITestInterface { internal int TestProperty { get; } } diff --git a/src/Snap.Hutao/Snap.Hutao/Control/Collection/AdvancedCollectionView/VectorChangedEventArgs.cs b/src/Snap.Hutao/Snap.Hutao/Control/Collection/AdvancedCollectionView/VectorChangedEventArgs.cs index d0e1a439..c5cb362b 100644 --- a/src/Snap.Hutao/Snap.Hutao/Control/Collection/AdvancedCollectionView/VectorChangedEventArgs.cs +++ b/src/Snap.Hutao/Snap.Hutao/Control/Collection/AdvancedCollectionView/VectorChangedEventArgs.cs @@ -7,7 +7,7 @@ namespace Snap.Hutao.Control.Collection.AdvancedCollectionView; internal sealed class VectorChangedEventArgs : IVectorChangedEventArgs { - public VectorChangedEventArgs(CollectionChange cc, int index = -1, object item = null!) + public VectorChangedEventArgs(CollectionChange cc, int index = -1, object item = default!) { CollectionChange = cc; Index = (uint)index; diff --git a/src/Snap.Hutao/Snap.Hutao/Control/Layout/WrapLayoutState.cs b/src/Snap.Hutao/Snap.Hutao/Control/Layout/WrapLayoutState.cs index 4f18691a..5a25f9de 100644 --- a/src/Snap.Hutao/Snap.Hutao/Control/Layout/WrapLayoutState.cs +++ b/src/Snap.Hutao/Snap.Hutao/Control/Layout/WrapLayoutState.cs @@ -25,10 +25,7 @@ internal sealed class WrapLayoutState public WrapItem GetItemAt(int index) { - if (index < 0) - { - throw new IndexOutOfRangeException(); - } + ArgumentOutOfRangeException.ThrowIfNegative(index); if (index <= (items.Count - 1)) { diff --git a/src/Snap.Hutao/Snap.Hutao/Core/ExceptionService/DatabaseCorruptedException.cs b/src/Snap.Hutao/Snap.Hutao/Core/ExceptionService/DatabaseCorruptedException.cs deleted file mode 100644 index f66043bf..00000000 --- a/src/Snap.Hutao/Snap.Hutao/Core/ExceptionService/DatabaseCorruptedException.cs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (c) DGP Studio. All rights reserved. -// Licensed under the MIT license. - -namespace Snap.Hutao.Core.ExceptionService; - -/// -/// 数据库损坏异常 -/// -[HighQuality] -[Obsolete("Use HutaoException instead")] -internal sealed class DatabaseCorruptedException : Exception -{ - /// - /// 构造一个新的用户数据损坏异常 - /// - /// 消息 - /// 内部错误 - public DatabaseCorruptedException(string message, Exception? innerException) - : base(SH.FormatCoreExceptionServiceDatabaseCorruptedMessage($"{message}\n{innerException?.Message}"), innerException) - { - } -} \ No newline at end of file diff --git a/src/Snap.Hutao/Snap.Hutao/Core/ExceptionService/HutaoException.cs b/src/Snap.Hutao/Snap.Hutao/Core/ExceptionService/HutaoException.cs index 923a9481..e90e4b22 100644 --- a/src/Snap.Hutao/Snap.Hutao/Core/ExceptionService/HutaoException.cs +++ b/src/Snap.Hutao/Snap.Hutao/Core/ExceptionService/HutaoException.cs @@ -1,6 +1,8 @@ // Copyright (c) DGP Studio. All rights reserved. // Licensed under the MIT license. +using System.Runtime.CompilerServices; + namespace Snap.Hutao.Core.ExceptionService; internal sealed class HutaoException : Exception @@ -11,11 +13,13 @@ internal sealed class HutaoException : Exception } [DoesNotReturn] + [MethodImpl(MethodImplOptions.NoInlining)] public static HutaoException Throw(string message, Exception? innerException = default) { throw new HutaoException(message, innerException); } + [MethodImpl(MethodImplOptions.NoInlining)] public static void ThrowIf([DoesNotReturnIf(true)] bool condition, string message, Exception? innerException = default) { if (condition) @@ -24,6 +28,7 @@ internal sealed class HutaoException : Exception } } + [MethodImpl(MethodImplOptions.NoInlining)] public static void ThrowIfNot([DoesNotReturnIf(false)] bool condition, string message, Exception? innerException = default) { if (!condition) @@ -33,18 +38,28 @@ internal sealed class HutaoException : Exception } [DoesNotReturn] + [MethodImpl(MethodImplOptions.NoInlining)] + public static ArgumentException Argument(string message, string? paramName) + { + throw new ArgumentException(message, paramName); + } + + [DoesNotReturn] + [MethodImpl(MethodImplOptions.NoInlining)] public static HutaoException GachaStatisticsInvalidItemId(uint id, Exception? innerException = default) { throw new HutaoException(SH.FormatServiceGachaStatisticsFactoryItemIdInvalid(id), innerException); } [DoesNotReturn] + [MethodImpl(MethodImplOptions.NoInlining)] public static HutaoException UserdataCorrupted(string message, Exception? innerException = default) { throw new HutaoException(message, innerException); } [DoesNotReturn] + [MethodImpl(MethodImplOptions.NoInlining)] public static InvalidCastException InvalidCast(string name, Exception? innerException = default) { string message = $"This instance of '{typeof(TFrom).FullName}' '{name}' doesn't implement '{typeof(TTo).FullName}'"; @@ -52,18 +67,21 @@ internal sealed class HutaoException : Exception } [DoesNotReturn] + [MethodImpl(MethodImplOptions.NoInlining)] public static InvalidOperationException InvalidOperation(string message, Exception? innerException = default) { throw new InvalidOperationException(message, innerException); } [DoesNotReturn] + [MethodImpl(MethodImplOptions.NoInlining)] public static NotSupportedException NotSupported(string? message = default, Exception? innerException = default) { throw new NotSupportedException(message, innerException); } [DoesNotReturn] + [MethodImpl(MethodImplOptions.NoInlining)] public static OperationCanceledException OperationCanceled(string message, Exception? innerException = default) { throw new OperationCanceledException(message, innerException); diff --git a/src/Snap.Hutao/Snap.Hutao/Core/ExceptionService/RuntimeEnvironmentException.cs b/src/Snap.Hutao/Snap.Hutao/Core/ExceptionService/RuntimeEnvironmentException.cs deleted file mode 100644 index a9c82957..00000000 --- a/src/Snap.Hutao/Snap.Hutao/Core/ExceptionService/RuntimeEnvironmentException.cs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (c) DGP Studio. All rights reserved. -// Licensed under the MIT license. - -namespace Snap.Hutao.Core.ExceptionService; - -/// -/// 运行环境异常 -/// 用户的计算机中的某些设置不符合要求 -/// -[HighQuality] -[Obsolete("Use HutaoException instead")] -internal sealed class RuntimeEnvironmentException : Exception -{ - /// - /// 构造一个新的运行环境异常 - /// - /// 消息 - /// 内部错误 - public RuntimeEnvironmentException(string message, Exception? innerException) - : base($"{message}\n{innerException?.Message}", innerException) - { - } -} \ No newline at end of file diff --git a/src/Snap.Hutao/Snap.Hutao/Core/ExceptionService/ThrowHelper.cs b/src/Snap.Hutao/Snap.Hutao/Core/ExceptionService/ThrowHelper.cs index 38b1fec1..5cdf3e36 100644 --- a/src/Snap.Hutao/Snap.Hutao/Core/ExceptionService/ThrowHelper.cs +++ b/src/Snap.Hutao/Snap.Hutao/Core/ExceptionService/ThrowHelper.cs @@ -1,9 +1,6 @@ // Copyright (c) DGP Studio. All rights reserved. // Licensed under the MIT license. -using Snap.Hutao.Service.Game; -using Snap.Hutao.Service.Game.Package; -using System.IO; using System.Runtime.CompilerServices; namespace Snap.Hutao.Core.ExceptionService; @@ -22,92 +19,4 @@ internal static class ThrowHelper { throw new ArgumentException(message, paramName); } - - [DoesNotReturn] - [MethodImpl(MethodImplOptions.NoInlining)] - public static DatabaseCorruptedException DatabaseCorrupted(string message, Exception? inner) - { - throw new DatabaseCorruptedException(message, inner); - } - - [DoesNotReturn] - [MethodImpl(MethodImplOptions.NoInlining)] - public static GameFileOperationException GameFileOperation(string message, Exception? inner) - { - throw new GameFileOperationException(message, inner); - } - - [DoesNotReturn] - [MethodImpl(MethodImplOptions.NoInlining)] - public static InvalidDataException InvalidData(string message, Exception? inner = default) - { - throw new InvalidDataException(message, inner); - } - - [MethodImpl(MethodImplOptions.NoInlining)] - public static void InvalidDataIf([DoesNotReturnIf(true)] bool condition, string message, Exception? inner = default) - { - if (condition) - { - throw new InvalidDataException(message, inner); - } - } - - [DoesNotReturn] - [MethodImpl(MethodImplOptions.NoInlining)] - public static InvalidOperationException InvalidOperation(string message, Exception? inner = default) - { - throw new InvalidOperationException(message, inner); - } - - [DoesNotReturn] - [MethodImpl(MethodImplOptions.NoInlining)] - public static NotSupportedException NotSupported() - { - throw new NotSupportedException(); - } - - [DoesNotReturn] - [MethodImpl(MethodImplOptions.NoInlining)] - public static NotSupportedException NotSupported(string message) - { - throw new NotSupportedException(message); - } - - [MethodImpl(MethodImplOptions.NoInlining)] - public static void NotSupportedIf(bool condition, string message) - { - if (condition) - { - throw new NotSupportedException(message); - } - } - - [DoesNotReturn] - [MethodImpl(MethodImplOptions.NoInlining)] - public static OperationCanceledException OperationCanceled(string message, Exception? inner = default) - { - throw new OperationCanceledException(message, inner); - } - - [DoesNotReturn] - [MethodImpl(MethodImplOptions.NoInlining)] - public static PackageConvertException PackageConvert(string message, Exception? inner = default) - { - throw new PackageConvertException(message, inner); - } - - [DoesNotReturn] - [MethodImpl(MethodImplOptions.NoInlining)] - public static RuntimeEnvironmentException RuntimeEnvironment(string message, Exception? inner) - { - throw new RuntimeEnvironmentException(message, inner); - } - - [DoesNotReturn] - [MethodImpl(MethodImplOptions.NoInlining)] - public static UserdataCorruptedException UserdataCorrupted(string message, Exception? inner) - { - throw new UserdataCorruptedException(message, inner); - } } \ No newline at end of file diff --git a/src/Snap.Hutao/Snap.Hutao/Core/ExceptionService/UserdataCorruptedException.cs b/src/Snap.Hutao/Snap.Hutao/Core/ExceptionService/UserdataCorruptedException.cs deleted file mode 100644 index d8de5ec5..00000000 --- a/src/Snap.Hutao/Snap.Hutao/Core/ExceptionService/UserdataCorruptedException.cs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (c) DGP Studio. All rights reserved. -// Licensed under the MIT license. - -namespace Snap.Hutao.Core.ExceptionService; - -/// -/// 用户数据损坏异常 -/// -[HighQuality] -[Obsolete("Use HutaoException instead")] -internal sealed class UserdataCorruptedException : Exception -{ - /// - /// 构造一个新的用户数据损坏异常 - /// - /// 消息 - /// 内部错误 - public UserdataCorruptedException(string message, Exception? innerException) - : base(SH.FormatCoreExceptionServiceUserdataCorruptedMessage($"{message}\n{innerException?.Message}"), innerException) - { - } -} \ No newline at end of file diff --git a/src/Snap.Hutao/Snap.Hutao/Core/IO/Http/Sharding/HttpShardCopyWorker.cs b/src/Snap.Hutao/Snap.Hutao/Core/IO/Http/Sharding/HttpShardCopyWorker.cs index 3c345662..12bcd97b 100644 --- a/src/Snap.Hutao/Snap.Hutao/Core/IO/Http/Sharding/HttpShardCopyWorker.cs +++ b/src/Snap.Hutao/Snap.Hutao/Core/IO/Http/Sharding/HttpShardCopyWorker.cs @@ -78,7 +78,7 @@ internal sealed class HttpShardCopyWorker : IDisposable using (HttpResponseMessage response = await httpClient.SendAsync(request, HttpCompletionOption.ResponseHeadersRead, token).ConfigureAwait(false)) { response.EnsureSuccessStatusCode(); - using (IMemoryOwner memoryOwner = MemoryPool.Shared.Rent()) + using (IMemoryOwner memoryOwner = MemoryPool.Shared.Rent(bufferSize)) { Memory buffer = memoryOwner.Memory; using (Stream stream = await response.Content.ReadAsStreamAsync(token).ConfigureAwait(false)) diff --git a/src/Snap.Hutao/Snap.Hutao/Core/IO/StreamReaderWriter.cs b/src/Snap.Hutao/Snap.Hutao/Core/IO/StreamReaderWriter.cs index 70690a23..5dedbec3 100644 --- a/src/Snap.Hutao/Snap.Hutao/Core/IO/StreamReaderWriter.cs +++ b/src/Snap.Hutao/Snap.Hutao/Core/IO/StreamReaderWriter.cs @@ -27,6 +27,7 @@ internal sealed class StreamReaderWriter : IDisposable } /// + [SuppressMessage("", "SH003")] public Task WriteAsync(string value) { return writer.WriteAsync(value); diff --git a/src/Snap.Hutao/Snap.Hutao/Core/Json/Converter/SeparatorCommaInt32EnumerableConverter.cs b/src/Snap.Hutao/Snap.Hutao/Core/Json/Converter/SeparatorCommaInt32EnumerableConverter.cs index 669e2e32..49e1773d 100644 --- a/src/Snap.Hutao/Snap.Hutao/Core/Json/Converter/SeparatorCommaInt32EnumerableConverter.cs +++ b/src/Snap.Hutao/Snap.Hutao/Core/Json/Converter/SeparatorCommaInt32EnumerableConverter.cs @@ -22,7 +22,7 @@ internal sealed class SeparatorCommaInt32EnumerableConverter : JsonConverter(); + return []; } /// diff --git a/src/Snap.Hutao/Snap.Hutao/Core/Logging/LoggerExtension.cs b/src/Snap.Hutao/Snap.Hutao/Core/Logging/LoggerExtension.cs index 747a3471..c7685cd9 100644 --- a/src/Snap.Hutao/Snap.Hutao/Core/Logging/LoggerExtension.cs +++ b/src/Snap.Hutao/Snap.Hutao/Core/Logging/LoggerExtension.cs @@ -83,9 +83,10 @@ internal static class LoggerExtension logger.LogColorized(logLevel, 0, exception, message, args); } + [SuppressMessage("", "CA2254")] public static void LogColorized(this ILogger logger, LogLevel logLevel, EventId eventId, Exception? exception, LogMessage message, params LogArgument[] args) { - string colorizedMessage = Colorize(message, args, out object?[] outArgs)!; + string? colorizedMessage = Colorize(message, args, out object?[] outArgs); logger.Log(logLevel, eventId, exception, colorizedMessage, outArgs); } diff --git a/src/Snap.Hutao/Snap.Hutao/Core/Validation/Must.cs b/src/Snap.Hutao/Snap.Hutao/Core/Validation/Must.cs deleted file mode 100644 index 712f1c81..00000000 --- a/src/Snap.Hutao/Snap.Hutao/Core/Validation/Must.cs +++ /dev/null @@ -1,56 +0,0 @@ -// Copyright (c) DGP Studio. All rights reserved. -// Licensed under the MIT license. - -using System.Runtime.CompilerServices; - -namespace Snap.Hutao.Core.Validation; - -/// -/// 封装验证方法,简化微软验证 -/// -[HighQuality] -[Obsolete("Use HutaoException instead")] -internal static class Must -{ - /// - /// Throws an if a condition does not evaluate to true. - /// - /// The condition to check. - /// message - /// The name of the parameter to blame in the exception, if thrown. - [MethodImpl(MethodImplOptions.NoInlining)] - public static void Argument([DoesNotReturnIf(false)] bool condition, string? message, [CallerArgumentExpression(nameof(condition))] string? parameterName = null) - { - if (!condition) - { - throw new ArgumentException(message, parameterName); - } - } - - /// - /// Throws an if a condition does not evaluate to true. - /// - /// The condition to check. - /// message - /// The name of the parameter to blame in the exception, if thrown. - [MethodImpl(MethodImplOptions.NoInlining)] - public static void Range([DoesNotReturnIf(false)] bool condition, string? message, [CallerArgumentExpression(nameof(condition))] string? parameterName = null) - { - if (!condition) - { - throw new ArgumentOutOfRangeException(parameterName, message); - } - } - - /// - /// Unconditionally throws an . - /// - /// 上下文 - /// Nothing. This method always throws. - [DoesNotReturn] - [MethodImpl(MethodImplOptions.NoInlining)] - public static Exception NeverHappen(string? context = null) - { - throw new NotSupportedException(context); - } -} diff --git a/src/Snap.Hutao/Snap.Hutao/Core/Windowing/HotKey/HotKeyCombination.cs b/src/Snap.Hutao/Snap.Hutao/Core/Windowing/HotKey/HotKeyCombination.cs index 481135ca..edd0c9bd 100644 --- a/src/Snap.Hutao/Snap.Hutao/Core/Windowing/HotKey/HotKeyCombination.cs +++ b/src/Snap.Hutao/Snap.Hutao/Core/Windowing/HotKey/HotKeyCombination.cs @@ -34,6 +34,7 @@ internal sealed class HotKeyCombination : ObservableObject private VirtualKey key; private bool isEnabled; + [SuppressMessage("", "SH002")] public HotKeyCombination(IServiceProvider serviceProvider, HWND hwnd, string settingKey, int hotKeyId, HOT_KEY_MODIFIERS defaultModifiers, VirtualKey defaultKey) { infoBarService = serviceProvider.GetRequiredService(); diff --git a/src/Snap.Hutao/Snap.Hutao/Core/Windowing/NotifyIcon/NotifyIconController.cs b/src/Snap.Hutao/Snap.Hutao/Core/Windowing/NotifyIcon/NotifyIconController.cs index 41619dc0..b8570522 100644 --- a/src/Snap.Hutao/Snap.Hutao/Core/Windowing/NotifyIcon/NotifyIconController.cs +++ b/src/Snap.Hutao/Snap.Hutao/Core/Windowing/NotifyIcon/NotifyIconController.cs @@ -31,6 +31,7 @@ internal sealed class NotifyIconController : IDisposable id = Unsafe.As(ref MemoryMarshal.GetArrayDataReference(MD5.HashData(Encoding.UTF8.GetBytes(iconFile.Path)))); xamlHostWindow = new(serviceProvider); + xamlHostWindow.MoveAndResize(default); messageWindow = new() { @@ -39,7 +40,6 @@ internal sealed class NotifyIconController : IDisposable }; CreateNotifyIcon(); - xamlHostWindow.MoveAndResize(GetRect()); } public void Dispose() diff --git a/src/Snap.Hutao/Snap.Hutao/Core/Windowing/NotifyIcon/NotifyIconMessageWindow.cs b/src/Snap.Hutao/Snap.Hutao/Core/Windowing/NotifyIcon/NotifyIconMessageWindow.cs index 39b6edf0..2269eaf0 100644 --- a/src/Snap.Hutao/Snap.Hutao/Core/Windowing/NotifyIcon/NotifyIconMessageWindow.cs +++ b/src/Snap.Hutao/Snap.Hutao/Core/Windowing/NotifyIcon/NotifyIconMessageWindow.cs @@ -143,6 +143,7 @@ internal sealed class NotifyIconMessageWindow : IDisposable return DefWindowProcW(hwnd, uMsg, wParam, lParam); } + [UnconditionalSuppressMessage("", "CS0649")] private readonly struct LPARAM2 { public readonly uint Low; diff --git a/src/Snap.Hutao/Snap.Hutao/Core/Windowing/XamlWindowNonRudeHWND.cs b/src/Snap.Hutao/Snap.Hutao/Core/Windowing/XamlWindowNonRudeHWND.cs index 6c993d32..8bc003b8 100644 --- a/src/Snap.Hutao/Snap.Hutao/Core/Windowing/XamlWindowNonRudeHWND.cs +++ b/src/Snap.Hutao/Snap.Hutao/Core/Windowing/XamlWindowNonRudeHWND.cs @@ -12,6 +12,7 @@ internal sealed class XamlWindowNonRudeHWND : IDisposable private const string NonRudeHWND = "NonRudeHWND"; private readonly HWND hwnd; + [SuppressMessage("", "SH002")] public XamlWindowNonRudeHWND(HWND hwnd) { this.hwnd = hwnd; diff --git a/src/Snap.Hutao/Snap.Hutao/GlobalUsing.cs b/src/Snap.Hutao/Snap.Hutao/GlobalUsing.cs index 5ba3272f..f49632c2 100644 --- a/src/Snap.Hutao/Snap.Hutao/GlobalUsing.cs +++ b/src/Snap.Hutao/Snap.Hutao/GlobalUsing.cs @@ -14,7 +14,6 @@ global using Snap.Hutao.Core.Annotation; global using Snap.Hutao.Core.DependencyInjection; global using Snap.Hutao.Core.DependencyInjection.Annotation; global using Snap.Hutao.Core.Threading; -global using Snap.Hutao.Core.Validation; global using Snap.Hutao.Extension; global using Snap.Hutao.Resource.Localization; diff --git a/src/Snap.Hutao/Snap.Hutao/Model/Intrinsic/Frozen/IntrinsicFrozen.cs b/src/Snap.Hutao/Snap.Hutao/Model/Intrinsic/Frozen/IntrinsicFrozen.cs index 7d9604a8..b214f0f7 100644 --- a/src/Snap.Hutao/Snap.Hutao/Model/Intrinsic/Frozen/IntrinsicFrozen.cs +++ b/src/Snap.Hutao/Snap.Hutao/Model/Intrinsic/Frozen/IntrinsicFrozen.cs @@ -11,25 +11,25 @@ namespace Snap.Hutao.Model.Intrinsic.Frozen; [HighQuality] internal static class IntrinsicFrozen { - public static FrozenSet AssociationTypes { get; } = Enum.GetValues().Select(e => e.GetLocalizedDescriptionOrDefault()).OfType().ToFrozenSet(); + public static FrozenSet AssociationTypes { get; } = NamesFromEnum(e => e.GetLocalizedDescriptionOrDefault()); - public static FrozenSet> AssociationTypeNameValues { get; } = Enum.GetValues().Select(e => new NameValue(e.GetLocalizedDescriptionOrDefault()!, e)).Where(nv => !string.IsNullOrEmpty(nv.Name)).ToFrozenSet(); + public static FrozenSet> AssociationTypeNameValues { get; } = NameValuesFromEnum(e => e.GetLocalizedDescriptionOrDefault()); - public static FrozenSet WeaponTypes { get; } = Enum.GetValues().Select(e => e.GetLocalizedDescriptionOrDefault()).OfType().ToFrozenSet(); + public static FrozenSet WeaponTypes { get; } = NamesFromEnum(e => e.GetLocalizedDescriptionOrDefault()); - public static FrozenSet> WeaponTypeNameValues { get; } = Enum.GetValues().Select(e => new NameValue(e.GetLocalizedDescriptionOrDefault()!, e)).Where(nv => !string.IsNullOrEmpty(nv.Name)).ToFrozenSet(); + public static FrozenSet> WeaponTypeNameValues { get; } = NameValuesFromEnum(e => e.GetLocalizedDescriptionOrDefault()); - public static FrozenSet ItemQualities { get; } = Enum.GetValues().Select(e => e.GetLocalizedDescriptionOrDefault()).OfType().ToFrozenSet(); + public static FrozenSet ItemQualities { get; } = NamesFromEnum(e => e.GetLocalizedDescriptionOrDefault()); - public static FrozenSet> ItemQualityNameValues { get; } = Enum.GetValues().Select(e => new NameValue(e.GetLocalizedDescriptionOrDefault()!, e)).Where(nv => !string.IsNullOrEmpty(nv.Name)).ToFrozenSet(); + public static FrozenSet> ItemQualityNameValues { get; } = NameValuesFromEnum(e => e.GetLocalizedDescriptionOrDefault()); - public static FrozenSet BodyTypes { get; } = Enum.GetValues().Select(e => e.GetLocalizedDescriptionOrDefault()).OfType().ToFrozenSet(); + public static FrozenSet BodyTypes { get; } = NamesFromEnum(e => e.GetLocalizedDescriptionOrDefault()); - public static FrozenSet> BodyTypeNameValues { get; } = Enum.GetValues().Select(e => new NameValue(e.GetLocalizedDescriptionOrDefault()!, e)).Where(nv => !string.IsNullOrEmpty(nv.Name)).ToFrozenSet(); + public static FrozenSet> BodyTypeNameValues { get; } = NameValuesFromEnum(e => e.GetLocalizedDescriptionOrDefault()); - public static FrozenSet FightProperties { get; } = Enum.GetValues().Select(e => e.GetLocalizedDescriptionOrDefault()).OfType().ToFrozenSet(); + public static FrozenSet FightProperties { get; } = NamesFromEnum(e => e.GetLocalizedDescriptionOrDefault()); - public static FrozenSet> FightPropertyNameValues { get; } = Enum.GetValues().Select(e => new NameValue(e.GetLocalizedDescriptionOrDefault()!, e)).Where(nv => !string.IsNullOrEmpty(nv.Name)).ToFrozenSet(); + public static FrozenSet> FightPropertyNameValues { get; } = NameValuesFromEnum(e => e.GetLocalizedDescriptionOrDefault()); public static FrozenSet ElementNames { get; } = FrozenSet.ToFrozenSet( [ @@ -63,4 +63,50 @@ internal static class IntrinsicFrozen SH.ModelMetadataMaterialWeaponEnhancementMaterial, SH.ModelMetadataMaterialWeaponAscensionMaterial, ]); + + private static FrozenSet NamesFromEnum(Func selector) + where TEnum : struct, Enum + { + return NamesFromEnumValues(Enum.GetValues(), selector); + } + + private static FrozenSet NamesFromEnumValues(TEnum[] values, Func selector) + { + return NotNull(values, selector).ToFrozenSet(); + + static IEnumerable NotNull(TEnum[] values, Func selector) + { + foreach (TEnum value in values) + { + string? name = selector(value); + if (!string.IsNullOrEmpty(name)) + { + yield return name; + } + } + } + } + + private static FrozenSet> NameValuesFromEnum(Func selector) + where TEnum : struct, Enum + { + return NameValuesFromEnumValues(Enum.GetValues(), selector); + } + + private static FrozenSet> NameValuesFromEnumValues(TEnum[] values, Func selector) + { + return NotNull(values, selector).ToFrozenSet(); + + static IEnumerable> NotNull(TEnum[] values, Func selector) + { + foreach (TEnum value in values) + { + string? name = selector(value); + if (!string.IsNullOrEmpty(name)) + { + yield return new(name, value); + } + } + } + } } \ No newline at end of file diff --git a/src/Snap.Hutao/Snap.Hutao/Service/AvatarInfo/AvatarInfoDbBulkOperation.cs b/src/Snap.Hutao/Snap.Hutao/Service/AvatarInfo/AvatarInfoDbBulkOperation.cs index 222047b3..4e6bca1c 100644 --- a/src/Snap.Hutao/Snap.Hutao/Service/AvatarInfo/AvatarInfoDbBulkOperation.cs +++ b/src/Snap.Hutao/Snap.Hutao/Service/AvatarInfo/AvatarInfoDbBulkOperation.cs @@ -32,7 +32,7 @@ internal sealed partial class AvatarInfoDbBulkOperation public async ValueTask> UpdateDbAvatarInfosByShowcaseAsync(string uid, IEnumerable webInfos, CancellationToken token) { - List dbInfos = await avatarInfoDbService.GetAvatarInfoListByUidAsync(uid).ConfigureAwait(false); + List dbInfos = await avatarInfoDbService.GetAvatarInfoListByUidAsync(uid, token).ConfigureAwait(false); EnsureItemsAvatarIdUnique(ref dbInfos, uid, out Dictionary dbInfoMap); using (IServiceScope scope = serviceProvider.CreateScope()) @@ -50,14 +50,14 @@ internal sealed partial class AvatarInfoDbBulkOperation AddOrUpdateAvatarInfo(entity, uid, appDbContext, webInfo); } - return await avatarInfoDbService.GetAvatarInfoListByUidAsync(uid).ConfigureAwait(false); + return await avatarInfoDbService.GetAvatarInfoListByUidAsync(uid, token).ConfigureAwait(false); } } public async ValueTask> UpdateDbAvatarInfosByGameRecordCharacterAsync(UserAndUid userAndUid, CancellationToken token) { string uid = userAndUid.Uid.Value; - List dbInfos = await avatarInfoDbService.GetAvatarInfoListByUidAsync(uid).ConfigureAwait(false); + List dbInfos = await avatarInfoDbService.GetAvatarInfoListByUidAsync(uid, token).ConfigureAwait(false); EnsureItemsAvatarIdUnique(ref dbInfos, uid, out Dictionary dbInfoMap); using (IServiceScope scope = serviceProvider.CreateScope()) @@ -103,14 +103,14 @@ internal sealed partial class AvatarInfoDbBulkOperation } Return: - return await avatarInfoDbService.GetAvatarInfoListByUidAsync(uid).ConfigureAwait(false); + return await avatarInfoDbService.GetAvatarInfoListByUidAsync(uid, token).ConfigureAwait(false); } public async ValueTask> UpdateDbAvatarInfosByCalculateAvatarDetailAsync(UserAndUid userAndUid, CancellationToken token) { token.ThrowIfCancellationRequested(); string uid = userAndUid.Uid.Value; - List dbInfos = await avatarInfoDbService.GetAvatarInfoListByUidAsync(uid).ConfigureAwait(false); + List dbInfos = await avatarInfoDbService.GetAvatarInfoListByUidAsync(uid, token).ConfigureAwait(false); EnsureItemsAvatarIdUnique(ref dbInfos, uid, out Dictionary dbInfoMap); using (IServiceScope scope = serviceProvider.CreateScope()) @@ -146,7 +146,7 @@ internal sealed partial class AvatarInfoDbBulkOperation } } - return await avatarInfoDbService.GetAvatarInfoListByUidAsync(uid).ConfigureAwait(false); + return await avatarInfoDbService.GetAvatarInfoListByUidAsync(uid, token).ConfigureAwait(false); } [MethodImpl(MethodImplOptions.AggressiveInlining)] diff --git a/src/Snap.Hutao/Snap.Hutao/Service/AvatarInfo/Factory/Builder/AvatarViewBuilderExtension.cs b/src/Snap.Hutao/Snap.Hutao/Service/AvatarInfo/Factory/Builder/AvatarViewBuilderExtension.cs index 12b2164a..e139a9ab 100644 --- a/src/Snap.Hutao/Snap.Hutao/Service/AvatarInfo/Factory/Builder/AvatarViewBuilderExtension.cs +++ b/src/Snap.Hutao/Snap.Hutao/Service/AvatarInfo/Factory/Builder/AvatarViewBuilderExtension.cs @@ -32,6 +32,7 @@ internal static class AvatarViewBuilderExtension return builder; } + [SuppressMessage("", "SH002")] public static TBuilder SetCalculatorRefreshTimeFormat(this TBuilder builder, DateTimeOffset refreshTime, Func format, string defaultValue) where TBuilder : IAvatarViewBuilder { @@ -116,6 +117,7 @@ internal static class AvatarViewBuilderExtension return builder.Configure(b => b.View.FetterLevel = level); } + [SuppressMessage("", "SH002")] public static TBuilder SetGameRecordRefreshTimeFormat(this TBuilder builder, DateTimeOffset refreshTime, Func format, string defaultValue) where TBuilder : IAvatarViewBuilder { @@ -128,6 +130,7 @@ internal static class AvatarViewBuilderExtension return builder.Configure(b => b.View.GameRecordRefreshTimeFormat = gameRecordRefreshTimeFormat); } + [SuppressMessage("", "SH002")] public static TBuilder SetId(this TBuilder builder, AvatarId id) where TBuilder : IAvatarViewBuilder { @@ -175,6 +178,7 @@ internal static class AvatarViewBuilderExtension return builder.Configure(b => b.View.Reliquaries = reliquaries); } + [SuppressMessage("", "SH002")] public static TBuilder SetShowcaseRefreshTimeFormat(this TBuilder builder, DateTimeOffset refreshTime, Func format, string defaultValue) where TBuilder : IAvatarViewBuilder { diff --git a/src/Snap.Hutao/Snap.Hutao/Service/AvatarInfo/Factory/Builder/WeaponViewBuilderExtension.cs b/src/Snap.Hutao/Snap.Hutao/Service/AvatarInfo/Factory/Builder/WeaponViewBuilderExtension.cs index 61b16311..4920d77f 100644 --- a/src/Snap.Hutao/Snap.Hutao/Service/AvatarInfo/Factory/Builder/WeaponViewBuilderExtension.cs +++ b/src/Snap.Hutao/Snap.Hutao/Service/AvatarInfo/Factory/Builder/WeaponViewBuilderExtension.cs @@ -43,6 +43,7 @@ internal static class WeaponViewBuilderExtension return builder.SetIcon(icon); } + [SuppressMessage("", "SH002")] public static TBuilder SetId(this TBuilder builder, WeaponId id) where TBuilder : IWeaponViewBuilder { diff --git a/src/Snap.Hutao/Snap.Hutao/Service/Cultivation/MaterialIdComparer.cs b/src/Snap.Hutao/Snap.Hutao/Service/Cultivation/MaterialIdComparer.cs index b579335e..496ee437 100644 --- a/src/Snap.Hutao/Snap.Hutao/Service/Cultivation/MaterialIdComparer.cs +++ b/src/Snap.Hutao/Snap.Hutao/Service/Cultivation/MaterialIdComparer.cs @@ -12,11 +12,13 @@ internal sealed class MaterialIdComparer : IComparer public static MaterialIdComparer Shared { get => LazyInitializer.EnsureInitialized(ref shared, ref syncRoot, () => new()); } + [SuppressMessage("", "SH002")] public int Compare(MaterialId x, MaterialId y) { return Transform(x).CompareTo(Transform(y)); } + [SuppressMessage("", "SH002")] private static uint Transform(MaterialId value) { return value.Value switch diff --git a/src/Snap.Hutao/Snap.Hutao/Service/DailyNote/NotifySuppression/NotifySuppressionContext.cs b/src/Snap.Hutao/Snap.Hutao/Service/DailyNote/NotifySuppression/NotifySuppressionContext.cs index aa0e64bd..cdbd654b 100644 --- a/src/Snap.Hutao/Snap.Hutao/Service/DailyNote/NotifySuppression/NotifySuppressionContext.cs +++ b/src/Snap.Hutao/Snap.Hutao/Service/DailyNote/NotifySuppression/NotifySuppressionContext.cs @@ -18,6 +18,7 @@ internal sealed class NotifySuppressionContext : INotifySuppressionContext public DailyNoteEntry Entry { get => entry; } + [SuppressMessage("", "SH002")] public void Add(DailyNoteNotifyInfo info) { infos.Add(info); diff --git a/src/Snap.Hutao/Snap.Hutao/Service/Game/Account/RegistryInterop.cs b/src/Snap.Hutao/Snap.Hutao/Service/Game/Account/RegistryInterop.cs index 627fb08e..24d5dc3b 100644 --- a/src/Snap.Hutao/Snap.Hutao/Service/Game/Account/RegistryInterop.cs +++ b/src/Snap.Hutao/Snap.Hutao/Service/Game/Account/RegistryInterop.cs @@ -70,7 +70,7 @@ internal static class RegistryInterop { SchemeType.ChineseOfficial => (ChineseKeyName, SdkChineseValueName), SchemeType.Oversea => (OverseaKeyName, SdkOverseaValueName), - _ => throw ThrowHelper.NotSupported($"Invalid account SchemeType: {scheme}"), + _ => throw HutaoException.NotSupported($"Invalid account SchemeType: {scheme}"), }; } } \ No newline at end of file diff --git a/src/Snap.Hutao/Snap.Hutao/Service/Game/Automation/ScreenCapture/GameScreenCaptureContext.cs b/src/Snap.Hutao/Snap.Hutao/Service/Game/Automation/ScreenCapture/GameScreenCaptureContext.cs index ccb0d299..4c0d10f8 100644 --- a/src/Snap.Hutao/Snap.Hutao/Service/Game/Automation/ScreenCapture/GameScreenCaptureContext.cs +++ b/src/Snap.Hutao/Snap.Hutao/Service/Game/Automation/ScreenCapture/GameScreenCaptureContext.cs @@ -22,6 +22,7 @@ internal readonly struct GameScreenCaptureContext private readonly IDirect3DDevice direct3DDevice; private readonly HWND hwnd; + [SuppressMessage("", "SH002")] public GameScreenCaptureContext(IDirect3DDevice direct3DDevice, HWND hwnd) { this.direct3DDevice = direct3DDevice; @@ -87,6 +88,7 @@ internal readonly struct GameScreenCaptureContext return clientBox.right <= width && clientBox.bottom <= height; } + [SuppressMessage("", "SH002")] private static DirectXPixelFormat DeterminePixelFormat(HWND hwnd) { HDC hdc = GetDC(hwnd); diff --git a/src/Snap.Hutao/Snap.Hutao/Service/Game/Automation/ScreenCapture/GameScreenCaptureMemoryPool.cs b/src/Snap.Hutao/Snap.Hutao/Service/Game/Automation/ScreenCapture/GameScreenCaptureMemoryPool.cs index 11f30fa4..d382030b 100644 --- a/src/Snap.Hutao/Snap.Hutao/Service/Game/Automation/ScreenCapture/GameScreenCaptureMemoryPool.cs +++ b/src/Snap.Hutao/Snap.Hutao/Service/Game/Automation/ScreenCapture/GameScreenCaptureMemoryPool.cs @@ -9,7 +9,7 @@ namespace Snap.Hutao.Service.Game.Automation.ScreenCapture; internal sealed class GameScreenCaptureMemoryPool : MemoryPool { - private static LazySlim lazyShared = new(() => new()); + private static readonly LazySlim LazyShared = new(() => new()); private readonly object syncRoot = new(); private readonly LinkedList unrentedBuffers = []; @@ -17,7 +17,7 @@ internal sealed class GameScreenCaptureMemoryPool : MemoryPool private int bufferCount; - public new static GameScreenCaptureMemoryPool Shared { get => lazyShared.Value; } + public static new GameScreenCaptureMemoryPool Shared { get => LazyShared.Value; } public override int MaxBufferSize { get => Array.MaxLength; } diff --git a/src/Snap.Hutao/Snap.Hutao/Service/Game/Automation/ScreenCapture/GameScreenCaptureSession.cs b/src/Snap.Hutao/Snap.Hutao/Service/Game/Automation/ScreenCapture/GameScreenCaptureSession.cs index e5e5dccc..91391bac 100644 --- a/src/Snap.Hutao/Snap.Hutao/Service/Game/Automation/ScreenCapture/GameScreenCaptureSession.cs +++ b/src/Snap.Hutao/Snap.Hutao/Service/Game/Automation/ScreenCapture/GameScreenCaptureSession.cs @@ -9,7 +9,6 @@ using Snap.Hutao.Win32.Graphics.Dxgi; using Snap.Hutao.Win32.Graphics.Dxgi.Common; using Snap.Hutao.Win32.System.WinRT.Graphics.Capture; using System.Buffers; -using System.Numerics; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using Windows.Graphics; @@ -114,8 +113,9 @@ internal sealed class GameScreenCaptureSession : IDisposable { UnsafeProcessFrameSurface(frame.Surface); } - catch (Exception ex) // TODO: test if it's device lost. + catch (Exception ex) { + // TODO: test if it's device lost. logger.LogError(ex, "Failed to process the frame surface."); needsReset = true; } @@ -209,8 +209,9 @@ internal sealed class GameScreenCaptureSession : IDisposable { subresource[row][..rowLength].CopyTo(buffer.Memory.Span.Slice(row * rowLength, rowLength)); } - +#pragma warning disable CA2000 frameRawPixelDataTaskCompletionSource.SetResult(new(buffer, (int)textureWidth, (int)textureHeight)); +#pragma warning restore CA2000 return; } @@ -235,8 +236,9 @@ internal sealed class GameScreenCaptureSession : IDisposable pixel.A = (byte)(float16Pixel.A * ByteMaxValue); } } - +#pragma warning disable CA2000 frameRawPixelDataTaskCompletionSource.SetResult(new(buffer, (int)textureWidth, (int)textureHeight)); +#pragma warning restore CA2000 return; } diff --git a/src/Snap.Hutao/Snap.Hutao/Service/Game/Package/PackageConvertException.cs b/src/Snap.Hutao/Snap.Hutao/Service/Game/Package/PackageConvertException.cs index 709824a3..3351c4a6 100644 --- a/src/Snap.Hutao/Snap.Hutao/Service/Game/Package/PackageConvertException.cs +++ b/src/Snap.Hutao/Snap.Hutao/Service/Game/Package/PackageConvertException.cs @@ -7,6 +7,7 @@ namespace Snap.Hutao.Service.Game.Package; /// 包转换异常 /// [HighQuality] +[Obsolete] internal sealed class PackageConvertException : Exception { /// diff --git a/src/Snap.Hutao/Snap.Hutao/Service/Game/Package/PackageConverter.cs b/src/Snap.Hutao/Snap.Hutao/Service/Game/Package/PackageConverter.cs index d7401fc4..ae992c04 100644 --- a/src/Snap.Hutao/Snap.Hutao/Service/Game/Package/PackageConverter.cs +++ b/src/Snap.Hutao/Snap.Hutao/Service/Game/Package/PackageConverter.cs @@ -180,7 +180,7 @@ internal sealed partial class PackageConverter } catch (IOException ex) { - throw ThrowHelper.PackageConvert(SH.ServiceGamePackageRequestPackageVerionFailed, ex); + throw HutaoException.Throw(SH.ServiceGamePackageRequestPackageVerionFailed, ex); } } @@ -252,13 +252,13 @@ internal sealed partial class PackageConverter { // System.IO.IOException: The response ended prematurely. // System.IO.IOException: Received an unexpected EOF or 0 bytes from the transport stream. - ThrowHelper.PackageConvert(SH.FormatServiceGamePackageRequestScatteredFileFailed(remoteName), ex); + HutaoException.Throw(SH.FormatServiceGamePackageRequestScatteredFileFailed(remoteName), ex); } } if (!string.Equals(info.Remote.Md5, await MD5.HashFileAsync(cacheFile).ConfigureAwait(false), StringComparison.OrdinalIgnoreCase)) { - ThrowHelper.PackageConvert(SH.FormatServiceGamePackageRequestScatteredFileFailed(remoteName)); + HutaoException.Throw(SH.FormatServiceGamePackageRequestScatteredFileFailed(remoteName)); } } @@ -318,7 +318,7 @@ internal sealed partial class PackageConverter { // Access to the path is denied. // When user install the game in special folder like 'Program Files' - throw ThrowHelper.GameFileOperation(SH.ServiceGamePackageRenameDataFolderFailed, ex); + throw HutaoException.Throw(SH.ServiceGamePackageRenameDataFolderFailed, ex); } // 重新下载所有 *pkg_version 文件 diff --git a/src/Snap.Hutao/Snap.Hutao/Service/Hutao/HutaoAsAService.cs b/src/Snap.Hutao/Snap.Hutao/Service/Hutao/HutaoAsAService.cs index 0042f693..963b3c2f 100644 --- a/src/Snap.Hutao/Snap.Hutao/Service/Hutao/HutaoAsAService.cs +++ b/src/Snap.Hutao/Snap.Hutao/Service/Hutao/HutaoAsAService.cs @@ -27,7 +27,7 @@ internal sealed partial class HutaoAsAService : IHutaoAsAService { RelayCommand dismissCommand = new(DismissAnnouncement); - ApplicationDataCompositeValue excludedIds = LocalSetting.Get(SettingKeys.ExcludedAnnouncementIds, new ApplicationDataCompositeValue()); + ApplicationDataCompositeValue excludedIds = LocalSetting.Get(SettingKeys.ExcludedAnnouncementIds, []); List data = excludedIds.Select(kvp => long.Parse(kvp.Key, CultureInfo.InvariantCulture)).ToList(); Response> response; @@ -56,7 +56,7 @@ internal sealed partial class HutaoAsAService : IHutaoAsAService { if (announcement is not null && announcements is not null) { - ApplicationDataCompositeValue excludedIds = LocalSetting.Get(SettingKeys.ExcludedAnnouncementIds, new ApplicationDataCompositeValue()); + ApplicationDataCompositeValue excludedIds = LocalSetting.Get(SettingKeys.ExcludedAnnouncementIds, []); foreach ((string key, object value) in excludedIds) { diff --git a/src/Snap.Hutao/Snap.Hutao/Service/Hutao/HutaoSpiralAbyssStatisticsCache.cs b/src/Snap.Hutao/Snap.Hutao/Service/Hutao/HutaoSpiralAbyssStatisticsCache.cs index 401efa83..e8ae7cd9 100644 --- a/src/Snap.Hutao/Snap.Hutao/Service/Hutao/HutaoSpiralAbyssStatisticsCache.cs +++ b/src/Snap.Hutao/Snap.Hutao/Service/Hutao/HutaoSpiralAbyssStatisticsCache.cs @@ -59,14 +59,14 @@ internal sealed partial class HutaoSpiralAbyssStatisticsCache : IHutaoSpiralAbys if (await metadataService.InitializeAsync().ConfigureAwait(false)) { Dictionary idAvatarMap = await GetIdAvatarMapExtendedAsync().ConfigureAwait(false); - List tasks = new(5) - { + List tasks = + [ AvatarAppearanceRankAsync(idAvatarMap), AvatarUsageRanksAsync(idAvatarMap), AvatarConstellationInfosAsync(idAvatarMap), TeamAppearancesAsync(idAvatarMap), OverviewAsync(), - }; + ]; await Task.WhenAll(tasks).ConfigureAwait(false); diff --git a/src/Snap.Hutao/Snap.Hutao/Service/Hutao/ObjectCacheDbService.cs b/src/Snap.Hutao/Snap.Hutao/Service/Hutao/ObjectCacheDbService.cs index f93c7eeb..4cd10218 100644 --- a/src/Snap.Hutao/Snap.Hutao/Service/Hutao/ObjectCacheDbService.cs +++ b/src/Snap.Hutao/Snap.Hutao/Service/Hutao/ObjectCacheDbService.cs @@ -55,7 +55,7 @@ internal sealed partial class ObjectCacheDbService : IObjectCacheDbService } catch (DbUpdateException ex) { - ThrowHelper.DatabaseCorrupted($"无法存储 Key:{key} 对应的值到数据库缓存", ex); + HutaoException.Throw($"无法存储 Key:{key} 对应的值到数据库缓存", ex); } return default!; diff --git a/src/Snap.Hutao/Snap.Hutao/Service/Job/JobIdentity.cs b/src/Snap.Hutao/Snap.Hutao/Service/Job/JobIdentity.cs index 868f7bbd..31de5784 100644 --- a/src/Snap.Hutao/Snap.Hutao/Service/Job/JobIdentity.cs +++ b/src/Snap.Hutao/Snap.Hutao/Service/Job/JobIdentity.cs @@ -1,9 +1,6 @@ // Copyright (c) DGP Studio. All rights reserved. // Licensed under the MIT license. -using Quartz; -using Snap.Hutao.Service.DailyNote; - namespace Snap.Hutao.Service.Job; internal static class JobIdentity diff --git a/src/Snap.Hutao/Snap.Hutao/Service/Job/QuartzService.cs b/src/Snap.Hutao/Snap.Hutao/Service/Job/QuartzService.cs index 41c5552b..67a1499b 100644 --- a/src/Snap.Hutao/Snap.Hutao/Service/Job/QuartzService.cs +++ b/src/Snap.Hutao/Snap.Hutao/Service/Job/QuartzService.cs @@ -62,7 +62,7 @@ internal sealed partial class QuartzService : IQuartzService, IDisposable { DisposeAsync().GetAwaiter().GetResult(); - async ValueTask DisposeAsync() + async Task DisposeAsync() { if (scheduler is null) { diff --git a/src/Snap.Hutao/Snap.Hutao/Service/SpiralAbyss/SpiralAbyssRecordService.cs b/src/Snap.Hutao/Snap.Hutao/Service/SpiralAbyss/SpiralAbyssRecordService.cs index 08afbaa8..1e546371 100644 --- a/src/Snap.Hutao/Snap.Hutao/Service/SpiralAbyss/SpiralAbyssRecordService.cs +++ b/src/Snap.Hutao/Snap.Hutao/Service/SpiralAbyss/SpiralAbyssRecordService.cs @@ -21,7 +21,6 @@ namespace Snap.Hutao.Service.SpiralAbyss; [Injection(InjectAs.Scoped, typeof(ISpiralAbyssRecordService))] internal sealed partial class SpiralAbyssRecordService : ISpiralAbyssRecordService { - //private readonly IOverseaSupportFactory gameRecordClientFactory; private readonly ISpiralAbyssRecordDbService spiralAbyssRecordDbService; private readonly IServiceScopeFactory serviceScopeFactory; private readonly IMetadataService metadataService; diff --git a/src/Snap.Hutao/Snap.Hutao/View/Converter/Int32ToVisibilityConverter.cs b/src/Snap.Hutao/Snap.Hutao/View/Converter/Int32ToVisibilityConverter.cs index cc5c1f80..92881058 100644 --- a/src/Snap.Hutao/Snap.Hutao/View/Converter/Int32ToVisibilityConverter.cs +++ b/src/Snap.Hutao/Snap.Hutao/View/Converter/Int32ToVisibilityConverter.cs @@ -22,6 +22,6 @@ internal sealed class Int32ToVisibilityConverter : IValueConverter /// public object ConvertBack(object value, Type targetType, object parameter, string language) { - throw ThrowHelper.NotSupported(); + throw HutaoException.NotSupported(); } } \ No newline at end of file diff --git a/src/Snap.Hutao/Snap.Hutao/View/Converter/Int32ToVisibilityRevertConverter.cs b/src/Snap.Hutao/Snap.Hutao/View/Converter/Int32ToVisibilityRevertConverter.cs index f194e67d..da318110 100644 --- a/src/Snap.Hutao/Snap.Hutao/View/Converter/Int32ToVisibilityRevertConverter.cs +++ b/src/Snap.Hutao/Snap.Hutao/View/Converter/Int32ToVisibilityRevertConverter.cs @@ -22,6 +22,6 @@ internal sealed class Int32ToVisibilityRevertConverter : IValueConverter /// public object ConvertBack(object value, Type targetType, object parameter, string language) { - throw ThrowHelper.NotSupported(); + throw HutaoException.NotSupported(); } } \ No newline at end of file diff --git a/src/Snap.Hutao/Snap.Hutao/View/Page/TestPage.xaml b/src/Snap.Hutao/Snap.Hutao/View/Page/TestPage.xaml index 089cbcfb..d0229615 100644 --- a/src/Snap.Hutao/Snap.Hutao/View/Page/TestPage.xaml +++ b/src/Snap.Hutao/Snap.Hutao/View/Page/TestPage.xaml @@ -98,13 +98,6 @@ Style="{ThemeResource SettingButtonStyle}"/> - -