10000 Merge pull request #1483 from libgit2/netstandard2.0 · libgit2/libgit2sharp@fe3742e · GitHub
[go: up one dir, main page]

Skip to content

Commit fe3742e

Browse files
authored
Merge pull request #1483 from libgit2/netstandard2.0
Move to .NET Standard 2.0
2 parents ed61c69 + 5379d6a commit fe3742e

Original file line numberDiff line numberDiff line change
@@ -13,3 +13,6 @@ insert_final_newline = true
1313
[*.{sln,csroj}]
1414
trim_trailing_whitespace = false
1515
insert_final_newline = false
16+
17+
[*.{props,targets}]
18+
indent_size = 2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33

44
language: csharp
55
dist: trusty
6-
dotnet: 1.0.1
6+
dotnet: 2.0.0
77
mono: none
8+
osx_image: xcode8.3
89

910
os:
1011
- osx
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
<Project>
2+
23
<PropertyGroup>
34
<OutputPath>$(MSBuildThisFileDirectory)bin\$(MSBuildProjectName)\$(Configuration)\</OutputPath>
45
<BaseIntermediateOutputPath>$(MSBuildThisFileDirectory)obj\$(MSBuildProjectName)\</BaseIntermediateOutputPath>
5-
6-
<CodeGenerationRoslynVersion>0.4.11</CodeGenerationRoslynVersion>
6+
<DefineConstants Condition=" '$(ExtraDefine)' != '' ">$(DefineConstants);$(ExtraDefine)</DefineConstants>
77
</PropertyGroup>
88

99
<ItemGroup>
1010
<PackageReference Include="Nerdbank.GitVersioning" Version="2.0.37-beta" PrivateAssets="all" />
1111
</ItemGroup>
12+
1213
</Project>
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
<Project>
2+
23
<PropertyGroup>
34
<PublicSign Condition=" '$(AssemblyOriginatorKeyFile)' != '' and '$(OS)' != 'Windows_NT' ">true</PublicSign>
5+
<TargetsForTfmSpecificContentInPackage>$(TargetsForTfmSpecificContentInPackage);IncludePDBsInPackage</TargetsForTfmSpecificContentInPackage>
46
</PropertyGroup>
7+
8+
<Target Name="IncludePDBsInPackage">
9+
<ItemGroup>
10+
<TfmSpecificPackageFile Include="$(OutputPath)\$(AssemblyName).pdb" PackagePath="lib/$(TargetFramework)" />
11+
</ItemGroup>
12+
</Target>
13+
514
</Project>
Original file line numberDiff line numberDiff line change
@@ -19,25 +19,25 @@ public void CanGetMinimumCompiledInFeatures()
1919
public void CanRetrieveValidVersionString()
2020
{
2121
// Version string format is:
22-
// Major.Minor.Patch[-somePreleaseTag]-libgit2_abbrev_hash (x86|x64 - features)
22+
// Major.Minor.Patch[-previewTag]+g{LibGit2Sharp_abbrev_hash}.libgit2-{libgit2_abbrev_hash} (x86|x64 - features)
2323
// Example output:
24-
// "0.17.0[-beta]+gdeadcafeee.LibGit2-06d772d (x86 - Threads, Https)"
24+
// "0.25.0-preview.52+g871d13a67f.libgit2-15e1193 (x86 - Threads, Https)"
2525

2626
string versionInfo = GlobalSettings.Version.ToString();
2727

2828
// The GlobalSettings.Version returned string should contain :
29-
// version: '0.17.0[-somePreleaseTag]+[gSomeGitCommit.]LibGit2-06d772d' LibGit2Sharp version number.
30-
// git2hash: '06d772d' LibGit2 library hash.
31-
// arch: 'x86' or 'x64' LibGit2 target.
32-
// git2Features: 'Threads, Ssh' LibGit2 features compiled with.
33-
string regex = @"^(?<version>\d+\.\d+\.\d+(-[\w\-\.]+)?\+(g(?<git2SharpHash>[a-f0-9]{10})\.)?LibGit2-[a-f0-9]{7}) \((?<arch>\w+) - (?<git2Features>(?:\w*(?:, )*\w+)*)\)$";
29+
// version: '0.25.0[-previewTag]' LibGit2Sharp version number.
30+
// git2SharpHash: '871d13a67f' LibGit2Sharp hash.
31+
// arch: 'x86' or 'x64' libgit2 target.
32+
// git2Features: 'Threads, Ssh' libgit2 features compiled with.
33+
string regex = @"^(?<version>\d+\.\d+\.\d+(-[\w\-\.]+)?\+(g(?<git2SharpHash>[a-f0-9]{10})\.)?libgit2-[a-f0-9]{7}) \((?<arch>\w+) - (?<git2Features>(?:\w*(?:, )*\w+)*)\)$";
3434

3535
Assert.NotNull(versionInfo);
3636

3737
Match regexResult = Regex.Match(versionInfo, regex);
3838

3939
Assert.True(regexResult.Success, "The following version string format is enforced:" +
40-
"Major.Minor.Patch[-somePreleaseTag]+[gSomeGitCommit].LibGit2-abbrev_hash (x86|x64 - features). " +
40+
"Major.Minor.Patch[-previewTag]+g{LibGit2Sharp_abbrev_hash}.libgit2-{libgit2_abbrev_hash} (x86|x64 - features). " +
4141
"But found \"" + versionInfo + "\" instead.");
4242
}
4343

