6 Commits
1.4.0 ... 1.4.1

Author SHA1 Message Date
Matt Nadareski
e596c7c2c1 Bump version 2024-11-15 20:32:23 -05:00
Matt Nadareski
910e963d13 Port extension attribute instead of framework gating 2024-11-15 20:30:15 -05:00
Matt Nadareski
751519fadb Framework only matters for executable 2024-11-15 20:20:33 -05:00
Matt Nadareski
f86f565136 Ensure tests pass 2024-11-13 00:43:29 -05:00
Matt Nadareski
1ad45c6d59 Ensure tests pass 2024-11-13 00:42:49 -05:00
Matt Nadareski
38796776ee Add .NET 9 to target frameworks 2024-11-13 00:34:24 -05:00
8 changed files with 24 additions and 78 deletions

View File

@@ -20,6 +20,12 @@ jobs:
- name: Restore dependencies
run: dotnet restore
- name: Build library
run: dotnet build
- name: Run tests
run: dotnet test
- name: Pack
run: dotnet pack

View File

@@ -14,4 +14,7 @@ jobs:
dotnet-version: 9.0.x
- name: Build
run: dotnet build
run: dotnet build
- name: Run tests
run: dotnet test

View File

@@ -0,0 +1,9 @@
#if NET20
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class | AttributeTargets.Method)]
internal sealed class ExtensionAttribute : Attribute {}
}
#endif

View File

