Skip to content

Commit 0e295fa

Browse files
committed
PR feedback and test both x64 and x86 platforms
1 parent 9398e8b commit 0e295fa

8 files changed

+59
-55
lines changed

Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<BaseIntermediateOutputPath>$(MSBuildThisFileDirectory)obj\$(MSBuildProjectName)\</BaseIntermediateOutputPath>
77
<DefineConstants Condition=" '$(ExtraDefine)' != '' ">$(DefineConstants);$(ExtraDefine)</DefineConstants>
88
<SignAssembly>true</SignAssembly>
9-
<AssemblyOriginatorKeyFile>..\libgit2sharp.snk</AssemblyOriginatorKeyFile>
9+
<AssemblyOriginatorKeyFile>$(MSBuildThisFileDirectory)libgit2sharp.snk</AssemblyOriginatorKeyFile>
1010
</PropertyGroup>
1111

1212
</Project>

LibGit2Sharp.TestApp/LibGit2Sharp.TestApp.csproj renamed to LibGit2Sharp.TestApp/x64/LibGit2Sharp.TestApp.x64.csproj

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,15 @@
33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
55
<TargetFramework>net461</TargetFramework>
6-
<PlatformTarget>AnyCPU</PlatformTarget>
6+
<PlatformTarget>x64</PlatformTarget>
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<ProjectReference Include="..\LibGit2Sharp\LibGit2Sharp.csproj" />
10+
<ProjectReference Include="..\..\LibGit2Sharp\LibGit2Sharp.csproj" />
11+
</ItemGroup>
12+
13+
<ItemGroup>
14+
<Compile Include="..\*.cs" />
1115
</ItemGroup>
1216

1317
</Project>
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net461</TargetFramework>
6+
<PlatformTarget>x86</PlatformTarget>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<ProjectReference Include="..\..\LibGit2Sharp\LibGit2Sharp.csproj" />
11+
</ItemGroup>
12+
13+
<ItemGroup>
14+
<Compile Include="..\*.cs" />
15+
</ItemGroup>
16+
17+
</Project>

LibGit2Sharp.Tests/GlobalSettingsFixture.cs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -53,23 +53,23 @@ public void TryingToResetNativeLibraryPathAfterLoadedThrows()
5353
Assert.Throws<LibGit2SharpException>(() => { GlobalSettings.NativeLibraryPath = "C:/Foo"; });
5454
}
5555

56-
[ConditionalFact(typeof(NetFramework))]
57-
public void LoadFromSpecifiedPath()
56+
[SkippableTheory]
57+
[InlineData(new object[] { "x86" })]
58+
[InlineData(new object[] { "x64" })]
59+
public void LoadFromSpecifiedPath(string platform)
5860
{
59-
#if NET461
60-
var nativeDllFileName = NativeDllName.Name + ".dll";
61+
Skip.IfNot(Platform.IsRunningOnNetFramework(), ".NET Framework only test.");
6162

62-
var testAppExe = typeof(TestApp).Assembly.Location;
63+
var nativeDllFileName = NativeDllName.Name + ".dll";
64+
var testDir = Path.GetDirectoryName(typeof(GlobalSettingsFixture).Assembly.Location);
65+
var testAppExe = Path.Combine(testDir, $"LibGit2Sharp.TestApp.{platform}.exe");
6366
var tempDir = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
6467
var platformDir = Path.Combine(tempDir, "plat");
6568

6669
try
6770
{
68-
Directory.CreateDirectory(Path.Combine(platformDir, "x86"));
69-
Directory.CreateDirectory(Path.Combine(platformDir, "x64"));
70-
71-
File.Copy(Path.Combine(GlobalSettings.NativeLibraryPath, "x86", nativeDllFileName), Path.Combine(platformDir, "x86", nativeDllFileName));
72-
File.Copy(Path.Combine(GlobalSettings.NativeLibraryPath, "x64", nativeDllFileName), Path.Combine(platformDir, "x64", nativeDllFileName));
71+
Directory.CreateDirectory(Path.Combine(platformDir, platform));
72+
File.Copy(Path.Combine(GlobalSettings.NativeLibraryPath, platform, nativeDllFileName), Path.Combine(platformDir, platform, nativeDllFileName));
7373

7474
var (output, exitCode) = ProcessHelper.RunProcess(testAppExe, arguments: $@"{NativeDllName.Name} ""{platformDir}""", workingDirectory: tempDir);
7575

@@ -80,7 +80,6 @@ public void LoadFromSpecifiedPath()
8080
{
8181
DirectoryHelper.DeleteDirectory(tempDir);
8282
}
83-
#endif
8483
}
8584
}
8685
}

LibGit2Sharp.Tests/LibGit2Sharp.Tests.csproj

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22

33
<PropertyGroup>
44
<TargetFrameworks>net461;netcoreapp2.0</TargetFrameworks>
5+
<DefineConstants Condition=" '$(TargetFramework)' == 'net461' ">$(DefineConstants);DESKTOP</DefineConstants>
56
</PropertyGroup>
67

