8000 Merge pull request #2085 from libgit2/net8-updates · libgit2/libgit2sharp@bfdb02a · GitHub
[go: up one dir, main page]

Skip to content
Sign in

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit bfdb02a

Browse files
authored
Merge pull request #2085 from libgit2/net8-updates
Updates for .NET 8
2 parents d9bf967 + 729ef8d commit bfdb02a

File tree

93 files changed

+422
-295
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+422
-295
lines changed

.github/workflows/ci.yml

+39-17
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,20 @@ jobs:
1515
runs-on: ubuntu-22.04
1616
steps:
1717
- name: Checkout
18-
uses: actions/checkout@v3.5.0
18+
uses: actions/checkout@v4.1.2
1919
with:
2020
fetch-depth: 0
2121
- name: Install .NET SDK
22-
uses: actions/setup-dotnet@v3.0.3
22+
uses: actions/setup-dotnet@v4.0.0
2323
with:
2424
dotnet-version: 8.0.x
2525
- name: Build
2626
run: dotnet build LibGit2Sharp.sln --configuration Release
2727
- name: Upload packages
28-
uses: actions/upload-artifact@v3.1.2
28+
uses: actions/upload-artifact@v4.3.1
2929
with:
3030
name: NuGet packages
31-
path: bin/Packages/
31+
path: artifacts/package/
3232
retention-days: 7
3333
- name: Verify trimming compatibility
3434
run: dotnet publish TrimmingTestApp
@@ -37,24 +37,36 @@ jobs:
3737
runs-on: ${{ matrix.os }}
3838
strategy:
3939
matrix:
40-
arch: [ amd64 ]
41-
os: [ windows-2019, macos-11 ]
42-
tfm: [ net472, net6.0, net7.0 ]
40+
arch: [ x64 ]
41+
os: [ windows-2019, windows-2022, macos-11, macos-12, macos-13 ]
42+
tfm: [ net472, net6.0, net8.0 ]
4343
exclude:
4444
- os: macos-11
4545
tfm: net472
46+
- os: macos-11
47+
tfm: net8.0
48+
- os: macos-12
49+
tfm: net472
50+
- os: macos-13
51+
tfm: net472
52+
include:
53+
- arch: arm64
54+
os: macos-14
55+
tfm: net6.0
56+
- arch: arm64
57+
os: macos-14
58+
tfm: net8.0
4659
fail-fast: false
4760
steps:
4861
- name: Checkout
49-
uses: actions/checkout@v3.5.0
62+
uses: actions/checkout@v4.1.2
5063
with:
5164
fetch-depth: 0
5265
- name: Install .NET SDK
53-
uses: actions/setup-dotnet@v3.0.3
66+
uses: actions/setup-dotnet@v4.0.0
5467
with:
5568
dotnet-version: |
5669
8.0.x
57-
7.0.x
5870
6.0.x
5971
- name: Run ${{ matrix.tfm }} tests
6072
run: dotnet test LibGit2Sharp.sln --configuration Release --framework ${{ matrix.tfm }} --logger "GitHubActions" /p:ExtraDefine=LEAKS_IDENTIFYING
@@ -65,22 +77,32 @@ jobs:
6577
matrix:
6678
arch: [ amd64 ]
6779
# arch: [ amd64, arm64 ]
68-
distro: [ alpine.3.13, alpine.3.14, alpine.3.15, alpine.3.16, alpine.3.17, centos.stream.8, debian.10, debian.11, fedora.36, ubuntu.18.04, ubuntu.20.04, ubuntu.22.04 ]
69-
sdk: [ '6.0', '7.0' ]
80+
distro: [ alpine.3.13, alpine.3.14, alpine.3.15, alpine.3.16, alpine.3.17, alpine.3.18, centos.stream.8, debian.10, debian.11, fedora.36, fedora.37, ubuntu.18.04, ubuntu.20.04, ubuntu.22.04 ]
81+
sdk: [ '6.0', '8.0' ]
7082
exclude:
7183
- distro: alpine.3.13
72-
sdk: '7.0'
84+
sdk: '8.0'
7385
- distro: alpine.3.14
74-
sdk: '7.0'
86+
sdk: '8.0'
87+
- distro: alpine.3.15
88+
sdk: '8.0'
89+
- distro: alpine.3.16
90+
sdk: '8.0'
91+
- distro: debian.10
92+
sdk: '8.0'
93+
- distro: fedora.36
94+
sdk: '8.0'
95+
- distro: ubuntu.18.04
96+
sdk: '8.0'
7597
include:
7698
- sdk: '6.0'
7799
tfm: net6.0
78-
- sdk: '7.0'
79-
tfm: net7.0
100+
- sdk: '8.0'
101+
tfm: net8.0
80102
fail-fast: false
81103
steps:
82104
- name: Checkout
83-
uses: actions/checkout@v3.5.0
105+
uses: actions/checkout@v4.1.2
84106
with:
85107
fetch-depth: 0
86108
- name: Setup QEMU

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,5 @@ _ReSharper*/
3838
*.DotSettings
3939

