Code clean

This commit is contained in:
2dust
2026-11-18 17:35:10 +08:00
parent 184a7c11b3
commit f6dc9d1833
33 changed files with 48 additions and 64 deletions
@@ -1,4 +1,3 @@
using ServiceLib.Tests.CoreConfig; using ServiceLib.Tests.CoreConfig;
namespace ServiceLib.Tests.Handler; namespace ServiceLib.Tests.Handler;
@@ -1,5 +1,3 @@
namespace ServiceLib.Handler; namespace ServiceLib.Handler;
public class SubscriptionHandler( public class SubscriptionHandler(
@@ -8,6 +8,7 @@ public class HttpClientHelper
// private readonly SocketsHttpHandler _directHandler = CreateSocketsHttpHandler(false); // private readonly SocketsHttpHandler _directHandler = CreateSocketsHttpHandler(false);
private readonly Lazy<SocketsHttpHandler> _directHandlerLazy = new(() => CreateSocketsHttpHandler(false)); private readonly Lazy<SocketsHttpHandler> _directHandlerLazy = new(() => CreateSocketsHttpHandler(false));
private Uri _proxyUri = null!; private Uri _proxyUri = null!;
public static HttpClientHelper Instance => _instance.Value; public static HttpClientHelper Instance => _instance.Value;
@@ -152,7 +152,7 @@ public class EndpointResolveManager
stream.WriteByte((byte)(value & 0xFF)); stream.WriteByte((byte)(value & 0xFF));
} }
#endregion #endregion Build DNS Query
#region Parse DNS Response #region Parse DNS Response
@@ -427,7 +427,7 @@ public class EndpointResolveManager
data[offset + 1]); data[offset + 1]);
} }
#endregion #endregion Parse DNS Response
} }
public interface IDnsResolver public interface IDnsResolver
-2
View File
@@ -1,5 +1,3 @@
namespace ServiceLib.Manager; namespace ServiceLib.Manager;
public class TaskManager public class TaskManager
@@ -512,7 +512,9 @@ public class MaskSettings4Ray
// udphop // udphop
public string? mode { get; set; } public string? mode { get; set; }
public string? interval { get; set; } public string? interval { get; set; }
// public List<string>? remoteIPs { get; set; } // public List<string>? remoteIPs { get; set; }
public string? remotePorts { get; set; } public string? remotePorts { get; set; }
+2
View File
@@ -9,8 +9,10 @@ public class SsServer
{ {
public string? remarks { get; set; } public string? remarks { get; set; }
public string? server { get; set; } public string? server { get; set; }
[JsonNumberHandling(JsonNumberHandling.AllowReadingFromString)] [JsonNumberHandling(JsonNumberHandling.AllowReadingFromString)]
public int server_port { get; set; } public int server_port { get; set; }
public string? method { get; set; } public string? method { get; set; }
public string? password { get; set; } public string? password { get; set; }
public string? plugin { get; set; } public string? plugin { get; set; }
@@ -1,5 +1,3 @@
namespace ServiceLib.ViewModels; namespace ServiceLib.ViewModels;
public partial class AddServer2ViewModel : MyReactiveObject, ICloseable public partial class AddServer2ViewModel : MyReactiveObject, ICloseable
@@ -1,5 +1,3 @@
namespace ServiceLib.ViewModels; namespace ServiceLib.ViewModels;
public partial class BackupAndRestoreViewModel : MyReactiveObject public partial class BackupAndRestoreViewModel : MyReactiveObject
@@ -1,5 +1,3 @@
namespace ServiceLib.ViewModels; namespace ServiceLib.ViewModels;
public partial class CheckUpdateViewModel : MyReactiveObject public partial class CheckUpdateViewModel : MyReactiveObject
@@ -1,5 +1,3 @@
namespace ServiceLib.ViewModels; namespace ServiceLib.ViewModels;
public partial class DNSSettingViewModel : MyReactiveObject, ICloseable public partial class DNSSettingViewModel : MyReactiveObject, ICloseable
@@ -1,5 +1,3 @@
namespace ServiceLib.ViewModels; namespace ServiceLib.ViewModels;
public partial class FullConfigTemplateViewModel : MyReactiveObject, ICloseable public partial class FullConfigTemplateViewModel : MyReactiveObject, ICloseable
@@ -1,5 +1,3 @@
namespace ServiceLib.ViewModels; namespace ServiceLib.ViewModels;
public class GlobalHotkeySettingViewModel : MyReactiveObject, ICloseable public class GlobalHotkeySettingViewModel : MyReactiveObject, ICloseable
@@ -1,5 +1,3 @@
namespace ServiceLib.ViewModels; namespace ServiceLib.ViewModels;
public partial class RoutingRuleSettingViewModel : MyReactiveObject, ICloseable public partial class RoutingRuleSettingViewModel : MyReactiveObject, ICloseable
@@ -1,5 +1,3 @@
namespace ServiceLib.ViewModels; namespace ServiceLib.ViewModels;
public partial class RoutingSettingViewModel : MyReactiveObject public partial class RoutingSettingViewModel : MyReactiveObject
@@ -1,5 +1,3 @@
namespace ServiceLib.ViewModels; namespace ServiceLib.ViewModels;
public partial class SubEditViewModel : MyReactiveObject, ICloseable public partial class SubEditViewModel : MyReactiveObject, ICloseable
@@ -1,5 +1,3 @@
namespace ServiceLib.ViewModels; namespace ServiceLib.ViewModels;
public partial class SubSettingViewModel : MyReactiveObject public partial class SubSettingViewModel : MyReactiveObject
@@ -1,6 +1,5 @@
using Semi.Avalonia; using Semi.Avalonia;
namespace v2rayN.Desktop.ViewModels; namespace v2rayN.Desktop.ViewModels;
public partial class ThemeSettingViewModel : MyReactiveObject public partial class ThemeSettingViewModel : MyReactiveObject
@@ -574,7 +574,6 @@ public partial class MainWindow : WindowBase<MainWindowViewModel>
}; };
}).DisposeWith(currentLayoutDisposables); }).DisposeWith(currentLayoutDisposables);
break; break;
} }
RestoreUI(); RestoreUI();
@@ -317,7 +317,6 @@ public partial class ProfilesView : ReactiveUserControl<ProfilesViewModel>
} }
} }
private void BtnAutofitColumnWidth_Click(object? sender, RoutedEventArgs e) private void BtnAutofitColumnWidth_Click(object? sender, RoutedEventArgs e)
{ {
AutofitColumnWidth(); AutofitColumnWidth();
@@ -155,6 +155,7 @@ public class UpdatePreReleaseSettingsTests
private readonly FieldInfo _configField = typeof(ConfigState) private readonly FieldInfo _configField = typeof(ConfigState)
.GetField("_current", BindingFlags.Instance | BindingFlags.NonPublic) .GetField("_current", BindingFlags.Instance | BindingFlags.NonPublic)
?? throw new MissingFieldException(typeof(ConfigState).FullName, "_current"); ?? throw new MissingFieldException(typeof(ConfigState).FullName, "_current");
private readonly object? _previousConfig; private readonly object? _previousConfig;
private readonly string? _previousLocalData; private readonly string? _previousLocalData;
private readonly string _configPath; private readonly string _configPath;
@@ -146,6 +146,7 @@ public class WebAuthRateLimitTests
await proxy.StopAsync(); await proxy.StopAsync();
} }
} }
private static WebApplication CreatePartitionTestApp() private static WebApplication CreatePartitionTestApp()
{ {
var builder = WebApplication.CreateBuilder(); var builder = WebApplication.CreateBuilder();
@@ -198,9 +199,12 @@ public class WebAuthRateLimitTests
private sealed class FixedProxy(Uri address) : IWebProxy private sealed class FixedProxy(Uri address) : IWebProxy
{ {
public ICredentials? Credentials { get; set; } public ICredentials? Credentials { get; set; }
public Uri GetProxy(Uri destination) => address; public Uri GetProxy(Uri destination) => address;
public bool IsBypassed(Uri host) => false; public bool IsBypassed(Uri host) => false;
} }
private sealed class TemporaryDirectory : IDisposable private sealed class TemporaryDirectory : IDisposable
{ {
public TemporaryDirectory() public TemporaryDirectory()
@@ -99,8 +99,10 @@ public class WebInstanceLockProcessTests
{ {
private readonly DirectoryInfo _directory = Directory.CreateTempSubdirectory("v2rayn-instance-lock-tests-"); private readonly DirectoryInfo _directory = Directory.CreateTempSubdirectory("v2rayn-instance-lock-tests-");
public string Path => _directory.FullName; public string Path => _directory.FullName;
public void Dispose() => _directory.Delete(recursive: true); public void Dispose() => _directory.Delete(recursive: true);
} }
private sealed class LockProcess : IAsyncDisposable private sealed class LockProcess : IAsyncDisposable
{ {
private static readonly TimeSpan Timeout = TimeSpan.FromSeconds(20); private static readonly TimeSpan Timeout = TimeSpan.FromSeconds(20);
@@ -6,6 +6,7 @@ public class WebLauncherTests
{ {
// Keep fixture PIDs outside Linux's assignable range so host services cannot affect stop tests. // Keep fixture PIDs outside Linux's assignable range so host services cannot affect stop tests.
private const int FakeOwnerProcessId = int.MaxValue - 1; private const int FakeOwnerProcessId = int.MaxValue - 1;
private const int OtherProcessId = int.MaxValue; private const int OtherProcessId = int.MaxValue;
[Test] [Test]
@@ -351,7 +351,9 @@ public class WebRestartCoordinatorTests
public bool HasExited { get; } = hasExited; public bool HasExited { get; } = hasExited;
public bool Killed { get; private set; } public bool Killed { get; private set; }
public bool Disposed { get; private set; } public bool Disposed { get; private set; }
public void KillTree() => Killed = true; public void KillTree() => Killed = true;
public void Dispose() => Disposed = true; public void Dispose() => Disposed = true;
} }
-1
View File
@@ -1,7 +1,6 @@
using System.Drawing; using System.Drawing;
using System.Windows.Media.Imaging; using System.Windows.Media.Imaging;
namespace v2rayN.Manager; namespace v2rayN.Manager;
public sealed class WindowsManager public sealed class WindowsManager
@@ -3,7 +3,6 @@ using MaterialDesignColors.ColorManipulation;
using MaterialDesignThemes.Wpf; using MaterialDesignThemes.Wpf;
using Microsoft.Win32; using Microsoft.Win32;
namespace v2rayN.ViewModels; namespace v2rayN.ViewModels;
public partial class ThemeSettingViewModel : MyReactiveObject public partial class ThemeSettingViewModel : MyReactiveObject
-1
View File
@@ -1138,7 +1138,6 @@
Style="{StaticResource DefTextBox}" /> Style="{StaticResource DefTextBox}" />
</StackPanel> </StackPanel>
</materialDesign:PopupBox> </materialDesign:PopupBox>
</Grid> </Grid>
<Separator <Separator