From 5c1547c2846d735bcd3cb8fe66925f370cc1df94 Mon Sep 17 00:00:00 2001 From: Adam Hathcock Date: Mon, 16 Feb 2026 11:03:59 +0000 Subject: [PATCH] build fixes --- .../Common/Rar/AsyncMarkingBinaryReader.cs | 1 + .../Compressors/LZMA/LzmaDecoder.Async.cs | 11 ++++++++++- src/SharpCompress/Compressors/LZMA/LzmaDecoder.cs | 8 +++++++- src/SharpCompress/Polyfills/StringExtensions.cs | 9 ++++++++- 4 files changed, 26 insertions(+), 3 deletions(-) diff --git a/src/SharpCompress/Common/Rar/AsyncMarkingBinaryReader.cs b/src/SharpCompress/Common/Rar/AsyncMarkingBinaryReader.cs index 5636f321..27d0e324 100644 --- a/src/SharpCompress/Common/Rar/AsyncMarkingBinaryReader.cs +++ b/src/SharpCompress/Common/Rar/AsyncMarkingBinaryReader.cs @@ -192,6 +192,7 @@ internal class AsyncMarkingBinaryReader : IDisposable } public virtual void Dispose() => _reader.Dispose(); + #if NET8_0_OR_GREATER public virtual ValueTask DisposeAsync() => _reader.DisposeAsync(); #endif diff --git a/src/SharpCompress/Compressors/LZMA/LzmaDecoder.Async.cs b/src/SharpCompress/Compressors/LZMA/LzmaDecoder.Async.cs index b1d061e8..d8f7c51b 100644 --- a/src/SharpCompress/Compressors/LZMA/LzmaDecoder.Async.cs +++ b/src/SharpCompress/Compressors/LZMA/LzmaDecoder.Async.cs @@ -9,8 +9,17 @@ using SharpCompress.Compressors.LZMA.RangeCoder; namespace SharpCompress.Compressors.LZMA; -public partial class Decoder : ICoder, ISetDecoderProperties +public partial class Decoder : IAsyncDisposable { + public async ValueTask DisposeAsync() + { + if (_outWindow is not null) + { + await _outWindow.DisposeAsync().ConfigureAwait(false); + _outWindow = null; + } + } + partial class LenDecoder { public async ValueTask DecodeAsync( diff --git a/src/SharpCompress/Compressors/LZMA/LzmaDecoder.cs b/src/SharpCompress/Compressors/LZMA/LzmaDecoder.cs index d12adbff..49a0e4c2 100644 --- a/src/SharpCompress/Compressors/LZMA/LzmaDecoder.cs +++ b/src/SharpCompress/Compressors/LZMA/LzmaDecoder.cs @@ -9,8 +9,14 @@ using SharpCompress.Compressors.LZMA.RangeCoder; namespace SharpCompress.Compressors.LZMA; -public partial class Decoder : ICoder, ISetDecoderProperties // ,System.IO.Stream +public partial class Decoder : ICoder, ISetDecoderProperties, IDisposable { + public void Dispose() + { + _outWindow?.Dispose(); + _outWindow = null; + } + private partial class LenDecoder { private BitDecoder _choice = new(); diff --git a/src/SharpCompress/Polyfills/StringExtensions.cs b/src/SharpCompress/Polyfills/StringExtensions.cs index c83dee70..84e1cbbe 100644 --- a/src/SharpCompress/Polyfills/StringExtensions.cs +++ b/src/SharpCompress/Polyfills/StringExtensions.cs @@ -1,4 +1,6 @@ -#if LEGACY_DOTNET +using System; + +#if LEGACY_DOTNET namespace SharpCompress; @@ -10,4 +12,9 @@ internal static class StringExtensions internal static bool Contains(this string text, char value) => text.IndexOf(value) > -1; } +[AttributeUsage( + AttributeTargets.Parameter | AttributeTargets.Property | AttributeTargets.ReturnValue +)] +public class NotNullAttribute : Attribute; + #endif