Skip to content

Move to .NET Standard 2.0 #1483

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 23 commits into from
Nov 11, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@ insert_final_newline = true
[*.{sln,csroj}]
trim_trailing_whitespace = false
insert_final_newline = false

[*.{props,targets}]
indent_size = 2
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@

language: csharp
dist: trusty
dotnet: 1.0.1
dotnet: 2.0.0
mono: none
osx_image: xcode8.3

os:
- osx
Expand Down
12 changes: 0 additions & 12 deletions CodeGeneration/CodeGeneration.csproj

This file was deleted.

312 changes: 0 additions & 312 deletions CodeGeneration/OfferFriendlyInteropOverloadsGenerator.cs

This file was deleted.

12 changes: 0 additions & 12 deletions CodeGenerationAttributes/CodeGenerationAttributes.csproj

This file was deleted.

21 changes: 0 additions & 21 deletions CodeGenerationAttributes/CustomMarshalerAttribute.cs

This file was deleted.

16 changes: 0 additions & 16 deletions CodeGenerationAttributes/OfferFriendlyInteropOverloadsAttribute.cs

This file was deleted.

5 changes: 3 additions & 2 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
<Project>

<PropertyGroup>
<OutputPath>$(MSBuildThisFileDirectory)bin\$(MSBuildProjectName)\$(Configuration)\</OutputPath>
<BaseIntermediateOutputPath>$(MSBuildThisFileDirectory)obj\$(MSBuildProjectName)\</BaseIntermediateOutputPath>

<CodeGenerationRoslynVersion>0.4.11</CodeGenerationRoslynVersion>
<DefineConstants Condition=" '$(ExtraDefine)' != '' ">$(DefineConstants);$(ExtraDefine)</DefineConstants>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Nerdbank.GitVersioning" Version="2.0.37-beta" PrivateAssets="all" />
</ItemGroup>

</Project>
9 changes: 9 additions & 0 deletions Directory.Build.targets
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
<Project>

<PropertyGroup>
<PublicSign Condition=" '$(AssemblyOriginatorKeyFile)' != '' and '$(OS)' != 'Windows_NT' ">true</PublicSign>
<TargetsForTfmSpecificContentInPackage>$(TargetsForTfmSpecificContentInPackage);IncludePDBsInPackage</TargetsForTfmSpecificContentInPackage>
</PropertyGroup>

<Target Name="IncludePDBsInPackage">
<ItemGroup>
<TfmSpecificPackageFile Include="$(OutputPath)\$(AssemblyName).pdb" PackagePath="lib/$(TargetFramework)" />
</ItemGroup>
</Target>

