From 5b5262e03e3a86c42be4ed8430d72a92998cf0d0 Mon Sep 17 00:00:00 2001 From: ChsBuffer <33744752+chsbuffer@users.noreply.github.com> Date: Fri, 30 Apr 2021 17:20:29 +0800 Subject: [PATCH] Update code style --- .editorconfig | 5 +-- Netch/Controllers/TUNController.cs | 26 +++++++-------- Netch/Forms/MainForm.cs | 52 +++++++++++++++--------------- Netch/Interfaces/IServerUtil.cs | 6 ++-- 4 files changed, 45 insertions(+), 44 deletions(-) diff --git a/.editorconfig b/.editorconfig index 53b779e8..475813fa 100644 --- a/.editorconfig +++ b/.editorconfig @@ -12,6 +12,7 @@ tab_width = 4 # Microsoft .NET properties csharp_new_line_before_members_in_object_initializers = false csharp_preferred_modifier_order = public, private, protected, internal, new, abstract, virtual, sealed, override, static, readonly, extern, unsafe, volatile, async:suggestion +csharp_space_after_cast = false csharp_style_var_elsewhere = true:suggestion csharp_style_var_for_built_in_types = true:suggestion csharp_style_var_when_type_is_apparent = true:suggestion @@ -27,7 +28,7 @@ dotnet_style_qualification_for_property = false:suggestion dotnet_style_require_accessibility_modifiers = for_non_interface_members:suggestion # ReSharper properties -resharper_align_multiline_switch_expression = true +resharper_align_multiline_switch_expression = false resharper_align_multline_type_parameter_constrains = true resharper_blank_lines_after_block_statements = 0 resharper_blank_lines_after_multiline_statements = 1 @@ -73,7 +74,7 @@ resharper_place_simple_initializer_on_single_line = true resharper_place_simple_switch_expression_on_single_line = true resharper_show_autodetect_configure_formatting_tip = false resharper_space_around_arrow_op = true -resharper_space_within_single_line_array_initializer_braces = false +resharper_space_within_single_line_array_initializer_braces = true resharper_use_indent_from_vs = false resharper_wrap_array_initializer_style = wrap_if_long resharper_wrap_before_arrow_with_expressions = true diff --git a/Netch/Controllers/TUNController.cs b/Netch/Controllers/TUNController.cs index 6c4d8f58..e96ec805 100644 --- a/Netch/Controllers/TUNController.cs +++ b/Netch/Controllers/TUNController.cs @@ -102,7 +102,7 @@ namespace Netch.Controllers RouteHelper.CreateUnicastIP(AddressFamily.InterNetwork, Global.Settings.TUNTAP.Address, - (byte) Utils.Utils.SubnetToCidr(Global.Settings.TUNTAP.Netmask), + (byte)Utils.Utils.SubnetToCidr(Global.Settings.TUNTAP.Netmask), _tunAdapter.InterfaceIndex); SetupRouteTable(mode); @@ -248,18 +248,18 @@ namespace Netch.Controllers return false; IAdapter adapter = routeType switch - { - RouteType.Outbound => _outboundAdapter, - RouteType.TUNTAP => _tunAdapter, - _ => throw new ArgumentOutOfRangeException(nameof(routeType), routeType, null) - }; + { + RouteType.Outbound => _outboundAdapter, + RouteType.TUNTAP => _tunAdapter, + _ => throw new ArgumentOutOfRangeException(nameof(routeType), routeType, null) + }; List ipList = routeType switch - { - RouteType.Outbound => _directIPs, - RouteType.TUNTAP => _proxyIPs, - _ => throw new ArgumentOutOfRangeException(nameof(routeType), routeType, null) - }; + { + RouteType.Outbound => _directIPs, + RouteType.TUNTAP => _proxyIPs, + _ => throw new ArgumentOutOfRangeException(nameof(routeType), routeType, null) + }; string gateway = adapter.Gateway.ToString(); var index = adapter.InterfaceIndex; @@ -270,13 +270,13 @@ namespace Netch.Controllers switch (action) { case Action.Create: - result = RouteHelper.CreateRoute(AddressFamily.InterNetwork, ip, (byte) cidr, gateway, index, metric); + result = RouteHelper.CreateRoute(AddressFamily.InterNetwork, ip, (byte)cidr, gateway, index, metric); if (record) ipList.Add(ipNetwork); break; case Action.Delete: - result = RouteHelper.DeleteRoute(AddressFamily.InterNetwork, ip, (byte) cidr, gateway, index, metric); + result = RouteHelper.DeleteRoute(AddressFamily.InterNetwork, ip, (byte)cidr, gateway, index, metric); break; default: throw new ArgumentOutOfRangeException(nameof(action), action, null); diff --git a/Netch/Forms/MainForm.cs b/Netch/Forms/MainForm.cs index 8c19f71e..81181c9b 100644 --- a/Netch/Forms/MainForm.cs +++ b/Netch/Forms/MainForm.cs @@ -1398,38 +1398,38 @@ namespace Netch.Forms switch (cbx.Items[e.Index]) { case Server item: - { - // 计算延迟底色 - var numBoxBackBrush = item.Delay switch { > 200 => Brushes.Red, > 80 => Brushes.Yellow, >= 0 => _greenBrush, _ => Brushes.Gray }; + { + // 计算延迟底色 + var numBoxBackBrush = item.Delay switch { > 200 => Brushes.Red, > 80 => Brushes.Yellow, >= 0 => _greenBrush, _ => Brushes.Gray }; - // 绘制延迟底色 - e.Graphics.FillRectangle(numBoxBackBrush, _numberBoxX, e.Bounds.Y, _numberBoxWidth, e.Bounds.Height); + // 绘制延迟底色 + e.Graphics.FillRectangle(numBoxBackBrush, _numberBoxX, e.Bounds.Y, _numberBoxWidth, e.Bounds.Height); - // 绘制延迟字符串 - TextRenderer.DrawText(e.Graphics, - item.Delay.ToString(), - cbx.Font, - new Point(_numberBoxX + _numberBoxWrap, e.Bounds.Y), - Color.Black, - TextFormatFlags.Left); + // 绘制延迟字符串 + TextRenderer.DrawText(e.Graphics, + item.Delay.ToString(), + cbx.Font, + new Point(_numberBoxX + _numberBoxWrap, e.Bounds.Y), + Color.Black, + TextFormatFlags.Left); - break; - } + break; + } case Models.Mode item: - { - // 绘制 模式Box 底色 - e.Graphics.FillRectangle(Brushes.Gray, _numberBoxX, e.Bounds.Y, _numberBoxWidth, e.Bounds.Height); + { + // 绘制 模式Box 底色 + e.Graphics.FillRectangle(Brushes.Gray, _numberBoxX, e.Bounds.Y, _numberBoxWidth, e.Bounds.Height); - // 绘制 模式行数 字符串 - TextRenderer.DrawText(e.Graphics, - item.Rule.Count.ToString(), - cbx.Font, - new Point(_numberBoxX + _numberBoxWrap, e.Bounds.Y), - Color.Black, - TextFormatFlags.Left); + // 绘制 模式行数 字符串 + TextRenderer.DrawText(e.Graphics, + item.Rule.Count.ToString(), + cbx.Font, + new Point(_numberBoxX + _numberBoxWrap, e.Bounds.Y), + Color.Black, + TextFormatFlags.Left); - break; - } + break; + } } } diff --git a/Netch/Interfaces/IServerUtil.cs b/Netch/Interfaces/IServerUtil.cs index 2242c087..8cbf4377 100644 --- a/Netch/Interfaces/IServerUtil.cs +++ b/Netch/Interfaces/IServerUtil.cs @@ -28,7 +28,7 @@ namespace Netch.Interfaces /// string[] UriScheme { get; } - public abstract Type ServerType { get; } + public Type ServerType { get; } public void Edit(Server s); @@ -36,9 +36,9 @@ namespace Netch.Interfaces string GetShareLink(Server s); - public abstract IServerController GetController(); + public IServerController GetController(); - public abstract IEnumerable ParseUri(string text); + public IEnumerable ParseUri(string text); bool CheckServer(Server s); }