diff --git a/src/modules/PowerOCR/PowerOCR/Helpers/WrappingStream.cs b/src/modules/PowerOCR/PowerOCR/Helpers/WrappingStream.cs index fc49112ef6..5b952d1f73 100644 --- a/src/modules/PowerOCR/PowerOCR/Helpers/WrappingStream.cs +++ b/src/modules/PowerOCR/PowerOCR/Helpers/WrappingStream.cs @@ -220,9 +220,6 @@ public class WrappingStream : Stream private void ThrowIfDisposed() { // throws an ObjectDisposedException if this object has been disposed - if (_streamBase == null) - { - throw new ObjectDisposedException(GetType().Name); - } + ObjectDisposedException.ThrowIf(_streamBase == null, this); } } diff --git a/src/modules/previewpane/common/Utilities/ReadonlyStream.cs b/src/modules/previewpane/common/Utilities/ReadonlyStream.cs index 82959a38c2..bb066df72d 100644 --- a/src/modules/previewpane/common/Utilities/ReadonlyStream.cs +++ b/src/modules/previewpane/common/Utilities/ReadonlyStream.cs @@ -240,10 +240,7 @@ namespace Common.Utilities private void CheckDisposed() { - if (_stream == null) - { - throw new ObjectDisposedException(nameof(ReadonlyStream)); - } + ObjectDisposedException.ThrowIf(_stream == null, this); } } }