-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #58 from make-software/netstandard-2-0-target
Prepare for multi-framework package publish
- Loading branch information
Showing
34 changed files
with
492 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
ame: Unity Compat - Build and Test | ||
|
||
on: | ||
push: | ||
branches: [netstandard-2-0-target] | ||
pull_request: | ||
branches: [netstandard-2-0-target] | ||
|
||
jobs: | ||
buildntest: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Setup .NET | ||
uses: actions/setup-dotnet@v1 | ||
with: | ||
dotnet-version: 7.0.x | ||
- name: Restore dependencies | ||
run: dotnet restore | ||
- name: Build | ||
run: dotnet build --no-restore | ||
- name: Test | ||
run: dotnet test --no-build --verbosity normal --filter "TestCategory!~NCTL" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation"> | ||
<s:String x:Key="/Default/Environment/Highlighting/HighlightingSourceSnapshotLocation/@EntryValue">C:\Users\d\AppData\Local\JetBrains\Rider2021.3\resharper-host\temp\Rider\vAny\CoverageData\_Casper.Network.SDK.-947408436\Snapshot\snapshot.utdcvr</s:String></wpf:ResourceDictionary> | ||
<s:String x:Key="/Default/Environment/UnitTesting/UnitTestSessionStore/Sessions/=240e6887_002D6585_002D487e_002D89bf_002D0b306f497b30/@EntryIndexedValue"><SessionState ContinuousTestingMode="0" IsActive="True" Name="All tests from Solution" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session"> | ||
<Solution /> | ||
</SessionState></s:String></wpf:ResourceDictionary> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using System; | ||
using System.Numerics; | ||
|
||
public class BigIntegerCompat | ||
{ | ||
public static BigInteger Create(byte[] value, bool isUnsigned = false, bool isBigEndian = false) | ||
{ | ||
#if NET7_0_OR_GREATER | ||
return new BigInteger(value, true, false); | ||
#elif NETSTANDARD2_0 | ||
if (value == null) | ||
{ | ||
throw new ArgumentNullException(nameof(value)); | ||
} | ||
|
||
if (isBigEndian) | ||
{ | ||
Array.Reverse(value); | ||
} | ||
|
||
if (isUnsigned) | ||
{ | ||
// Ensure that the resulting BigInteger is treated as an unsigned value by appending a 0 byte if necessary | ||
if (value[value.Length - 1] >= 0x80) | ||
{ | ||
Array.Resize(ref value, value.Length + 1); | ||
value[value.Length - 1] = 0; | ||
} | ||
} | ||
|
||
return new BigInteger(value); | ||
#endif | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#if NETSTANDARD2_0 | ||
|
||
using System; | ||
using System.Numerics; | ||
|
||
public static class BigIntegerExtensions | ||
{ | ||
public static byte[] ToByteArray(this BigInteger value, bool isUnsigned = false) | ||
{ | ||
byte[] bytes = value.ToByteArray(); | ||
|
||
if (isUnsigned) | ||
{ | ||
if (value < 0) | ||
{ | ||
throw new InvalidOperationException("Cannot retrieve an unsigned byte array representation of a negative BigInteger."); | ||
} | ||
|
||
// If the BigInteger is positive and the highest byte is 0x80 or higher, | ||
// an additional byte is added to indicate a positive number when using two's complement notation. | ||
// For the unsigned representation, this additional byte is not necessary. | ||
if (bytes.Length > 1 && bytes[bytes.Length - 1] == 0) | ||
{ | ||
Array.Resize(ref bytes, bytes.Length - 1); | ||
} | ||
} | ||
|
||
return bytes; | ||
} | ||
|
||
public static int GetBitLength(this BigInteger value) | ||
{ | ||
// If the value is zero, its bit length is 0 | ||
if (value == BigInteger.Zero) | ||
return 0; | ||
|
||
// Get the byte array without the sign | ||
byte[] bytes = value.ToByteArray(); | ||
|
||
// Find the highest-order byte with a non-zero value | ||
int highestByte = bytes.Length - 1; | ||
while (highestByte > 0 && bytes[highestByte] == 0) | ||
{ | ||
highestByte--; | ||
} | ||
|
||
// Count the bits in the last used byte | ||
int bitsInLastByte = 0; | ||
byte lastByte = bytes[highestByte]; | ||
while (lastByte != 0) | ||
{ | ||
bitsInLastByte++; | ||
lastByte >>= 1; | ||
} | ||
|
||
// Calculate the total bit length | ||
// (Number of full bytes minus 1) * 8 + bits in last byte | ||
return highestByte * 8 + bitsInLastByte; | ||
} | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
|
||
using System; | ||
|
||
public static class BitConverterExtensions | ||
{ | ||
public static Int64 ToInt64(byte[] value, int startIndex = 0) | ||
{ | ||
return BitConverter.ToInt64(value, startIndex); | ||
} | ||
|
||
public static Int32 ToInt32(byte[] value, int startIndex = 0) | ||
{ | ||
return BitConverter.ToInt32(value, startIndex); | ||
} | ||
|
||
public static UInt64 ToUInt64(byte[] value, int startIndex = 0) | ||
{ | ||
return BitConverter.ToUInt64(value, startIndex); | ||
} | ||
|
||
public static UInt32 ToUInt32(byte[] value, int startIndex = 0) | ||
{ | ||
return BitConverter.ToUInt32(value, startIndex); | ||
} | ||
} | ||
|
Oops, something went wrong.