78
<ItemGroup>
89
<ProjectReference Include="..\LibGit2Sharp\LibGit2Sharp.csproj" />
9-
<ProjectReference Include="..\LibGit2Sharp.TestApp\LibGit2Sharp.TestApp.csproj" Condition="'$(TargetFramework)' == 'net461'" />
10+
<ProjectReference Include="..\LibGit2Sharp.TestApp\x86\LibGit2Sharp.TestApp.x86.csproj" Condition="'$(TargetFramework)' == 'net461'" ReferenceOutputAssembly="false" OutputItemType="TestAppExe" />
11+
<ProjectReference Include="..\LibGit2Sharp.TestApp\x64\LibGit2Sharp.TestApp.x64.csproj" Condition="'$(TargetFramework)' == 'net461'" ReferenceOutputAssembly="false" OutputItemType="TestAppExe" />
1012
</ItemGroup>
1113

1214
<ItemGroup>
@@ -18,8 +20,20 @@
1820
<PackageReference Include="xunit.skippablefact" Version="1.3.3" />
1921
</ItemGroup>
2022

21-
<ItemGroup>
22-
<Compile Remove="desktop\**" Condition=" '$(TargetFramework)' != 'net461' " />
23+
<Target Name="CopyTestAppExes" AfterTargets="ResolveProjectReferences">
24+
<ItemGroup>
25+
<_TestAppFile Include="@(TestAppExe->'%(RootDir)%(Directory)%(Filename).exe')" />
26+
<_TestAppFile Include="@(TestAppExe->'%(RootDir)%(Directory)%(Filename).exe.config')" />
27+
<_TestAppFile Include="@(TestAppExe->'%(RootDir)%(Directory)%(Filename).pdb')" />
28+
</ItemGroup>
29+
30+
<ItemGroup>
31+
<Content Include="@(_TestAppFile)" CopyToOutputDirectory="PreserveNewest" Visible="false" />
32+
</ItemGroup>
33+
</Target>
34+
35+
<ItemGroup Condition="'$(TargetFramework)' != 'net461'">
36+
<Compile Remove="desktop\**" />
2337
</ItemGroup>
2438

2539
</Project>

LibGit2Sharp.Tests/SetErrorFixture.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public void FormatAggregateException()
4949
Exception exceptionToThrow = new AggregateException(aggregateExceptionMessage, new Exception(innerExceptionMessage), new Exception(innerExceptionMessage2));
5050

5151
StringBuilder sb = new StringBuilder();
52-
#if NET461
52+
#if DESKTOP
5353
sb.AppendLine(aggregateExceptionMessage);
5454
#else
5555
sb.AppendLine($"{aggregateExceptionMessage} ({innerExceptionMessage}) ({innerExceptionMessage2})");

LibGit2Sharp.Tests/TestHelpers/ConditionalFactAttribute.cs

Lines changed: 0 additions & 36 deletions
This file was deleted.

LibGit2Sharp.sln

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
1515
version.json = version.json
1616
EndProjectSection
1717
EndProject
18-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LibGit2Sharp.TestApp", "LibGit2Sharp.TestApp\LibGit2Sharp.TestApp.csproj", "{86453D2C-4953-4DF4-B12A-ADE579608BAA}"
18+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LibGit2Sharp.TestApp.x86", "LibGit2Sharp.TestApp\x86\LibGit2Sharp.TestApp.x86.csproj", "{86453D2C-4953-4DF4-B12A-ADE579608BAA}"
19+
EndProject
20+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LibGit2Sharp.TestApp.x64", "LibGit2Sharp.TestApp\x64\LibGit2Sharp.TestApp.x64.csproj", "{5C55175D-6A1F-4C51-B791-BF7DD00124EE}"
1921
EndProject
2022
Global
2123
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -35,6 +37,10 @@ Global
3537
{86453D2C-4953-4DF4-B12A-ADE579608BAA}.Debug|Any CPU.Build.0 = Debug|Any CPU
3638
{86453D2C-4953-4DF4-B12A-ADE579608BAA}.Release|Any CPU.ActiveCfg = Release|Any CPU
3739
{86453D2C-4953-4DF4-B12A-ADE579608BAA}.Release|Any CPU.Build.0 = Release|Any CPU
40+
{5C55175D-6A1F-4C51-B791-BF7DD00124EE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
41+
{5C55175D-6A1F-4C51-B791-BF7DD00124EE}.Debug|Any CPU.Build.0 = Debug|Any CPU
42+
{5C55175D-6A1F-4C51-B791-BF7DD00124EE}.Release|Any CPU.ActiveCfg = Release|Any CPU
43+
{5C55175D-6A1F-4C51-B791-BF7DD00124EE}.Release|Any CPU.Build.0 = Release|Any CPU
3844
EndGlobalSection
3945
GlobalSection(SolutionProperties) = preSolution
4046
HideSolutionNode = FALSE

0 commit comments

Comments
 (0)