Original file line numberDiff line numberDiff line change
@@ -1,32 +1,29 @@
11
<Project Sdk="Microsoft.NET.Sdk">
2+
23
<PropertyGroup>
3-
<TargetFrameworks>net46;netcoreapp1.0</TargetFrameworks>
4+
<TargetFrameworks>net46;netcoreapp2.0</TargetFrameworks>
45
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
56
<DefineConstants Condition=" '$(TargetFramework)' == 'net46' ">$(DefineConstants);DESKTOP</DefineConstants>
67
<IsPackable>false</IsPackable>
78
</PropertyGroup>
9+
810
<ItemGroup>
9-
<Compile Include="..\LibGit2Sharp\Core\Epoch.cs">
10-
<Link>TestHelpers\Epoch.cs</Link>
11-
</Compile>
12-
<Compile Include="..\LibGit2Sharp\Core\Platform.cs">
13-
<Link>TestHelpers\Platform.cs</Link>
14-
</Compile>
11+
<Compile Include="..\LibGit2Sharp\Core\Epoch.cs" Link="TestHelpers\Epoch.cs" />
12+
<Compile Include="..\LibGit2Sharp\Core\Platform.cs" Link="TestHelpers\Platform.cs" />
1513
<Compile Remove="desktop\**" Condition=" '$(TargetFramework)' != 'net46' " />
1614
</ItemGroup>
15+
1716
<ItemGroup>
1817
<ProjectReference Include="..\LibGit2Sharp\LibGit2Sharp.csproj" />
1918
</ItemGroup>
19+
2020
<ItemGroup>
2121
<PackageReference Include="Moq" Version="4.7.99" />
2222
<PackageReference Include="xunit" Version="2.2.0" />
2323
<PackageReference Include="xunit.skippablefact" Version="1.3.3" />
2424
<PackageReference Include="xunit.runner.visualstudio" Version="2.2.0" />
2525
<PackageReference Include="xunit.runner.console" Version="2.2.0" />
26-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" />
26+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.3.0" />
2727
</ItemGroup>
28-
<ItemGroup>
29-
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
30-
</ItemGroup>
31-
<Import Project="..\LibGit2Sharp\ExtraDefine.targets" />
32-
</Project>
28+
29+
</Project>
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,49 @@
1313

