Skip to content

Commit 7c78387

Browse files
authored
Merge pull request #1891 from libgit2/add-net50
Add .NET 5 test target
2 parents 10c9446 + 37a094c commit 7c78387

File tree

7 files changed

+28
-37
lines changed

7 files changed

+28
-37
lines changed

Diff for: Directory.Build.props

+1-4
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,5 @@
77
<PackageOutputPath>$(MSBuildThisFileDirectory)bin\Packages\$(Configuration)\</PackageOutputPath>
88
<DefineConstants Condition=" '$(ExtraDefine)' != '' ">$(DefineConstants);$(ExtraDefine)</DefineConstants>
99
</PropertyGroup>
10-
11-
<ItemGroup>
12-
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0" PrivateAssets="All" />
13-
</ItemGroup>
10+
1411
</Project>

Diff for: LibGit2Sharp.Tests/BlobFixture.cs

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
using System.Text;
44
using LibGit2Sharp.Tests.TestHelpers;
55
using Xunit;
6-
using Xunit.Extensions;
76

87
namespace LibGit2Sharp.Tests
98
{
@@ -44,6 +43,7 @@ public void CanGetBlobAsFilteredText(string autocrlf, string expectedText)
4443
}
4544
}
4645

46+
#if NETFRAMEWORK || NETCOREAPP2_1
4747
[Theory]
4848
[InlineData("ascii", 4, "31 32 33 34")]
4949
[InlineData("utf-7", 4, "31 32 33 34")]
@@ -83,6 +83,7 @@ public void CanGetBlobAsTextWithVariousEncodings(string encodingName, int expect
8383
Assert.Equal(expectedUtf7Chars, string.Join(" ", utf7Chars));
8484
}
8585
}
86+
#endif
8687

8788
[Fact]
8889
public void CanGetBlobSize()
@@ -185,7 +186,7 @@ public void CanStageAFileGeneratedFromABlobContentStream()
185186
var sb = new StringBuilder();
186187
for (int j = 0; j < 2000; j++)
187188
{
188-
sb.Append(((i + 1)*(j + 1)).ToString("X8"));
189+
sb.Append(((i + 1) * (j + 1)).ToString("X8"));
189190
}
190191
File.AppendAllText(Path.Combine(repo.Info.WorkingDirectory, "small.txt"), sb.ToString());
191192
}

Diff for: LibGit2Sharp.Tests/LibGit2Sharp.Tests.csproj

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

33
<PropertyGroup>
4-
<TargetFrameworks>net472;netcoreapp2.1</TargetFrameworks>
4+
<TargetFrameworks>net472;netcoreapp2.1;net5.0</TargetFrameworks>
55
</PropertyGroup>
66

77
<ItemGroup>
88
<ProjectReference Include="..\LibGit2Sharp\LibGit2Sharp.csproj" />
9-
<ProjectReference Include="..\NativeLibraryLoadTestApp\x86\NativeLibraryLoadTestApp.x86.csproj" Condition="'$(TargetFramework)' != 'netcoreapp2.1'" ReferenceOutputAssembly="false" OutputItemType="TestAppExe" />
10-
<ProjectReference Include="..\NativeLibraryLoadTestApp\x64\NativeLibraryLoadTestApp.x64.csproj" Condition="'$(TargetFramework)' != 'netcoreapp2.1'" ReferenceOutputAssembly="false" OutputItemType="TestAppExe" />
9+
<ProjectReference Include="..\NativeLibraryLoadTestApp\x86\NativeLibraryLoadTestApp.x86.csproj" Condition="'$(TargetFramework)' == 'net472'" ReferenceOutputAssembly="false" OutputItemType="TestAppExe" />
10+
<ProjectReference Include="..\NativeLibraryLoadTestApp\x64\NativeLibraryLoadTestApp.x64.csproj" Condition="'$(TargetFramework)' == 'net472'" ReferenceOutputAssembly="false" OutputItemType="TestAppExe" />
1111
</ItemGroup>
1212

1313
<ItemGroup>
1414
<PackageReference Include="coverlet.msbuild" Version="2.7.0" />
15-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.4.0" />
16-
<PackageReference Include="Moq" Version="4.10.1" />
17-
<PackageReference Include="System.ValueTuple" Version="4.5.0" />
15+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.10.0" />
16+
<PackageReference Include="Moq" Version="4.16.1" />
1817
<PackageReference Include="xunit" Version="2.4.1" />
1918
<PackageReference Include="xunit.runner.console" Version="2.4.1" />
20-
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1" />
21-
<PackageReference Include="xunit.skippablefact" Version="1.3.12" />
19+
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3" />
20+
<PackageReference Include="xunit.skippablefact" Version="1.4.13" />
2221
</ItemGroup>
2322

2423
<ItemGroup>
2524
<Compile Include="..\LibGit2Sharp\Core\Platform.cs" Link="TestHelpers\Platform.cs" />
26-
<Compile Remove="desktop\**" Condition="'$(TargetFramework)' == 'netcoreapp2.1'" />
25+
<Compile Remove="desktop\**" Condition="'$(TargetFramework)' != 'net472'" />
2726
<Content Include="Resources\**\*.*" CopyToOutputDirectory="PreserveNewest" />
2827
<None Update="xunit.runner.json" CopyToOutputDirectory="PreserveNewest" />
2928
</ItemGroup>

