Skip to content
Open
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
4 changes: 2 additions & 2 deletions src/Sandbox/Sandbox.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>netcoreapp3.1;net5.0;net6.0;net7.0;net8.0;net9.0;net462</TargetFrameworks>
<LangVersion>9.0</LangVersion>
<TargetFrameworks>net8.0;net9.0;net10.0;net48</TargetFrameworks>
<LangVersion>14</LangVersion>
<TieredCompilation>false</TieredCompilation>
</PropertyGroup>

Expand Down
8 changes: 6 additions & 2 deletions src/Zstd.Extern/Zstd.Extern.csproj
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netcoreapp3.1;net5.0;netstandard2.0;net462</TargetFrameworks>
<LangVersion>9</LangVersion>
<TargetFrameworks>net8.0;net9.0;net10.0;netstandard2.0;netstandard2.1;net48</TargetFrameworks>
<LangVersion>14</LangVersion>
</PropertyGroup>

<PropertyGroup>
<IsAotCompatible Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net8.0'))">true</IsAotCompatible>
</PropertyGroup>

<ItemGroup>
Expand Down
8 changes: 4 additions & 4 deletions src/ZstdSharp.Benchmark/ZstdSharp.Benchmark.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>netcoreapp3.1;net5.0;net6.0;net462;net7.0;net8.0;net9.0</TargetFrameworks>
<LangVersion>9.0</LangVersion>
<TargetFrameworks>net8.0;net9.0;net10.0;net48</TargetFrameworks>
<LangVersion>14</LangVersion>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
Expand All @@ -15,8 +15,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.15.2" />
<PackageReference Include="BenchmarkDotNet.Diagnostics.Windows" Version="0.15.2" />
<PackageReference Include="BenchmarkDotNet" Version="0.15.8" />
<PackageReference Include="BenchmarkDotNet.Diagnostics.Windows" Version="0.15.8" />
</ItemGroup>

<ItemGroup>
Expand Down
40 changes: 20 additions & 20 deletions src/ZstdSharp.Test/ZstdNetSteamingTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public static byte[] GetBuffer(int length, DataFill dataFill)
public class ZstdNetSteamingTests
{
[Fact]
public async void StreamingCompressionZeroAndOneByte()
public async Task StreamingCompressionZeroAndOneByte()
{
var data = new byte[] {0, 0, 0, 1, 2, 3, 4, 0, 0, 0};

Expand All @@ -57,15 +57,15 @@ public async void StreamingCompressionZeroAndOneByte()
{
compressionStream.Write(data, 0, 0);
compressionStream.Write(ReadOnlySpan<byte>.Empty);
await compressionStream.WriteAsync(data, 0, 0);
await compressionStream.WriteAsync(ReadOnlyMemory<byte>.Empty);
await compressionStream.WriteAsync(data, 0, 0, TestContext.Current.CancellationToken);
await compressionStream.WriteAsync(ReadOnlyMemory<byte>.Empty, TestContext.Current.CancellationToken);

compressionStream.Write(data, 3, 1);
compressionStream.Write(new ReadOnlySpan<byte>(data, 4, 1));
compressionStream.Flush();
await compressionStream.WriteAsync(data, 5, 1);
await compressionStream.WriteAsync(new ReadOnlyMemory<byte>(data, 6, 1));
await compressionStream.FlushAsync();
await compressionStream.WriteAsync(data, 5, 1, TestContext.Current.CancellationToken);
await compressionStream.WriteAsync(new ReadOnlyMemory<byte>(data, 6, 1), TestContext.Current.CancellationToken);
await compressionStream.FlushAsync(TestContext.Current.CancellationToken);
}

tempStream.Seek(0, SeekOrigin.Begin);
Expand All @@ -75,13 +75,13 @@ public async void StreamingCompressionZeroAndOneByte()
{
Assert.Equal(0, decompressionStream.Read(result, 0, 0));
Assert.Equal(0, decompressionStream.Read(Span<byte>.Empty));
Assert.Equal(0, await decompressionStream.ReadAsync(result, 0, 0));
Assert.Equal(0, await decompressionStream.ReadAsync(Memory<byte>.Empty));
Assert.Equal(0, await decompressionStream.ReadAsync(result, 0, 0, TestContext.Current.CancellationToken));
Assert.Equal(0, await decompressionStream.ReadAsync(Memory<byte>.Empty, TestContext.Current.CancellationToken));

Assert.Equal(1, decompressionStream.Read(result, 3, 1));
Assert.Equal(1, decompressionStream.Read(new Span<byte>(result, 4, 1)));
Assert.Equal(1, await decompressionStream.ReadAsync(result, 5, 1));
Assert.Equal(1, await decompressionStream.ReadAsync(new Memory<byte>(result, 6, 1)));
Assert.Equal(1, await decompressionStream.ReadAsync(result, 5, 1, TestContext.Current.CancellationToken));
Assert.Equal(1, await decompressionStream.ReadAsync(new Memory<byte>(result, 6, 1), TestContext.Current.CancellationToken));
}

Assert.True(data.SequenceEqual(result));
Expand Down Expand Up @@ -346,8 +346,8 @@ public async Task RoundTrip_StreamingToStreamingAsync(
}

int bytesRead;
while ((bytesRead = await testStream.ReadAsync(buffer, offset, copyBufferSize)) > 0)
await compressionStream.WriteAsync(buffer, offset, bytesRead);
while ((bytesRead = await testStream.ReadAsync(buffer, offset, copyBufferSize, TestContext.Current.CancellationToken)) > 0)
await compressionStream.WriteAsync(buffer, offset, bytesRead, TestContext.Current.CancellationToken);
}

tempStream.Seek(0, SeekOrigin.Begin);
Expand All @@ -362,8 +362,8 @@ public async Task RoundTrip_StreamingToStreamingAsync(
}

int bytesRead;
while ((bytesRead = await decompressionStream.ReadAsync(buffer, offset, copyBufferSize)) > 0)
await resultStream.WriteAsync(buffer, offset, bytesRead);
while ((bytesRead = await decompressionStream.ReadAsync(buffer, offset, copyBufferSize, TestContext.Current.CancellationToken)) > 0)
await resultStream.WriteAsync(buffer, offset, bytesRead, TestContext.Current.CancellationToken);
}

