From ffca922035d0de9874733ed1f248a6c88e3b003f Mon Sep 17 00:00:00 2001 From: rameel Date: Sat, 5 Jul 2025 22:49:07 +0500 Subject: [PATCH 1/8] Update NuGet packages --- Ramstack.Globbing.Tests/Ramstack.Globbing.Tests.csproj | 8 ++++---- Ramstack.Globbing/Ramstack.Globbing.csproj | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Ramstack.Globbing.Tests/Ramstack.Globbing.Tests.csproj b/Ramstack.Globbing.Tests/Ramstack.Globbing.Tests.csproj index a36ea1e..2a75b0b 100644 --- a/Ramstack.Globbing.Tests/Ramstack.Globbing.Tests.csproj +++ b/Ramstack.Globbing.Tests/Ramstack.Globbing.Tests.csproj @@ -12,10 +12,10 @@ - - - - + + + + diff --git a/Ramstack.Globbing/Ramstack.Globbing.csproj b/Ramstack.Globbing/Ramstack.Globbing.csproj index a86a289..4cbbbbb 100644 --- a/Ramstack.Globbing/Ramstack.Globbing.csproj +++ b/Ramstack.Globbing/Ramstack.Globbing.csproj @@ -42,7 +42,7 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive From 4496b883372da20e6f3d64f605b70b1c707850ba Mon Sep 17 00:00:00 2001 From: rameel Date: Sat, 5 Jul 2025 23:01:52 +0500 Subject: [PATCH 2/8] Reduce number of checks, allowing better CQ --- Ramstack.Globbing/Internal/FileTreeHelper.cs | 22 +++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/Ramstack.Globbing/Internal/FileTreeHelper.cs b/Ramstack.Globbing/Internal/FileTreeHelper.cs index 4f9f0b7..1ff5fb1 100644 --- a/Ramstack.Globbing/Internal/FileTreeHelper.cs +++ b/Ramstack.Globbing/Internal/FileTreeHelper.cs @@ -10,28 +10,34 @@ internal static class FileTreeHelper /// /// Constructs the full name of a file by combining the path and the name. /// - /// A buffer used for constructing the full name. + /// A buffer used for constructing the full name. /// It should be obtained from an array pool and will be resized if necessary. /// The path of the file. /// The name of the file. /// /// A representing the full name of the file. /// - public static ReadOnlySpan GetFullName(ref char[] buffer, string path, string name) + public static ReadOnlySpan GetFullName(ref char[] chars, string path, string name) { - var length = path.Length + name.Length + 1; - if (buffer.Length < length) + var array = chars; + var count = path.Length + name.Length + 1; + + if (array.Length < count) { - ArrayPool.Shared.Return(buffer); - buffer = ArrayPool.Shared.Rent(length); + ArrayPool.Shared.Return(array); + array = ArrayPool.Shared.Rent(count); + chars = array; + + // Force null check to assist JIT + _ = array.Length; } - var fullName = buffer.AsSpan(0, length); + var fullName = array.AsSpan(); path.TryCopyTo(fullName); fullName[path.Length] = '/'; name.TryCopyTo(fullName.Slice(path.Length + 1)); - return fullName; + return fullName.Slice(0, count); } } From ea2dfa7c130b20508504a9865974955b95a5c824 Mon Sep 17 00:00:00 2001 From: rameel Date: Sat, 5 Jul 2025 23:07:29 +0500 Subject: [PATCH 3/8] Remove type specifications --- .../Traversal/DirectoryInfoExtensions.cs | 18 +++++++++--------- Ramstack.Globbing/Traversal/Files.cs | 6 +++--- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Ramstack.Globbing/Traversal/DirectoryInfoExtensions.cs b/Ramstack.Globbing/Traversal/DirectoryInfoExtensions.cs index 4cb40d2..0777dab 100644 --- a/Ramstack.Globbing/Traversal/DirectoryInfoExtensions.cs +++ b/Ramstack.Globbing/Traversal/DirectoryInfoExtensions.cs @@ -755,10 +755,10 @@ private static IEnumerable EnumerateFiles(string path, string[] patter { flags = Files.AdjustMatchFlags(flags); - return new FileSystemEnumerable(path, (ref FileSystemEntry entry) => (FileInfo)entry.ToFileSystemInfo(), options) + return new FileSystemEnumerable(path, (ref entry) => (FileInfo)entry.ToFileSystemInfo(), options) { - ShouldIncludePredicate = (ref FileSystemEntry entry) => Files.ShouldInclude(ref entry, patterns, excludes, flags, target), - ShouldRecursePredicate = (ref FileSystemEntry entry) => Files.ShouldRecurse(ref entry, patterns, excludes, flags) + ShouldIncludePredicate = (ref entry) => Files.ShouldInclude(ref entry, patterns, excludes, flags, target), + ShouldRecursePredicate = (ref entry) => Files.ShouldRecurse(ref entry, patterns, excludes, flags) }; } @@ -766,10 +766,10 @@ private static IEnumerable EnumerateDirectories(string path, stri { flags = Files.AdjustMatchFlags(flags); - return new FileSystemEnumerable(path, (ref FileSystemEntry entry) => (DirectoryInfo)entry.ToFileSystemInfo(), options) + return new FileSystemEnumerable(path, (ref entry) => (DirectoryInfo)entry.ToFileSystemInfo(), options) { - ShouldIncludePredicate = (ref FileSystemEntry entry) => Files.ShouldInclude(ref entry, patterns, excludes, flags, target), - ShouldRecursePredicate = (ref FileSystemEntry entry) => Files.ShouldRecurse(ref entry, patterns, excludes, flags) + ShouldIncludePredicate = (ref entry) => Files.ShouldInclude(ref entry, patterns, excludes, flags, target), + ShouldRecursePredicate = (ref entry) => Files.ShouldRecurse(ref entry, patterns, excludes, flags) }; } @@ -777,10 +777,10 @@ private static IEnumerable EnumerateInfos(string path, string[] { flags = Files.AdjustMatchFlags(flags); - return new FileSystemEnumerable(path, (ref FileSystemEntry entry) => entry.ToFileSystemInfo(), options) + return new FileSystemEnumerable(path, (ref entry) => entry.ToFileSystemInfo(), options) { - ShouldIncludePredicate = (ref FileSystemEntry entry) => Files.ShouldInclude(ref entry, patterns, excludes, flags, target), - ShouldRecursePredicate = (ref FileSystemEntry entry) => Files.ShouldRecurse(ref entry, patterns, excludes, flags) + ShouldIncludePredicate = (ref entry) => Files.ShouldInclude(ref entry, patterns, excludes, flags, target), + ShouldRecursePredicate = (ref entry) => Files.ShouldRecurse(ref entry, patterns, excludes, flags) }; } } diff --git a/Ramstack.Globbing/Traversal/Files.cs b/Ramstack.Globbing/Traversal/Files.cs index 55e8cdc..c6e3c18 100644 --- a/Ramstack.Globbing/Traversal/Files.cs +++ b/Ramstack.Globbing/Traversal/Files.cs @@ -755,10 +755,10 @@ private static IEnumerable EnumerateEntries(string path, string[] patter { flags = AdjustMatchFlags(flags); - return new FileSystemEnumerable(Path.GetFullPath(path), (ref FileSystemEntry entry) => entry.ToFullPath(), options) + return new FileSystemEnumerable(Path.GetFullPath(path), (ref entry) => entry.ToFullPath(), options) { - ShouldIncludePredicate = (ref FileSystemEntry entry) => ShouldInclude(ref entry, patterns, excludes, flags, target), - ShouldRecursePredicate = (ref FileSystemEntry entry) => ShouldRecurse(ref entry, patterns, excludes, flags) + ShouldIncludePredicate = (ref entry) => ShouldInclude(ref entry, patterns, excludes, flags, target), + ShouldRecursePredicate = (ref entry) => ShouldRecurse(ref entry, patterns, excludes, flags) }; } } From 31f3ce07a2a9330d42f850efe2c083c45f8641ac Mon Sep 17 00:00:00 2001 From: rameel Date: Sat, 5 Jul 2025 23:15:56 +0500 Subject: [PATCH 4/8] Use double quotes --- .../Traversal/DirectoryInfoExtensions.cs | 120 +++++++++--------- Ramstack.Globbing/Traversal/Files.cs | 120 +++++++++--------- 2 files changed, 120 insertions(+), 120 deletions(-) diff --git a/Ramstack.Globbing/Traversal/DirectoryInfoExtensions.cs b/Ramstack.Globbing/Traversal/DirectoryInfoExtensions.cs index 0777dab..c8ed791 100644 --- a/Ramstack.Globbing/Traversal/DirectoryInfoExtensions.cs +++ b/Ramstack.Globbing/Traversal/DirectoryInfoExtensions.cs @@ -23,19 +23,19 @@ public static class DirectoryInfoExtensions /// /// /// - /// Supported meta-characters include '*', '?', '\' and '[', ']'. - /// And inside character classes '-', '!' and ']'. + /// Supported meta-characters include "*", "?", "\" and "[", "]". + /// And inside character classes "-", "!" and "]". /// /// /// /// - /// The '.' and '..' symbols do not have any special treatment and are processed + /// The "." and ".." symbols do not have any special treatment and are processed /// as regular characters for matching. /// /// /// /// - /// Character classes can be negated by prefixing them with '!', such as [!0-9], + /// Character classes can be negated by prefixing them with "!", such as [!0-9], /// which matches all characters except digits. /// /// @@ -59,7 +59,7 @@ public static class DirectoryInfoExtensions /// /// /// - /// The '**' sequence in the glob pattern can be used to match zero or more directories and subdirectories. + /// The "**" sequence in the glob pattern can be used to match zero or more directories and subdirectories. /// It can be used at the beginning, middle, or end of a pattern, for example, /// "**/file.txt", "dir/**/*.txt", "dir/**". /// @@ -85,19 +85,19 @@ public static IEnumerable EnumerateFiles(this DirectoryInfo directory, /// /// /// - /// Supported meta-characters include '*', '?', '\' and '[', ']'. - /// And inside character classes '-', '!' and ']'. + /// Supported meta-characters include "*", "?", "\" and "[", "]". + /// And inside character classes "-", "!" and "]". /// /// /// /// - /// The '.' and '..' symbols do not have any special treatment and are processed + /// The "." and ".." symbols do not have any special treatment and are processed /// as regular characters for matching. /// /// /// /// - /// Character classes can be negated by prefixing them with '!', such as [!0-9], + /// Character classes can be negated by prefixing them with "!", such as [!0-9], /// which matches all characters except digits. /// /// @@ -121,7 +121,7 @@ public static IEnumerable EnumerateFiles(this DirectoryInfo directory, /// /// /// - /// The '**' sequence in the glob pattern can be used to match zero or more directories and subdirectories. + /// The "**" sequence in the glob pattern can be used to match zero or more directories and subdirectories. /// It can be used at the beginning, middle, or end of a pattern, for example, /// "**/file.txt", "dir/**/*.txt", "dir/**". /// @@ -147,19 +147,19 @@ public static IEnumerable EnumerateFiles(this DirectoryInfo directory, /// /// /// - /// Supported meta-characters include '*', '?', '\' and '[', ']'. - /// And inside character classes '-', '!' and ']'. + /// Supported meta-characters include "*", "?", "\" and "[", "]". + /// And inside character classes "-", "!" and "]". /// /// /// /// - /// The '.' and '..' symbols do not have any special treatment and are processed + /// The "." and ".." symbols do not have any special treatment and are processed /// as regular characters for matching. /// /// /// /// - /// Character classes can be negated by prefixing them with '!', such as [!0-9], + /// Character classes can be negated by prefixing them with "!", such as [!0-9], /// which matches all characters except digits. /// /// @@ -183,7 +183,7 @@ public static IEnumerable EnumerateFiles(this DirectoryInfo directory, /// /// /// - /// The '**' sequence in the glob pattern can be used to match zero or more directories and subdirectories. + /// The "**" sequence in the glob pattern can be used to match zero or more directories and subdirectories. /// It can be used at the beginning, middle, or end of a pattern, for example, /// "**/file.txt", "dir/**/*.txt", "dir/**". /// @@ -209,19 +209,19 @@ public static IEnumerable EnumerateFiles(this DirectoryInfo directory, /// /// /// - /// Supported meta-characters include '*', '?', '\' and '[', ']'. - /// And inside character classes '-', '!' and ']'. + /// Supported meta-characters include "*", "?", "\" and "[", "]". + /// And inside character classes "-", "!" and "]". /// /// /// /// - /// The '.' and '..' symbols do not have any special treatment and are processed + /// The "." and ".." symbols do not have any special treatment and are processed /// as regular characters for matching. /// /// /// /// - /// Character classes can be negated by prefixing them with '!', such as [!0-9], + /// Character classes can be negated by prefixing them with "!", such as [!0-9], /// which matches all characters except digits. /// /// @@ -245,7 +245,7 @@ public static IEnumerable EnumerateFiles(this DirectoryInfo directory, /// /// /// - /// The '**' sequence in the glob pattern can be used to match zero or more directories and subdirectories. + /// The "**" sequence in the glob pattern can be used to match zero or more directories and subdirectories. /// It can be used at the beginning, middle, or end of a pattern, for example, /// "**/file.txt", "dir/**/*.txt", "dir/**". /// @@ -271,19 +271,19 @@ public static IEnumerable EnumerateFiles(this DirectoryInfo directory, /// /// /// - /// Supported meta-characters include '*', '?', '\' and '[', ']'. - /// And inside character classes '-', '!' and ']'. + /// Supported meta-characters include "*", "?", "\" and "[", "]". + /// And inside character classes "-", "!" and "]". /// /// /// /// - /// The '.' and '..' symbols do not have any special treatment and are processed + /// The "." and ".." symbols do not have any special treatment and are processed /// as regular characters for matching. /// /// /// /// - /// Character classes can be negated by prefixing them with '!', such as [!0-9], + /// Character classes can be negated by prefixing them with "!", such as [!0-9], /// which matches all characters except digits. /// /// @@ -307,7 +307,7 @@ public static IEnumerable EnumerateFiles(this DirectoryInfo directory, /// /// /// - /// The '**' sequence in the glob pattern can be used to match zero or more directories and subdirectories. + /// The "**" sequence in the glob pattern can be used to match zero or more directories and subdirectories. /// It can be used at the beginning, middle, or end of a pattern, for example, /// "**/file.txt", "dir/**/*.txt", "dir/**". /// @@ -333,19 +333,19 @@ public static IEnumerable EnumerateDirectories(this DirectoryInfo /// /// /// - /// Supported meta-characters include '*', '?', '\' and '[', ']'. - /// And inside character classes '-', '!' and ']'. + /// Supported meta-characters include "*", "?", "\" and "[", "]". + /// And inside character classes "-", "!" and "]". /// /// /// /// - /// The '.' and '..' symbols do not have any special treatment and are processed + /// The "." and ".." symbols do not have any special treatment and are processed /// as regular characters for matching. /// /// /// /// - /// Character classes can be negated by prefixing them with '!', such as [!0-9], + /// Character classes can be negated by prefixing them with "!", such as [!0-9], /// which matches all characters except digits. /// /// @@ -369,7 +369,7 @@ public static IEnumerable EnumerateDirectories(this DirectoryInfo /// /// /// - /// The '**' sequence in the glob pattern can be used to match zero or more directories and subdirectories. + /// The "**" sequence in the glob pattern can be used to match zero or more directories and subdirectories. /// It can be used at the beginning, middle, or end of a pattern, for example, /// "**/file.txt", "dir/**/*.txt", "dir/**". /// @@ -395,19 +395,19 @@ public static IEnumerable EnumerateDirectories(this DirectoryInfo /// /// /// - /// Supported meta-characters include '*', '?', '\' and '[', ']'. - /// And inside character classes '-', '!' and ']'. + /// Supported meta-characters include "*", "?", "\" and "[", "]". + /// And inside character classes "-", "!" and "]". /// /// /// /// - /// The '.' and '..' symbols do not have any special treatment and are processed + /// The "." and ".." symbols do not have any special treatment and are processed /// as regular characters for matching. /// /// /// /// - /// Character classes can be negated by prefixing them with '!', such as [!0-9], + /// Character classes can be negated by prefixing them with "!", such as [!0-9], /// which matches all characters except digits. /// /// @@ -431,7 +431,7 @@ public static IEnumerable EnumerateDirectories(this DirectoryInfo /// /// /// - /// The '**' sequence in the glob pattern can be used to match zero or more directories and subdirectories. + /// The "**" sequence in the glob pattern can be used to match zero or more directories and subdirectories. /// It can be used at the beginning, middle, or end of a pattern, for example, /// "**/file.txt", "dir/**/*.txt", "dir/**". /// @@ -457,19 +457,19 @@ public static IEnumerable EnumerateDirectories(this DirectoryInfo /// /// /// - /// Supported meta-characters include '*', '?', '\' and '[', ']'. - /// And inside character classes '-', '!' and ']'. + /// Supported meta-characters include "*", "?", "\" and "[", "]". + /// And inside character classes "-", "!" and "]". /// /// /// /// - /// The '.' and '..' symbols do not have any special treatment and are processed + /// The "." and ".." symbols do not have any special treatment and are processed /// as regular characters for matching. /// /// /// /// - /// Character classes can be negated by prefixing them with '!', such as [!0-9], + /// Character classes can be negated by prefixing them with "!", such as [!0-9], /// which matches all characters except digits. /// /// @@ -493,7 +493,7 @@ public static IEnumerable EnumerateDirectories(this DirectoryInfo /// /// /// - /// The '**' sequence in the glob pattern can be used to match zero or more directories and subdirectories. + /// The "**" sequence in the glob pattern can be used to match zero or more directories and subdirectories. /// It can be used at the beginning, middle, or end of a pattern, for example, /// "**/file.txt", "dir/**/*.txt", "dir/**". /// @@ -519,19 +519,19 @@ public static IEnumerable EnumerateDirectories(this DirectoryInfo /// /// /// - /// Supported meta-characters include '*', '?', '\' and '[', ']'. - /// And inside character classes '-', '!' and ']'. + /// Supported meta-characters include "*", "?", "\" and "[", "]". + /// And inside character classes "-", "!" and "]". /// /// /// /// - /// The '.' and '..' symbols do not have any special treatment and are processed + /// The "." and ".." symbols do not have any special treatment and are processed /// as regular characters for matching. /// /// /// /// - /// Character classes can be negated by prefixing them with '!', such as [!0-9], + /// Character classes can be negated by prefixing them with "!", such as [!0-9], /// which matches all characters except digits. /// /// @@ -555,7 +555,7 @@ public static IEnumerable EnumerateDirectories(this DirectoryInfo /// /// /// - /// The '**' sequence in the glob pattern can be used to match zero or more directories and subdirectories. + /// The "**" sequence in the glob pattern can be used to match zero or more directories and subdirectories. /// It can be used at the beginning, middle, or end of a pattern, for example, /// "**/file.txt", "dir/**/*.txt", "dir/**". /// @@ -581,19 +581,19 @@ public static IEnumerable EnumerateFileSystemInfos(this Director /// /// /// - /// Supported meta-characters include '*', '?', '\' and '[', ']'. - /// And inside character classes '-', '!' and ']'. + /// Supported meta-characters include "*", "?", "\" and "[", "]". + /// And inside character classes "-", "!" and "]". /// /// /// /// - /// The '.' and '..' symbols do not have any special treatment and are processed + /// The "." and ".." symbols do not have any special treatment and are processed /// as regular characters for matching. /// /// /// /// - /// Character classes can be negated by prefixing them with '!', such as [!0-9], + /// Character classes can be negated by prefixing them with "!", such as [!0-9], /// which matches all characters except digits. /// /// @@ -617,7 +617,7 @@ public static IEnumerable EnumerateFileSystemInfos(this Director /// /// /// - /// The '**' sequence in the glob pattern can be used to match zero or more directories and subdirectories. + /// The "**" sequence in the glob pattern can be used to match zero or more directories and subdirectories. /// It can be used at the beginning, middle, or end of a pattern, for example, /// "**/file.txt", "dir/**/*.txt", "dir/**". /// @@ -643,19 +643,19 @@ public static IEnumerable EnumerateFileSystemInfos(this Director /// /// /// - /// Supported meta-characters include '*', '?', '\' and '[', ']'. - /// And inside character classes '-', '!' and ']'. + /// Supported meta-characters include "*", "?", "\" and "[", "]". + /// And inside character classes "-", "!" and "]". /// /// /// /// - /// The '.' and '..' symbols do not have any special treatment and are processed + /// The "." and ".." symbols do not have any special treatment and are processed /// as regular characters for matching. /// /// /// /// - /// Character classes can be negated by prefixing them with '!', such as [!0-9], + /// Character classes can be negated by prefixing them with "!", such as [!0-9], /// which matches all characters except digits. /// /// @@ -679,7 +679,7 @@ public static IEnumerable EnumerateFileSystemInfos(this Director /// /// /// - /// The '**' sequence in the glob pattern can be used to match zero or more directories and subdirectories. + /// The "**" sequence in the glob pattern can be used to match zero or more directories and subdirectories. /// It can be used at the beginning, middle, or end of a pattern, for example, /// "**/file.txt", "dir/**/*.txt", "dir/**". /// @@ -705,19 +705,19 @@ public static IEnumerable EnumerateFileSystemInfos(this Director /// /// /// - /// Supported meta-characters include '*', '?', '\' and '[', ']'. - /// And inside character classes '-', '!' and ']'. + /// Supported meta-characters include "*", "?", "\" and "[", "]". + /// And inside character classes "-", "!" and "]". /// /// /// /// - /// The '.' and '..' symbols do not have any special treatment and are processed + /// The "." and ".." symbols do not have any special treatment and are processed /// as regular characters for matching. /// /// /// /// - /// Character classes can be negated by prefixing them with '!', such as [!0-9], + /// Character classes can be negated by prefixing them with "!", such as [!0-9], /// which matches all characters except digits. /// /// @@ -741,7 +741,7 @@ public static IEnumerable EnumerateFileSystemInfos(this Director /// /// /// - /// The '**' sequence in the glob pattern can be used to match zero or more directories and subdirectories. + /// The "**" sequence in the glob pattern can be used to match zero or more directories and subdirectories. /// It can be used at the beginning, middle, or end of a pattern, for example, /// "**/file.txt", "dir/**/*.txt", "dir/**". /// diff --git a/Ramstack.Globbing/Traversal/Files.cs b/Ramstack.Globbing/Traversal/Files.cs index c6e3c18..f04def3 100644 --- a/Ramstack.Globbing/Traversal/Files.cs +++ b/Ramstack.Globbing/Traversal/Files.cs @@ -23,19 +23,19 @@ public static partial class Files /// /// /// - /// Supported meta-characters include '*', '?', '\' and '[', ']'. - /// And inside character classes '-', '!' and ']'. + /// Supported meta-characters include "*", "?", "\" and "[", "]". + /// And inside character classes "-", "!" and "]". /// /// /// /// - /// The '.' and '..' symbols do not have any special treatment and are processed + /// The "." and ".." symbols do not have any special treatment and are processed /// as regular characters for matching. /// /// /// /// - /// Character classes can be negated by prefixing them with '!', such as [!0-9], + /// Character classes can be negated by prefixing them with "!", such as [!0-9], /// which matches all characters except digits. /// /// @@ -59,7 +59,7 @@ public static partial class Files /// /// /// - /// The '**' sequence in the glob pattern can be used to match zero or more directories and subdirectories. + /// The "**" sequence in the glob pattern can be used to match zero or more directories and subdirectories. /// It can be used at the beginning, middle, or end of a pattern, for example, /// "**/file.txt", "dir/**/*.txt", "dir/**". /// @@ -85,19 +85,19 @@ public static IEnumerable EnumerateFiles(string path, string pattern, st /// /// /// - /// Supported meta-characters include '*', '?', '\' and '[', ']'. - /// And inside character classes '-', '!' and ']'. + /// Supported meta-characters include "*", "?", "\" and "[", "]". + /// And inside character classes "-", "!" and "]". /// /// /// /// - /// The '.' and '..' symbols do not have any special treatment and are processed + /// The "." and ".." symbols do not have any special treatment and are processed /// as regular characters for matching. /// /// /// /// - /// Character classes can be negated by prefixing them with '!', such as [!0-9], + /// Character classes can be negated by prefixing them with "!", such as [!0-9], /// which matches all characters except digits. /// /// @@ -121,7 +121,7 @@ public static IEnumerable EnumerateFiles(string path, string pattern, st /// /// /// - /// The '**' sequence in the glob pattern can be used to match zero or more directories and subdirectories. + /// The "**" sequence in the glob pattern can be used to match zero or more directories and subdirectories. /// It can be used at the beginning, middle, or end of a pattern, for example, /// "**/file.txt", "dir/**/*.txt", "dir/**". /// @@ -147,19 +147,19 @@ public static IEnumerable EnumerateFiles(string path, string[] patterns, /// /// /// - /// Supported meta-characters include '*', '?', '\' and '[', ']'. - /// And inside character classes '-', '!' and ']'. + /// Supported meta-characters include "*", "?", "\" and "[", "]". + /// And inside character classes "-", "!" and "]". /// /// /// /// - /// The '.' and '..' symbols do not have any special treatment and are processed + /// The "." and ".." symbols do not have any special treatment and are processed /// as regular characters for matching. /// /// /// /// - /// Character classes can be negated by prefixing them with '!', such as [!0-9], + /// Character classes can be negated by prefixing them with "!", such as [!0-9], /// which matches all characters except digits. /// /// @@ -183,7 +183,7 @@ public static IEnumerable EnumerateFiles(string path, string[] patterns, /// /// /// - /// The '**' sequence in the glob pattern can be used to match zero or more directories and subdirectories. + /// The "**" sequence in the glob pattern can be used to match zero or more directories and subdirectories. /// It can be used at the beginning, middle, or end of a pattern, for example, /// "**/file.txt", "dir/**/*.txt", "dir/**". /// @@ -209,19 +209,19 @@ public static IEnumerable EnumerateFiles(string path, string pattern, st /// /// /// - /// Supported meta-characters include '*', '?', '\' and '[', ']'. - /// And inside character classes '-', '!' and ']'. + /// Supported meta-characters include "*", "?", "\" and "[", "]". + /// And inside character classes "-", "!" and "]". /// /// /// /// - /// The '.' and '..' symbols do not have any special treatment and are processed + /// The "." and ".." symbols do not have any special treatment and are processed /// as regular characters for matching. /// /// /// /// - /// Character classes can be negated by prefixing them with '!', such as [!0-9], + /// Character classes can be negated by prefixing them with "!", such as [!0-9], /// which matches all characters except digits. /// /// @@ -245,7 +245,7 @@ public static IEnumerable EnumerateFiles(string path, string pattern, st /// /// /// - /// The '**' sequence in the glob pattern can be used to match zero or more directories and subdirectories. + /// The "**" sequence in the glob pattern can be used to match zero or more directories and subdirectories. /// It can be used at the beginning, middle, or end of a pattern, for example, /// "**/file.txt", "dir/**/*.txt", "dir/**". /// @@ -271,19 +271,19 @@ public static IEnumerable EnumerateFiles(string path, string[] patterns, /// /// /// - /// Supported meta-characters include '*', '?', '\' and '[', ']'. - /// And inside character classes '-', '!' and ']'. + /// Supported meta-characters include "*", "?", "\" and "[", "]". + /// And inside character classes "-", "!" and "]". /// /// /// /// - /// The '.' and '..' symbols do not have any special treatment and are processed + /// The "." and ".." symbols do not have any special treatment and are processed /// as regular characters for matching. /// /// /// /// - /// Character classes can be negated by prefixing them with '!', such as [!0-9], + /// Character classes can be negated by prefixing them with "!", such as [!0-9], /// which matches all characters except digits. /// /// @@ -307,7 +307,7 @@ public static IEnumerable EnumerateFiles(string path, string[] patterns, /// /// /// - /// The '**' sequence in the glob pattern can be used to match zero or more directories and subdirectories. + /// The "**" sequence in the glob pattern can be used to match zero or more directories and subdirectories. /// It can be used at the beginning, middle, or end of a pattern, for example, /// "**/file.txt", "dir/**/*.txt", "dir/**". /// @@ -333,19 +333,19 @@ public static IEnumerable EnumerateDirectories(string path, string patte /// /// /// - /// Supported meta-characters include '*', '?', '\' and '[', ']'. - /// And inside character classes '-', '!' and ']'. + /// Supported meta-characters include "*", "?", "\" and "[", "]". + /// And inside character classes "-", "!" and "]". /// /// /// /// - /// The '.' and '..' symbols do not have any special treatment and are processed + /// The "." and ".." symbols do not have any special treatment and are processed /// as regular characters for matching. /// /// /// /// - /// Character classes can be negated by prefixing them with '!', such as [!0-9], + /// Character classes can be negated by prefixing them with "!", such as [!0-9], /// which matches all characters except digits. /// /// @@ -369,7 +369,7 @@ public static IEnumerable EnumerateDirectories(string path, string patte /// /// /// - /// The '**' sequence in the glob pattern can be used to match zero or more directories and subdirectories. + /// The "**" sequence in the glob pattern can be used to match zero or more directories and subdirectories. /// It can be used at the beginning, middle, or end of a pattern, for example, /// "**/file.txt", "dir/**/*.txt", "dir/**". /// @@ -395,19 +395,19 @@ public static IEnumerable EnumerateDirectories(string path, string[] pat /// /// /// - /// Supported meta-characters include '*', '?', '\' and '[', ']'. - /// And inside character classes '-', '!' and ']'. + /// Supported meta-characters include "*", "?", "\" and "[", "]". + /// And inside character classes "-", "!" and "]". /// /// /// /// - /// The '.' and '..' symbols do not have any special treatment and are processed + /// The "." and ".." symbols do not have any special treatment and are processed /// as regular characters for matching. /// /// /// /// - /// Character classes can be negated by prefixing them with '!', such as [!0-9], + /// Character classes can be negated by prefixing them with "!", such as [!0-9], /// which matches all characters except digits. /// /// @@ -431,7 +431,7 @@ public static IEnumerable EnumerateDirectories(string path, string[] pat /// /// /// - /// The '**' sequence in the glob pattern can be used to match zero or more directories and subdirectories. + /// The "**" sequence in the glob pattern can be used to match zero or more directories and subdirectories. /// It can be used at the beginning, middle, or end of a pattern, for example, /// "**/file.txt", "dir/**/*.txt", "dir/**". /// @@ -457,19 +457,19 @@ public static IEnumerable EnumerateDirectories(string path, string patte /// /// /// - /// Supported meta-characters include '*', '?', '\' and '[', ']'. - /// And inside character classes '-', '!' and ']'. + /// Supported meta-characters include "*", "?", "\" and "[", "]". + /// And inside character classes "-", "!" and "]". /// /// /// /// - /// The '.' and '..' symbols do not have any special treatment and are processed + /// The "." and ".." symbols do not have any special treatment and are processed /// as regular characters for matching. /// /// /// /// - /// Character classes can be negated by prefixing them with '!', such as [!0-9], + /// Character classes can be negated by prefixing them with "!", such as [!0-9], /// which matches all characters except digits. /// /// @@ -493,7 +493,7 @@ public static IEnumerable EnumerateDirectories(string path, string patte /// /// /// - /// The '**' sequence in the glob pattern can be used to match zero or more directories and subdirectories. + /// The "**" sequence in the glob pattern can be used to match zero or more directories and subdirectories. /// It can be used at the beginning, middle, or end of a pattern, for example, /// "**/file.txt", "dir/**/*.txt", "dir/**". /// @@ -519,19 +519,19 @@ public static IEnumerable EnumerateDirectories(string path, string[] pat /// /// /// - /// Supported meta-characters include '*', '?', '\' and '[', ']'. - /// And inside character classes '-', '!' and ']'. + /// Supported meta-characters include "*", "?", "\" and "[", "]". + /// And inside character classes "-", "!" and "]". /// /// /// /// - /// The '.' and '..' symbols do not have any special treatment and are processed + /// The "." and ".." symbols do not have any special treatment and are processed /// as regular characters for matching. /// /// /// /// - /// Character classes can be negated by prefixing them with '!', such as [!0-9], + /// Character classes can be negated by prefixing them with "!", such as [!0-9], /// which matches all characters except digits. /// /// @@ -555,7 +555,7 @@ public static IEnumerable EnumerateDirectories(string path, string[] pat /// /// /// - /// The '**' sequence in the glob pattern can be used to match zero or more directories and subdirectories. + /// The "**" sequence in the glob pattern can be used to match zero or more directories and subdirectories. /// It can be used at the beginning, middle, or end of a pattern, for example, /// "**/file.txt", "dir/**/*.txt", "dir/**". /// @@ -581,19 +581,19 @@ public static IEnumerable EnumerateFileSystemEntries(string path, string /// /// /// - /// Supported meta-characters include '*', '?', '\' and '[', ']'. - /// And inside character classes '-', '!' and ']'. + /// Supported meta-characters include "*", "?", "\" and "[", "]". + /// And inside character classes "-", "!" and "]". /// /// /// /// - /// The '.' and '..' symbols do not have any special treatment and are processed + /// The "." and ".." symbols do not have any special treatment and are processed /// as regular characters for matching. /// /// /// /// - /// Character classes can be negated by prefixing them with '!', such as [!0-9], + /// Character classes can be negated by prefixing them with "!", such as [!0-9], /// which matches all characters except digits. /// /// @@ -617,7 +617,7 @@ public static IEnumerable EnumerateFileSystemEntries(string path, string /// /// /// - /// The '**' sequence in the glob pattern can be used to match zero or more directories and subdirectories. + /// The "**" sequence in the glob pattern can be used to match zero or more directories and subdirectories. /// It can be used at the beginning, middle, or end of a pattern, for example, /// "**/file.txt", "dir/**/*.txt", "dir/**". /// @@ -643,19 +643,19 @@ public static IEnumerable EnumerateFileSystemEntries(string path, string /// /// /// - /// Supported meta-characters include '*', '?', '\' and '[', ']'. - /// And inside character classes '-', '!' and ']'. + /// Supported meta-characters include "*", "?", "\" and "[", "]". + /// And inside character classes "-", "!" and "]". /// /// /// /// - /// The '.' and '..' symbols do not have any special treatment and are processed + /// The "." and ".." symbols do not have any special treatment and are processed /// as regular characters for matching. /// /// /// /// - /// Character classes can be negated by prefixing them with '!', such as [!0-9], + /// Character classes can be negated by prefixing them with "!", such as [!0-9], /// which matches all characters except digits. /// /// @@ -679,7 +679,7 @@ public static IEnumerable EnumerateFileSystemEntries(string path, string /// /// /// - /// The '**' sequence in the glob pattern can be used to match zero or more directories and subdirectories. + /// The "**" sequence in the glob pattern can be used to match zero or more directories and subdirectories. /// It can be used at the beginning, middle, or end of a pattern, for example, /// "**/file.txt", "dir/**/*.txt", "dir/**". /// @@ -705,19 +705,19 @@ public static IEnumerable EnumerateFileSystemEntries(string path, string /// /// /// - /// Supported meta-characters include '*', '?', '\' and '[', ']'. - /// And inside character classes '-', '!' and ']'. + /// Supported meta-characters include "*", "?", "\" and "[", "]". + /// And inside character classes "-", "!" and "]". /// /// /// /// - /// The '.' and '..' symbols do not have any special treatment and are processed + /// The "." and ".." symbols do not have any special treatment and are processed /// as regular characters for matching. /// /// /// /// - /// Character classes can be negated by prefixing them with '!', such as [!0-9], + /// Character classes can be negated by prefixing them with "!", such as [!0-9], /// which matches all characters except digits. /// /// @@ -741,7 +741,7 @@ public static IEnumerable EnumerateFileSystemEntries(string path, string /// /// /// - /// The '**' sequence in the glob pattern can be used to match zero or more directories and subdirectories. + /// The "**" sequence in the glob pattern can be used to match zero or more directories and subdirectories. /// It can be used at the beginning, middle, or end of a pattern, for example, /// "**/file.txt", "dir/**/*.txt", "dir/**". /// From 6fa73ea13883143d609728c61885fc48b6d95dc4 Mon Sep 17 00:00:00 2001 From: rameel Date: Sat, 5 Jul 2025 23:16:51 +0500 Subject: [PATCH 5/8] Suppress false ReSharper warning --- Ramstack.Globbing/Traversal/FileTreeAsyncEnumerable.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Ramstack.Globbing/Traversal/FileTreeAsyncEnumerable.cs b/Ramstack.Globbing/Traversal/FileTreeAsyncEnumerable.cs index 0188803..088a298 100644 --- a/Ramstack.Globbing/Traversal/FileTreeAsyncEnumerable.cs +++ b/Ramstack.Globbing/Traversal/FileTreeAsyncEnumerable.cs @@ -77,7 +77,9 @@ IAsyncEnumerator IAsyncEnumerable.GetAsyncEnumerator(Cancellat ? (source = CancellationTokenSource.CreateLinkedTokenSource(_cancellationToken, cancellationToken)).Token : _cancellationToken; + // ReSharper disable PossiblyMistakenUseOfCancellationToken return EnumerateAsync(source, cancellationToken).GetAsyncEnumerator(cancellationToken); + // ReSharper restore PossiblyMistakenUseOfCancellationToken } private async IAsyncEnumerable EnumerateAsync(CancellationTokenSource? source, [EnumeratorCancellation] CancellationToken cancellationToken) From 8b608de6bbbcc0275dc501f522f3ac7727222c22 Mon Sep 17 00:00:00 2001 From: rameel Date: Sat, 5 Jul 2025 23:18:54 +0500 Subject: [PATCH 6/8] Use CancellationToken.None instead of default for clarity --- Ramstack.Globbing/Traversal/FileTreeAsyncEnumerable.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Ramstack.Globbing/Traversal/FileTreeAsyncEnumerable.cs b/Ramstack.Globbing/Traversal/FileTreeAsyncEnumerable.cs index 088a298..1a9bf5d 100644 --- a/Ramstack.Globbing/Traversal/FileTreeAsyncEnumerable.cs +++ b/Ramstack.Globbing/Traversal/FileTreeAsyncEnumerable.cs @@ -72,8 +72,8 @@ IAsyncEnumerator IAsyncEnumerable.GetAsyncEnumerator(Cancellat { CancellationTokenSource? source = null; - if (_cancellationToken != default) - cancellationToken = cancellationToken != default + if (_cancellationToken != CancellationToken.None) + cancellationToken = cancellationToken != CancellationToken.None ? (source = CancellationTokenSource.CreateLinkedTokenSource(_cancellationToken, cancellationToken)).Token : _cancellationToken; From 8f92eb6b3612f847c48f24711d95216bcff6b31a Mon Sep 17 00:00:00 2001 From: rameel Date: Sat, 5 Jul 2025 23:20:05 +0500 Subject: [PATCH 7/8] Visual Studio auto-adjusted solution file formatting --- Ramstack.Globbing.sln | 3 --- 1 file changed, 3 deletions(-) diff --git a/Ramstack.Globbing.sln b/Ramstack.Globbing.sln index 5454d5e..6d7b975 100644 --- a/Ramstack.Globbing.sln +++ b/Ramstack.Globbing.sln @@ -1,4 +1,3 @@ - Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.11.35017.193 @@ -36,6 +35,4 @@ Global GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {449CB7E2-8227-4220-94D5-301CB5CC4EBC} EndGlobalSection - GlobalSection(NestedProjects) = preSolution - EndGlobalSection EndGlobal From db5168fdf40c61ca19fdc8af3716b398dcf20306 Mon Sep 17 00:00:00 2001 From: rameel Date: Sat, 5 Jul 2025 23:20:45 +0500 Subject: [PATCH 8/8] Restrict publish workflow to repo, add GitHub release step --- .github/workflows/publish.yml | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 15438c5..ac17c22 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -6,11 +6,15 @@ on: - "[0-9]+.[0-9]+.[0-9]+" - "[0-9]+.[0-9]+.[0-9]+-[a-z]+.[0-9]+" +permissions: + contents: write + jobs: publish: + if: github.repository == 'rameel/ramstack.globbing' runs-on: ubuntu-latest steps: - - name: Setup .NET + - name: Install .NET uses: actions/setup-dotnet@v4 with: dotnet-version: 9.0.x @@ -21,8 +25,14 @@ jobs: - name: Build run: dotnet build -c Release - - name: Pack + - name: Create NuGet Packages run: dotnet pack -c Release -o ./nuget --no-build - - name: Publish + - name: Publish NuGet Packages run: dotnet nuget push ./nuget/*.nupkg --api-key ${{secrets.NUGET_API_KEY}} --skip-duplicate -s https://api.nuget.org/v3/index.json + + - name: Create GitHub Release + uses: softprops/action-gh-release@v2 + with: + draft: true + files: nuget/*