@@ -9,11 +9,7 @@ namespace SabreTools.Matching
/// <summary>
/// Indicates whether the specified array is null or has a length of zero
/// </summary>
#if NET20
public static bool IsNullOrEmpty(Array? array)
#else
public static bool IsNullOrEmpty(this Array? array)
#endif
{
return array == null || array.Length == 0;
}
@@ -21,11 +17,7 @@ namespace SabreTools.Matching
/// <summary>
/// Find all positions of one array in another, if possible, if possible
/// </summary>
#if NET20
public static List<int> FindAllPositions(byte[] stack, byte?[]? needle, int start = 0, int end = -1)
#else
public static List<int> FindAllPositions(this byte[] stack, byte?[]? needle, int start = 0, int end = -1)
#endif
{
// Get the outgoing list
List<int> positions = [];
@@ -51,11 +43,7 @@ namespace SabreTools.Matching
/// <summary>
/// Find the first position of one array in another, if possible
/// </summary>
#if NET20
public static bool FirstPosition(byte[] stack, byte[]? needle, out int position, int start = 0, int end = -1)
#else
public static bool FirstPosition(this byte[] stack, byte[]? needle, out int position, int start = 0, int end = -1)
#endif
{
// Convert the needle to a nullable byte array
byte?[]? nullableNeedle = null;
@@ -68,11 +56,7 @@ namespace SabreTools.Matching
/// <summary>
/// Find the first position of one array in another, if possible
/// </summary>
#if NET20
public static bool FirstPosition(byte[] stack, byte?[]? needle, out int position, int start = 0, int end = -1)
#else
public static bool FirstPosition(this byte[] stack, byte?[]? needle, out int position, int start = 0, int end = -1)
#endif
{
var matcher = new ContentMatch(needle, start, end);
position = matcher.Match(stack, false);
@@ -82,11 +66,7 @@ namespace SabreTools.Matching
/// <summary>
/// Find the last position of one array in another, if possible
/// </summary>
#if NET20
public static bool LastPosition(byte[] stack, byte[]? needle, out int position, int start = 0, int end = -1)
#else
public static bool LastPosition(this byte[] stack, byte[]? needle, out int position, int start = 0, int end = -1)
#endif
{
// Convert the needle to a nullable byte array
byte?[]? nullableNeedle = null;
@@ -99,11 +79,7 @@ namespace SabreTools.Matching
/// <summary>
/// Find the last position of one array in another, if possible
/// </summary>
#if NET20
public static bool LastPosition(byte[] stack, byte?[]? needle, out int position, int start = 0, int end = -1)
#else
public static bool LastPosition(this byte[] stack, byte?[]? needle, out int position, int start = 0, int end = -1)
#endif
{
var matcher = new ContentMatch(needle, start, end);
position = matcher.Match(stack, true);
@@ -113,11 +89,7 @@ namespace SabreTools.Matching
/// <summary>
/// See if a byte array starts with another
/// </summary>
#if NET20
public static bool StartsWith(byte[] stack, byte[]? needle, bool exact = false)
#else
public static bool StartsWith(this byte[] stack, byte[]? needle, bool exact = false)
#endif
{
// If we have any invalid inputs, we return false
if (needle == null
@@ -134,11 +106,7 @@ namespace SabreTools.Matching
/// <summary>
/// See if a byte array starts with another
/// </summary>
#if NET20
public static bool StartsWith(byte[] stack, byte?[]? needle, bool exact = false)
#else
public static bool StartsWith(this byte[] stack, byte?[]? needle, bool exact = false)
#endif
{
// If we have any invalid inputs, we return false
if (needle == null
@@ -155,11 +123,7 @@ namespace SabreTools.Matching
/// <summary>
/// See if a byte array ends with another
/// </summary>
#if NET20
public static bool EndsWith(byte[] stack, byte[]? needle, bool exact = false)
#else
public static bool EndsWith(this byte[] stack, byte[]? needle, bool exact = false)
#endif
{
// If we have any invalid inputs, we return false
if (needle == null
@@ -176,11 +140,7 @@ namespace SabreTools.Matching
/// <summary>
/// See if a byte array ends with another
/// </summary>
#if NET20
public static bool EndsWith(byte[] stack, byte?[]? needle, bool exact = false)
#else
public static bool EndsWith(this byte[] stack, byte?[]? needle, bool exact = false)
#endif
{
// If we have any invalid inputs, we return false
if (needle == null

View File

@@ -67,16 +67,7 @@ namespace SabreTools.Matching
continue;
// Format the list of all positions found
#if NET20 || NET35
var positionStrs = new List<string>();
foreach (int pos in positions)
{
positionStrs.Add(pos.ToString());
}
string positionsString = string.Join(", ", [.. positionStrs]);
#else
string positionsString = string.Join(", ", positions);
#endif
string positionsString = string.Join(", ", [.. positions.ConvertAll(p => p.ToString())]);
// If we there is no version method, just return the match name
if (matcher.GetArrayVersion == null)
@@ -162,16 +153,7 @@ namespace SabreTools.Matching
continue;
// Format the list of all positions found
#if NET20 || NET35
var positionStrs = new List<string>();
foreach (int pos in positions)
{
positionStrs.Add(pos.ToString());
}
string positionsString = string.Join(", ", [.. positionStrs]);
#else
string positionsString = string.Join(", ", positions);
#endif
string positionsString = string.Join(", ", [.. positions.ConvertAll(p => p.ToString())]);
// If we there is no version method, just return the match name
if (matcher.GetStreamVersion == null)

View File

@@ -6,7 +6,7 @@
<LangVersion>latest</LangVersion>
<Nullable>enable</Nullable>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<Version>1.4.0</Version>
<Version>1.4.1</Version>
<!-- Package Properties -->
<Authors>Matt Nadareski</Authors>
@@ -21,20 +21,6 @@
<WarningsNotAsErrors>NU1903</WarningsNotAsErrors>
</PropertyGroup>
<!-- Support All Frameworks -->
<PropertyGroup Condition="$(TargetFramework.StartsWith(`net2`)) OR $(TargetFramework.StartsWith(`net3`)) OR $(TargetFramework.StartsWith(`net4`))">
<RuntimeIdentifiers>win-x86;win-x64</RuntimeIdentifiers>
</PropertyGroup>
<PropertyGroup Condition="$(TargetFramework.StartsWith(`netcoreapp`)) OR $(TargetFramework.StartsWith(`net5`))">
<RuntimeIdentifiers>win-x86;win-x64;win-arm64;linux-x64;linux-arm64;osx-x64</RuntimeIdentifiers>
</PropertyGroup>
<PropertyGroup Condition="$(TargetFramework.StartsWith(`net6`)) OR $(TargetFramework.StartsWith(`net7`)) OR $(TargetFramework.StartsWith(`net8`)) OR $(TargetFramework.StartsWith(`net9`))">
<RuntimeIdentifiers>win-x86;win-x64;win-arm64;linux-x64;linux-arm64;osx-x64;osx-arm64</RuntimeIdentifiers>
</PropertyGroup>
<PropertyGroup Condition="$(RuntimeIdentifier.StartsWith(`osx-arm`))">
<TargetFrameworks>net6.0;net7.0;net8.0;net9.0</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<None Include="../README.md" Pack="true" PackagePath="" />
</ItemGroup>

View File

@@ -1,7 +1,7 @@
#! /bin/bash
# This batch file assumes the following:
# - .NET 8.0 (or newer) SDK is installed and in PATH
# - .NET 9.0 (or newer) SDK is installed and in PATH
#
# If any of these are not satisfied, the operation may fail
# in an unpredictable way and result in an incomplete output.

View File

@@ -1,5 +1,5 @@
# This batch file assumes the following:
# - .NET 8.0 (or newer) SDK is installed and in PATH
# - .NET 9.0 (or newer) SDK is installed and in PATH
#
# If any of these are not satisfied, the operation may fail
# in an unpredictable way and result in an incomplete output.