Assert.True(testStream.ToArray().SequenceEqual(resultStream.ToArray()));
Expand Down Expand Up @@ -409,15 +409,15 @@ public async Task Pipe_StreamingToStreamingAsync(
using (var decomp = new DecompressionStream(pipeClient))
{
var data = new byte[] { 0, 1, 2 };
await comp.WriteAsync(data);
await comp.FlushAsync();
await comp.WriteAsync(data, TestContext.Current.CancellationToken);
await comp.FlushAsync(TestContext.Current.CancellationToken);

var buf = new byte[outputBufSize];

var received = new List<byte>();
while (received.Count < data.Length)
{
var count = await decomp.ReadAsync(buf);
var count = await decomp.ReadAsync(buf, TestContext.Current.CancellationToken);
received.AddRange(buf.Take(count));
}

Expand Down Expand Up @@ -518,8 +518,8 @@ public async Task FlushAsyncTest()
var bs = new BufferedStream(ms, 4096);
using var writer = new CompressionStream(bs);
var src = new byte[1] { 42 };
await writer.WriteAsync(src);
await writer.FlushAsync();
await writer.WriteAsync(src, TestContext.Current.CancellationToken);
await writer.FlushAsync(TestContext.Current.CancellationToken);
Assert.True(ms.ToArray().Length > 0);
}

Expand All @@ -530,7 +530,7 @@ public async Task DisposeFlushAsyncTest()
var bs = new BufferedStream(ms, 4096);
using var writer = new CompressionStream(bs, leaveOpen: true);
var src = new byte[1] { 42 };
await writer.WriteAsync(src);
await writer.WriteAsync(src, TestContext.Current.CancellationToken);
await writer.DisposeAsync();
Assert.True(ms.ToArray().Length == 0);
bs.Dispose();
Expand Down
15 changes: 8 additions & 7 deletions src/ZstdSharp.Test/ZstdSharp.Test.csproj
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netcoreapp3.1;net5.0;net6.0;net7.0;net8.0;net9.0;net462</TargetFrameworks>
<OutputType>Exe</OutputType>
<TargetFrameworks>net8.0;net9.0;net10.0;net48</TargetFrameworks>
<LangVersion>14</LangVersion>
<IsPackable>false</IsPackable>
<LangVersion>9</LangVersion>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
Expand All @@ -15,14 +16,14 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageReference Include="xunit" Version="2.9.0" />
<PackageReference Include="Xunit.Combinatorial" Version="1.6.24" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="18.4.0" />
<PackageReference Include="xunit.v3" Version="3.2.2" />
<PackageReference Include="Xunit.Combinatorial" Version="2.0.24" />
<PackageReference Include="xunit.runner.visualstudio" Version="3.1.5">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="6.0.2">
<PackageReference Include="coverlet.collector" Version="8.0.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
2 changes: 1 addition & 1 deletion src/ZstdSharp/CompressionStream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ private void WriteInternal(ReadOnlySpan<byte> buffer, ZSTD_EndDirective directiv
{
EnsureNotDisposed();

var input = new ZSTD_inBuffer_s {pos = 0, size = buffer != null ? (nuint) buffer.Length : 0};
var input = new ZSTD_inBuffer_s {pos = 0, size = (nuint)buffer.Length};
nuint remaining;
do
{
Expand Down
2 changes: 0 additions & 2 deletions src/ZstdSharp/Unsafe/Bitstream.cs
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,6 @@ private static BIT_DStream_status BIT_reloadDStream(BIT_DStream_t* bitD)
{
if (bitD->bitsConsumed > (uint)(sizeof(nuint) * 8))
{
const nuint zeroFilled = 0;
bitD->ptr = (sbyte*)&static_zeroFilled[0];
return BIT_DStream_status.BIT_DStream_overflow;
}
Expand Down Expand Up @@ -563,7 +562,6 @@ private static BIT_DStream_status BIT_reloadDStream(ref nuint bitD_bitContainer,
{
if (bitD_bitsConsumed > (uint)(sizeof(nuint) * 8))
{
const nuint zeroFilled = 0;
bitD_ptr = (sbyte*)&static_zeroFilled[0];
return BIT_DStream_status.BIT_DStream_overflow;
}
Expand Down
2 changes: 0 additions & 2 deletions src/ZstdSharp/Unsafe/HufDecompress.cs
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,6 @@ private static void HUF_decompress4X1_usingDTable_internal_fast_c_loop(HUF_Decom
for (; ; )
{
byte* olimit;
int stream;
{
assert(op0 <= op1);
assert(ip0 >= ilowest);
Expand Down Expand Up @@ -1446,7 +1445,6 @@ private static void HUF_decompress4X2_usingDTable_internal_fast_c_loop(HUF_Decom
for (; ; )
{
byte* olimit;
int stream;
{
assert(op0 <= oend0);
assert(ip0 >= ilowest);
Expand Down
2 changes: 1 addition & 1 deletion src/ZstdSharp/Unsafe/ZstdDecompressBlock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1412,7 +1412,7 @@ private static nuint ZSTD_decompressSequences_bodySplitLitBuffer(ZSTD_DCtx_s* dc
private static nuint ZSTD_decompressSequences_body(ZSTD_DCtx_s* dctx, void* dst, nuint maxDstSize, void* seqStart, nuint seqSize, int nbSeq, ZSTD_longOffset_e isLongOffset)
{
// HACK, force nbSeq to stack (better register usage)
System.Threading.Thread.VolatileRead(ref nbSeq);
System.Threading.Volatile.Read(ref nbSeq);
byte* ip = (byte*)seqStart;
byte* iend = ip + seqSize;
byte* ostart = (byte*)dst;
Expand Down
22 changes: 13 additions & 9 deletions src/ZstdSharp/ZstdSharp.csproj
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netcoreapp3.1;net5.0;net6.0;net7.0;net8.0;net9.0;netstandard2.1;netstandard2.0;net462</TargetFrameworks>
<LangVersion>9.0</LangVersion>
<TargetFrameworks>net8.0;net9.0;net10.0;netstandard2.0;netstandard2.1;net48</TargetFrameworks>
<LangVersion>14</LangVersion>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
<Authors>Oleg Stepanischev</Authors>
Expand All @@ -20,6 +20,10 @@
<Version>0.8.7</Version>
</PropertyGroup>

<PropertyGroup>
<IsAotCompatible Condition="$([MSBuild]::IsTargetFrameworkCompatible('$(TargetFramework)', 'net8.0'))">true</IsAotCompatible>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<DefineConstants>TRACE</DefineConstants>
Expand All @@ -30,22 +34,22 @@
<DefineConstants>TRACE</DefineConstants>
</PropertyGroup>

<ItemGroup Condition="'$(TargetFramework)'=='netstandard2.0' Or '$(TargetFramework)'=='net462'">
<PackageReference Include="System.Memory" Version="4.6.0" />
<PackageReference Include="System.Threading.Tasks.Extensions" Version="4.5.4" />
<ItemGroup Condition="'$(TargetFramework)'=='netstandard2.0' Or '$(TargetFramework)'=='net48'">
<PackageReference Include="System.Memory" Version="4.6.3" />
<PackageReference Include="System.Threading.Tasks.Extensions" Version="4.6.3" />
</ItemGroup>

<ItemGroup Condition="!$([MSBuild]::IsTargetFrameworkCompatible($(TargetFramework), 'net5.0'))">
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="6.1.0" />
<PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="6.1.2" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Fody" Version="6.9.1">
<PackageReference Include="Fody" Version="6.9.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="InlineMethod.Fody" Version="0.8.4" PrivateAssets="all" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All" />
<PackageReference Include="InlineMethod.Fody" Version="0.8.7" PrivateAssets="all" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="10.0.201" PrivateAssets="All" />
</ItemGroup>

</Project>