Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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/*
8 changes: 4 additions & 4 deletions Ramstack.Globbing.Tests/Ramstack.Globbing.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="NUnit" Version="4.1.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
<PackageReference Include="System.Linq.Async" Version="6.0.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.13.0" />
<PackageReference Include="NUnit" Version="4.3.2" />
<PackageReference Include="NUnit3TestAdapter" Version="5.0.0" />
<PackageReference Include="System.Linq.Async" Version="6.0.3" />
</ItemGroup>

<ItemGroup>
Expand Down
3 changes: 0 additions & 3 deletions Ramstack.Globbing.sln
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.11.35017.193
Expand Down Expand Up @@ -36,6 +35,4 @@ Global
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {449CB7E2-8227-4220-94D5-301CB5CC4EBC}
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
EndGlobalSection
EndGlobal
22 changes: 14 additions & 8 deletions Ramstack.Globbing/Internal/FileTreeHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,34 @@ internal static class FileTreeHelper
/// <summary>
/// Constructs the full name of a file by combining the path and the name.
/// </summary>
/// <param name="buffer">A buffer used for constructing the full name.
/// <param name="chars">A buffer used for constructing the full name.
/// It should be obtained from an array pool and will be resized if necessary.</param>
/// <param name="path">The path of the file.</param>
/// <param name="name">The name of the file.</param>
/// <returns>
/// A <see cref="ReadOnlySpan{T}"/> representing the full name of the file.
/// </returns>
public static ReadOnlySpan<char> GetFullName(ref char[] buffer, string path, string name)
public static ReadOnlySpan<char> 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<char>.Shared.Return(buffer);
buffer = ArrayPool<char>.Shared.Rent(length);
ArrayPool<char>.Shared.Return(array);
array = ArrayPool<char>.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);
}
}
2 changes: 1 addition & 1 deletion Ramstack.Globbing/Ramstack.Globbing.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="MinVer" Version="5.0.0">
<PackageReference Include="MinVer" Version="6.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
138 changes: 69 additions & 69 deletions Ramstack.Globbing/Traversal/DirectoryInfoExtensions.cs

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions Ramstack.Globbing/Traversal/FileTreeAsyncEnumerable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,14 @@ IAsyncEnumerator<TResult> IAsyncEnumerable<TResult>.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;

// ReSharper disable PossiblyMistakenUseOfCancellationToken
return EnumerateAsync(source, cancellationToken).GetAsyncEnumerator(cancellationToken);
// ReSharper restore PossiblyMistakenUseOfCancellationToken
}

private async IAsyncEnumerable<TResult> EnumerateAsync(CancellationTokenSource? source, [EnumeratorCancellation] CancellationToken cancellationToken)
Expand Down
Loading