Skip to content

Commit

Permalink
Pipes for all, version++
Browse files Browse the repository at this point in the history
  • Loading branch information
MiloszKrajewski committed Nov 5, 2022
1 parent 549f3c8 commit 58a9ca3
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 43 deletions.
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 1.3.1-beta (2022/11/05)
* ADDED: retrofitted support for Pipes for older .NET versions

## 1.3.0-beta (2022/11/03)
* CHANGED: Dropped compatibility with .NET 4.5 and .NET Standard 1.6
* ADDED: Added .NET 6.0 as a target
Expand Down
6 changes: 3 additions & 3 deletions Common.targets
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Project>
<PropertyGroup>
<Version>1.3.0-beta</Version>
<AssemblyVersion>1.3.0</AssemblyVersion>
<FileVersion>1.3.0</FileVersion>
<Version>1.3.1-beta</Version>
<AssemblyVersion>1.3.1</AssemblyVersion>
<FileVersion>1.3.1</FileVersion>
</PropertyGroup>
<PropertyGroup>
<Product>K4os.Compression.LZ4</Product>
Expand Down
3 changes: 2 additions & 1 deletion global.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"sdk": {
"version": "6.0.300"
"version": "6.0.402",
"rollForward": "latestMinor"
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#if NET5_0_OR_GREATER

using System;
using System.Buffers;
using System.Diagnostics.CodeAnalysis;
Expand Down Expand Up @@ -86,10 +84,11 @@ private static ReadResult<EmptyState> ReadFromSequence(
return ReadResult.Create(default(EmptyState), totalRead);
}

#if NETSTANDARD2_1_OR_GREATER || NET5_0_OR_GREATER
[DoesNotReturn]
#endif
private static void ThrowPendingReadsCancelled() =>
throw new OperationCanceledException(
$"Pending {nameof(PipeReader)} operations has been cancelled");
}

#endif
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#if NET5_0_OR_GREATER

using System;
using System.IO.Pipelines;
using System.Threading;
Expand Down Expand Up @@ -64,5 +62,3 @@ private static void CheckSyncOverAsync()
"Asynchronous methods cannot be called synchronously when executed in SynchronizationContext.");
}
}

#endif
12 changes: 6 additions & 6 deletions src/K4os.Compression.LZ4.Streams/Frames/LZ4FrameReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,12 @@ protected virtual void Dispose(bool disposing)
/// </summary>
protected virtual void ReleaseResources() { }

/// <summary>
/// Releases unmanaged resources.
/// </summary>
/// <returns>Task indicating operation is finished.</returns>
protected virtual Task ReleaseResourcesAsync() => Task.CompletedTask;

/// <inheritdoc />
public void Dispose()
{
Expand All @@ -216,12 +222,6 @@ public virtual async ValueTask DisposeAsync()
}
}

/// <summary>
/// Releases unmanaged resources.
/// </summary>
/// <returns>Task indicating operation is finished.</returns>
protected virtual Task ReleaseResourcesAsync() => Task.CompletedTask;

#endif

// ReSharper disable once UnusedParameter.Local
Expand Down
12 changes: 6 additions & 6 deletions src/K4os.Compression.LZ4.Streams/Frames/LZ4FrameWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,12 @@ protected virtual void Dispose(bool disposing)
/// Releases all unmanaged resources.
/// </summary>
protected virtual void ReleaseResources() { }

/// <summary>
/// Releases all unmanaged resources.
/// </summary>
/// <returns>Task indicating completion of the operation.</returns>
protected virtual Task ReleaseResourcesAsync() => Task.CompletedTask;

#if NETSTANDARD2_1_OR_GREATER || NET5_0_OR_GREATER

Expand All @@ -258,12 +264,6 @@ public virtual async ValueTask DisposeAsync()
}
}

/// <summary>
/// Releases all unmanaged resources.
/// </summary>
/// <returns>Task indicating completion of the operation.</returns>
protected virtual Task ReleaseResourcesAsync() => Task.CompletedTask;

#endif

// ReSharper disable once UnusedParameter.Local
Expand Down
24 changes: 7 additions & 17 deletions src/K4os.Compression.LZ4.Streams/Frames/LZ4FrameWriter.wrappers.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
using System;
using System.Buffers;
using System.IO;
using System.IO.Pipelines;
using System.Threading.Tasks;
using K4os.Compression.LZ4.Encoders;
using K4os.Compression.LZ4.Streams.Abstractions;
using K4os.Compression.LZ4.Streams.Adapters;

#if NETSTANDARD2_1_OR_GREATER || NET5_0_OR_GREATER
using System.Threading.Tasks;
#endif

#if NET5_0_OR_GREATER
using System.IO.Pipelines;
#endif

namespace K4os.Compression.LZ4.Streams.Frames;

/// <summary>
Expand Down Expand Up @@ -134,21 +128,19 @@ protected override void ReleaseResources()
if (!_leaveOpen) _stream.Dispose();
base.ReleaseResources();
}

#if NETSTANDARD2_1_OR_GREATER || NET5_0_OR_GREATER


/// <inheritdoc />
protected override async Task ReleaseResourcesAsync()
{
#if NETSTANDARD2_1_OR_GREATER || NET5_0_OR_GREATER
if (!_leaveOpen) await _stream.DisposeAsync();
#else
if (!_leaveOpen) _stream.Dispose();
#endif
await base.ReleaseResourcesAsync();
}

#endif
}

#if NET5_0_OR_GREATER

/// <summary>
/// <see cref="ILZ4FrameWriter"/> implementation for <see cref="PipeWriter"/>.
/// </summary>
Expand Down Expand Up @@ -189,5 +181,3 @@ protected override async Task ReleaseResourcesAsync()
await base.ReleaseResourcesAsync();
}
}

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@
<ItemGroup>
<ProjectReference Include="..\K4os.Compression.LZ4\K4os.Compression.LZ4.csproj"/>
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)'=='net5.0' or '$(TargetFramework)'=='net6.0'">
<PackageReference Include="System.IO.Pipelines" Version="6.0.3"/>
</ItemGroup>
<ItemGroup>
<PackageReference Include="System.IO.Pipelines" Version="6.0.3"/>
<PackageReference Include="K4os.Hash.xxHash" Version="1.0.7"/>
</ItemGroup>
<Import Project="..\..\Common.targets"/>
Expand Down

0 comments on commit 58a9ca3

Please sign in to comment.