From 92884007181c7602239b283a5b2b2c72f619bd1d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 27 Aug 2026 16:53:55 +0000 Subject: [PATCH 1/3] Bump NUnit from 4.5.1 to 4.6.1 --- updated-dependencies: - dependency-name: NUnit dependency-version: 4.6.1 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- UnitTests/UnitTests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/UnitTests/UnitTests.csproj b/UnitTests/UnitTests.csproj index 38d4bb15..950c67f2 100644 --- a/UnitTests/UnitTests.csproj +++ b/UnitTests/UnitTests.csproj @@ -9,7 +9,7 @@ NUnit2045 - + From c40cc056b0f3342108965edd4a3abb7012fcef01 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 1 Sep 2026 15:55:40 +0000 Subject: [PATCH 2/3] Bump NUnit from 4.5.1 to 4.6.1 --- updated-dependencies: - dependency-name: NUnit dependency-version: 4.6.1 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- UnitTests/UnitTests.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/UnitTests/UnitTests.csproj b/UnitTests/UnitTests.csproj index 9f1c7134..60914a08 100644 --- a/UnitTests/UnitTests.csproj +++ b/UnitTests/UnitTests.csproj @@ -9,7 +9,7 @@ NUnit2045 - + From a652d196547b6c530232b7de3edf75433884289d Mon Sep 17 00:00:00 2001 From: Ben Watson Date: Wed, 2 Sep 2026 13:05:28 -0700 Subject: [PATCH 3/3] Fix build errors --- UnitTests/Tests.cs | 204 ++++++++++++++++++++++----------------------- 1 file changed, 102 insertions(+), 102 deletions(-) diff --git a/UnitTests/Tests.cs b/UnitTests/Tests.cs index 5b07a0d3..9830f06b 100644 --- a/UnitTests/Tests.cs +++ b/UnitTests/Tests.cs @@ -102,41 +102,41 @@ public void RecyclableMemoryManagerSetsBlockSizeLargeBufferMultipleAndMaximumBuf [Test] public void RecyclableMemoryManagerThrowsExceptionOnZeroBlockSize() { - Assert.Throws(() => new RecyclableMemoryStreamManager(new RecyclableMemoryStreamManager.Options { BlockSize = 0, LargeBufferMultiple = 100, MaximumBufferSize = 200, UseExponentialLargeBuffer = this.UseExponentialLargeBuffer })); - Assert.Throws(() => new RecyclableMemoryStreamManager(new RecyclableMemoryStreamManager.Options { BlockSize = -1, LargeBufferMultiple = 100, MaximumBufferSize = 200, UseExponentialLargeBuffer = this.UseExponentialLargeBuffer })); - Assert.DoesNotThrow(() => new RecyclableMemoryStreamManager(new RecyclableMemoryStreamManager.Options { BlockSize = 1, LargeBufferMultiple = 100, MaximumBufferSize = 200, UseExponentialLargeBuffer = this.UseExponentialLargeBuffer })); + Assert.Throws((Action)(() => new RecyclableMemoryStreamManager(new RecyclableMemoryStreamManager.Options { BlockSize = 0, LargeBufferMultiple = 100, MaximumBufferSize = 200, UseExponentialLargeBuffer = this.UseExponentialLargeBuffer }))); + Assert.Throws((Action)(() => new RecyclableMemoryStreamManager(new RecyclableMemoryStreamManager.Options { BlockSize = -1, LargeBufferMultiple = 100, MaximumBufferSize = 200, UseExponentialLargeBuffer = this.UseExponentialLargeBuffer }))); + Assert.DoesNotThrow((Action)(() => new RecyclableMemoryStreamManager(new RecyclableMemoryStreamManager.Options { BlockSize = 1, LargeBufferMultiple = 100, MaximumBufferSize = 200, UseExponentialLargeBuffer = this.UseExponentialLargeBuffer }))); } [Test] public void RecyclableMemoryManagerThrowsExceptionOnZeroLargeBufferMultipleSize() { - Assert.Throws(() => new RecyclableMemoryStreamManager(new RecyclableMemoryStreamManager.Options { BlockSize = 100, LargeBufferMultiple = 0, MaximumBufferSize = 200, UseExponentialLargeBuffer = this.UseExponentialLargeBuffer })); - Assert.Throws(() => new RecyclableMemoryStreamManager(new RecyclableMemoryStreamManager.Options { BlockSize = 100, LargeBufferMultiple = -1, MaximumBufferSize = 200, UseExponentialLargeBuffer = this.UseExponentialLargeBuffer })); - Assert.DoesNotThrow(() => new RecyclableMemoryStreamManager(new RecyclableMemoryStreamManager.Options { BlockSize = 100, LargeBufferMultiple = 100, MaximumBufferSize = 200, UseExponentialLargeBuffer = this.UseExponentialLargeBuffer })); + Assert.Throws((Action)(() => new RecyclableMemoryStreamManager(new RecyclableMemoryStreamManager.Options { BlockSize = 100, LargeBufferMultiple = 0, MaximumBufferSize = 200, UseExponentialLargeBuffer = this.UseExponentialLargeBuffer }))); + Assert.Throws((Action)(() => new RecyclableMemoryStreamManager(new RecyclableMemoryStreamManager.Options { BlockSize = 100, LargeBufferMultiple = -1, MaximumBufferSize = 200, UseExponentialLargeBuffer = this.UseExponentialLargeBuffer }))); + Assert.DoesNotThrow((Action)(() => new RecyclableMemoryStreamManager(new RecyclableMemoryStreamManager.Options { BlockSize = 100, LargeBufferMultiple = 100, MaximumBufferSize = 200, UseExponentialLargeBuffer = this.UseExponentialLargeBuffer }))); } [Test] public void RecyclableMemoryManagerThrowsExceptionOnMaximumBufferSizeLessThanBlockSize() { - Assert.Throws(() => new RecyclableMemoryStreamManager(new RecyclableMemoryStreamManager.Options { BlockSize = 100, LargeBufferMultiple = 100, MaximumBufferSize = 99, UseExponentialLargeBuffer = this.UseExponentialLargeBuffer })); - Assert.DoesNotThrow(() => new RecyclableMemoryStreamManager(new RecyclableMemoryStreamManager.Options { BlockSize = 100, LargeBufferMultiple = 100, MaximumBufferSize = 100, UseExponentialLargeBuffer = this.UseExponentialLargeBuffer })); + Assert.Throws((Action)(() => new RecyclableMemoryStreamManager(new RecyclableMemoryStreamManager.Options { BlockSize = 100, LargeBufferMultiple = 100, MaximumBufferSize = 99, UseExponentialLargeBuffer = this.UseExponentialLargeBuffer }))); + Assert.DoesNotThrow((Action)(() => new RecyclableMemoryStreamManager(new RecyclableMemoryStreamManager.Options { BlockSize = 100, LargeBufferMultiple = 100, MaximumBufferSize = 100, UseExponentialLargeBuffer = this.UseExponentialLargeBuffer }))); } [Test] public virtual void RecyclableMemoryManagerThrowsExceptionOnMaximumBufferNotMultipleOrExponentialOfLargeBufferMultiple() { - Assert.Throws(() => new RecyclableMemoryStreamManager(new RecyclableMemoryStreamManager.Options { BlockSize = 100, LargeBufferMultiple = 1024, MaximumBufferSize = 2025, UseExponentialLargeBuffer = this.UseExponentialLargeBuffer })); - Assert.Throws(() => new RecyclableMemoryStreamManager(new RecyclableMemoryStreamManager.Options { BlockSize = 100, LargeBufferMultiple = 1024, MaximumBufferSize = 2023, UseExponentialLargeBuffer = this.UseExponentialLargeBuffer })); - Assert.DoesNotThrow(() => new RecyclableMemoryStreamManager(new RecyclableMemoryStreamManager.Options { BlockSize = 100, LargeBufferMultiple = 1024, MaximumBufferSize = 2048, UseExponentialLargeBuffer = this.UseExponentialLargeBuffer })); + Assert.Throws((Action)(() => new RecyclableMemoryStreamManager(new RecyclableMemoryStreamManager.Options { BlockSize = 100, LargeBufferMultiple = 1024, MaximumBufferSize = 2025, UseExponentialLargeBuffer = this.UseExponentialLargeBuffer }))); + Assert.Throws((Action)(() => new RecyclableMemoryStreamManager(new RecyclableMemoryStreamManager.Options { BlockSize = 100, LargeBufferMultiple = 1024, MaximumBufferSize = 2023, UseExponentialLargeBuffer = this.UseExponentialLargeBuffer }))); + Assert.DoesNotThrow((Action)(() => new RecyclableMemoryStreamManager(new RecyclableMemoryStreamManager.Options { BlockSize = 100, LargeBufferMultiple = 1024, MaximumBufferSize = 2048, UseExponentialLargeBuffer = this.UseExponentialLargeBuffer }))); } [Test] public void RecyclableMemoryManagerThrowsExceptionOnNegativeMaxFreeSizes() { - Assert.Throws(() => new RecyclableMemoryStreamManager(new RecyclableMemoryStreamManager.Options { BlockSize = 1, LargeBufferMultiple = 100, MaximumBufferSize = 200, UseExponentialLargeBuffer = false, MaximumSmallPoolFreeBytes = -1, MaximumLargePoolFreeBytes = 1000 })); - Assert.Throws(() => new RecyclableMemoryStreamManager(new RecyclableMemoryStreamManager.Options { BlockSize = 1, LargeBufferMultiple = 100, MaximumBufferSize = 200, UseExponentialLargeBuffer = false, MaximumSmallPoolFreeBytes = 1000, MaximumLargePoolFreeBytes = -1 })); - Assert.DoesNotThrow(() => new RecyclableMemoryStreamManager(new RecyclableMemoryStreamManager.Options { BlockSize = 1, LargeBufferMultiple = 100, MaximumBufferSize = 200, UseExponentialLargeBuffer = false, MaximumSmallPoolFreeBytes = 1000, MaximumLargePoolFreeBytes = 1000 })); - Assert.DoesNotThrow(() => new RecyclableMemoryStreamManager(new RecyclableMemoryStreamManager.Options { BlockSize = 1, LargeBufferMultiple = 100, MaximumBufferSize = 200, UseExponentialLargeBuffer = false, MaximumSmallPoolFreeBytes = 0, MaximumLargePoolFreeBytes = 0 })); + Assert.Throws((Action)(() => new RecyclableMemoryStreamManager(new RecyclableMemoryStreamManager.Options { BlockSize = 1, LargeBufferMultiple = 100, MaximumBufferSize = 200, UseExponentialLargeBuffer = false, MaximumSmallPoolFreeBytes = -1, MaximumLargePoolFreeBytes = 1000 }))); + Assert.Throws((Action)(() => new RecyclableMemoryStreamManager(new RecyclableMemoryStreamManager.Options { BlockSize = 1, LargeBufferMultiple = 100, MaximumBufferSize = 200, UseExponentialLargeBuffer = false, MaximumSmallPoolFreeBytes = 1000, MaximumLargePoolFreeBytes = -1 }))); + Assert.DoesNotThrow((Action)(() => new RecyclableMemoryStreamManager(new RecyclableMemoryStreamManager.Options { BlockSize = 1, LargeBufferMultiple = 100, MaximumBufferSize = 200, UseExponentialLargeBuffer = false, MaximumSmallPoolFreeBytes = 1000, MaximumLargePoolFreeBytes = 1000 }))); + Assert.DoesNotThrow((Action)(() => new RecyclableMemoryStreamManager(new RecyclableMemoryStreamManager.Options { BlockSize = 1, LargeBufferMultiple = 100, MaximumBufferSize = 200, UseExponentialLargeBuffer = false, MaximumSmallPoolFreeBytes = 0, MaximumLargePoolFreeBytes = 0 }))); } [Test] @@ -211,7 +211,7 @@ public void GetVeryLargeBufferRecordsCallStack() public void ReturnLargerBufferWithNullBufferThrowsException() { var memMgr = this.GetMemoryManager(); - Assert.Throws(() => memMgr.ReturnLargeBuffer(null!, DefaultId, DefaultTag)); + Assert.Throws((Action)(() => memMgr.ReturnLargeBuffer(null!, DefaultId, DefaultTag))); } [Test] @@ -219,21 +219,21 @@ public void ReturnLargeBufferWithWrongSizedBufferThrowsException() { var memMgr = this.GetMemoryManager(); var buffer = new byte[100]; - Assert.Throws(() => memMgr.ReturnLargeBuffer(buffer, DefaultId, DefaultTag)); + Assert.Throws((Action)(() => memMgr.ReturnLargeBuffer(buffer, DefaultId, DefaultTag))); } [Test] public void ReturnNullBlockThrowsException() { var memMgr = this.GetMemoryManager(); - Assert.Throws(() => memMgr.ReturnBlock(null!, Guid.Empty, string.Empty)); + Assert.Throws((Action)(() => memMgr.ReturnBlock(null!, Guid.Empty, string.Empty))); } [Test] public void ReturnNullBlocksThrowsException() { var memMgr = this.GetMemoryManager(); - Assert.Throws(() => memMgr.ReturnBlocks(null!, Guid.Empty, string.Empty)); + Assert.Throws((Action)(() => memMgr.ReturnBlocks(null!, Guid.Empty, string.Empty))); } [Test] @@ -241,7 +241,7 @@ public void ReturnBlockWithInvalidBufferThrowsException() { var memMgr = this.GetMemoryManager(); var buffer = new byte[memMgr.options.BlockSize + 1]; - Assert.Throws(() => memMgr.ReturnBlock(buffer, Guid.Empty, string.Empty)); + Assert.Throws((Action)(() => memMgr.ReturnBlock(buffer, Guid.Empty, string.Empty))); } [Test] @@ -252,7 +252,7 @@ public void ReturnBlocksWithInvalidBuffersThrowsException() buffers.Add(memMgr.GetBlock()); buffers.Add(new byte[memMgr.options.BlockSize + 1]); buffers.Add(memMgr.GetBlock()); - Assert.Throws(() => memMgr.ReturnBlocks(buffers, Guid.Empty, string.Empty)); + Assert.Throws((Action)(() => memMgr.ReturnBlocks(buffers, Guid.Empty, string.Empty))); } [Test] @@ -263,7 +263,7 @@ public void ReturnBlocksWithNullBufferThrowsException() buffers.Add(memMgr.GetBlock()); buffers.Add(null!); buffers.Add(memMgr.GetBlock()); - Assert.Throws(() => memMgr.ReturnBlocks(buffers, Guid.Empty, string.Empty)); + Assert.Throws((Action)(() => memMgr.ReturnBlocks(buffers, Guid.Empty, string.Empty))); } [Test] @@ -291,7 +291,7 @@ public void ReturnZeroLengthBufferThrowsException() { var memMgr = this.GetMemoryManager(); var emptyBuffer = Array.Empty(); - Assert.Throws(() => memMgr.ReturnLargeBuffer(emptyBuffer, DefaultId, DefaultTag)); + Assert.Throws((Action)(() => memMgr.ReturnLargeBuffer(emptyBuffer, DefaultId, DefaultTag))); } [Test] @@ -608,8 +608,8 @@ public void MaxIntAllocationSucceeds() public void GetSpanMemoryWithNegativeHintFails() { var stream = this.GetDefaultStream(); - Assert.Throws(() => stream.GetSpan(-1)); - Assert.Throws(() => stream.GetMemory(-1)); + Assert.Throws((Action)(() => stream.GetSpan(-1))); + Assert.Throws((Action)(() => stream.GetMemory(-1))); } [Test] @@ -617,8 +617,8 @@ public void GetSpanMemoryWithTooLargeHintFails() { var stream = this.GetDefaultStream(); stream.Position = 1; - Assert.Throws(() => stream.GetSpan(int.MaxValue)); - Assert.Throws(() => stream.GetMemory(int.MaxValue)); + Assert.Throws((Action)(() => stream.GetSpan(int.MaxValue))); + Assert.Throws((Action)(() => stream.GetMemory(int.MaxValue))); } [Test] @@ -627,8 +627,8 @@ public void GetSpanMemoryWithHintLargerThanMaximumStreamCapacityFails() var memoryManager = this.GetMemoryManager(); memoryManager.options.MaximumStreamCapacity = short.MaxValue; var stream = new RecyclableMemoryStream(memoryManager, string.Empty, 0); - Assert.Throws(() => stream.GetSpan(short.MaxValue + 1)); - Assert.Throws(() => stream.GetMemory(short.MaxValue + 1)); + Assert.Throws((Action)(() => stream.GetSpan(short.MaxValue + 1))); + Assert.Throws((Action)(() => stream.GetMemory(short.MaxValue + 1))); } [Test] @@ -1004,35 +1004,35 @@ public void WriteAfterLargeBufferDoesNotAllocateMoreBlocks() public void WriteNullBufferThrowsException() { var stream = this.GetDefaultStream(); - Assert.Throws(() => stream.Write(null!, 0, 0)); + Assert.Throws((Action)(() => stream.Write(null!, 0, 0))); } [Test] public void WriteStartPastBufferThrowsException() { var stream = this.GetDefaultStream(); - Assert.Throws(() => stream.Write([0, 1], 2, 1)); + Assert.Throws((Action)(() => stream.Write([0, 1], 2, 1))); } [Test] public void WriteStartBeforeBufferThrowsException() { var stream = this.GetDefaultStream(); - Assert.Throws(() => stream.Write([0, 1], -1, 0)); + Assert.Throws((Action)(() => stream.Write([0, 1], -1, 0))); } [Test] public void WriteNegativeCountThrowsException() { var stream = this.GetDefaultStream(); - Assert.Throws(() => stream.Write([0, 1], 0, -1)); + Assert.Throws((Action)(() => stream.Write([0, 1], 0, -1))); } [Test] public void WriteCountOutOfRangeThrowsException() { var stream = this.GetDefaultStream(); - Assert.Throws(() => stream.Write([0, 1], 0, 3)); + Assert.Throws((Action)(() => stream.Write([0, 1], 0, 3))); } // This is a valid test, but it's too resource-intensive to run on a regular basis. @@ -1702,7 +1702,7 @@ void read() public void ReadNullBufferThrowsException() { var stream = this.GetDefaultStream(); - Assert.Throws(() => stream.Read(null!, 0, 1)); + Assert.Throws((Action)(() => stream.Read(null!, 0, 1))); } [Test] @@ -1710,7 +1710,7 @@ public void ReadNegativeOffsetThrowsException() { var bufferLength = 100; var stream = this.GetDefaultStream(); - Assert.Throws(() => stream.Read(new byte[bufferLength], -1, 1)); + Assert.Throws((Action)(() => stream.Read(new byte[bufferLength], -1, 1))); } [Test] @@ -1718,7 +1718,7 @@ public void ReadOffsetPastEndThrowsException() { var bufferLength = 100; var stream = this.GetDefaultStream(); - Assert.Throws(() => stream.Read(new byte[bufferLength], bufferLength, 1)); + Assert.Throws((Action)(() => stream.Read(new byte[bufferLength], bufferLength, 1))); } [Test] @@ -1726,7 +1726,7 @@ public void ReadNegativeCountThrowsException() { var bufferLength = 100; var stream = this.GetDefaultStream(); - Assert.Throws(() => stream.Read(new byte[bufferLength], 0, -1)); + Assert.Throws((Action)(() => stream.Read(new byte[bufferLength], 0, -1))); } [Test] @@ -1734,7 +1734,7 @@ public void ReadCountOutOfBoundsThrowsException() { var bufferLength = 100; var stream = this.GetDefaultStream(); - Assert.Throws(() => stream.Read(new byte[bufferLength], 0, bufferLength + 1)); + Assert.Throws((Action)(() => stream.Read(new byte[bufferLength], 0, bufferLength + 1))); } [Test] @@ -1742,9 +1742,9 @@ public void ReadOffsetPlusCountLargerThanBufferThrowsException() { var bufferLength = 100; var stream1 = this.GetDefaultStream(); - Assert.Throws(() => stream1.Read(new byte[bufferLength], bufferLength / 2, bufferLength / 2 + 1)); + Assert.Throws((Action)(() => stream1.Read(new byte[bufferLength], bufferLength / 2, bufferLength / 2 + 1))); var stream2 = this.GetDefaultStream(); - Assert.Throws(() => stream2.Read(new byte[bufferLength], bufferLength / 2 + 1, bufferLength / 2)); + Assert.Throws((Action)(() => stream2.Read(new byte[bufferLength], bufferLength / 2 + 1, bufferLength / 2))); } [Test] @@ -2098,7 +2098,7 @@ public void CapacityThrowsOnTooLargeStream() var stream = this.GetDefaultStream(); stream.Capacity64 = (long)Int32.MaxValue + 1; Assert.That(stream.Capacity64, Is.EqualTo((long)Int32.MaxValue + 1)); - Assert.Throws(() => { var cap = stream.Capacity; }); + Assert.Throws((Action)(() => { var cap = stream.Capacity; })); } #endregion @@ -2107,7 +2107,7 @@ public void CapacityThrowsOnTooLargeStream() public void SetLengthThrowsExceptionOnNegativeValue() { var stream = this.GetDefaultStream(); - Assert.Throws(() => stream.SetLength(-1)); + Assert.Throws((Action)(() => stream.SetLength(-1))); } [Test] @@ -2244,13 +2244,13 @@ public void ToArrayThrowsExceptionWhenConfigured() stream.Write(buffer, 0, bufferLength); // Ensure default is false - Assert.DoesNotThrow(() => stream.ToArray()); + Assert.DoesNotThrow((Action)(() => stream.ToArray())); stream.MemoryManager.options.ThrowExceptionOnToArray = true; - Assert.Throws(() => stream.ToArray()); + Assert.Throws((Action)(() => stream.ToArray())); stream.MemoryManager.options.ThrowExceptionOnToArray = false; - Assert.DoesNotThrow(() => stream.ToArray()); + Assert.DoesNotThrow((Action)(() => stream.ToArray())); } #endregion @@ -2285,28 +2285,28 @@ public void CanTimeoutIsFalse() public void SeekFromBeginToBeforeBeginThrowsException() { var stream = this.GetDefaultStream(); - Assert.Throws(() => stream.Seek(-1, SeekOrigin.Begin)); + Assert.Throws((Action)(() => stream.Seek(-1, SeekOrigin.Begin))); } [Test] public void SeekFromCurrentToBeforeBeginThrowsException() { var stream = this.GetDefaultStream(); - Assert.Throws(() => stream.Seek(-1, SeekOrigin.Current)); + Assert.Throws((Action)(() => stream.Seek(-1, SeekOrigin.Current))); } [Test] public void SeekFromEndToBeforeBeginThrowsException() { var stream = this.GetDefaultStream(); - Assert.Throws(() => stream.Seek(-1, SeekOrigin.End)); + Assert.Throws((Action)(() => stream.Seek(-1, SeekOrigin.End))); } [Test] public void SeekWithBadOriginThrowsException() { var stream = this.GetDefaultStream(); - Assert.Throws(() => stream.Seek(1, (SeekOrigin)99)); + Assert.Throws((Action)(() => stream.Seek(1, (SeekOrigin)99))); } [Test] @@ -2370,7 +2370,7 @@ public void SeekPastEndAndWriteHasCorrectLengthAndPosition() public void PositionSetToNegativeThrowsException() { var stream = this.GetDefaultStream(); - Assert.Throws(() => stream.Position = -1); + Assert.Throws((Action)(() => stream.Position = -1)); } [Test] @@ -2393,7 +2393,7 @@ public void AdvanceByNegativeThrowsException() { var stream = this.GetDefaultStream(); stream.Position = 10; - Assert.Throws(() => stream.Advance(-1)); + Assert.Throws((Action)(() => stream.Advance(-1))); } [Test] @@ -2401,7 +2401,7 @@ public void AdvancePastLargerThanMaxStreamLengthThrowsException() { var stream = this.GetDefaultStream(); stream.Advance(1); - Assert.Throws(() => stream.Advance(Int32.MaxValue)); + Assert.Throws((Action)(() => stream.Advance(Int32.MaxValue))); } [Test] @@ -2409,7 +2409,7 @@ public void AdvancePastTempBufferLengthThrowsException() { var stream = this.GetDefaultStream(); var memory = stream.GetMemory(stream.MemoryManager.options.BlockSize + 1); - Assert.Throws(() => stream.Advance(memory.Length + 1)); + Assert.Throws((Action)(() => stream.Advance(memory.Length + 1))); } [Test] @@ -2417,7 +2417,7 @@ public void AdvancePastBlockLengthThrowsException() { var stream = this.GetDefaultStream(); var memory = stream.GetMemory(); - Assert.Throws(() => stream.Advance(memory.Length + 1)); + Assert.Throws((Action)(() => stream.Advance(memory.Length + 1))); } [Test] @@ -2427,7 +2427,7 @@ public void AdvancePastLargeBufferLengthThrowsException() stream.Position = stream.MemoryManager.options.BlockSize + 1; stream.GetBuffer(); var memory = stream.GetMemory(); - Assert.Throws(() => stream.Advance(memory.Length + 1)); + Assert.Throws((Action)(() => stream.Advance(memory.Length + 1))); } [Test] @@ -2502,7 +2502,7 @@ public void Dispose_PartiallyConstructedStream_DoesNotThrow(bool assignMemoryMan } var dispose = typeof(RecyclableMemoryStream).GetMethod("Dispose", BindingFlags.Instance | BindingFlags.NonPublic, null, [typeof(bool)], null)!; - Assert.DoesNotThrow(() => dispose.Invoke(stream, [false])); + Assert.DoesNotThrow((Action)(() => dispose.Invoke(stream, [false]))); } finally { @@ -2632,20 +2632,20 @@ public void AccessingObjectAfterDisposeThrowsObjectDisposedException() Assert.That(stream.CanSeek, Is.False); Assert.That(stream.CanWrite, Is.False); - Assert.Throws(() => { var x = stream.Capacity; }); - Assert.Throws(() => { var x = stream.Length; }); - Assert.Throws(() => { var x = stream.MemoryManager; }); - Assert.Throws(() => { var x = stream.Id; }); - Assert.Throws(() => { var x = stream.Tag; }); - Assert.Throws(() => { var x = stream.Position; }); - Assert.Throws(() => { var x = stream.ReadByte(); }); - Assert.Throws(() => { var x = stream.Read(buffer, 0, buffer.Length); }); - Assert.Throws(() => { stream.WriteByte(255); }); - Assert.Throws(() => { stream.Write(buffer, 0, buffer.Length); }); - Assert.Throws(() => { stream.SetLength(100); }); - Assert.Throws(() => { stream.Seek(0, SeekOrigin.Begin); }); - Assert.Throws(() => { var x = stream.ToArray(); }); - Assert.Throws(() => { var x = stream.GetBuffer(); }); + Assert.Throws((Action)(() => { var x = stream.Capacity; })); + Assert.Throws((Action)(() => { var x = stream.Length; })); + Assert.Throws((Action)(() => { var x = stream.MemoryManager; })); + Assert.Throws((Action)(() => { var x = stream.Id; })); + Assert.Throws((Action)(() => { var x = stream.Tag; })); + Assert.Throws((Action)(() => { var x = stream.Position; })); + Assert.Throws((Action)(() => { var x = stream.ReadByte(); })); + Assert.Throws((Action)(() => { var x = stream.Read(buffer, 0, buffer.Length); })); + Assert.Throws((Action)(() => { stream.WriteByte(255); })); + Assert.Throws((Action)(() => { stream.Write(buffer, 0, buffer.Length); })); + Assert.Throws((Action)(() => { stream.SetLength(100); })); + Assert.Throws((Action)(() => { stream.Seek(0, SeekOrigin.Begin); })); + Assert.Throws((Action)(() => { var x = stream.ToArray(); })); + Assert.Throws((Action)(() => { var x = stream.GetBuffer(); })); } [Test] @@ -2805,7 +2805,7 @@ public void GetStreamWithOnlyReadOnlySpan() public void WriteToNullStreamThrowsException() { var stream = this.GetDefaultStream(); - Assert.Throws(() => stream.WriteTo(null!)); + Assert.Throws((Action)(() => stream.WriteTo(null!))); } [Test] @@ -2884,17 +2884,17 @@ public void WriteToOtherStreamOffsetCountHasEqualContentsFullStream(int bufferSi public void WriteToOtherStreamOffsetCountThrowException() { var stream = this.GetDefaultStream(); - Assert.Throws(() => stream.WriteTo((Stream)null!, 0, (int)stream.Length)); - Assert.Throws(() => stream.WriteTo(stream, -1, (int)stream.Length)); - Assert.Throws(() => stream.WriteTo(stream, 1, (int)stream.Length)); - Assert.Throws(() => stream.WriteTo(stream, 0, (int)stream.Length + 1)); + Assert.Throws((Action)(() => stream.WriteTo((Stream)null!, 0, (int)stream.Length))); + Assert.Throws((Action)(() => stream.WriteTo(stream, -1, (int)stream.Length))); + Assert.Throws((Action)(() => stream.WriteTo(stream, 1, (int)stream.Length))); + Assert.Throws((Action)(() => stream.WriteTo(stream, 0, (int)stream.Length + 1))); } [Test] public void WriteToByteArray_NullTarget() { using var stream = this.GetDefaultStream(); - Assert.Throws(() => stream.WriteTo(null!)); + Assert.Throws((Action)(() => stream.WriteTo(null!))); } [Test] @@ -2951,7 +2951,7 @@ public void WriteToByteArray_CountLargerThanSourceWithZeroOffset() using var stream = this.GetDefaultStream(); stream.Write(sourceBuffer); byte[] targetBuffer = new byte[sourceBuffer.Length]; - Assert.Throws(() => stream.WriteTo(targetBuffer, 0, sourceBuffer.Length + 1)); + Assert.Throws((Action)(() => stream.WriteTo(targetBuffer, 0, sourceBuffer.Length + 1))); } [Test] @@ -2961,7 +2961,7 @@ public void WriteToByteArray_CountLargerThanSourceWithNonZeroOffset() using var stream = this.GetDefaultStream(); stream.Write(sourceBuffer); byte[] targetBuffer = new byte[sourceBuffer.Length]; - Assert.Throws(() => stream.WriteTo(targetBuffer, 1, sourceBuffer.Length)); + Assert.Throws((Action)(() => stream.WriteTo(targetBuffer, 1, sourceBuffer.Length))); } [Test] @@ -2971,7 +2971,7 @@ public void WriteToByteArray_CountLargerThanTargetZeroOffset() using var stream = this.GetDefaultStream(); stream.Write(sourceBuffer); byte[] targetBuffer = new byte[sourceBuffer.Length]; - Assert.Throws(() => stream.WriteTo(targetBuffer, 0, sourceBuffer.Length, 1)); + Assert.Throws((Action)(() => stream.WriteTo(targetBuffer, 0, sourceBuffer.Length, 1))); } [Test] @@ -2981,7 +2981,7 @@ public void WriteToByteArray_CountLargerThanTargetNonZeroOffset() using var stream = this.GetDefaultStream(); stream.Write(sourceBuffer); byte[] targetBuffer = new byte[sourceBuffer.Length]; - Assert.Throws(() => stream.WriteTo(targetBuffer, 1, sourceBuffer.Length - 1, 2)); + Assert.Throws((Action)(() => stream.WriteTo(targetBuffer, 1, sourceBuffer.Length - 1, 2))); } [Test] @@ -2991,7 +2991,7 @@ public void WriteToByteArray_TargetOffsetLargerThanTarget() using var stream = this.GetDefaultStream(); stream.Write(sourceBuffer); byte[] targetBuffer = new byte[sourceBuffer.Length]; - Assert.Throws(() => stream.WriteTo(targetBuffer, 0, 1, sourceBuffer.Length)); + Assert.Throws((Action)(() => stream.WriteTo(targetBuffer, 0, 1, sourceBuffer.Length))); } [Test] @@ -3001,7 +3001,7 @@ public void WriteToByteArray_NegativeOffsetThrowsException() using var stream = this.GetDefaultStream(); stream.Write(sourceBuffer); byte[] targetBuffer = new byte[sourceBuffer.Length]; - Assert.Throws(() => stream.WriteTo(targetBuffer, -1, sourceBuffer.Length)); + Assert.Throws((Action)(() => stream.WriteTo(targetBuffer, -1, sourceBuffer.Length))); } @@ -3012,7 +3012,7 @@ public void WriteToByteArray_NegativeTargetOffsetThrowsException() using var stream = this.GetDefaultStream(); stream.Write(sourceBuffer); byte[] targetBuffer = new byte[sourceBuffer.Length]; - Assert.Throws(() => stream.WriteTo(targetBuffer, 0, sourceBuffer.Length, -1)); + Assert.Throws((Action)(() => stream.WriteTo(targetBuffer, 0, sourceBuffer.Length, -1))); } @@ -3034,8 +3034,8 @@ public void MaximumStreamCapacity_Limit() var stream = this.GetDefaultStream(); var maxCapacity = DefaultMaximumBufferSize * 2; stream.MemoryManager.options.MaximumStreamCapacity = maxCapacity; - Assert.DoesNotThrow(() => stream.Capacity = maxCapacity); - Assert.Throws(() => stream.Capacity = maxCapacity + 1); + Assert.DoesNotThrow((Action)(() => stream.Capacity = maxCapacity)); + Assert.Throws((Action)(() => stream.Capacity = maxCapacity + 1)); } [Test] @@ -3044,9 +3044,9 @@ public void MaximumStreamCapacity_StreamUnchanged() var stream = this.GetDefaultStream(); var maxCapacity = DefaultMaximumBufferSize * 2; stream.MemoryManager.options.MaximumStreamCapacity = maxCapacity; - Assert.DoesNotThrow(() => stream.Capacity = maxCapacity); + Assert.DoesNotThrow((Action)(() => stream.Capacity = maxCapacity)); var oldCapacity = stream.Capacity; - Assert.Throws(() => stream.Capacity = maxCapacity + 1); + Assert.Throws((Action)(() => stream.Capacity = maxCapacity + 1)); Assert.That(stream.Capacity, Is.EqualTo(oldCapacity)); } @@ -3062,7 +3062,7 @@ public void MaximumStreamCapacity_StreamUnchangedAfterWriteOverLimit() var oldCapacity = stream.Capacity; var oldPosition = stream.Position; var buffer2 = this.GetRandomBuffer(maxCapacity); - Assert.Throws(() => stream.Write(buffer2, 0, buffer2.Length)); + Assert.Throws((Action)(() => stream.Write(buffer2, 0, buffer2.Length))); Assert.That(stream.Length, Is.EqualTo(oldLength)); Assert.That(stream.Capacity, Is.EqualTo(oldCapacity)); Assert.That(stream.Position, Is.EqualTo(oldPosition)); @@ -3094,7 +3094,7 @@ public void CopyTo() public void CopyToAsyncThrowsOnNullDestination() { using var stream = this.GetDefaultStream(); - Assert.Throws(() => stream.CopyToAsync(null!, DefaultBlockSize, CancellationToken.None)); + Assert.Throws((Action)(() => stream.CopyToAsync(null!, DefaultBlockSize, CancellationToken.None))); } [Test] @@ -3103,7 +3103,7 @@ public void CopyToAsyncThrowsIfDisposed() var stream = this.GetDefaultStream(); using var otherStream = this.GetDefaultStream(); stream.Dispose(); - Assert.Throws(() => stream.CopyToAsync(otherStream, DefaultBlockSize, CancellationToken.None)); + Assert.Throws((Action)(() => stream.CopyToAsync(otherStream, DefaultBlockSize, CancellationToken.None))); } [TestCase(0)] @@ -3339,7 +3339,7 @@ public void VeryLargeStream_ExistingLargeBufferThrowsOnMultiGBLength() var data = this.GetRandomBuffer(1 << 20); stream.Write(data); var buffer = stream.GetBuffer(); - Assert.Throws(() => stream.SetLength(DefaultVeryLargeStreamSize)); + Assert.Throws((Action)(() => stream.SetLength(DefaultVeryLargeStreamSize))); } [Test] @@ -3350,7 +3350,7 @@ public void VeryLargeStream_GetBufferThrows() Assert.Ignore("Disable test due to increased memory consumption that currently does not work with the hardware limits of the GitHub runners."); } var stream = this.GetMultiGBStream(); - Assert.Throws(() => stream.GetBuffer()); + Assert.Throws((Action)(() => stream.GetBuffer())); } [Test] @@ -3363,7 +3363,7 @@ public void VeryLargeStream_SetPositionThrowsIfLargeBuffer() var stream = this.GetDefaultStream(); stream.SetLength(1 << 20); var buffer = stream.GetBuffer(); - Assert.Throws(() => stream.Position = DefaultVeryLargeStreamSize); + Assert.Throws((Action)(() => stream.Position = DefaultVeryLargeStreamSize)); } [Test] @@ -3518,7 +3518,7 @@ public void EventStreamOverCapacity() }; var stream = mgr.GetStream("UnitTest", 13); - Assert.Throws(() => stream.Capacity = mgr.options.BlockSize * 2); + Assert.Throws((Action)(() => stream.Capacity = mgr.options.BlockSize * 2)); Assert.That(raised, Is.True); } @@ -3960,11 +3960,11 @@ public override void RecyclableMemoryManagerUsingMultipleOrExponentialLargeBuffe [Test] public override void RecyclableMemoryManagerThrowsExceptionOnMaximumBufferNotMultipleOrExponentialOfLargeBufferMultiple() { - Assert.Throws(() => new RecyclableMemoryStreamManager(new RecyclableMemoryStreamManager.Options { BlockSize = 100, LargeBufferMultiple = 1024, MaximumBufferSize = 2025, UseExponentialLargeBuffer = this.UseExponentialLargeBuffer })); - Assert.Throws(() => new RecyclableMemoryStreamManager(new RecyclableMemoryStreamManager.Options { BlockSize = 100, LargeBufferMultiple = 1024, MaximumBufferSize = 2023, UseExponentialLargeBuffer = this.UseExponentialLargeBuffer })); - Assert.Throws(() => new RecyclableMemoryStreamManager(new RecyclableMemoryStreamManager.Options { BlockSize = 100, LargeBufferMultiple = 1024, MaximumBufferSize = 3072, UseExponentialLargeBuffer = this.UseExponentialLargeBuffer })); - Assert.DoesNotThrow(() => new RecyclableMemoryStreamManager(new RecyclableMemoryStreamManager.Options { BlockSize = 100, LargeBufferMultiple = 1024, MaximumBufferSize = 2048, UseExponentialLargeBuffer = this.UseExponentialLargeBuffer })); - Assert.DoesNotThrow(() => new RecyclableMemoryStreamManager(new RecyclableMemoryStreamManager.Options { BlockSize = 100, LargeBufferMultiple = 1024, MaximumBufferSize = 4096, UseExponentialLargeBuffer = this.UseExponentialLargeBuffer })); + Assert.Throws((Action)(() => new RecyclableMemoryStreamManager(new RecyclableMemoryStreamManager.Options { BlockSize = 100, LargeBufferMultiple = 1024, MaximumBufferSize = 2025, UseExponentialLargeBuffer = this.UseExponentialLargeBuffer }))); + Assert.Throws((Action)(() => new RecyclableMemoryStreamManager(new RecyclableMemoryStreamManager.Options { BlockSize = 100, LargeBufferMultiple = 1024, MaximumBufferSize = 2023, UseExponentialLargeBuffer = this.UseExponentialLargeBuffer }))); + Assert.Throws((Action)(() => new RecyclableMemoryStreamManager(new RecyclableMemoryStreamManager.Options { BlockSize = 100, LargeBufferMultiple = 1024, MaximumBufferSize = 3072, UseExponentialLargeBuffer = this.UseExponentialLargeBuffer }))); + Assert.DoesNotThrow((Action)(() => new RecyclableMemoryStreamManager(new RecyclableMemoryStreamManager.Options { BlockSize = 100, LargeBufferMultiple = 1024, MaximumBufferSize = 2048, UseExponentialLargeBuffer = this.UseExponentialLargeBuffer }))); + Assert.DoesNotThrow((Action)(() => new RecyclableMemoryStreamManager(new RecyclableMemoryStreamManager.Options { BlockSize = 100, LargeBufferMultiple = 1024, MaximumBufferSize = 4096, UseExponentialLargeBuffer = this.UseExponentialLargeBuffer }))); } [Test] @@ -4023,7 +4023,7 @@ public void InvalidLargeBufferSizeDoesNotCauseOverflow() const int LargeBufferMultiple = 1024; const int MaxBufferSize = int.MaxValue; - Assert.Throws(() => new RecyclableMemoryStreamManager( + Assert.Throws((Action)(() => new RecyclableMemoryStreamManager( new RecyclableMemoryStreamManager.Options { BlockSize = BlockSize, @@ -4031,7 +4031,7 @@ public void InvalidLargeBufferSizeDoesNotCauseOverflow() MaximumBufferSize = MaxBufferSize, UseExponentialLargeBuffer = this.UseExponentialLargeBuffer, AggressiveBufferReturn = this.AggressiveBufferRelease - })); + }))); } [Test]