4040
_NCrunch_LibGit2Sharp/
41-
packages/
41+
artifacts/
4242
worktree.playlist

Directory.Build.props

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
<Project>
22

33
<PropertyGroup>
4+
<EnableNETAnalyzers>true</EnableNETAnalyzers>
45
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
5-
<OutputPath>$(MSBuildThisFileDirectory)bin\$(MSBuildProjectName)\$(Configuration)\</OutputPath>
6-
<BaseIntermediateOutputPath>$(MSBuildThisFileDirectory)obj\$(MSBuildProjectName)\</BaseIntermediateOutputPath>
7-
<PackageOutputPath>$(MSBuildThisFileDirectory)bin\Packages\</PackageOutputPath>
6+
<UseArtifactsOutput>true</UseArtifactsOutput>
87
<DefineConstants Condition=" '$(ExtraDefine)' != '' ">$(DefineConstants);$(ExtraDefine)</DefineConstants>
98
</PropertyGroup>
109

LibGit2Sharp.Tests/BranchFixture.cs

+2-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
using System.Linq;
55
using LibGit2Sharp.Tests.TestHelpers;
66
using Xunit;
7-
using Xunit.Extensions;
87

98
namespace LibGit2Sharp.Tests
109
{
@@ -103,7 +102,7 @@ public void CanCreateAnUnbornBranch()
103102
public void CanCreateBranchUsingAbbreviatedSha()
104103
{
105104
string path = SandboxBareTestRepo();
106-
using (var repo = new Repository(path, new RepositoryOptions{ Identity = Constants.Identity }))
105+
using (var repo = new Repository(path, new RepositoryOptions { Identity = Constants.Identity }))
107106
{
108107
EnableRefLog(repo);
109108

@@ -1001,7 +1000,7 @@ public void OnlyOneBranchIsTheHead()
10011000
continue;
10021001
}
10031002

1004-
Assert.True(false, string.Format("Both '{0}' and '{1}' appear to be Head.", head.CanonicalName, branch.CanonicalName));
1003+
Assert.Fail(string.Format("Both '{0}' and '{1}' appear to be Head.", head.CanonicalName, branch.CanonicalName));
10051004
}
10061005

10071006
Assert.NotNull(head);

LibGit2Sharp.Tests/CommitFixture.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ public void CanEnumerateCommitsFromATagWhichPointsToABlob()
406406
{
407407
AssertEnumerationOfCommits(
408408
repo => new CommitFilter { IncludeReachableFrom = repo.Tags["point_to_blob"] },
409-
new string[] { });
409+
Array.Empty<string>());
410410
}
411411

412412
[Fact]
@@ -421,7 +421,7 @@ public void CanEnumerateCommitsFromATagWhichPointsToATree()
421421

