Skip to content

Commit

Permalink
Target netstandard2.1 and netcoreapp3.0 (#99)
Browse files Browse the repository at this point in the history
.NET Core 2.1 introduced some runtime changes to support Span<T> and ByReference. Along with this comes the ability to do things like reinterpret memory as a different type. In .NET Framework the garbage collector couldn't track these references. These features proved useful enough that support for .NET Framework was dropped.

* Target netstandard2.1 and netcoreapp3.0
* Build: Zip native builds. Put version in zip filename
* Always build native exe on AppVeyor
  • Loading branch information
Thealexbarney committed Nov 29, 2019
1 parent f304f66 commit 57586d7
Show file tree
Hide file tree
Showing 22 changed files with 158 additions and 815 deletions.
2 changes: 1 addition & 1 deletion GitVersion.yml
@@ -1,6 +1,6 @@
mode: ContinuousDeployment
increment: Patch
next-version: 0.7.0
next-version: 0.8.0
branches:
master:
tag: alpha
2 changes: 1 addition & 1 deletion appveyor.yml
Expand Up @@ -4,5 +4,5 @@ environment:
myget_api_key:
secure: 0xJoYAtR6psXCRvk1qm5czDObkeRjHKPjfe5gIExXVFPwA0VVODYv/hBZYUtz2F3
build_script:
- ps: .\build.ps1
- ps: .\build.ps1 appveyorbuild
test: off
293 changes: 142 additions & 151 deletions build/Build.cs

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions build/_build.csproj
Expand Up @@ -10,8 +10,7 @@
</PropertyGroup>

<ItemGroup>
<PackageDownload Include="GitVersion.Tool" Version="[5.1.2]" />
<PackageReference Include="ILRepack.Lib" Version="2.0.18" NoWarn="NU1701" />
<PackageDownload Include="GitVersion.Tool" Version="[5.0.1]" />
<PackageReference Include="NuGet.CommandLine" Version="5.3.1" />
<PackageReference Include="Nuke.Common" Version="0.23.4" />
<PackageReference Include="SharpZipLib" Version="1.2.0" />
Expand Down
17 changes: 0 additions & 17 deletions src/LibHac/Common/SpanHelpers.cs
@@ -1,26 +1,16 @@
using System;
using System.Runtime.CompilerServices;

#if NETCOREAPP
using System.Runtime.InteropServices;
#endif

namespace LibHac.Common
{
public static class SpanHelpers
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#if NETCOREAPP
public static Span<T> CreateSpan<T>(ref T reference, int length)
{
return MemoryMarshal.CreateSpan(ref reference, length);
}
#else
public static unsafe Span<T> CreateSpan<T>(ref T reference, int length)
{
return new Span<T>(Unsafe.AsPointer(ref reference), length);
}
#endif

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Span<T> AsSpan<T>(ref T reference) where T : unmanaged
Expand All @@ -43,17 +33,10 @@ public static unsafe Span<T> CreateSpan<T>(ref T reference, int length)
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
#if NETCOREAPP
public static ReadOnlySpan<T> CreateReadOnlySpan<T>(ref T reference, int length)
{
return MemoryMarshal.CreateReadOnlySpan(ref reference, length);
}
#else
public static unsafe ReadOnlySpan<T> CreateReadOnlySpan<T>(ref T reference, int length)
{
return new ReadOnlySpan<T>(Unsafe.AsPointer(ref reference), length);
}
#endif

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static ReadOnlySpan<T> AsReadOnlySpan<T>(ref T reference) where T : unmanaged
Expand Down
4 changes: 0 additions & 4 deletions src/LibHac/Common/StringUtils.cs
Expand Up @@ -80,11 +80,7 @@ public static int Concat(Span<byte> dest, int destLength, ReadOnlySpan<byte> sou

public static string Utf8ToString(ReadOnlySpan<byte> value)
{
#if STRING_SPAN
return Encoding.UTF8.GetString(value);
#else
return Encoding.UTF8.GetString(value.ToArray());
#endif
}

public static string Utf8ZToString(ReadOnlySpan<byte> value)
Expand Down
13 changes: 0 additions & 13 deletions src/LibHac/Compatibility/Env.cs

This file was deleted.

0 comments on commit 57586d7

Please sign in to comment.