Daniel Chalmers 3 年之前
父节点
当前提交
2057e18b66
共有 4 个文件被更改,包括 10 次插入9 次删除
  1. 2 2
      .editorconfig
  2. 1 1
      DesktopClock/DateTimeUtil.cs
  3. 2 2
      DesktopClock/DesktopClock.csproj
  4. 5 4
      DesktopClock/Properties/Settings.cs

+ 2 - 2
.editorconfig

@@ -100,11 +100,10 @@ csharp_style_prefer_switch_expression = true
 
 # Null-checking preferences
 csharp_style_conditional_delegate_call = true
-csharp_style_prefer_parameter_null_checking = false:error
 
 # Modifier preferences
 csharp_prefer_static_local_function = true:warning
-csharp_preferred_modifier_order = public,private,protected,internal,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,volatile,async
+csharp_preferred_modifier_order = public,private,protected,internal,file,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,required,volatile,async
 
 # Code-block preferences
 csharp_prefer_braces = when_multiline:warning
@@ -123,6 +122,7 @@ csharp_style_prefer_local_over_anonymous_function = true
 csharp_style_prefer_null_check_over_type_check = true:warning
 csharp_style_prefer_range_operator = true
 csharp_style_prefer_tuple_swap = true:silent
+csharp_style_prefer_utf8_string_literals = true
 csharp_style_throw_expression = true
 csharp_style_unused_value_assignment_preference = discard_variable:warning
 csharp_style_unused_value_expression_statement_preference = discard_variable

+ 1 - 1
DesktopClock/DateTimeUtil.cs

@@ -33,7 +33,7 @@ public static class DateTimeUtil
     /// Common date time formatting strings and an example string for each.
     /// </summary>
     public static IReadOnlyDictionary<string, string> DateTimeFormatsAndExamples { get; } =
-        DateTimeFormats.ToDictionary(f => f, f => DateTimeOffset.Now.ToString(f));
+        DateTimeFormats.ToDictionary(f => f, DateTimeOffset.Now.ToString);
 
     public static IReadOnlyCollection<TimeZoneInfo> TimeZones { get; } = TimeZoneInfo.GetSystemTimeZones();
 

+ 2 - 2
DesktopClock/DesktopClock.csproj

@@ -16,11 +16,11 @@
   </PropertyGroup>
 
   <ItemGroup>
-    <PackageReference Include="CommunityToolkit.Mvvm" Version="7.1.2" />
+    <PackageReference Include="CommunityToolkit.Mvvm" Version="8.0.0" />
     <PackageReference Include="Costura.Fody" Version="5.7.0" PrivateAssets="All" />
     <PackageReference Include="Humanizer.Core" Version="2.14.1" />
     <PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
-    <PackageReference Include="PropertyChanged.Fody" Version="3.4.1" PrivateAssets="All" />
+    <PackageReference Include="PropertyChanged.Fody" Version="4.0.2" PrivateAssets="All" />
     <PackageReference Include="WpfWindowPlacement" Version="4.0.2" />
   </ItemGroup>
 </Project>

+ 5 - 4
DesktopClock/Properties/Settings.cs

@@ -95,10 +95,11 @@ public sealed class Settings : INotifyPropertyChanged
     /// </summary>
     private static Settings Load()
     {
-        using (var fileStream = new FileStream(Path, FileMode.Open))
-        using (var streamReader = new StreamReader(fileStream))
-        using (var jsonReader = new JsonTextReader(streamReader))
-            return JsonSerializer.Create(_jsonSerializerSettings).Deserialize<Settings>(jsonReader);
+        using var fileStream = new FileStream(Path, FileMode.Open);
+        using var streamReader = new StreamReader(fileStream);
+        using var jsonReader = new JsonTextReader(streamReader);
+
+        return JsonSerializer.Create(_jsonSerializerSettings).Deserialize<Settings>(jsonReader);
     }
 
     /// <summary>