422422
AssertEnumerationOfCommitsInRepo(repo,
423423
r => new CommitFilter { IncludeReachableFrom = tag },
424-
new string[] { });
424+
Array.Empty<string>());
425425
}
426426
}
427427

LibGit2Sharp.Tests/DiffTreeToTreeFixture.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ namespace LibGit2Sharp.Tests
99
{
1010
public class DiffTreeToTreeFixture : BaseFixture
1111
{
12-
private static readonly string subBranchFilePath = String.Join("/", "1", "branch_file.txt");
12+
private static readonly string subBranchFilePath = string.Join("/", "1", "branch_file.txt");
1313

1414
[Fact]
1515
public void ComparingATreeAgainstItselfReturnsNoDifference()
@@ -27,7 +27,7 @@ public void ComparingATreeAgainstItselfReturnsNoDifference()
2727
using (var patch = repo.Diff.Compare<Patch>(tree, tree))
2828
{
2929
Assert.Empty(patch);
30-
Assert.Equal(String.Empty, patch);
30+
Assert.Equal(string.Empty, patch);
3131
}
3232
}
3333
}

LibGit2Sharp.Tests/FetchFixture.cs

+14-14
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public void CanFetchIntoAnEmptyRepository(string url)
4242
}
4343

4444
// Perform the actual fetch
45-
Comma F438 nds.Fetch(repo, remoteName, new string[0], new FetchOptions { OnUpdateTips = expectedFetchState.RemoteUpdateTipsHandler }, null);
45+
Commands.Fetch(repo, remoteName, Array.Empty<string>(), new FetchOptions { OnUpdateTips = expectedFetchState.RemoteUpdateTipsHandler }, null);
4646

4747
// Verify the expected
4848
expectedFetchState.CheckUpdatedReferences(repo);
@@ -62,7 +62,7 @@ public void CanFetchIntoAnEmptyRepositoryWithCredentials()
6262
repo.Network.Remotes.Add(remoteName, Constants.PrivateRepoUrl);
6363

6464
// Perform the actual fetch
65-
Commands.Fetch(repo, remoteName, new string[0], new FetchOptions
65+
Commands.Fetch(repo, remoteName, Array.Empty<string>(), new FetchOptions
6666
{
6767
CredentialsProvider = Constants.PrivateRepoCredentials
6868
}, null);
@@ -98,7 +98,7 @@ public void CanFetchAllTagsIntoAnEmptyRepository(string url)
9898
}
9999

