From 391663ac67457443376f60f32cb149cede2b246d Mon Sep 17 00:00:00 2001 From: catester Date: Sat, 14 Mar 2015 12:46:34 +0200 Subject: [PATCH] Replaced NotImplementedException for streams Especially for streams, it is more appropriate to throw NotSupportedException instead of NotImplementedException. Usually consumers of streams expect NotSupportedException to handle errors. There are other places that also use NotImplementedException but I didn't examine them for now. I only modified stream classes in SharpCompress.IO. For reference about this best practise, please see these articles: http://blogs.msdn.com/b/brada/archive/2004/07/29/201354.aspx http://blogs.msdn.com/b/jaredpar/archive/2008/12/12/notimplementedexception-vs-notsupportedexception.aspx --- SharpCompress/IO/CountingWritableSubStream.cs | 12 ++++++------ SharpCompress/IO/MarkingBinaryReader.cs | 12 ++++++------ SharpCompress/IO/ReadOnlySubStream.cs | 14 +++++++------- SharpCompress/IO/RewindableStream.cs | 10 +++++----- 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/SharpCompress/IO/CountingWritableSubStream.cs b/SharpCompress/IO/CountingWritableSubStream.cs index 3ba15008..ef493445 100644 --- a/SharpCompress/IO/CountingWritableSubStream.cs +++ b/SharpCompress/IO/CountingWritableSubStream.cs @@ -35,28 +35,28 @@ namespace SharpCompress.IO public override long Length { - get { throw new NotImplementedException(); } + get { throw new NotSupportedException(); } } public override long Position { - get { throw new NotImplementedException(); } - set { throw new NotImplementedException(); } + get { throw new NotSupportedException(); } + set { throw new NotSupportedException(); } } public override int Read(byte[] buffer, int offset, int count) { - throw new NotImplementedException(); + throw new NotSupportedException(); } public override long Seek(long offset, SeekOrigin origin) { - throw new NotImplementedException(); + throw new NotSupportedException(); } public override void SetLength(long value) { - throw new NotImplementedException(); + throw new NotSupportedException(); } public override void Write(byte[] buffer, int offset, int count) diff --git a/SharpCompress/IO/MarkingBinaryReader.cs b/SharpCompress/IO/MarkingBinaryReader.cs index 4864309f..a9a5d1be 100644 --- a/SharpCompress/IO/MarkingBinaryReader.cs +++ b/SharpCompress/IO/MarkingBinaryReader.cs @@ -21,17 +21,17 @@ namespace SharpCompress.IO public override int Read() { - throw new NotImplementedException(); + throw new NotSupportedException(); } public override int Read(byte[] buffer, int index, int count) { - throw new NotImplementedException(); + throw new NotSupportedException(); } public override int Read(char[] buffer, int index, int count) { - throw new NotImplementedException(); + throw new NotSupportedException(); } public override bool ReadBoolean() @@ -57,12 +57,12 @@ namespace SharpCompress.IO public override char ReadChar() { - throw new NotImplementedException(); + throw new NotSupportedException(); } public override char[] ReadChars(int count) { - throw new NotImplementedException(); + throw new NotSupportedException(); } #if !PORTABLE @@ -115,7 +115,7 @@ namespace SharpCompress.IO public override string ReadString() { - throw new NotImplementedException(); + throw new NotSupportedException(); } public override ushort ReadUInt16() diff --git a/SharpCompress/IO/ReadOnlySubStream.cs b/SharpCompress/IO/ReadOnlySubStream.cs index 5761fdb7..21b7dd76 100644 --- a/SharpCompress/IO/ReadOnlySubStream.cs +++ b/SharpCompress/IO/ReadOnlySubStream.cs @@ -48,18 +48,18 @@ namespace SharpCompress.IO public override void Flush() { - throw new System.NotImplementedException(); + throw new System.NotSupportedException(); } public override long Length { - get { throw new System.NotImplementedException(); } + get { throw new System.NotSupportedException(); } } public override long Position { - get { throw new System.NotImplementedException(); } - set { throw new System.NotImplementedException(); } + get { throw new System.NotSupportedException(); } + set { throw new System.NotSupportedException(); } } public override int Read(byte[] buffer, int offset, int count) @@ -78,17 +78,17 @@ namespace SharpCompress.IO public override long Seek(long offset, SeekOrigin origin) { - throw new System.NotImplementedException(); + throw new System.NotSupportedException(); } public override void SetLength(long value) { - throw new System.NotImplementedException(); + throw new System.NotSupportedException(); } public override void Write(byte[] buffer, int offset, int count) { - throw new System.NotImplementedException(); + throw new System.NotSupportedException(); } } } \ No newline at end of file diff --git a/SharpCompress/IO/RewindableStream.cs b/SharpCompress/IO/RewindableStream.cs index 6e8fe060..7946eec6 100644 --- a/SharpCompress/IO/RewindableStream.cs +++ b/SharpCompress/IO/RewindableStream.cs @@ -84,12 +84,12 @@ namespace SharpCompress.IO public override void Flush() { - throw new System.NotImplementedException(); + throw new System.NotSupportedException(); } public override long Length { - get { throw new System.NotImplementedException(); } + get { throw new System.NotSupportedException(); } } public override long Position @@ -147,17 +147,17 @@ namespace SharpCompress.IO public override long Seek(long offset, SeekOrigin origin) { - throw new System.NotImplementedException(); + throw new System.NotSupportedException(); } public override void SetLength(long value) { - throw new System.NotImplementedException(); + throw new System.NotSupportedException(); } public override void Write(byte[] buffer, int offset, int count) { - throw new System.NotImplementedException(); + throw new System.NotSupportedException(); } } } \ No newline at end of file