</Project>
16 changes: 8 additions & 8 deletions LibGit2Sharp.Tests/GlobalSettingsFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,25 @@ public void CanGetMinimumCompiledInFeatures()
public void CanRetrieveValidVersionString()
{
// Version string format is:
// Major.Minor.Patch[-somePreleaseTag]-libgit2_abbrev_hash (x86|x64 - features)
// Major.Minor.Patch[-previewTag]+g{LibGit2Sharp_abbrev_hash}.libgit2-{libgit2_abbrev_hash} (x86|x64 - features)
// Example output:
// "0.17.0[-beta]+gdeadcafeee.LibGit2-06d772d (x86 - Threads, Https)"
// "0.25.0-preview.52+g871d13a67f.libgit2-15e1193 (x86 - Threads, Https)"

string versionInfo = GlobalSettings.Version.ToString();

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

Assert.NotNull(versionInfo);

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

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

Expand Down
23 changes: 10 additions & 13 deletions LibGit2Sharp.Tests/LibGit2Sharp.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,32 +1,29 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net46;netcoreapp1.0</TargetFrameworks>
<TargetFrameworks>net46;netcoreapp2.0</TargetFrameworks>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DefineConstants Condition=" '$(TargetFramework)' == 'net46' ">$(DefineConstants);DESKTOP</DefineConstants>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<Compile Include="..\LibGit2Sharp\Core\Epoch.cs">
<Link>TestHelpers\Epoch.cs</Link>
</Compile>
<Compile Include="..\LibGit2Sharp\Core\Platform.cs">
<Link>TestHelpers\Platform.cs</Link>
</Compile>
<Compile Include="..\LibGit2Sharp\Core\Epoch.cs" Link="TestHelpers\Epoch.cs" />
<Compile Include="..\LibGit2Sharp\Core\Platform.cs" Link="TestHelpers\Platform.cs" />
<Compile Remove="desktop\**" Condition=" '$(TargetFramework)' != 'net46' " />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\LibGit2Sharp\LibGit2Sharp.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Moq" Version="4.7.99" />
<PackageReference Include="xunit" Version="2.2.0" />
<PackageReference Include="xunit.skippablefact" Version="1.3.3" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.2.0" />
<PackageReference Include="xunit.runner.console" Version="2.2.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.3.0" />
</ItemGroup>
<ItemGroup>
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
</ItemGroup>
<Import Project="..\LibGit2Sharp\ExtraDefine.targets" />
</Project>

</Project>
38 changes: 37 additions & 1 deletion LibGit2Sharp.Tests/MetaFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,49 @@

namespace LibGit2Sharp.Tests
{
public partial class MetaFixture
public class MetaFixture
{
private static readonly HashSet<Type> explicitOnlyInterfaces = new HashSet<Type>
{
typeof(IBelongToARepository), typeof(IDiffResult),
};

[Fact]
public void LibGit2SharpPublicInterfacesCoverAllPublicMembers()
{
var methodsMissingFromInterfaces =
from t in typeof(IRepository).GetTypeInfo().Assembly.GetExportedTypes()
where !t.GetTypeInfo().IsInterface
where t.GetTypeInfo().GetInterfaces().Any(i => i.GetTypeInfo().IsPublic && i.Namespace == typeof(IRepository).Namespace && !explicitOnlyInterfaces.Contains(i))
let interfaceTargetMethods = from i in t.GetTypeInfo().GetInterfaces()
from im in t.GetInterfaceMap(i).TargetMethods
select im
from tm in t.GetMethods(BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.Instance)
where !interfaceTargetMethods.Contains(tm)
select t.Name + " has extra method " + tm.Name;

Assert.Equal("", string.Join(Environment.NewLine,
methodsMissingFromInterfaces.ToArray()));
}

[Fact]
public void LibGit2SharpExplicitOnlyInterfacesAreIndeedExplicitOnly()
{
var methodsMissingFromInterfaces =
from t in typeof(IRepository).GetTypeInfo().Assembly.GetExportedTypes()
where t.GetInterfaces().Any(explicitOnlyInterfaces.Contains)
let interfaceTargetMethods = from i in t.GetInterfaces()
where explicitOnlyInterfaces.Contains(i)
from im in t.GetTypeInfo().GetInterfaceMap(i).TargetMethods
select im
from tm in t.GetMethods(BindingFlags.DeclaredOnly | BindingFlags.Public | BindingFlags.Instance)
where interfaceTargetMethods.Contains(tm)
select t.Name + " has public method " + tm.Name + " which should be explicitly implemented.";

Assert.Equal("", string.Join(Environment.NewLine,
methodsMissingFromInterfaces.ToArray()));
}

[Fact]
public void PublicTestMethodsAreFactsOrTheories()
{
Expand Down
46 changes: 0 additions & 46 deletions LibGit2Sharp.Tests/desktop/MetaFixture.cs

This file was deleted.

20 changes: 8 additions & 12 deletions LibGit2Sharp.sln
Original file line number Diff line number Diff line change
@@ -1,24 +1,21 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26407.1
VisualStudioVersion = 15.0.26730.10
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LibGit2Sharp", "LibGit2Sharp\LibGit2Sharp.csproj", "{EE6ED99F-CB12-4683-B055-D28FC7357A34}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LibGit2Sharp", "LibGit2Sharp\LibGit2Sharp.csproj", "{EE6ED99F-CB12-4683-B055-D28FC7357A34}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LibGit2Sharp.Tests", "LibGit2Sharp.Tests\LibGit2Sharp.Tests.csproj", "{286E63EB-04DD-4ADE-88D6-041B57800761}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodeGenerationAttributes", "CodeGenerationAttributes\CodeGenerationAttributes.csproj", "{E1A8B99F-B2F6-4A38-9DF6-8792056D70FF}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LibGit2Sharp.Tests", "LibGit2Sharp.Tests\LibGit2Sharp.Tests.csproj", "{286E63EB-04DD-4ADE-88D6-041B57800761}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{0CA739FD-DA4D-4F64-9834-DA14A3ECD04B}"
ProjectSection(SolutionItems) = preProject
.gitignore = .gitignore
Directory.Build.props = Directory.Build.props
Directory.Build.targets = Directory.Build.targets
nuget.config = nuget.config
version.json = version.json
EndProjectSection
EndProject
Global
GlobalSection(SharedMSBuildProjectFiles) = preSolution
EndGlobalSection
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
Expand All @@ -32,12 +29,11 @@ Global
{286E63EB-04DD-4ADE-88D6-041B57800761}.Debug|Any CPU.Build.0 = Debug|Any CPU
{286E63EB-04DD-4ADE-88D6-041B57800761}.Release|Any CPU.ActiveCfg = Release|Any CPU
{286E63EB-04DD-4ADE-88D6-041B57800761}.Release|Any CPU.Build.0 = Release|Any CPU
{E1A8B99F-B2F6-4A38-9DF6-8792056D70FF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E1A8B99F-B2F6-4A38-9DF6-8792056D70FF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E1A8B99F-B2F6-4A38-9DF6-8792056D70FF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E1A8B99F-B2F6-4A38-9DF6-8792056D70FF}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {9BD5F77D-E47D-4621-9AA0-8598766902B9}
EndGlobalSection
EndGlobal
7 changes: 0 additions & 7 deletions LibGit2Sharp/AmbiguousSpecificationException.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
using System;
using System.Globalization;
#if DESKTOP
using System.Runtime.Serialization;
#endif

namespace LibGit2Sharp
{
/// <summary>
/// The exception that is thrown when the provided specification cannot uniquely identify a reference, an object or a path.
/// </summary>
#if DESKTOP
[Serializable]
#endif
public class AmbiguousSpecificationException : LibGit2SharpException
{
/// <summary>
Expand Down Expand Up @@ -47,7 +42,6 @@ public AmbiguousSpecificationException(string message, Exception innerException)
: base(message, innerException)
{ }

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