100100
// Perform the actual fetch
101-
Commands.Fetch(repo, remoteName, new string[0], new FetchOptions
101+
Commands.Fetch(repo, remoteName, Array.Empty<string>(), new FetchOptions
102102
{
103103
TagFetchMode = TagFetchMode.All,
104104
OnUpdateTips = expectedFetchState.RemoteUpdateTipsHandler
@@ -179,7 +179,7 @@ public void FetchRespectsConfiguredAutoTagSetting(TagFetchMode tagFetchMode, int
179179
r => r.TagFetchMode = tagFetchMode);
180180

181181
// Perform the actual fetch.
182-
Commands.Fetch(repo, remoteName, new string[0], null, null);
182+
Commands.Fetch(repo, remoteName, Array.Empty<string>(), null, null);
183183

184184
// Verify the number of fetched tags.
185185
Assert.Equal(expectedTagCount, repo.Tags.Count());
@@ -197,7 +197,7 @@ public void CanFetchAllTagsAfterAnInitialClone()
197197

198198
using (var repo = new Repository(clonedRepoPath))
199199
{
200-
Commands.Fetch(repo, "origin", new string[0], new FetchOptions { TagFetchMode = TagFetchMode.All }, null);
200+
Commands.Fetch(repo, "origin", Array.Empty<string>(), new FetchOptions { TagFetchMode = TagFetchMode.All }, null);
201201
}
202202
}
203203

@@ -223,17 +223,17 @@ public void FetchHonorsTheFetchPruneConfigurationEntry()
223223

224224
// No pruning when the configuration entry isn't defined
225225
Assert.Null(clonedRepo.Config.Get<bool>("fetch.prune"));
226-
Commands.Fetch(clonedRepo, "origin", new string[0], null, null);
226+
Commands.Fetch(clonedRepo, "origin", Array.Empty<string>(), null, null);
227227
Assert.Equal(5, clonedRepo.Branches.Count(b => b.IsRemote && b.FriendlyName != "origin/HEAD"));
228228

229229
// No pruning when the configuration entry is set to false
230230
clonedRepo.Config.Set<bool>("fetch.prune", false);
231-
Commands.Fetch(clonedRepo, "origin", new string[0], null, null);
231+
Commands.Fetch(clonedRepo, "origin", Array.Empty<string>(), null, null);
232232
Assert.Equal(5, clonedRepo.Branches.Count(b => b.IsRemote && b.FriendlyName != "origin/HEAD"));
233233

234234
// Auto pruning when the configuration entry is set to true
235235
clonedRepo.Config.Set<bool>("fetch.prune", true);
236-
Commands.Fetch(clonedRepo, "origin", new string[0], null, null);
236+
Commands.Fetch(clonedRepo, "origin", Array.Empty<string>(), null, null);
237237
Assert.Equal(4, clonedRepo.Branches.Count(b => b.IsRemote && b.FriendlyName != "origin/HEAD"));
238238
}
239239
}
@@ -248,10 +248,10 @@ public void CannotFetchWithForbiddenCustomHeaders()
248248
string clonedRepoPath = Repository.Clone(url, scd.DirectoryPath);
249249

250250
const string knownHeader = "User-Agent: mygit-201";
251-
var options = new FetchOptions { CustomHeaders = new String[] { knownHeader } };
251+
var options = new FetchOptions { CustomHeaders = new string[] { knownHeader } };
252252
using (var repo = new Repository(clonedRepoPath))
253253
{
254-
Assert.Throws<LibGit2SharpException>(() => Commands.Fetch(repo, "origin", new string[0], options, null));
254+
Assert.Throws<LibGit2SharpException>(() => Commands.Fetch(repo, "origin", Array.Empty<string>(), options, null));
255255
}
256256
}
257257

@@ -265,10 +265,10 @@ public void CanFetchWithCustomHeaders()
265265
string clonedRepoPath = Repository.Clone(url, scd.DirectoryPath);
266266

267267
const string knownHeader = "X-Hello: mygit-201";
268-
var options = new FetchOptions { CustomHeaders = new String[] { knownHeader } };
268+
var options = new FetchOptions { CustomHeaders = new string[] { knownHeader } };
269269
using (var repo = new Repository(clonedRepoPath))
270270
{
271-
Commands.Fetch(repo, "origin", new string[0], options, null);
271+
Commands.Fetch(repo, "origin", Array.Empty<string>(), options, null);
272272
}
273273
}
274274

@@ -282,10 +282,10 @@ public void CannotFetchWithMalformedCustomHeaders()
282282
string clonedRepoPath = Repository.Clone(url, scd.DirectoryPath);
283283

284284
const string knownHeader = "Hello world";
285-
var options = new FetchOptions { CustomHeaders = new String[] { knownHeader } };
285+
var options = new FetchOptions { CustomHeaders = new string[] { knownHeader } };
286286
using (var repo = new Repository(clonedRepoPath))
287287
{
288-
Assert.Throws<LibGit2SharpException>(() => Commands.Fetch(repo, "origin", new string[0], options, null));
288+
Assert.Throws<LibGit2SharpException>(() => Commands.Fetch(repo, "origin", Array.Empty<string>(), options, null));
289289
}
290290
}
291291

LibGit2Sharp.Tests/FilterBranchFixture.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ public void CanRewriteTreesByInjectingTreeEntry()
234234