1414
namespace LibGit2Sharp.Tests
1515
{
16-
public partial class MetaFixture
16+
public class MetaFixture
1717
{
1818
private static readonly HashSet<Type> explicitOnlyInterfaces = new HashSet<Type>
1919
{
2020
typeof(IBelongToARepository), typeof(IDiffResult),
2121
};
2222

23+
[Fact]
24+
public void LibGit2SharpPublicInterfacesCoverAllPublicMembers()
25+
{
26+
var methodsMissingFromInterfaces =
27+
from t in typeof(IRepository).GetTypeInfo().Assembly.GetExportedTypes()
28+
where !t.GetTypeInfo().IsInterface
29+
where t.GetTypeInfo().GetInterfaces().Any(i => i.GetTypeInfo().IsPublic && i.Namespace == typeof(IRepository).Namespace && !explicitOnlyInterfaces.Contains(i))
30+
let interfaceTargetMethods = from i in t.GetTypeInfo().GetInterfaces()
31+
from im in t.GetInterfaceMap(i).TargetMethods
32+
select im
33+
from tm in t.GetMethods(BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.Instance)
34+
where !interfaceTargetMethods.Contains(tm)
35+
select t.Name + " has extra method " + tm.Name;
36+
37+
Assert.Equal("", string.Join(Environment.NewLine,
38+
methodsMissingFromInterfaces.ToArray()));
39+
}
40+
41+
[Fact]
42+
public void LibGit2SharpExplicitOnlyInterfacesAreIndeedExplicitOnly()
43+
{
44+
var methodsMissingFromInterfaces =
45+
from t in typeof(IRepository).GetTypeInfo().Assembly.GetExportedTypes()
46+
where t.GetInterfaces().Any(explicitOnlyInterfaces.Contains)
47+
let interfaceTargetMethods = from i in t.GetInterfaces()
48+
where explicitOnlyInterfaces.Contains(i)
49+
from im in t.GetTypeInfo().GetInterfaceMap(i).TargetMethods
50+
select im
51+
from tm in t.GetMethods(BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.Instance)
52+
where interfaceTargetMethods.Contains(tm)
53+
select t.Name + " has public method " + tm.Name + " which should be explicitly implemented.";
54+
55+
Assert.Equal("", string.Join(Environment.NewLine,
56+
methodsMissingFromInterfaces.ToArray()));
57+
}
58+
2359
[Fact]
2460
public void PublicTestMethodsAreFactsOrTheories()
2561
{
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,21 @@
1-
21
Microsoft Visual Studio Solution File, Format Version 12.00
32
# Visual Studio 15
4-
VisualStudioVersion = 15.0.26407.1
3+
VisualStudioVersion = 15.0.26730.10
54
MinimumVisualStudioVersion = 10.0.40219.1
6-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LibGit2Sharp", "LibGit2Sharp\LibGit2Sharp.csproj", "{EE6ED99F-CB12-4683-B055-D28FC7357A34}"
5+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LibGit2Sharp", "LibGit2Sharp\LibGit2Sharp.csproj", "{EE6ED99F-CB12-4683-B055-D28FC7357A34}"
76
EndProject
8-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LibGit2Sharp.Tests", "LibGit2Sharp.Tests\LibGit2Sharp.Tests.csproj", "{286E63EB-04DD-4ADE-88D6-041B57800761}"
9-
EndProject
10-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodeGenerationAttributes", "CodeGenerationAttributes\CodeGenerationAttributes.csproj", "{E1A8B99F-B2F6-4A38-9DF6-8792056D70FF}"
7+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LibGit2Sharp.Tests", "LibGit2Sharp.Tests\LibGit2Sharp.Tests.csproj", "{286E63EB-04DD-4ADE-88D6-041B57800761}"
118
EndProject
129
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{0CA739FD-DA4D-4F64-9834-DA14A3ECD04B}"
1310
ProjectSection(SolutionItems) = preProject
1411
.gitignore = .gitignore
12+
Directory.Build.props = Directory.Build.props
13+
Directory.Build.targets = Directory.Build.targets
1514
nuget.config = nuget.config
1615
version.json = version.json
1716
EndProjectSection
1817
EndProject
1918
Global
20-
GlobalSection(SharedMSBuildProjectFiles) = preSolution
21-
EndGlobalSection
2219
GlobalSection(SolutionConfigurationPlatforms) = preSolution
2320
Debug|Any CPU = Debug|Any CPU
2421
Release|Any CPU = Release|Any CPU
@@ -32,12 +29,11 @@ Global
3229
{286E63EB-04DD-4ADE-88D6-041B57800761}.Debug|Any CPU.Build.0 = Debug|Any CPU
3330
{286E63EB-04DD-4ADE-88D6-041B57800761}.Release|Any CPU.ActiveCfg = Release|Any CPU
3431
{286E63EB-04DD-4ADE-88D6-041B57800761}.Release|Any CPU.Build.0 = Release|Any CPU
35-
{E1A8B99F-B2F6-4A38-9DF6-8792056D70FF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
36-
{E1A8B99F-B2F6-4A38-9DF6-8792056D70FF}.Debug|Any CPU.Build.0 = Debug|Any CPU
37-
{E1A8B99F-B2F6-4A38-9DF6-8792056D70FF}.Release|Any CPU.ActiveCfg = Release|Any CPU
38-
{E1A8B99F-B2F6-4A38-9DF6-8792056D70FF}.Release|Any CPU.Build.0 = Release|Any CPU
3932
EndGlobalSection
4033
GlobalSection(SolutionProperties) = preSolution
4134
HideSolutionNode = FALSE
4235
EndGlobalSection
36+
GlobalSection(ExtensibilityGlobals) = postSolution
37+
SolutionGuid = {9BD5F77D-E47D-4621-9AA0-8598766902B9}
38+
EndGlobalSection
4339
EndGlobal
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,12 @@
11
using System;
2-
using System.Globalization;
3-
#if DESKTOP
42
using System.Runtime.Serialization;
5-
#endif
63

74
namespace LibGit2Sharp
85
{
96
/// <summary>
107
/// The exception that is thrown when the provided specification cannot uniquely identify a reference, an object or a path.
118
/// </summary>
12-
#if DESKTOP
139
[Serializable]
14-
#endif
1510
public class AmbiguousSpecificationException : LibGit2SharpException
1611
{
1712
/// <summary>
@@ -47,7 +42,6 @@ public AmbiguousSpecificationException(string message, Exception innerException)
4742
: base(message, innerException)
4843
{ }
4944

50-
#if DESKTOP
5145
/// <summary>
5246
/// Initializes a new instance of the <see cref="AmbiguousSpecificationException"/> class with a serialized data.
5347
/// </summary>
@@ -56,6 +50,5 @@ public AmbiguousSpecificationException(string message, Exception innerException)
5650
protected AmbiguousSpecificationException(SerializationInfo info, StreamingContext context)
5751
: base(info, context)
5852
{ }
59-
#endif
6053
}
6154
}