15 Commits
1.5.1 ... 1.6.0

Author SHA1 Message Date
Matt Nadareski
036ee4246b Bump version 2025-07-23 10:13:30 -04:00
Matt Nadareski
8e3bcb9015 Update nuget packages 2025-07-23 10:11:08 -04:00
Matt Nadareski
8b1ac53ccf Remove now-unnecessary prefixes 2025-07-23 10:08:53 -04:00
Matt Nadareski
0c9e255d48 Split tests to match classes 2025-07-23 10:08:30 -04:00
Matt Nadareski
1227488572 Be consistent about end-of-file newlines 2025-07-23 10:07:10 -04:00
Matt Nadareski
bd878cf1a1 Fix nullability issue in MatchUtil 2025-07-23 10:04:43 -04:00
Matt Nadareski
b436b64c3a Be consistent about end-of-file newlines 2025-07-23 10:00:50 -04:00
Matt Nadareski
6f6d071a79 Add summaries to IMatch 2025-07-23 09:58:46 -04:00
Matt Nadareski
69130a6e9f Add .NET Standard 2.0 and 2.1 2025-07-23 09:52:35 -04:00
Matt Nadareski
93847420a5 Bump version 2025-05-12 08:11:12 -04:00
Matt Nadareski
76e13a47ec Fix length-based comparison issue 2025-05-12 08:09:59 -04:00
Matt Nadareski
4f56d716d4 Update copyright 2024-12-30 21:20:49 -05:00
Matt Nadareski
cd7e89f869 Remove unnecessary action step 2024-12-30 21:20:32 -05:00
Matt Nadareski
0810b4b083 Ensure .NET versions are installed for testing 2024-12-19 10:51:23 -05:00
Matt Nadareski
ba0b126714 Ensure .NET versions are installed for testing 2024-12-19 10:49:39 -05:00
26 changed files with 103 additions and 51 deletions

View File

@@ -16,7 +16,10 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 9.0.x
dotnet-version: |
6.0.x
8.0.x
9.0.x
- name: Run tests
run: dotnet test
@@ -24,12 +27,6 @@ jobs:
- name: Run publish script
run: ./publish-nix.sh
- name: Upload build
uses: actions/upload-artifact@v4
with:
name: 'Nuget Package'
path: "*.nupkg,*.snupkg"
- name: Upload to rolling
uses: ncipollo/release-action@v1.14.0
with:

View File

@@ -11,7 +11,10 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 9.0.x
dotnet-version: |
6.0.x
8.0.x
9.0.x
- name: Build
run: dotnet build

View File

@@ -8,7 +8,7 @@ namespace SabreTools.Matching.Test.Compare
public class NaturalComparerTests
{
[Fact]
public void NaturalComparer_ListSortTest()
public void ListSort_Numeric()
{
// Setup arrays
string[] sortable = ["0", "100", "5", "2", "1000"];
@@ -22,17 +22,17 @@ namespace SabreTools.Matching.Test.Compare
}
[Fact]
public void NaturalReversedComparer_ListSortTest()
public void ListSort_Mixed()
{
// Setup arrays
string[] sortable = ["0", "100", "5", "2", "1000"];
string[] expected = ["1000", "100", "5", "2", "0"];
string[] sortable = ["b3b", "c", "b", "a", "a1"];
string[] expected = ["a", "a1", "b", "b3b", "c"];
// Run sorting on array
Array.Sort(sortable, new NaturalReversedComparer());
Array.Sort(sortable, new NaturalComparer());
// Check the output
Assert.True(sortable.SequenceEqual(expected));
}
}
}
}

View File

@@ -11,7 +11,7 @@ namespace SabreTools.Matching.Test.Compare
int actual = NaturalComparerUtil.ComparePaths(null, null);
Assert.Equal(0, actual);
}
[Fact]
public void CompareNumeric_SingleNull_Ordered()
{
@@ -63,4 +63,4 @@ namespace SabreTools.Matching.Test.Compare
Assert.Equal(-1, actual);
}
}
}
}

View File

@@ -0,0 +1,38 @@
using System;
using System.Linq;
using SabreTools.Matching.Compare;
using Xunit;
namespace SabreTools.Matching.Test.Compare
{
public class NaturalReversedComparerTests
{
[Fact]
public void ListSort_Numeric()
{
// Setup arrays
string[] sortable = ["0", "100", "5", "2", "1000"];
string[] expected = ["1000", "100", "5", "2", "0"];
// Run sorting on array
Array.Sort(sortable, new NaturalReversedComparer());
// Check the output
Assert.True(sortable.SequenceEqual(expected));
}
[Fact]
public void ListSort_Mixed()
{
// Setup arrays
string[] sortable = ["b3b", "c", "b", "a", "a1"];
string[] expected = ["c", "b3b", "b", "a1", "a"];
// Run sorting on array
Array.Sort(sortable, new NaturalReversedComparer());
// Check the output
Assert.True(sortable.SequenceEqual(expected));
}
}
}

View File

@@ -199,4 +199,4 @@ namespace SabreTools.Matching.Test.Content
#endregion
}
}
}

View File

@@ -268,4 +268,4 @@ namespace SabreTools.Matching.Test.Content
#endregion
}
}
}

View File

@@ -393,4 +393,4 @@ namespace SabreTools.Matching.Test
#endregion
}
}
}

View File

@@ -321,4 +321,4 @@ namespace SabreTools.Matching.Test
#endregion
}
}
}

View File

@@ -19,4 +19,4 @@ namespace SabreTools.Matching.Test.Paths
Assert.Equal(expected, fpm.Needle);
}
}
}
}

View File

