diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml
index 79edddb..ec88274 100644
--- a/.github/workflows/dotnet.yml
+++ b/.github/workflows/dotnet.yml
@@ -40,6 +40,9 @@ jobs:
- name: Tests
run: dotnet test --no-build --configuration ${{ matrix.configuration }} src
continue-on-error: ${{ matrix.os == 'macos-latest' }}
+ - name: Tests (Full Framework)
+ run: dotnet test --configuration ${{ matrix.configuration }} src/VCDiff.Tests/VCDiff.Tests.NetFx.csproj
+ if: ${{ matrix.os == 'windows-latest' }}
- name: Upload code coverage
uses: codecov/codecov-action@v1.2.1
with:
diff --git a/src/VCDiff.Tests/VCDiff.Tests.NetFx.csproj b/src/VCDiff.Tests/VCDiff.Tests.NetFx.csproj
new file mode 100644
index 0000000..b959938
--- /dev/null
+++ b/src/VCDiff.Tests/VCDiff.Tests.NetFx.csproj
@@ -0,0 +1,9 @@
+
+
+
+
+
+ net462;net48
+
+
+
diff --git a/src/VCDiff.Tests/VCDiff.Tests.csproj b/src/VCDiff.Tests/VCDiff.Tests.csproj
index 982e31e..6603641 100644
--- a/src/VCDiff.Tests/VCDiff.Tests.csproj
+++ b/src/VCDiff.Tests/VCDiff.Tests.csproj
@@ -3,6 +3,7 @@
netcoreapp3.0;netcoreapp3.1;net5.0;net6.0
false
+ latest
diff --git a/src/VCDiff/Encoders/BlockHash.cs b/src/VCDiff/Encoders/BlockHash.cs
index 5470558..19a301a 100644
--- a/src/VCDiff/Encoders/BlockHash.cs
+++ b/src/VCDiff/Encoders/BlockHash.cs
@@ -302,7 +302,7 @@ private unsafe bool BlockContentsMatch(long block1, long tOffset, byte *sourcePt
}
}
}
-#else
+#elif NETSTANDARD2_1
int vectorSize = Vector.Count;
if (lengthToExamine >= vectorSize)
{
@@ -476,7 +476,7 @@ private unsafe long MatchingBytesToLeftSse2(long start, long tstart, byte* sourc
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private unsafe long MatchingBytesToLeft(long start, long tstart, byte* sourcePtr, byte* targetPtr, ByteBuffer target, long maxBytes)
{
-#if NETCOREAPP3_1 || NET5_0
+#if NETCOREAPP3_1 || NET5_0 || NET5_0_OR_GREATER
if (Avx2.IsSupported) return MatchingBytesToLeftAvx2(start, tstart, sourcePtr, targetPtr, maxBytes);
if (Sse2.IsSupported) return MatchingBytesToLeftSse2(start, tstart, sourcePtr, targetPtr, maxBytes);
#endif
@@ -490,6 +490,7 @@ private unsafe long MatchingBytesToLeft(long start, long tstart, byte* sourcePtr
var tBuf = target.AsSpan();
var sBuf = source.AsSpan();
+#if NETCOREAPP3_1 || NET5_0 || NET5_0_OR_GREATER || NETSTANDARD2_1_OR_GREATER
while (sindex >= vectorSize && tindex >= vectorSize && bytesFound <= maxBytes - vectorSize)
{
tindex -= vectorSize;
@@ -505,6 +506,7 @@ private unsafe long MatchingBytesToLeft(long start, long tstart, byte* sourcePtr
bytesFound += vectorSize;
}
+#endif
while (bytesFound < maxBytes)
{
@@ -624,6 +626,8 @@ private unsafe long MatchingBytesToRight(long end, long tstart, byte* sourcePtr,
long trgLength = target.Length;
byte* tPtr = targetPtr;
byte* sPtr = sourcePtr;
+
+#if NETCOREAPP3_1 || NET5_0 || NET5_0_OR_GREATER || NETSTANDARD2_1_OR_GREATER
int vectorSize = Vector.Count;
var tBuf = target.AsSpan();
var sBuf = source.AsSpan();
@@ -641,6 +645,7 @@ private unsafe long MatchingBytesToRight(long end, long tstart, byte* sourcePtr,
tindex += vectorSize;
sindex += vectorSize;
}
+#endif
while (bytesFound < maxBytes)
{
diff --git a/src/VCDiff/Encoders/InstructionMap.cs b/src/VCDiff/Encoders/InstructionMap.cs
index 5961169..bf3c11d 100644
--- a/src/VCDiff/Encoders/InstructionMap.cs
+++ b/src/VCDiff/Encoders/InstructionMap.cs
@@ -114,7 +114,7 @@ public void Add(byte first, byte inst, byte size, byte mode, byte opcode)
private int[] NewSizeOpcodeArray(int size)
{
int[] nn = new int[size];
- Array.Fill(nn, CodeTable.kNoOpcode);
+ new Span(nn).Fill(CodeTable.kNoOpcode);
return nn;
}
@@ -147,8 +147,7 @@ public OpcodeMap(int numInstAndModes, int maxSize)
this.maxSize = maxSize + 1;
this.numInstAndModes = numInstAndModes;
opcodes = new int[numInstAndModes * this.maxSize];
-
- Array.Fill(opcodes, CodeTable.kNoOpcode);
+ new Span(opcodes).Fill(CodeTable.kNoOpcode);
}
public void Add(byte inst, byte size, byte mode, byte opcode)
diff --git a/src/VCDiff/Shared/ByteBuffer.cs b/src/VCDiff/Shared/ByteBuffer.cs
index 4528ef8..2722470 100644
--- a/src/VCDiff/Shared/ByteBuffer.cs
+++ b/src/VCDiff/Shared/ByteBuffer.cs
@@ -13,7 +13,7 @@ namespace VCDiff.Shared
public class ByteBuffer : IByteBuffer, IDisposable
{
private MemoryHandle? byteHandle;
- private unsafe byte* bytePtr;
+ private unsafe byte* bytePtr;
private int length;
private int offset;
@@ -31,7 +31,7 @@ private ByteBuffer()
public unsafe ByteBuffer(byte[] bytes)
{
offset = 0;
- var memory = bytes != null ? new Memory(bytes) : Memory.Empty;
+ var memory = bytes != null ? new Memory(bytes) : Memory.Empty;
this.byteHandle = memory.Pin();
CreateFromPointer((byte*)this.byteHandle.Value.Pointer, memory.Length);
}
@@ -65,9 +65,14 @@ private unsafe void CreateFromPointer(byte* pointer, int length)
this.bytePtr = pointer;
this.length = length;
}
-
+
+#if NET5_0 || NET5_0_OR_GREATER || NETCOREAPP3_1 || NETSTANDARD2_1_OR_GREATER
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public unsafe Span AsSpan() => MemoryMarshal.CreateSpan(ref Unsafe.AsRef(bytePtr), length);
+#else
+ [MethodImpl(MethodImplOptions.AggressiveInlining)]
+ public unsafe Span AsSpan() => new Span(bytePtr, length);
+#endif
///
/// Dangerously gets the byte pointer.
@@ -104,7 +109,8 @@ public int Position
set => offset = value;
}
- public int Length {
+ public int Length
+ {
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get => length;
}
@@ -119,7 +125,11 @@ public int Length {
public unsafe Span PeekBytes(int len)
{
int sliceLen = offset + len > this.length ? this.length - offset : len;
+#if NET5_0 || NET5_0_OR_GREATER || NETCOREAPP3_1 || NETSTANDARD2_1_OR_GREATER
return MemoryMarshal.CreateSpan(ref Unsafe.AsRef(bytePtr + offset), sliceLen);
+#else
+ return new Span(bytePtr + offset, sliceLen);
+#endif
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
diff --git a/src/VCDiff/Shared/Intrinsics.cs b/src/VCDiff/Shared/Intrinsics.cs
index a9a2872..a55dbd8 100644
--- a/src/VCDiff/Shared/Intrinsics.cs
+++ b/src/VCDiff/Shared/Intrinsics.cs
@@ -65,7 +65,7 @@ public static unsafe void FillArrayVectorized(long* first, int numValues, long v
}
#else
// Accelerate via loop unrolled solution.
- MemoryMarshal.CreateSpan(ref Unsafe.AsRef((void*) first), numValues).Fill(value);
+ new Span((void*)first, numValues).Fill(value);
#endif
}
diff --git a/src/VCDiff/VCDiff.csproj b/src/VCDiff/VCDiff.csproj
index 5e301d2..4b7a2b6 100644
--- a/src/VCDiff/VCDiff.csproj
+++ b/src/VCDiff/VCDiff.csproj
@@ -3,11 +3,12 @@
VCDiff
- netstandard2.1;netcoreapp3.1;net5.0;net6.0
+ netstandard2.0;netstandard2.1;netcoreapp3.1;net5.0;net6.0
enable
4.0.1
true
true
+ $(NoWarn);CS1591
@@ -20,8 +21,14 @@
true
snupkg
+
-
+
+
+ all
+ runtime; build; native; contentfiles; analyzers
+
+
\ No newline at end of file