Support ancient .NET in NaturalSort

This commit is contained in:
Matt Nadareski
2024-02-28 19:52:25 -05:00
parent 778399cad7
commit 953e0c028d
4 changed files with 27 additions and 9 deletions

View File

@@ -48,13 +48,13 @@ namespace NaturalSort
if (!table.TryGetValue(x, out string[]? x1)) if (!table.TryGetValue(x, out string[]? x1))
{ {
//x1 = Regex.Split(x.Replace(" ", string.Empty), "([0-9]+)"); //x1 = Regex.Split(x.Replace(" ", string.Empty), "([0-9]+)");
x1 = Regex.Split(x.ToLowerInvariant(), "([0-9]+)").Where(s => !string.IsNullOrWhiteSpace(s)).ToArray(); x1 = Regex.Split(x.ToLowerInvariant(), "([0-9]+)").Where(s => !string.IsNullOrEmpty(s)).ToArray();
table.Add(x, x1); table.Add(x, x1);
} }
if (!table.TryGetValue(y, out string[]? y1)) if (!table.TryGetValue(y, out string[]? y1))
{ {
//y1 = Regex.Split(y.Replace(" ", string.Empty), "([0-9]+)"); //y1 = Regex.Split(y.Replace(" ", string.Empty), "([0-9]+)");
y1 = Regex.Split(y.ToLowerInvariant(), "([0-9]+)").Where(s => !string.IsNullOrWhiteSpace(s)).ToArray(); y1 = Regex.Split(y.ToLowerInvariant(), "([0-9]+)").Where(s => !string.IsNullOrEmpty(s)).ToArray();
table.Add(y, y1); table.Add(y, y1);
} }

View File

@@ -48,13 +48,13 @@ namespace NaturalSort
if (!table.TryGetValue(x, out string[]? x1)) if (!table.TryGetValue(x, out string[]? x1))
{ {
//x1 = Regex.Split(x.Replace(" ", string.Empty), "([0-9]+)"); //x1 = Regex.Split(x.Replace(" ", string.Empty), "([0-9]+)");
x1 = Regex.Split(x.ToLowerInvariant(), "([0-9]+)").Where(s => !string.IsNullOrWhiteSpace(s)).ToArray(); x1 = Regex.Split(x.ToLowerInvariant(), "([0-9]+)").Where(s => !string.IsNullOrEmpty(s)).ToArray();
table.Add(x, x1); table.Add(x, x1);
} }
if (!table.TryGetValue(y, out string[]? y1)) if (!table.TryGetValue(y, out string[]? y1))
{ {
//y1 = Regex.Split(y.Replace(" ", string.Empty), "([0-9]+)"); //y1 = Regex.Split(y.Replace(" ", string.Empty), "([0-9]+)");
y1 = Regex.Split(y.ToLowerInvariant(), "([0-9]+)").Where(s => !string.IsNullOrWhiteSpace(s)).ToArray(); y1 = Regex.Split(y.ToLowerInvariant(), "([0-9]+)").Where(s => !string.IsNullOrEmpty(s)).ToArray();
table.Add(y, y1); table.Add(y, y1);
} }

View File

@@ -1,10 +1,28 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFrameworks>net6.0;net8.0</TargetFrameworks> <!-- Assembly Properties -->
<TargetFrameworks>net20;net35;net40;net452;net462;net472;net48;netcoreapp3.1;net5.0;net6.0;net7.0;net8.0</TargetFrameworks>
<RuntimeIdentifiers>win-x86;win-x64;win-arm64;linux-x64;linux-arm64;osx-x64</RuntimeIdentifiers>
<CheckEolTargetFramework>false</CheckEolTargetFramework>
<IncludeSourceRevisionInInformationalVersion>false</IncludeSourceRevisionInInformationalVersion>
<LangVersion>latest</LangVersion> <LangVersion>latest</LangVersion>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<SuppressTfmSupportBuildWarnings>true</SuppressTfmSupportBuildWarnings>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors> <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<Version>1.1.2</Version>
<!-- Package Properties -->
<Authors>Matt Nadareski</Authors>
<Copyright>Copyright (c)2016-2023 motoschifo, Matt Nadareski</Copyright>
<PackageProjectUrl>https://github.com/SabreTools/</PackageProjectUrl>
<RepositoryUrl>https://github.com/SabreTools/SabreTools</RepositoryUrl>
<RepositoryType>git</RepositoryType>
</PropertyGroup> </PropertyGroup>
<!-- Support for old .NET versions -->
<ItemGroup Condition="$(TargetFramework.StartsWith(`net2`)) OR $(TargetFramework.StartsWith(`net3`))">
<PackageReference Include="Net30.LinqBridge" Version="1.3.0" />
</ItemGroup>
</Project> </Project>