@@ -183,4 +183,4 @@ namespace SabreTools.Matching.Test.Paths
#endregion
}
}
}

View File

@@ -290,4 +290,4 @@ namespace SabreTools.Matching.Test.Paths
#endregion
}
}
}

View File

@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net6.0;net8.0;net9.0</TargetFrameworks>
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
<IsPackable>false</IsPackable>
<LangVersion>latest</LangVersion>
<NoWarn>NU1903</NoWarn>
@@ -10,13 +10,13 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="coverlet.collector" Version="6.0.2">
<PackageReference Include="coverlet.collector" Version="6.0.4">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageReference Include="xunit" Version="2.9.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.14.1" />
<PackageReference Include="xunit" Version="2.9.3" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.3">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>

View File

@@ -66,9 +66,9 @@ namespace SabreTools.Matching.Compare
return PartCompare(x1[i], y1[i]);
}
if (y1.Length > x1.Length)
if (x1.Length > y1.Length)
return 1;
else if (x1.Length > y1.Length)
else if (y1.Length > x1.Length)
return -1;
else
return x.CompareTo(y);

View File

@@ -329,4 +329,4 @@ namespace SabreTools.Matching.Content
#endregion
}
}
}

View File

@@ -235,4 +235,4 @@ namespace SabreTools.Matching.Content
#endregion
}
}
}

View File

@@ -28,4 +28,4 @@ namespace SabreTools.Matching
/// <param name="positions">List of positions in the Stream that were matched</param>
/// <returns>Version string on success, null on failure</returns>
public delegate string? GetStreamVersion(string path, Stream? content, List<int> positions);
}
}

View File

@@ -6,4 +6,4 @@ namespace System.Runtime.CompilerServices
internal sealed class ExtensionAttribute : Attribute {}
}
#endif
#endif

View File

@@ -223,4 +223,4 @@ namespace SabreTools.Matching
return FirstPosition(stack, needle, start: stack.Length - needle.Length) > -1;
}
}
}
}

View File

@@ -1,7 +1,13 @@
namespace SabreTools.Matching
{
/// <summary>
/// Represents a matcher for a particular type
/// </summary>
public interface IMatch<T>
{
/// <summary>
/// Nullable typed data to be matched
/// </summary>
T? Needle { get; }
}
}

View File

@@ -17,4 +17,4 @@ namespace SabreTools.Matching
/// </summary>
public string SetName { get; }
}
}
}

View File

@@ -98,7 +98,7 @@ namespace SabreTools.Matching
var version = matcher.GetArrayVersion(file, stack, positions);
if (version == null)
continue;
// Trim and add the version
version = version.Trim();
if (version.Length > 0)
@@ -212,7 +212,7 @@ namespace SabreTools.Matching
var version = matcher.GetStreamVersion(file, stack, positions);
if (version == null)
continue;
// Trim and add the version
version = version.Trim();
if (version.Length > 0)
@@ -314,12 +314,20 @@ namespace SabreTools.Matching
foreach (var matcher in matchSets)
{
// Determine if the matcher passes
List<string> matches = any
? [matcher.MatchesAny(stack)]
: matcher.MatchesAll(stack);
List<string> matches = [];
if (any)
{
string? anyMatch = matcher.MatchesAny(stack);
if (anyMatch != null)
matches = [anyMatch];
}
else
{
matches = matcher.MatchesAll(stack);
}
// If we don't have a pass, just continue
if (matches.Count == 0 || matches[0] == null)
if (matches.Count == 0)
continue;
// Build the output string
@@ -333,7 +341,7 @@ namespace SabreTools.Matching
var version = matcher.GetVersion(matches[0], stack);
if (version == null)
continue;
// Trim and add the version
version = version.Trim();
if (version.Length > 0)
@@ -353,4 +361,4 @@ namespace SabreTools.Matching
#endregion
}
}
}

View File

@@ -15,4 +15,4 @@ namespace SabreTools.Matching.Paths
public FilePathMatch(string needle, bool matchCase = false)
: base($"{Path.DirectorySeparatorChar}{needle}", matchCase, true) { }
}
}
}

View File

@@ -89,4 +89,4 @@ namespace SabreTools.Matching.Paths
#endregion
}
}
}

View File

@@ -152,4 +152,4 @@ namespace SabreTools.Matching.Paths
#endregion
}
}
}

View File

@@ -2,19 +2,19 @@
<PropertyGroup>
<!-- Assembly Properties -->
<TargetFrameworks>net20;net35;net40;net452;net462;net472;net48;netcoreapp3.1;net5.0;net6.0;net7.0;net8.0;net9.0</TargetFrameworks>
<TargetFrameworks>net20;net35;net40;net452;net462;net472;net48;netcoreapp3.1;net5.0;net6.0;net7.0;net8.0;net9.0;netstandard2.0;netstandard2.1</TargetFrameworks>
<IncludeSymbols>true</IncludeSymbols>
<LangVersion>latest</LangVersion>
<NoWarn>NU1903</NoWarn>
<Nullable>enable</Nullable>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<Version>1.5.1</Version>
<Version>1.6.0</Version>
<!-- Package Properties -->
<Authors>Matt Nadareski</Authors>
<Description>Byte array and stream matching library</Description>
<Copyright>Copyright (c) Matt Nadareski 2018-2024</Copyright>
<Copyright>Copyright (c) Matt Nadareski 2018-2025</Copyright>
<PackageProjectUrl>https://github.com/SabreTools/</PackageProjectUrl>
<PackageReadmeFile>README.md</PackageReadmeFile>
<RepositoryUrl>https://github.com/SabreTools/SabreTools.Matching</RepositoryUrl>