235235
AssertSucceedingButNotError();
236236

237-
Assert.Equal(new Commit[0],
237+
Assert.Equal(Array.Empty<Commit>(),
238238
repo.Commits
239239
.QueryBy(new CommitFilter {IncludeReachableFrom = repo.Branches})
240240
.Where(c => c["README"] != null

LibGit2Sharp.Tests/FilterFixture.cs

+7-10
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
using System;
22
using System.Collections.Generic;
3-
using System.Linq;
43
using System.IO;
4+
using System.Threading.Tasks;
55
using LibGit2Sharp.Tests.TestHelpers;
66
using Xunit;
7-
using System.Threading.Tasks;
87

98
namespace LibGit2Sharp.Tests
109
{
@@ -174,7 +173,7 @@ public void CleanFilterWritesOutputToObjectTree()
174173
}
175174

176175
[Fact]
177-
public void CanHandleMultipleSmudgesConcurrently()
176+
public async Task CanHandleMultipleSmudgesConcurrently()
178177
{
179178
const string decodedInput = "This is a substitution cipher";
180179
const string encodedInput = "Guvf vf n fhofgvghgvba pvcure";
@@ -193,20 +192,18 @@ public void CanHandleMultipleSmudgesConcurrently()
193192

194193
for (int i = 0; i < count; i++)
195194
{
196-
tasks[i] = Task.Factory.StartNew(() =>
195+
tasks[i] = Task.Run(() =>
197196
{
198197
string repoPath = InitNewRepository();
199198
return CheckoutFileForSmudge(repoPath, branchName, encodedInput);
200199
});
201200
}
202201

203-
Task.WaitAll(tasks);
202+
var files = await Task.WhenAll(tasks);
204203

205-
foreach(var task in tasks)
204+
foreach (var file in files)
206205
{
207-
FileInfo expectedFile = task.Result;
208-
209-
string readAllText = File.ReadAllText(expectedFile.FullName);
206+
string readAllText = File.ReadAllText(file.FullName);
210207
Assert.Equal(decodedInput, readAllText);
211208
}
212209
}
@@ -399,7 +396,7 @@ private FileInfo CheckoutFileForSmudge(string repoPath, string branchName, strin
399396
return expectedPath;
400397
}
401398

402-
private static FileInfo CommitFileOnBranch(Repository repo, string branchName, String content)
399+
private static FileInfo CommitFileOnBranch(Repository repo, string branchName, string content)
403400
{
404401
var branch = repo.CreateBranch(branchName);
405402
Commands.Checkout(repo, branch.FriendlyName);

LibGit2Sharp.Tests/LibGit2Sharp.Tests.csproj

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks Condition="'$(TargetFrameworks)'==''">net472;net6.0;net7.0</TargetFrameworks>
4+
<TargetFrameworks Condition="'$(TargetFrameworks)'==''">net472;net6.0;net8.0</TargetFrameworks>
55
</PropertyGroup>
66

77
<ItemGroup>
@@ -11,12 +11,12 @@
1111
</ItemGroup>
1212

1313
<ItemGroup>
14-
<PackageReference Include="GitHubActionsTestLogger" Version="2.0.1" />
15-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0" />
16-
<PackageReference Include="Moq" Version="4.18.4" />
17-
<PackageReference Include="xunit" Version="2.4.2" />
18-
<PackageReference Include="xunit.runner.console" Version="2.4.2" />
19-
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5" />
14+
<PackageReference Include="GitHubActionsTestLogger" Version="2.3.3" />
15+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
16+
<PackageReference Include="Moq" Version="4.20.70" />
17+
<PackageReference Include="xunit" Version="2.7.0" />
18+
<PackageReference Include="xunit.runner.console" Version="2.7.0" />
19+
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.7" />
2020
<PackageReference Include="xunit.skippablefact" Version="1.4.13" />
2121
</ItemGroup>
2222

0 commit comments

Comments
 (0)
0