فهرست منبع

ref: 更新到 C# 语言版本 13,回滚 ArgumentReplace

龙腾猫跃 6 ماه پیش
والد
کامیت
6432370f86
8فایلهای تغییر یافته به همراه45 افزوده شده و 66 حذف شده
  1. 4 10
      Extensions/EnumerableExtensions.cs
  2. 4 8
      Extensions/StringExtensions.cs
  3. 0 5
      General/MsDelta.cs
  4. 1 3
      General/OneOf.cs
  5. 31 18
      MeloongCore.csproj
  6. 1 9
      Utils/DirectoryUtils.cs
  7. 3 7
      Utils/MathUtils.cs
  8. 1 6
      Utils/PathUtils.cs

+ 4 - 10
Extensions/EnumerableExtensions.cs

@@ -1,10 +1,4 @@
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-
-namespace MeloongCore.Extensions;
+namespace MeloongCore.Extensions;
 public static class EnumerableExtensions {
 
     #region Distinct
@@ -133,7 +127,7 @@ public static class EnumerableExtensions {
                 isFirst = false;
             else
                 builder.Append(split);
-            if (element != null) builder.Append(element.ToString());
+            if (element is not null) builder.Append(element.ToString());
         }
         return builder.ToString();
     }
@@ -149,7 +143,7 @@ public static class EnumerableExtensions {
                 isFirst = false;
             else
                 builder.Append(split);
-            if (element != null) builder.Append(element.ToString());
+            if (element is not null) builder.Append(element.ToString());
         }
         return builder.ToString();
     }
@@ -160,7 +154,7 @@ public static class EnumerableExtensions {
     /// 判断集合是否有且仅有一个元素。
     /// </summary>
     public static bool IsSingle<T>(this IEnumerable<T> source) {
-        if (source == null) return false;
+        if (source is null) return false;
         if (source is IList<T> list) return list.Count == 1;
         using var enumerator = source.GetEnumerator();
         if (!enumerator.MoveNext()) return false;

+ 4 - 8
Extensions/StringExtensions.cs

@@ -1,8 +1,4 @@
-using System;
-using System.Linq;
-using System.Runtime.CompilerServices;
-
-namespace MeloongCore.Extensions;
+namespace MeloongCore.Extensions;
 public static class StringExtensions {
 
     #region 区域性 / 大小写 简化
@@ -12,7 +8,7 @@ public static class StringExtensions {
     /// </summary>
     [MethodImpl(MethodImplOptions.AggressiveInlining)]
     public static bool StartsWithF(this string value, string prefix, bool ignoreCase = false) {
-        if (value == null) return false;
+        if (value is null) return false;
         return value.StartsWith(prefix, ignoreCase ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal);
     }
     /// <summary>
@@ -20,7 +16,7 @@ public static class StringExtensions {
     /// </summary>
     [MethodImpl(MethodImplOptions.AggressiveInlining)]
     public static bool EndsWithF(this string value, string suffix, bool ignoreCase = false) {
-        if (value == null) return false;
+        if (value is null) return false;
         return value.EndsWith(suffix, ignoreCase ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal);
     }
 
@@ -85,7 +81,7 @@ public static class StringExtensions {
         if (splitStr.IsSingle())
             return fullStr.Split(splitStr[0]);
         else
-            return fullStr.Split(new[] {splitStr}, StringSplitOptions.None);
+            return fullStr.Split([splitStr], StringSplitOptions.None);
     }
 
     /// <summary>

+ 0 - 5
General/MsDelta.cs

@@ -1,8 +1,3 @@
-using System;
-using System.ComponentModel;
-using System.IO;
-using System.Runtime.InteropServices;
-
 namespace MeloongCore;
 
 /// <summary>

+ 1 - 3
General/OneOf.cs

@@ -1,6 +1,4 @@
-using System;
-
-namespace MeloongCore;
+namespace MeloongCore;
 
 public readonly struct OneOf<T0, T1> {
     private readonly int _index;

+ 31 - 18
MeloongCore.csproj

@@ -1,25 +1,38 @@
 <Project Sdk="Microsoft.NET.Sdk">
 
-  <PropertyGroup>
-    <TargetFramework>net462</TargetFramework>
-    <OutputType>Library</OutputType>
-    <AllowUnsafeBlocks>True</AllowUnsafeBlocks>
-	<OutDir>bin\</OutDir>
-	<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
-	<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
-	<Configurations>Debug;Release;Snapshot</Configurations>
-	<Deterministic>true</Deterministic>
-	<LangVersion>13.0</LangVersion>
-  </PropertyGroup>
+	<PropertyGroup>
+		<TargetFramework>net462</TargetFramework>
+		<OutputType>Library</OutputType>
+		<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
+		<OutDir>bin\</OutDir>
+		<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
+		<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
+		<Configurations>Debug;Release;Snapshot</Configurations>
+		<Deterministic>true</Deterministic>
+		<LangVersion>13.0</LangVersion>
+	</PropertyGroup>
 
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
-    <DefineConstants>$(DefineConstants);SNAPSHOT</DefineConstants>
-  </PropertyGroup>
+	<ItemGroup>
+		<Using Include="System" />
+		<Using Include="System.ComponentModel" />
+		<Using Include="System.Collections" />
+		<Using Include="System.Collections.Generic" />
+		<Using Include="System.Linq" />
+		<Using Include="System.Text" />
+		<Using Include="System.IO" />
+		<Using Include="System.Runtime.CompilerServices" />
+		<Using Include="System.Runtime.InteropServices" />
+		<Using Include="MeloongCore.Extensions" />
+	</ItemGroup>
 
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'" />
+	<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
+		<DefineConstants>$(DefineConstants);SNAPSHOT</DefineConstants>
+	</PropertyGroup>
 
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Snapshot|AnyCPU'">
-    <Optimize>True</Optimize>
-  </PropertyGroup>
+	<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'" />
+
+	<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Snapshot|AnyCPU'">
+		<Optimize>True</Optimize>
+	</PropertyGroup>
 
 </Project>

+ 1 - 9
Utils/DirectoryUtils.cs

@@ -1,12 +1,4 @@
-using MeloongCore.Extensions;
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace MeloongCore;
+namespace MeloongCore;
 public static class DirectoryUtils {
 
     /// <summary>

+ 3 - 7
Utils/MathUtils.cs

@@ -1,10 +1,6 @@
-using MeloongCore.Extensions;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Numerics;
-namespace MeloongCore;
+using System.Numerics;
 
+namespace MeloongCore;
 public static class MathUtils {
 
     #region 进制转换
@@ -62,7 +58,7 @@ public static class MathUtils {
         // 负数的结束处理与返回
         if (isNegative) results.Add('-');
         results.Reverse();
-        return new string(results.ToArray());
+        return new([..results]);
     }
 
     #endregion

+ 1 - 6
Utils/PathUtils.cs

@@ -1,9 +1,4 @@
-using MeloongCore.Extensions;
-using System.IO;
-using System.Runtime.InteropServices;
-using System.Text;
-namespace MeloongCore;
-
+namespace MeloongCore;
 public static class PathUtils {
 
     /// <summary>