Skip to content

Commit 67c39da

Browse files
committed
Remove net40 target
1 parent 43b4c07 commit 67c39da

13 files changed

+27
-113
lines changed

LibGit2Sharp.Tests/LibGit2Sharp.Tests.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>net46;netcoreapp2.0</TargetFrameworks>
5-
<DefineConstants Condition=" '$(TargetFramework)' == 'net46' ">$(DefineConstants);DESKTOP</DefineConstants>
4+
<TargetFrameworks>net461;netcoreapp2.0</TargetFrameworks>
5+
<DefineConstants Condition=" '$(TargetFramework)' == 'net461' ">$(DefineConstants);DESKTOP</DefineConstants>
66
</PropertyGroup>
77

88
<ItemGroup>
@@ -21,7 +21,7 @@
2121
<ItemGroup>
2222
<Compile Include="..\LibGit2Sharp\Core\Epoch.cs" Link="TestHelpers\Epoch.cs" />
2323
<Compile Include="..\LibGit2Sharp\Core\Platform.cs" Link="TestHelpers\Platform.cs" />
24-
<Compile Remove="desktop\**" Condition=" '$(TargetFramework)' != 'net46' " />
24+
<Compile Remove="desktop\**" Condition=" '$(TargetFramework)' != 'net461' " />
2525
</ItemGroup>
2626

2727
</Project>

LibGit2Sharp.Tests/app.config

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

LibGit2Sharp/Core/ArrayMarshaler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public ArrayMarshaler(T[] objs)
1313

1414
for (var i = 0; i < objs.Length; i++)
1515
{
16-
IntPtr ptr = Marshal.AllocHGlobal(MarshalPortable.SizeOf<T>());
16+
IntPtr ptr = Marshal.AllocHGlobal(Marshal.SizeOf<T>());
1717
ptrs[i] = ptr;
1818
Marshal.StructureToPtr(objs[i], ptr, false);
1919
}

