Skip to content

Commit 6a03687

Browse files
authored
Merge pull request #29 from rameel/cleanup
Clean up and formatting
2 parents bb8d9c1 + db5168f commit 6a03687

8 files changed

Lines changed: 168 additions & 153 deletions

File tree

.github/workflows/publish.yml

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,15 @@ on:
66
- "[0-9]+.[0-9]+.[0-9]+"
77
- "[0-9]+.[0-9]+.[0-9]+-[a-z]+.[0-9]+"
88

9+
permissions:
10+
contents: write
11+
912
jobs:
1013
publish:
14+
if: github.repository == 'rameel/ramstack.globbing'
1115
runs-on: ubuntu-latest
1216
steps:
13-
- name: Setup .NET
17+
- name: Install .NET
1418
uses: actions/setup-dotnet@v4
1519
with:
1620
dotnet-version: 9.0.x
@@ -21,8 +25,14 @@ jobs:
2125
- name: Build
2226
run: dotnet build -c Release
2327

24-
- name: Pack
28+
- name: Create NuGet Packages
2529
run: dotnet pack -c Release -o ./nuget --no-build
2630

27-
- name: Publish
31+
- name: Publish NuGet Packages
2832
run: dotnet nuget push ./nuget/*.nupkg --api-key ${{secrets.NUGET_API_KEY}} --skip-duplicate -s https://api.nuget.org/v3/index.json
33+
34+
- name: Create GitHub Release
35+
uses: softprops/action-gh-release@v2
36+
with:
37+
draft: true
38+
files: nuget/*

Ramstack.Globbing.Tests/Ramstack.Globbing.Tests.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
</ItemGroup>
1313

1414
<ItemGroup>
15-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
16-
<PackageReference Include="NUnit" Version="4.1.0" />
17-
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
18-
<PackageReference Include="System.Linq.Async" Version="6.0.1" />
15+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.13.0" />
16+
<PackageReference Include="NUnit" Version="4.3.2" />
17+
<PackageReference Include="NUnit3TestAdapter" Version="5.0.0" />
18+
<PackageReference Include="System.Linq.Async" Version="6.0.3" />
1919
</ItemGroup>
2020

2121
<ItemGroup>

Ramstack.Globbing.sln

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
Microsoft Visual Studio Solution File, Format Version 12.00
32
# Visual Studio Version 17
43
VisualStudioVersion = 17.11.35017.193
@@ -36,6 +35,4 @@ Global
3635
GlobalSection(ExtensibilityGlobals) = postSolution
3736
SolutionGuid = {449CB7E2-8227-4220-94D5-301CB5CC4EBC}
3837
EndGlobalSection
39-
GlobalSection(NestedProjects) = preSolution
40-
EndGlobalSection
4138
EndGlobal

Ramstack.Globbing/Internal/FileTreeHelper.cs

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,28 +10,34 @@ internal static class FileTreeHelper
1010
/// <summary>
1111
/// Constructs the full name of a file by combining the path and the name.
1212
/// </summary>
13-
/// <param name="buffer">A buffer used for constructing the full name.
13+
/// <param name="chars">A buffer used for constructing the full name.
1414
/// It should be obtained from an array pool and will be resized if necessary.</param>
1515
/// <param name="path">The path of the file.</param>
1616
/// <param name="name">The name of the file.</param>
1717
/// <returns>
1818
/// A <see cref="ReadOnlySpan{T}"/> representing the full name of the file.
1919
/// </returns>
20-
public static ReadOnlySpan<char> GetFullName(ref char[] buffer, string path, string name)
20+
public static ReadOnlySpan<char> GetFullName(ref char[] chars, string path, string name)
2121
{
22-
var length = path.Length + name.Length + 1;
23-
if (buffer.Length < length)
22+
var array = chars;
23+
var count = path.Length + name.Length + 1;
24+
25+
if (array.Length < count)
2426
{
25-
ArrayPool<char>.Shared.Return(buffer);
26-
buffer = ArrayPool<char>.Shared.Rent(length);
27+
ArrayPool<char>.Shared.Return(array);
28+
array = ArrayPool<char>.Shared.Rent(count);
29+
chars = array;
30+
31+
// Force null check to assist JIT
32+
_ = array.Length;
2733
}
2834

29-
var fullName = buffer.AsSpan(0, length);
35+
var fullName = array.AsSpan();
3036

3137
path.TryCopyTo(fullName);
3238
fullName[path.Length] = '/';
3339
name.TryCopyTo(fullName.Slice(path.Length + 1));
3440

35-
return fullName;
41+
return fullName.Slice(0, count);
3642
}
3743
}

Ramstack.Globbing/Ramstack.Globbing.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
<PrivateAssets>all</PrivateAssets>
4343
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
4444
</PackageReference>
45-
<PackageReference Include="MinVer" Version="5.0.0">
45+
<PackageReference Include="MinVer" Version="6.0.0">
4646
<PrivateAssets>all</PrivateAssets>
4747
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
4848
</PackageReference>

Ramstack.Globbing/Traversal/DirectoryInfoExtensions.cs

Lines changed: 69 additions & 69 deletions
Large diffs are not rendered by default.

Ramstack.Globbing/Traversal/FileTreeAsyncEnumerable.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,14 @@ IAsyncEnumerator<TResult> IAsyncEnumerable<TResult>.GetAsyncEnumerator(Cancellat
7272
{
7373
CancellationTokenSource? source = null;
7474

75-
if (_cancellationToken != default)
76-
cancellationToken = cancellationToken != default
75+
if (_cancellationToken != CancellationToken.None)
76+
cancellationToken = cancellationToken != CancellationToken.None
7777
? (source = CancellationTokenSource.CreateLinkedTokenSource(_cancellationToken, cancellationToken)).Token
7878
: _cancellationToken;
7979

80+
// ReSharper disable PossiblyMistakenUseOfCancellationToken
8081
return EnumerateAsync(source, cancellationToken).GetAsyncEnumerator(cancellationToken);
82+
// ReSharper restore PossiblyMistakenUseOfCancellationToken
8183
}
8284

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

0 commit comments

Comments
 (0)