Skip to content

Commit 49c8fac

Browse files
committed
Update .editorconfig and cleanup code
1 parent 51fd252 commit 49c8fac

File tree

5 files changed

+18
-58
lines changed

5 files changed

+18
-58
lines changed

.editorconfig

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ dotnet_style_readonly_field = true
6767
dotnet_code_quality_unused_parameters = all
6868

6969
# 禁止显示首选项
70-
dotnet_remove_unnecessary_suppression_exclusions = 0
70+
dotnet_remove_unnecessary_suppression_exclusions = none
7171

7272
# 新行首选项
7373
dotnet_style_allow_multiple_blank_lines_experimental = false:suggestion
@@ -105,12 +105,14 @@ csharp_style_conditional_delegate_call = true
105105
csharp_prefer_static_local_function = true
106106
csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async
107107
csharp_style_prefer_readonly_struct = true
108+
csharp_style_prefer_readonly_struct_member = true
108109

109110
# 代码块首选项
110111
csharp_prefer_braces = true:suggestion
111112
csharp_prefer_simple_using_statement = true
112113
csharp_style_namespace_declarations = file_scoped:suggestion
113114
csharp_style_prefer_method_group_conversion = true
115+
csharp_style_prefer_primary_constructors = true
114116
csharp_style_prefer_top_level_statements = true
115117

116118
# 表达式级首选项
@@ -125,7 +127,7 @@ csharp_style_prefer_range_operator = true
125127
csharp_style_prefer_tuple_swap = true
126128
csharp_style_prefer_utf8_string_literals = true
127129
csharp_style_throw_expression = true
128-
csharp_style_unused_value_assignment_preference = discard_variable:silent
130+
csharp_style_unused_value_assignment_preference = discard_variable
129131
csharp_style_unused_value_expression_statement_preference = discard_variable
130132

131133
# "using" 指令首选项
@@ -205,6 +207,10 @@ dotnet_naming_rule.抽象类_should_be_abstractmethod.severity = suggestion
205207
dotnet_naming_rule.抽象类_should_be_abstractmethod.symbols = 抽象类
206208
dotnet_naming_rule.抽象类_should_be_abstractmethod.style = abstractmethod
207209

210+
dotnet_naming_rule.常量_should_be_pascalcase.severity = suggestion
211+
dotnet_naming_rule.常量_should_be_pascalcase.symbols = 常量
212+
dotnet_naming_rule.常量_should_be_pascalcase.style = pascalcase
213+
208214
dotnet_naming_rule.非字段成员_should_be_pascalcase.severity = suggestion
209215
dotnet_naming_rule.非字段成员_should_be_pascalcase.symbols = 非字段成员
210216
dotnet_naming_rule.非字段成员_should_be_pascalcase.style = pascalcase
@@ -271,6 +277,10 @@ dotnet_naming_symbols.异步方法.applicable_kinds = method, local_function
271277
dotnet_naming_symbols.异步方法.applicable_accessibilities = *
272278
dotnet_naming_symbols.异步方法.required_modifiers = async
273279

280+
dotnet_naming_symbols.常量.applicable_kinds = property, field
281+
dotnet_naming_symbols.常量.applicable_accessibilities = *
282+
dotnet_naming_symbols.常量.required_modifiers = const
283+
274284
# 命名样式
275285

276286
dotnet_naming_style.pascalcase.required_prefix =

IPConfig/Converters/EnumDescriptionConverter.cs

Lines changed: 0 additions & 22 deletions
This file was deleted.

IPConfig/Extensions/EnumExtensions.cs

Lines changed: 0 additions & 26 deletions
This file was deleted.

IPConfig/Helpers/ThemeWatcher.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ public enum WindowsTheme
3131
Dark = 2,
3232
}
3333

34-
private const string _registryKeyPath = @"Software\Microsoft\Windows\CurrentVersion\Themes\Personalize";
34+
private const string RegistryKeyPath = @"Software\Microsoft\Windows\CurrentVersion\Themes\Personalize";
3535

36-
private const string _registryValueName = "AppsUseLightTheme";
36+
private const string RegistryValueName = "AppsUseLightTheme";
3737

3838
private static WindowsTheme _currentWindowsTheme;
3939

@@ -45,8 +45,8 @@ public static WindowsTheme GetCurrentWindowsTheme()
4545

4646
try
4747
{
48-
using var key = Registry.CurrentUser.OpenSubKey(_registryKeyPath);
49-
object? registryValueObject = key?.GetValue(_registryValueName);
48+
using var key = Registry.CurrentUser.OpenSubKey(RegistryKeyPath);
49+
object? registryValueObject = key?.GetValue(RegistryValueName);
5050

5151
if (registryValueObject is null)
5252
{
@@ -72,8 +72,8 @@ public static void StartThemeWatching()
7272
CultureInfo.InvariantCulture,
7373
@"SELECT * FROM RegistryValueChangeEvent WHERE Hive = 'HKEY_USERS' AND KeyPath = '{0}\\{1}' AND ValueName = '{2}'",
7474
currentUser?.User?.Value,
75-
_registryKeyPath.Replace(@"\", @"\\"),
76-
_registryValueName);
75+
RegistryKeyPath.Replace(@"\", @"\\"),
76+
RegistryValueName);
7777

7878
try
7979
{

IPConfig/Themes/MyResources.xaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
<sys:Boolean x:Key="True">True</sys:Boolean>
77
<sys:Boolean x:Key="False">False</sys:Boolean>
88

9-
<conv:EnumDescriptionConverter x:Key="EnumDescriptionConverter" />
10-
119
<conv:MultiValueEqualsConverter x:Key="MultiValueEqualsConverter" />
1210

1311
<conv:StringRemoveNewLineConverter x:Key="StringRemoveNewLineConverter" />

0 commit comments

Comments
 (0)