LibGit2Sharp/Core/GitOdbBackend.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ internal struct GitOdbBackend
88
{
99
static GitOdbBackend()
1010
{
11-
GCHandleOffset = MarshalPortable.OffsetOf<GitOdbBackend>(nameof(GCHandle)).ToInt32();
11+
GCHandleOffset = Marshal.OffsetOf<GitOdbBackend>(nameof(GCHandle)).ToInt32();
1212
}
1313

1414
public uint Version;

LibGit2Sharp/Core/GitOdbBackendStream.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ internal class GitOdbBackendStream
1515
{
1616
static GitOdbBackendStream()
1717
{
18-
GCHandleOffset = MarshalPortable.OffsetOf<GitOdbBackendStream>(nameof(GCHandle)).ToInt32();
18+
GCHandleOffset = Marshal.OffsetOf<GitOdbBackendStream>(nameof(GCHandle)).ToInt32();
1919
}
2020

2121
public IntPtr Backend;

LibGit2Sharp/Core/GitSmartSubtransport.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ internal class GitSmartSubtransport
88
{
99
static GitSmartSubtransport()
1010
{
11-
GCHandleOffset = MarshalPortable.OffsetOf<GitSmartSubtransport>(nameof(GCHandle)).ToInt32();
11+
GCHandleOffset = Marshal.OffsetOf<GitSmartSubtransport>(nameof(GCHandle)).ToInt32();
1212
}
1313

1414
public action_callback Action;

LibGit2Sharp/Core/GitSmartSubtransportStream.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ internal class GitSmartSubtransportStream
88
{
99
static GitSmartSubtransportStream()
1010
{
11-
GCHandleOffset = MarshalPortable.OffsetOf<GitSmartSubtransportStream>(nameof(GCHandle)).ToInt32();
11+
GCHandleOffset = Marshal.OffsetOf<GitSmartSubtransportStream>(nameof(GCHandle)).ToInt32();
1212
}
1313

1414
public IntPtr SmartTransport;

LibGit2Sharp/Core/MarshalPortable.cs

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

LibGit2Sharp/Core/Platform.cs

Lines changed: 14 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System;
2-
using System.IO;
32
using System.Runtime.InteropServices;
43

54
namespace LibGit2Sharp.Core
@@ -13,68 +12,29 @@ internal enum OperatingSystemType
1312

1413
internal static class Platform
1514
{
16-
private static Lazy<OperatingSystemType> _operatingSystem = new Lazy<OperatingSystemType>(
17-
DetermineOperatingSystem,
18-
System.Threading.LazyThreadSafetyMode.PublicationOnly);
15+
public static string ProcessorArchitecture => IntPtr.Size == 8 ? "x64" : "x86";
1916

20-
public static string ProcessorArchitecture
17+
public static OperatingSystemType OperatingSystem
2118
{
22-
get { return IntPtr.Size == 8 ? "x64" : "x86"; }
23-
}
24-
25-
public static OperatingSystemType OperatingSystem => _operatingSystem.Value;
26-
27-
private static OperatingSystemType DetermineOperatingSystem()
28-
{
29-
#if DESKTOP
30-
// See http://www.mono-project.com/docs/faq/technical/#how-to-detect-the-execution-platform
31-
switch ((int)Environment.OSVersion.Platform)
19+
get
3220
{
33-
case 4:
34-
case 128:
21+
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
22+
{
23+
return OperatingSystemType.Windows;
24+
}
25+
26+
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
27+
{
3528
return OperatingSystemType.Unix;
29+
}
3630

37-
case 6:
31+
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
32+
{
3833
return OperatingSystemType.MacOSX;
34+
}
3935

40-
default:
41-
return OperatingSystemType.Windows;
42-
}
43-
#else
44-
try
45-
{
46-
return OperatingSystem_CoreFxStyle();
47-
}
48-
catch (FileNotFoundException)
49-
{
50-
// We're probably running on .NET 4.6.1 or earlier where the API isn't available.
51-
// This would suggest we're running on Windows. Although if our portable library
52-
// is being used on mono, it could be *nix or OSX too.
53-
return OperatingSystemType.Windows;
54-
}
55-
#endif
56-
}
57-
58-
#if !DESKTOP
59-
private static OperatingSystemType OperatingSystem_CoreFxStyle()
60-
{
61-
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
62-
{
63-
return OperatingSystemType.Windows;
64-
}
65-
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
66-
{
67-
return OperatingSystemType.Unix;
68-
}
69-
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
70-
{
71-
return OperatingSystemType.MacOSX;
72-
}
73-
else
74-
{
7536
throw new InvalidOperationException();
7637
}
7738
}
78-
#endif
7939
}
8040
}

LibGit2Sharp/Filter.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -261,16 +261,16 @@ int StreamCreateCallback(out IntPtr git_writestream_out, GitFilter self, IntPtr
261261
Marshal.StructureToPtr(state.thisStream, state.thisPtr, false);
262262

263263
state.nextPtr = git_writestream_next;
264-
state.nextStream = MarshalPortable.PtrToStructure<GitWriteStream>(state.nextPtr);
265-
264+
state.nextStream = Marshal.PtrToStructure<GitWriteStream>(state.nextPtr);
265+
266266
state.filterSource = FilterSource.FromNativePtr(filterSourcePtr);
267267
state.output = new WriteStream(state.nextStream, state.nextPtr);
268268

269269
Create(state.filterSource.Path, state.filterSource.Root, state.filterSource.SourceMode);
270270

271271
if (!activeStreams.TryAdd(state.thisPtr, state))
272272
{
273-
// AFAICT this is a theoretical error that could only happen if we manage
273+
// AFAICT this is a theoretical error that could only happen if we manage
274274
// to free the stream pointer but fail to remove the dictionary entry.
275275
throw new InvalidOperationException("Overlapping stream pointers");
276276
}

LibGit2Sharp/GlobalSettings.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ static GlobalSettings()
2323
{
2424
if (Platform.OperatingSystem == OperatingSystemType.Windows)
2525
{
26-
#if DESKTOP
2726
/* Assembly.CodeBase is not actually a correctly formatted
2827
* URI. It's merely prefixed with `file:///` and has its
2928
* backslashes flipped. This is superior to EscapedCodeBase,
@@ -45,9 +44,6 @@ static GlobalSettings()
4544
}
4645

4746
managedPath = Path.GetDirectoryName(managedPath);
48-
#else
49-
string managedPath = AppContext.BaseDirectory;
50-
#endif
5147

5248
nativeLibraryPath = Path.Combine(managedPath, "lib", "win32");
5349
}

LibGit2Sharp/LibGit2Sharp.csproj

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>net40;netstandard2.0</TargetFrameworks>
4+
<TargetFramework>netstandard2.0</TargetFramework>
55
<GenerateDocumentationFile>true</GenerateDocumentationFile>
66
<Description>LibGit2Sharp brings all the might and speed of libgit2, a native Git implementation, to the managed world of .Net and Mono.</Description>
77
<Company>LibGit2Sharp contributors</Company>
@@ -12,7 +12,6 @@
1212
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
1313
<SignAssembly>true</SignAssembly>
1414
<AssemblyOriginatorKeyFile>..\libgit2sharp.snk</AssemblyOriginatorKeyFile>
15-
<DefineConstants Condition=" '$(TargetFramework)' == 'net40' ">$(DefineConstants);DESKTOP</DefineConstants>
1615
</PropertyGroup>
1716

1817
<!-- Disable SourceLink when running on Travis CI -->

LibGit2Sharp/ObjectDatabase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ private unsafe Blob CreateBlob(Stream stream, string hintpath, long? numberOfByt
239239
}
240240

241241
IntPtr writestream_ptr = Proxy.git_blob_create_fromstream(repo.Handle, hintpath);
242-
GitWriteStream writestream = MarshalPortable.PtrToStructure<GitWriteStream>(writestream_ptr);
242+
GitWriteStream writestream = Marshal.PtrToStructure<GitWriteStream>(writestream_ptr);
243243

244244
try
245245
{

0 commit comments

Comments
 (0)