Skip to content

Commit c22e759

Browse files
committed
Cleanup
* Remove all backwards compatible code and preprocessor statements * Renamed StrangeCrc.cs to BZip2Crc.cs
1 parent ef11927 commit c22e759

39 files changed

Lines changed: 61 additions & 487 deletions

ICSharpCode.SharpZipLib/AssemblyInfo.cs

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -36,36 +36,12 @@
3636
using System;
3737
using System.Reflection;
3838

39-
// Version name | Version number | Release date
40-
// 1.0 RTM | 1.0.2268.0 | 2002 late
41-
// 1.0 SP1 | 1.0.3111.0 | 2003
42-
// 1.0 SP2 | 1.0.3316.0 | unknown
43-
// 1.0 SP3 | 1.0.4292.0 | 2005 January
44-
// 2.0 RTM | 2.0.5238.0 | 2005 October
45-
// 2.0 SP1 | 2.0.6129.0 | 2006 June
46-
// 2.0 SP2 | 2.0.7045.0 | 2007 March
47-
48-
#if (NET_1_0)
49-
[assembly: AssemblyTitle("SharpZipLib for .NET Framework 1.0")]
50-
#elif (NET_1_1)
51-
[assembly: AssemblyTitle("SharpZipLib for .NET Framework 1.1")]
52-
#elif (NETCF_1_0)
53-
[assembly: AssemblyTitle("SharpZipLib for .NET Compact Framework 1.0")]
54-
#elif (NETCF_2_0)
55-
[assembly: AssemblyTitle("SharpZipLib for .NET Compact Framework 2.0")]
56-
#else
5739
[assembly: AssemblyTitle("SharpZipLib")]
58-
#endif
59-
6040
[assembly: AssemblyDescription("A free C# compression library")]
6141
[assembly: AssemblyDefaultAlias("ICSharpCode.SharpZipLib")]
6242
[assembly: AssemblyCulture("")]
6343

6444
[assembly: CLSCompliant(true)]
6545

66-
#if (!NETCF)
67-
//
68-
// If #Zip is strongly named it still allows partially trusted callers
69-
//
46+
// If SharpZipLib is strongly named it still allows partially trusted callers
7047
[assembly: System.Security.AllowPartiallyTrustedCallers]
71-
#endif

ICSharpCode.SharpZipLib/BZip2/BZip2.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,6 @@
3333
// obligated to do so. If you do not wish to do so, delete this
3434
// exception statement from your version.
3535

36-
// Suppress this in CF and 1.1, not needed. Static classes introduced in C# version 2.0
37-
#if !NETCF_2_0 && !NET_1_1
38-
3936
using System;
4037
using System.IO;
4138

@@ -102,4 +99,3 @@ public static void Compress(Stream inStream, Stream outStream, bool isStreamOwne
10299

103100
}
104101
}
105-
#endif

ICSharpCode.SharpZipLib/BZip2/BZip2Exception.cs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// BZip2.cs
1+
// BZip2Exception.cs
22
//
33
// Copyright © 2000-2016 AlphaSierraPapa for the SharpZipLib Team
44
//
@@ -34,23 +34,17 @@
3434
// exception statement from your version.
3535

3636
using System;
37-
38-
#if !NETCF_1_0 && !NETCF_2_0
3937
using System.Runtime.Serialization;
40-
#endif
4138

