diff --git a/MatchUtil.cs b/MatchUtil.cs
index 38563a8..fc910b7 100644
--- a/MatchUtil.cs
+++ b/MatchUtil.cs
@@ -1,4 +1,6 @@
+#if NET40_OR_GREATER || NETCOREAPP
using System.Collections.Concurrent;
+#endif
using System.Collections.Generic;
using System.IO;
using System.Linq;
@@ -20,7 +22,11 @@ namespace SabreTools.Matching
/// Enumerable of ContentMatchSets to be run on the file
/// True to include positional data, false otherwise
/// List of strings representing the matched protections, null or empty otherwise
+#if NET35
+ public static Queue? GetAllMatches(string file, byte[]? stack, IEnumerable? matchers, bool includeDebug = false)
+#else
public static ConcurrentQueue? GetAllMatches(string file, byte[]? stack, IEnumerable? matchers, bool includeDebug = false)
+#endif
{
return FindAllMatches(file, stack, matchers, includeDebug, false);
}
@@ -51,14 +57,22 @@ namespace SabreTools.Matching
/// True to include positional data, false otherwise
/// True to stop after the first match, false otherwise
/// List of strings representing the matched protections, null or empty otherwise
+#if NET35
+ private static Queue? FindAllMatches(string file, byte[]? stack, IEnumerable? matchers, bool includeDebug, bool stopAfterFirst)
+#else
private static ConcurrentQueue? FindAllMatches(string file, byte[]? stack, IEnumerable? matchers, bool includeDebug, bool stopAfterFirst)
+#endif
{
// If there's no mappings, we can't match
if (matchers == null || !matchers.Any())
return null;
// Initialize the queue of matched protections
+#if NET35
+ var matchedProtections = new Queue();
+#else
var matchedProtections = new ConcurrentQueue();
+#endif
// Loop through and try everything otherwise
foreach (var matcher in matchers)
@@ -75,7 +89,7 @@ namespace SabreTools.Matching
{
positionStrs.Add(pos.ToString());
}
- string positionsString = string.Join(", ", positionStrs.ToArray());
+ string positionsString = string.Join(", ", [.. positionStrs]);
#else
string positionsString = string.Join(", ", positions);
#endif
@@ -117,7 +131,11 @@ namespace SabreTools.Matching
/// Enumerable of ContentMatchSets to be run on the file
/// True to include positional data, false otherwise
/// List of strings representing the matched protections, null or empty otherwise
+#if NET35
+ public static Queue? GetAllMatches(string file, Stream? stack, IEnumerable? matchers, bool includeDebug = false)
+#else
public static ConcurrentQueue? GetAllMatches(string file, Stream? stack, IEnumerable? matchers, bool includeDebug = false)
+#endif
{
return FindAllMatches(file, stack, matchers, includeDebug, false);
}
@@ -148,14 +166,22 @@ namespace SabreTools.Matching
/// True to include positional data, false otherwise
/// True to stop after the first match, false otherwise
/// List of strings representing the matched protections, null or empty otherwise
+#if NET35
+ private static Queue? FindAllMatches(string file, Stream? stack, IEnumerable? matchers, bool includeDebug, bool stopAfterFirst)
+#else
private static ConcurrentQueue? FindAllMatches(string file, Stream? stack, IEnumerable? matchers, bool includeDebug, bool stopAfterFirst)
+#endif
{
// If there's no mappings, we can't match
if (matchers == null || !matchers.Any())
return null;
// Initialize the queue of matched protections
+#if NET35
+ var matchedProtections = new Queue();
+#else
var matchedProtections = new ConcurrentQueue();
+#endif
// Loop through and try everything otherwise
foreach (var matcher in matchers)
@@ -172,7 +198,7 @@ namespace SabreTools.Matching
{
positionStrs.Add(pos.ToString());
}
- string positionsString = string.Join(", ", positionStrs.ToArray());
+ string positionsString = string.Join(", ", [.. positionStrs]);
#else
string positionsString = string.Join(", ", positions);
#endif
@@ -213,7 +239,11 @@ namespace SabreTools.Matching
/// Enumerable of PathMatchSets to be run on the file
/// True if any path match is a success, false if all have to match
/// List of strings representing the matched protections, null or empty otherwise
+#if NET35
+ public static Queue GetAllMatches(string file, IEnumerable? matchers, bool any = false)
+#else
public static ConcurrentQueue GetAllMatches(string file, IEnumerable? matchers, bool any = false)
+#endif
{
return FindAllMatches(new List { file }, matchers, any, false);
}
@@ -225,7 +255,11 @@ namespace SabreTools.Matching
/// Enumerable of PathMatchSets to be run on the file
/// True if any path match is a success, false if all have to match
/// List of strings representing the matched protections, null or empty otherwise
+#if NET35
+ public static Queue GetAllMatches(IEnumerable? files, IEnumerable? matchers, bool any = false)
+#else
public static ConcurrentQueue GetAllMatches(IEnumerable? files, IEnumerable? matchers, bool any = false)
+#endif
{
return FindAllMatches(files, matchers, any, false);
}
@@ -270,21 +304,29 @@ namespace SabreTools.Matching
/// True if any path match is a success, false if all have to match
/// True to stop after the first match, false otherwise
/// List of strings representing the matched protections, null or empty otherwise
+#if NET35
+ private static Queue FindAllMatches(IEnumerable? files, IEnumerable? matchers, bool any, bool stopAfterFirst)
+#else
private static ConcurrentQueue FindAllMatches(IEnumerable? files, IEnumerable? matchers, bool any, bool stopAfterFirst)
+#endif
{
// If there's no mappings, we can't match
if (matchers == null || !matchers.Any())
- return new ConcurrentQueue();
+ return new();
// Initialize the list of matched protections
+#if NET35
+ var matchedProtections = new Queue();
+#else
var matchedProtections = new ConcurrentQueue();
+#endif
// Loop through and try everything otherwise
foreach (var matcher in matchers)
{
// Determine if the matcher passes
bool passes;
- var firstMatchedString = string.Empty;
+ string? firstMatchedString;
if (any)
{
(bool anyPasses, var matchedString) = matcher.MatchesAny(files);
diff --git a/SabreTools.Matching.csproj b/SabreTools.Matching.csproj
index 3bce46c..9a69395 100644
--- a/SabreTools.Matching.csproj
+++ b/SabreTools.Matching.csproj
@@ -2,7 +2,7 @@
- net40;net452;net462;net472;net48;netcoreapp3.1;net5.0;net6.0;net7.0;net8.0
+ net35;net40;net452;net462;net472;net48;netcoreapp3.1;net5.0;net6.0;net7.0;net8.0
win-x86;win-x64;win-arm64;linux-x64;linux-arm64;osx-x64;osx-arm64
latest
enable
@@ -26,6 +26,9 @@
+
+
+