Diff for: LibGit2Sharp.Tests/TestHelpers/BaseFixture.cs

+7-4
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
using System.Reflection;
88
using System.Text;
99
using System.Text.RegularExpressions;
10-
using LibGit2Sharp.Core;
1110
using Xunit;
1211

1312
namespace LibGit2Sharp.Tests.TestHelpers
@@ -21,7 +20,7 @@ public BaseFixture()
2120
BuildFakeConfigs(this);
2221

2322
#if LEAKS_IDENTIFYING
24-
LeaksContainer.Clear();
23+
Core.LeaksContainer.Clear();
2524
#endif
2625
}
2726

@@ -65,7 +64,11 @@ private static void SetUpTestEnvironment()
6564

6665
if (resourcesPath == null)
6766
{
67+
#if NETFRAMEWORK
6868
resourcesPath = Path.Combine(Directory.GetParent(new Uri(typeof(BaseFixture).GetTypeInfo().Assembly.CodeBase).LocalPath).FullName, "Resources");
69+
#else
70+
resourcesPath = Path.Combine(Directory.GetParent(typeof(BaseFixture).GetTypeInfo().Assembly.Location).FullName, "Resources");
71+
#endif
6972
}
7073

7174
ResourcesDirectory = new DirectoryInfo(resourcesPath);
@@ -273,11 +276,11 @@ public virtual void Dispose()
273276
GC.Collect();
274277
GC.WaitForPendingFinalizers();
275278

276-
if (LeaksContainer.TypeNames.Any())
279+
if (Core.LeaksContainer.TypeNames.Any())
277280
{
278281
Assert.False(true, string.Format("Some handles of the following types haven't been properly released: {0}.{1}"
279282
+ "In order to get some help fixing those leaks, uncomment the define LEAKS_TRACKING in Libgit2Object.cs{1}"
280-
+ "and run the tests locally.", string.Join(", ", LeaksContainer.TypeNames), Environment.NewLine));
283+
+ "and run the tests locally.", string.Join(", ", Core.LeaksContainer.TypeNames), Environment.NewLine));
281284
}
282285
#endif
283286
}

Diff for: LibGit2Sharp/LibGit2Sharp.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
<ItemGroup>
3535
<PackageReference Include="LibGit2Sharp.NativeBinaries" Version="[2.0.312]" PrivateAssets="none" />
3636
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="all" />
37-
<PackageReference Include="Nerdbank.GitVersioning" Version="3.0.50" PrivateAssets="all" />
37+
<PackageReference Include="Nerdbank.GitVersioning" Version="3.4.220" PrivateAssets="all" />
3838
</ItemGroup>
3939

4040
<Import Project="..\Targets\CodeGenerator.targets" />

Diff for: azure-pipelines/dotnet.yml

+7-16
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,6 @@ steps:
66
- script: dotnet pack --no-build -c $(BuildConfiguration) /v:m /bl:"$(Build.ArtifactStagingDirectory)/build_logs/pack.binlog"
77
displayName: dotnet pack
88

9-
- task: DotNetCoreCLI@2
10-
displayName: dotnet test -f net46 (w/ coverage)
11-
inputs:
12-
command: test
13-
arguments: --no-build -c $(BuildConfiguration) -f net46 --filter "TestCategory!=FailsInCloudTest & TestCategory!=FailsWhileInstrumented" -v n /p:CollectCoverage=true
14-
testRunTitle: net46-$(Agent.JobName)
15-
condition: and(succeeded(), eq(variables['Agent.OS'], 'Windows_NT'))
16-
17-
- task: DotNetCoreCLI@2
18-
displayName: dotnet test -f net46 (w/o coverage)
19-
inputs:
20-
command: test
21-
arguments: --no-build -c $(BuildConfiguration) -f net46 --filter "TestCategory!=FailsInCloudTest & TestCategory=FailsWhileInstrumented" -v n
22-
testRunTitle: net46-$(Agent.JobName)-nocoverage
23-
condition: and(succeeded(), eq(variables['Agent.OS'], 'Windows_NT'))
24-
259
- task: DotNetCoreCLI@2
2610
displayName: dotnet test -f net472 (w/ coverage)
2711
inputs:
@@ -45,6 +29,13 @@ steps:
4529
arguments: --no-build -c $(BuildConfiguration) -f netcoreapp2.1 --filter "TestCategory!=FailsInCloudTest" -v n /p:CollectCoverage=true
4630
testRunTitle: netcoreapp2.1-$(Agent.JobName)
4731

32+
- task: DotNetCoreCLI@2
33+
displayName: dotnet test -f net5.0
34+
inputs:
35+
command: test
36+
arguments: --no-build -c $(BuildConfiguration) -f net5.0 --filter "TestCategory!=FailsInCloudTest" -v n /p:CollectCoverage=true
37+
testRunTitle: net5.0-$(Agent.JobName)
38+
4839
- task: PowerShell@2
4940
inputs:
5041
filePath: azure-pipelines/artifacts/_pipelines.ps1

Diff for: global.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"sdk": {
3-
"version": "3.1.201"
3+
"version": "5.0.301"
44
}
55
}

0 commit comments

Comments
 (0)