ref: 更新到 C# 语言版本 13,回滚 ArgumentReplace
This commit is contained in:
1 parent
6db2c6cfa2
commit
6432370f86
8 files changed
+45
-66
No files matched your search
@@ -1,10 +1,4 @@
|
|||||||
using System;
|
namespace MeloongCore.Extensions;
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace MeloongCore.Extensions;
|
|
||||||
public static class EnumerableExtensions {
|
public static class EnumerableExtensions {
|
||||||
|
|
||||||
#region Distinct
|
#region Distinct
|
||||||
@@ -133,7 +127,7 @@ public static class EnumerableExtensions {
|
|||||||
isFirst = false;
|
isFirst = false;
|
||||||
else
|
else
|
||||||
builder.Append(split);
|
builder.Append(split);
|
||||||
if (element != null) builder.Append(element.ToString());
|
if (element is not null) builder.Append(element.ToString());
|
||||||
}
|
}
|
||||||
return builder.ToString();
|
return builder.ToString();
|
||||||
}
|
}
|
||||||
@@ -149,7 +143,7 @@ public static class EnumerableExtensions {
|
|||||||
isFirst = false;
|
isFirst = false;
|
||||||
else
|
else
|
||||||
builder.Append(split);
|
builder.Append(split);
|
||||||
if (element != null) builder.Append(element.ToString());
|
if (element is not null) builder.Append(element.ToString());
|
||||||
}
|
}
|
||||||
return builder.ToString();
|
return builder.ToString();
|
||||||
}
|
}
|
||||||
@@ -160,7 +154,7 @@ public static class EnumerableExtensions {
|
|||||||
/// 判断集合是否有且仅有一个元素。
|
/// 判断集合是否有且仅有一个元素。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static bool IsSingle<T>(this IEnumerable<T> source) {
|
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;
|
if (source is IList<T> list) return list.Count == 1;
|
||||||
using var enumerator = source.GetEnumerator();
|
using var enumerator = source.GetEnumerator();
|
||||||
if (!enumerator.MoveNext()) return false;
|
if (!enumerator.MoveNext()) return false;
|
||||||
|
|||||||
@@ -1,8 +1,4 @@
|
|||||||
using System;
|
namespace MeloongCore.Extensions;
|
||||||
using System.Linq;
|
|
||||||
using System.Runtime.CompilerServices;
|
|
||||||
|
|
||||||
namespace MeloongCore.Extensions;
|
|
||||||
public static class StringExtensions {
|
public static class StringExtensions {
|
||||||
|
|
||||||
#region 区域性 / 大小写 简化
|
#region 区域性 / 大小写 简化
|
||||||
@@ -12,7 +8,7 @@ public static class StringExtensions {
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public static bool StartsWithF(this string value, string prefix, bool ignoreCase = false) {
|
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);
|
return value.StartsWith(prefix, ignoreCase ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal);
|
||||||
}
|
}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -20,7 +16,7 @@ public static class StringExtensions {
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public static bool EndsWithF(this string value, string suffix, bool ignoreCase = false) {
|
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);
|
return value.EndsWith(suffix, ignoreCase ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -85,7 +81,7 @@ public static class StringExtensions {
|
|||||||
if (splitStr.IsSingle())
|
if (splitStr.IsSingle())
|
||||||
return fullStr.Split(splitStr[0]);
|
return fullStr.Split(splitStr[0]);
|
||||||
else
|
else
|
||||||
return fullStr.Split(new[] {splitStr}, StringSplitOptions.None);
|
return fullStr.Split([splitStr], StringSplitOptions.None);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -1,8 +1,3 @@
|
|||||||
using System;
|
|
||||||
using System.ComponentModel;
|
|
||||||
using System.IO;
|
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
|
|
||||||
namespace MeloongCore;
|
namespace MeloongCore;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
+1
-3
@@ -1,6 +1,4 @@
|
|||||||
using System;
|
namespace MeloongCore;
|
||||||
|
|
||||||
namespace MeloongCore;
|
|
||||||
|
|
||||||
public readonly struct OneOf<T0, T1> {
|
public readonly struct OneOf<T0, T1> {
|
||||||
private readonly int _index;
|
private readonly int _index;
|
||||||
|
|||||||
+31
-18
@@ -1,25 +1,38 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net462</TargetFramework>
|
<TargetFramework>net462</TargetFramework>
|
||||||
<OutputType>Library</OutputType>
|
<OutputType>Library</OutputType>
|
||||||
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
|
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
|
||||||
<OutDir>bin\</OutDir>
|
<OutDir>bin\</OutDir>
|
||||||
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
|
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
|
||||||
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
|
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
|
||||||
<Configurations>Debug;Release;Snapshot</Configurations>
|
<Configurations>Debug;Release;Snapshot</Configurations>
|
||||||
<Deterministic>true</Deterministic>
|
<Deterministic>true</Deterministic>
|
||||||
<LangVersion>13.0</LangVersion>
|
<LangVersion>13.0</LangVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
<ItemGroup>
|
||||||
<DefineConstants>$(DefineConstants);SNAPSHOT</DefineConstants>
|
<Using Include="System" />
|
||||||
</PropertyGroup>
|
<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'">
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'" />
|
||||||
<Optimize>True</Optimize>
|
|
||||||
</PropertyGroup>
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Snapshot|AnyCPU'">
|
||||||
|
<Optimize>True</Optimize>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
@@ -1,12 +1,4 @@
|
|||||||
using MeloongCore.Extensions;
|
namespace MeloongCore;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace MeloongCore;
|
|
||||||
public static class DirectoryUtils {
|
public static class DirectoryUtils {
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
+3
-7
@@ -1,10 +1,6 @@
|
|||||||
using MeloongCore.Extensions;
|
using System.Numerics;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Numerics;
|
|
||||||
namespace MeloongCore;
|
|
||||||
|
|
||||||
|
namespace MeloongCore;
|
||||||
public static class MathUtils {
|
public static class MathUtils {
|
||||||
|
|
||||||
#region 进制转换
|
#region 进制转换
|
||||||
@@ -62,7 +58,7 @@ public static class MathUtils {
|
|||||||
// 负数的结束处理与返回
|
// 负数的结束处理与返回
|
||||||
if (isNegative) results.Add('-');
|
if (isNegative) results.Add('-');
|
||||||
results.Reverse();
|
results.Reverse();
|
||||||
return new string(results.ToArray());
|
return new([..results]);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
+1
-6
@@ -1,9 +1,4 @@
|
|||||||
using MeloongCore.Extensions;
|
namespace MeloongCore;
|
||||||
using System.IO;
|
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
using System.Text;
|
|
||||||
namespace MeloongCore;
|
|
||||||
|
|
||||||
public static class PathUtils {
|
public static class PathUtils {
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
Reference in new issue
Block a user