4239
namespace ICSharpCode.SharpZipLib.BZip2
4340
{
4441
/// <summary>
4542
/// BZip2Exception represents exceptions specific to Bzip2 algorithm
4643
/// </summary>
47-
#if !NETCF_1_0 && !NETCF_2_0
4844
[Serializable]
49-
#endif
5045
public class BZip2Exception : SharpZipBaseException
5146
{
5247

53-
#if !NETCF_1_0 && !NETCF_2_0
5448
/// <summary>
5549
/// Deserialization constructor
5650
/// </summary>
@@ -61,7 +55,6 @@ protected BZip2Exception(SerializationInfo info, StreamingContext context)
6155

6256
{
6357
}
64-
#endif
6558
/// <summary>
6659
/// Initialise a new instance of BZip2Exception.
6760
/// </summary>

ICSharpCode.SharpZipLib/BZip2/BZip2InputStream.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -913,7 +913,7 @@ The current block size is 100000 * this number.
913913

914914
int bsBuff;
915915
int bsLive;
916-
IChecksum mCrc = new StrangeCRC();
916+
IChecksum mCrc = new BZip2Crc();
917917

918918
bool[] inUse = new bool[256];
919919
int nInUse;

ICSharpCode.SharpZipLib/BZip2/BZip2OutputStream.cs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -377,16 +377,10 @@ public int BytesWritten
377377
/// Releases the unmanaged resources used by the <see cref="BZip2OutputStream"/> and optionally releases the managed resources.
378378
/// </summary>
379379
/// <param name="disposing">true to release both managed and unmanaged resources; false to release only unmanaged resources.</param>
380-
#if NET_1_0 || NET_1_1 || NETCF_1_0
381-
protected virtual void Dispose(bool disposing)
382-
#else
383380
override protected void Dispose(bool disposing)
384-
#endif
385381
{
386382
try {
387-
#if !NET_1_0 && !NET_1_1 && !NETCF_1_0
388383
base.Dispose(disposing);
389-
#endif
390384
if( !disposed_ ) {
391385
disposed_=true;
392386

@@ -1829,7 +1823,7 @@ The current block size is 100000 * this number.
18291823
int bytesOut;
18301824
int bsBuff;
18311825
int bsLive;
1832-
IChecksum mCrc = new StrangeCRC();
1826+
IChecksum mCrc = new BZip2Crc();
18331827

18341828
bool[] inUse = new bool[256];
18351829
int nInUse;

ICSharpCode.SharpZipLib/Checksums/Adler32.cs

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -172,38 +172,22 @@ public void Update(byte[] buffer, int offset, int count)
172172
}
173173

174174
if (offset < 0) {
175-
#if NETCF_1_0
176-
throw new ArgumentOutOfRangeException("offset");
177-
#else
178175
throw new ArgumentOutOfRangeException(nameof(offset), "cannot be negative");
179-
#endif
180176
}
181177

182178
if ( count < 0 )
183179
{
184-
#if NETCF_1_0
185-
throw new ArgumentOutOfRangeException("count");
186-
#else
187180
throw new ArgumentOutOfRangeException(nameof(count), "cannot be negative");
188-
#endif
189181
}
190182

191183
if (offset >= buffer.Length)
192184
{
193-
#if NETCF_1_0
194-
throw new ArgumentOutOfRangeException("offset");
195-
#else
196185
throw new ArgumentOutOfRangeException(nameof(offset), "not a valid index into buffer");
197-
#endif
198186
}
199187

200188
if (offset + count > buffer.Length)
201189
{
202-
#if NETCF_1_0
203-
throw new ArgumentOutOfRangeException("count");
204-
#else
205190
throw new ArgumentOutOfRangeException(nameof(count), "exceeds buffer size");
206-
#endif
207191
}
208192

209193
//(By Per Bothner)

ICSharpCode.SharpZipLib/Checksums/StrangeCrc.cs renamed to ICSharpCode.SharpZipLib/Checksums/BZip2Crc.cs

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// StrangeCRC.cs - computes a crc used in the bziplib
1+
// BZip2Crc.cs - computes a crc used in the bzip2lib
22
//
33
// Copyright © 2000-2016 AlphaSierraPapa for the SharpZipLib Team
44
//
@@ -43,7 +43,7 @@ namespace ICSharpCode.SharpZipLib.Checksums
4343
/// <summary>
4444
/// Bzip2 checksum algorithm
4545
/// </summary>
46-
public class StrangeCRC : IChecksum
46+
public class BZip2Crc : IChecksum
4747
{
4848
readonly static uint[] crc32Table = {
4949
0x00000000, 0x04c11db7, 0x09823b6e, 0x0d4326d9,
@@ -115,9 +115,9 @@ public class StrangeCRC : IChecksum
115115
int globalCrc;
116116

117117
/// <summary>
118-
/// Initialise a default instance of <see cref="StrangeCRC"></see>
118+
/// Initialise a default instance of <see cref="BZip2Crc"></see>
119119
/// </summary>
120-
public StrangeCRC()
120+
public BZip2Crc()
121121
{
122122
Reset();
123123
}
@@ -179,20 +179,12 @@ public void Update(byte[] buffer, int offset, int count)
179179

180180
if ( offset < 0 )
181181
{
182-
#if NETCF_1_0
183-
throw new ArgumentOutOfRangeException("offset");
184-
#else
185182
throw new ArgumentOutOfRangeException(nameof(offset), "cannot be less than zero");
186-
#endif
187183
}
188184

189185
if ( count < 0 )
190186
{
191-
#if NETCF_1_0
192-
throw new ArgumentOutOfRangeException("count");
193-
#else
194187
throw new ArgumentOutOfRangeException(nameof(count), "cannot be less than zero");
195-
#endif
196188
}
197189

198190
if ( offset + count > buffer.Length )

ICSharpCode.SharpZipLib/Checksums/Crc32.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -200,11 +200,7 @@ public void Update(byte[] buffer, int offset, int count)
200200
}
201201

202202
if ( count < 0 ) {
203-
#if NETCF_1_0
204-
throw new ArgumentOutOfRangeException("count");
205-
#else
206203
throw new ArgumentOutOfRangeException(nameof(count), "Count cannot be less than zero");
207-
#endif
208204
}
209205

210206
if (offset < 0 || offset + count > buffer.Length) {

ICSharpCode.SharpZipLib/Core/NameFilter.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,11 +152,7 @@ public static string[] SplitQuoted(string original)
152152
else if (original[endIndex] == escape) {
153153
endIndex += 1;
154154
if (endIndex >= original.Length) {
155-
#if NETCF_1_0
156-
throw new ArgumentException("Missing terminating escape character");
157-
#else
158155
throw new ArgumentException("Missing terminating escape character", nameof(original));
159-
#endif
160156
}
161157
// include escape if this is not an escaped separator
162158
if (Array.IndexOf(separators, original[endIndex]) < 0)

ICSharpCode.SharpZipLib/Core/PathFilter.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -212,11 +212,7 @@ public DateTime MinDate
212212
set
213213
{
214214
if ( value > maxDate_ ) {
215-
#if NETCF_1_0
216-
throw new ArgumentOutOfRangeException("value");
217-
#else
218215
throw new ArgumentOutOfRangeException(nameof(value), "Exceeds MaxDate");
219-
#endif
220216
}
221217

222218
minDate_ = value;
@@ -237,11 +233,7 @@ public DateTime MaxDate
237233
set
238234
{
239235
if ( minDate_ > value ) {
240-
#if NETCF_1_0
241-
throw new ArgumentOutOfRangeException("value");
242-
#else
243236
throw new ArgumentOutOfRangeException(nameof(value), "Exceeds MinDate");
244-
#endif
245237
}
246238

247239
maxDate_ = value;

0 commit comments

Comments
 (0)