From 816ed947bfe4639798cb4be0c4b75dd12be03a86 Mon Sep 17 00:00:00 2001 From: Edwin Engelen Date: Fri, 23 Jul 2021 14:38:25 +0200 Subject: [PATCH 1/2] Migrate from Portable Class Library to .NET Standard 2.0 --- .../Properties/AssemblyInfo.cs | Bin 1874 -> 218 bytes .../Zlib.Portable.Tests.csproj | 57 +-- src/Zlib.Portable.Tests/ZlibUnitTest1.cs | 357 +++++++++--------- src/Zlib.Portable.Tests/packages.config | 4 - src/Zlib.Portable/Properties/AssemblyInfo.cs | 29 -- src/Zlib.Portable/Zlib.Portable.csproj | 107 +----- 6 files changed, 204 insertions(+), 350 deletions(-) delete mode 100644 src/Zlib.Portable.Tests/packages.config delete mode 100644 src/Zlib.Portable/Properties/AssemblyInfo.cs diff --git a/src/Zlib.Portable.Tests/Properties/AssemblyInfo.cs b/src/Zlib.Portable.Tests/Properties/AssemblyInfo.cs index eec53af8bf9b16d5444091a67d7c8c75e01cf7ee..0b40b3db58bd266bff6635116d60c7a2b5866a15 100644 GIT binary patch literal 218 zcmZ`!I|{-;5bZrhN^JtRT1hIwLb7&}BF3i-%9dtV;!d4D9O za4lR`gD-1b7@biJ>)Ds#&?OlXSj+E{i1fVYd(5e9jrYaTg;9X|G@3Gc#TD!`K63Y% z;y;+IXIL(YDShN1a2_G8k?5TJvm`q4Ho|g+B;z{}wOFg%|J-w$Ag%1yB{i(yuD_?e zYGz97axEIni&TgRY& z7qb}^)6{IcOmQ5_Nc}u^yEtu{Ce2N0r{3#N{U)1=Ug`0^=bl^Vk+Cp`8MO5QAa>PVY%TGAh^3|v#eRpK>aO{V zes-n7ev!>0d{^uNrsA>MeJC pi|_N+S$+af?EWwG%^vPMXW9 - + - Debug - AnyCPU - {047A98B2-BC96-41B4-ADD8-2167FB1B6502} - Library - Properties ZlibTest ZlibTest - v4.5 + net472;net5.0 + ZlibTest + Dino Chiesa + DotNetZip Library + test modules for Ionic's ZLIB + Copyright © 2006-2011 Dino Chiesa. Ported to Portable Class Library by Robert McLaws. + 1.9.1.9000 + 1.9.1.9000 + bin\$(Configuration)\ - true full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 AllRules.ruleset pdbonly - true - bin\Release\ - TRACE - prompt - 4 AllRules.ruleset - bin\Release-Signed\ TRACE true pdbonly - AnyCPU - prompt MinimumRecommendedRules.ruleset true ..\Zlib.Portable.snk - - ..\packages\NUnit.2.6.3\lib\nunit.framework.dll - True - - - - - - - + @@ -62,20 +41,8 @@ Zlib.Portable.snk - - - {ad1688bf-75a9-4c42-b6d0-40aa3b28a102} - Zlib.Portable - + - - \ No newline at end of file diff --git a/src/Zlib.Portable.Tests/ZlibUnitTest1.cs b/src/Zlib.Portable.Tests/ZlibUnitTest1.cs index e6a7a0a..959c1ca 100644 --- a/src/Zlib.Portable.Tests/ZlibUnitTest1.cs +++ b/src/Zlib.Portable.Tests/ZlibUnitTest1.cs @@ -1,23 +1,20 @@ using System; -using System.IO.Compression; -using System.Text; using System.Collections.Generic; -using Ionic.Zlib; using System.IO; -using NUnit.Framework; using System.Reflection; +using NUnit.Framework; namespace Ionic.Zlib.Tests { public class UnitTest1 { System.Random rnd; - Dictionary TestStrings; + Dictionary TestStrings; public UnitTest1() { this.rnd = new System.Random(); - TestStrings = new Dictionary () + TestStrings = new Dictionary() { { "LetMeDoItNow", LetMeDoItNow }, { "GoPlacidly", GoPlacidly }, @@ -40,8 +37,8 @@ public void MyTestInitialize() { string parentDir = GetTestBinDir(); - TopLevelDir = System.IO.Path.Combine( parentDir, String.Format( "Ionic.ZlibTest-{0}.tmp", System.DateTime.Now.ToString( "yyyyMMMdd-HHmmss" ) ) ); - System.IO.Directory.CreateDirectory( TopLevelDir ); + TopLevelDir = System.IO.Path.Combine(parentDir, String.Format("Ionic.ZlibTest-{0}.tmp", System.DateTime.Now.ToString("yyyyMMMdd-HHmmss"))); + System.IO.Directory.CreateDirectory(TopLevelDir); } @@ -49,7 +46,7 @@ public void MyTestInitialize() [TearDown] public void MyTestCleanup() { - System.IO.Directory.Delete( TopLevelDir, true ); + System.IO.Directory.Delete(TopLevelDir, true); } #region Helpers @@ -83,7 +80,7 @@ private static void CopyStream(System.IO.Stream src, System.IO.Stream dest) { byte[] buffer = new byte[1024]; int len = 0; - while ((len=src.Read(buffer, 0, buffer.Length)) > 0) + while ((len = src.Read(buffer, 0, buffer.Length)) > 0) { dest.Write(buffer, 0, len); } @@ -121,28 +118,30 @@ private string GetContentFile(string fileName) public void zlib_Compat_decompress_wi13446() { var zlibbedFile = GetContentFile("zlibbed.file"); - var streamCopy = new Action( (source,dest,bufferSize) => { - var temp = new byte[bufferSize]; - while (true) - { - var read = source.Read(temp, 0, temp.Length); - if (read <= 0) break; - dest.Write(temp, 0, read); - } - }); + var streamCopy = new Action((source, dest, bufferSize) => + { + var temp = new byte[bufferSize]; + while (true) + { + var read = source.Read(temp, 0, temp.Length); + if (read <= 0) break; + dest.Write(temp, 0, read); + } + }); - var unpack = new Action ((bufferSize) => { - using (var output = new MemoryStream()) + var unpack = new Action((bufferSize) => + { + using (var output = new MemoryStream()) + { + using (var input = File.OpenRead(zlibbedFile)) { - using (var input = File.OpenRead(zlibbedFile)) + using (var zinput = new ZlibStream(input, CompressionMode.Decompress)) { - using (var zinput = new ZlibStream(input, CompressionMode.Decompress)) - { - streamCopy(zinput, output, bufferSize); - } + streamCopy(zinput, output, bufferSize); } } - }); + } + }); unpack(1024); unpack(16384); @@ -596,7 +595,7 @@ public void Zlib_ZlibStream_CompressWhileReading_wi8557() // first, compress: msSinkCompressed = new System.IO.MemoryStream(); - ZlibStream zIn= new ZlibStream(StringToMemoryStream(WhatWouldThingsHaveBeenLike), + ZlibStream zIn = new ZlibStream(StringToMemoryStream(WhatWouldThingsHaveBeenLike), CompressionMode.Compress, CompressionLevel.BestCompression, true); @@ -673,7 +672,7 @@ private byte[] InflateBuffer(byte[] b, int length) for (int pass = 0; pass < 2; pass++) { - FlushType flush = (pass==0) + FlushType flush = (pass == 0) ? FlushType.None : FlushType.Finish; do @@ -736,7 +735,7 @@ private byte[] DeflateBuffer(byte[] b, CompressionLevel level) for (int pass = 0; pass < 2; pass++) { - FlushType flush = (pass==0) + FlushType flush = (pass == 0) ? FlushType.None : FlushType.Finish; do @@ -911,7 +910,7 @@ public void Zlib_GZipStream_ByteByByte_CheckCrc() { if (n > 0) { - for (int i=0; i < n; i++) + for (int i = 0; i < n; i++) compressor.WriteByte(buffer[i]); } @@ -938,12 +937,12 @@ public void Zlib_GZipStream_ByteByByte_CheckCrc() { switch (j) { - case 0: - decompressor = new Ionic.Zlib.GZipStream(input, CompressionMode.Decompress, true); - break; - case 1: - decompressor = new System.IO.Compression.GZipStream(input, System.IO.Compression.CompressionMode.Decompress, true); - break; + case 0: + decompressor = new Ionic.Zlib.GZipStream(input, CompressionMode.Decompress, true); + break; + case 1: + decompressor = new System.IO.Compression.GZipStream(input, System.IO.Compression.CompressionMode.Decompress, true); + break; } string DecompressedFile = @@ -970,7 +969,7 @@ public void Zlib_GZipStream_ByteByByte_CheckCrc() { if (decompressor as Ionic.Zlib.GZipStream != null) { - var gz = (Ionic.Zlib.GZipStream) decompressor; + var gz = (Ionic.Zlib.GZipStream)decompressor; gz.Close(); // sets the final CRC Assert.AreEqual(gz.Crc32, crc1); } @@ -1007,7 +1006,7 @@ private void _DecompressEmptyStream(Type t) using (MemoryStream ms1 = new MemoryStream()) { Object[] args = { ms1, CompressionMode.Decompress, false }; - using (Stream decompressor = (Stream) Activator.CreateInstance(t, args)) + using (Stream decompressor = (Stream)Activator.CreateInstance(t, args)) { using (MemoryStream ms2 = new MemoryStream()) { @@ -1021,7 +1020,7 @@ private void _DecompressEmptyStream(Type t) // we know there is no more data. Want to insure it does // not throw. - if (m==1) + if (m == 1) n = decompressor.Read(working, 0, working.Length); @@ -1045,9 +1044,9 @@ public void Zlib_DeflateStream_InMemory() CompressionLevel.BestCompression}; // compress with various Ionic levels, and System.IO.Compression (default level) - for (int k= 0; k < levels.Length + 1; k++) + for (int k = 0; k < levels.Length + 1; k++) { - MemoryStream ms= new MemoryStream(); + MemoryStream ms = new MemoryStream(); Stream compressor = null; if (k == levels.Length) @@ -1078,12 +1077,12 @@ public void Zlib_DeflateStream_InMemory() switch (j) { - case 0: - decompressor = new Ionic.Zlib.DeflateStream(slow, CompressionMode.Decompress, false); - break; - case 1: - decompressor = new System.IO.Compression.DeflateStream(slow, System.IO.Compression.CompressionMode.Decompress, false); - break; + case 0: + decompressor = new Ionic.Zlib.DeflateStream(slow, CompressionMode.Decompress, false); + break; + case 1: + decompressor = new System.IO.Compression.DeflateStream(slow, System.IO.Compression.CompressionMode.Decompress, false); + break; } Console.WriteLine("using decompressor: {0}", decompressor.GetType().FullName); @@ -1107,20 +1106,20 @@ public void Zlib_CloseTwice() for (int i = 0; i < 3; i++) { - MemoryStream ms1= new MemoryStream(); + MemoryStream ms1 = new MemoryStream(); Stream compressor = null; switch (i) { - case 0: - compressor= new DeflateStream(ms1, CompressionMode.Compress, CompressionLevel.BestCompression, false); - break; - case 1: - compressor = new GZipStream(ms1, CompressionMode.Compress, false); - break; - case 2: - compressor = new ZlibStream(ms1, CompressionMode.Compress, false); - break; + case 0: + compressor = new DeflateStream(ms1, CompressionMode.Compress, CompressionLevel.BestCompression, false); + break; + case 1: + compressor = new GZipStream(ms1, CompressionMode.Compress, false); + break; + case 2: + compressor = new ZlibStream(ms1, CompressionMode.Compress, false); + break; } Console.WriteLine("Text to compress is {0} bytes: '{1}'", @@ -1141,15 +1140,15 @@ public void Zlib_CloseTwice() switch (i) { - case 0: - decompressor = new DeflateStream(ms2, CompressionMode.Decompress, false); - break; - case 1: - decompressor = new GZipStream(ms2, CompressionMode.Decompress, false); - break; - case 2: - decompressor = new ZlibStream(ms2, CompressionMode.Decompress, false); - break; + case 0: + decompressor = new DeflateStream(ms2, CompressionMode.Decompress, false); + break; + case 1: + decompressor = new GZipStream(ms2, CompressionMode.Decompress, false); + break; + case 2: + decompressor = new ZlibStream(ms2, CompressionMode.Decompress, false); + break; } Console.WriteLine("using decompressor: {0}", decompressor.GetType().FullName); @@ -1170,17 +1169,18 @@ public void Zlib_CloseTwice() [Test] - [ExpectedException(typeof(System.ObjectDisposedException))] public void Zlib_DisposedException_DeflateStream() { - string TextToCompress = LetMeDoItNow; + Assert.Throws(() => + { + string TextToCompress = LetMeDoItNow; - MemoryStream ms1= new MemoryStream(); + MemoryStream ms1 = new MemoryStream(); - Stream compressor= new DeflateStream(ms1, CompressionMode.Compress, false); + Stream compressor = new DeflateStream(ms1, CompressionMode.Compress, false); Console.WriteLine("Text to compress is {0} bytes: '{1}'", - TextToCompress.Length, TextToCompress); + TextToCompress.Length, TextToCompress); Console.WriteLine("using compressor: {0}", compressor.GetType().FullName); StreamWriter sw = new StreamWriter(compressor, System.Text.Encoding.ASCII); @@ -1193,7 +1193,7 @@ public void Zlib_DisposedException_DeflateStream() Console.WriteLine("Compressed stream is {0} bytes long", a.Length); var ms2 = new MemoryStream(a); - Stream decompressor = new DeflateStream(ms2, CompressionMode.Decompress, false); + Stream decompressor = new DeflateStream(ms2, CompressionMode.Decompress, false); Console.WriteLine("using decompressor: {0}", decompressor.GetType().FullName); @@ -1201,92 +1201,96 @@ public void Zlib_DisposedException_DeflateStream() string DecompressedText = sr.ReadToEnd(); sr.Close(); - Console.WriteLine("decompressor.CanRead = {0}",decompressor.CanRead); + Console.WriteLine("decompressor.CanRead = {0}", decompressor.CanRead); Console.WriteLine("Read {0} characters: '{1}'", DecompressedText.Length, DecompressedText); Console.WriteLine("\n"); Assert.AreEqual(TextToCompress, DecompressedText); - + }); } [Test] - [ExpectedException(typeof(System.ObjectDisposedException))] public void Zlib_DisposedException_GZipStream() { - string TextToCompress = IhaveaDream; + Assert.Throws(() => + { + string TextToCompress = IhaveaDream; - MemoryStream ms1= new MemoryStream(); + MemoryStream ms1 = new MemoryStream(); - Stream compressor= new GZipStream(ms1, CompressionMode.Compress, false); + Stream compressor = new GZipStream(ms1, CompressionMode.Compress, false); - Console.WriteLine("Text to compress is {0} bytes: '{1}'", - TextToCompress.Length, TextToCompress); - Console.WriteLine("using compressor: {0}", compressor.GetType().FullName); + Console.WriteLine("Text to compress is {0} bytes: '{1}'", + TextToCompress.Length, TextToCompress); + Console.WriteLine("using compressor: {0}", compressor.GetType().FullName); - StreamWriter sw = new StreamWriter(compressor, System.Text.Encoding.ASCII); - sw.Write(TextToCompress); - sw.Close(); // implicitly closes compressor - sw.Close(); // implicitly closes compressor, again + StreamWriter sw = new StreamWriter(compressor, System.Text.Encoding.ASCII); + sw.Write(TextToCompress); + sw.Close(); // implicitly closes compressor + sw.Close(); // implicitly closes compressor, again - compressor.Close(); // explicitly closes compressor - var a = ms1.ToArray(); - Console.WriteLine("Compressed stream is {0} bytes long", a.Length); + compressor.Close(); // explicitly closes compressor + var a = ms1.ToArray(); + Console.WriteLine("Compressed stream is {0} bytes long", a.Length); - var ms2 = new MemoryStream(a); - Stream decompressor = new GZipStream(ms2, CompressionMode.Decompress, false); + var ms2 = new MemoryStream(a); + Stream decompressor = new GZipStream(ms2, CompressionMode.Decompress, false); - Console.WriteLine("using decompressor: {0}", decompressor.GetType().FullName); + Console.WriteLine("using decompressor: {0}", decompressor.GetType().FullName); - var sr = new StreamReader(decompressor, System.Text.Encoding.ASCII); - string DecompressedText = sr.ReadToEnd(); - sr.Close(); + var sr = new StreamReader(decompressor, System.Text.Encoding.ASCII); + string DecompressedText = sr.ReadToEnd(); + sr.Close(); - Console.WriteLine("decompressor.CanRead = {0}",decompressor.CanRead); + Console.WriteLine("decompressor.CanRead = {0}", decompressor.CanRead); - Console.WriteLine("Read {0} characters: '{1}'", DecompressedText.Length, DecompressedText); - Console.WriteLine("\n"); - Assert.AreEqual(TextToCompress, DecompressedText); + Console.WriteLine("Read {0} characters: '{1}'", DecompressedText.Length, DecompressedText); + Console.WriteLine("\n"); + Assert.AreEqual(TextToCompress, DecompressedText); + }); } [Test] - [ExpectedException(typeof(System.ObjectDisposedException))] public void Zlib_DisposedException_ZlibStream() { - string TextToCompress = IhaveaDream; + Assert.Throws(() => + { + string TextToCompress = IhaveaDream; - MemoryStream ms1= new MemoryStream(); + MemoryStream ms1 = new MemoryStream(); - Stream compressor= new ZlibStream(ms1, CompressionMode.Compress, false); + Stream compressor = new ZlibStream(ms1, CompressionMode.Compress, false); - Console.WriteLine("Text to compress is {0} bytes: '{1}'", - TextToCompress.Length, TextToCompress); - Console.WriteLine("using compressor: {0}", compressor.GetType().FullName); + Console.WriteLine("Text to compress is {0} bytes: '{1}'", + TextToCompress.Length, TextToCompress); + Console.WriteLine("using compressor: {0}", compressor.GetType().FullName); - StreamWriter sw = new StreamWriter(compressor, System.Text.Encoding.ASCII); - sw.Write(TextToCompress); - sw.Close(); // implicitly closes compressor - sw.Close(); // implicitly closes compressor, again + StreamWriter sw = new StreamWriter(compressor, System.Text.Encoding.ASCII); + sw.Write(TextToCompress); + sw.Close(); // implicitly closes compressor + sw.Close(); // implicitly closes compressor, again - compressor.Close(); // explicitly closes compressor - var a = ms1.ToArray(); - Console.WriteLine("Compressed stream is {0} bytes long", a.Length); + compressor.Close(); // explicitly closes compressor + var a = ms1.ToArray(); + Console.WriteLine("Compressed stream is {0} bytes long", a.Length); - var ms2 = new MemoryStream(a); - Stream decompressor = new ZlibStream(ms2, CompressionMode.Decompress, false); + var ms2 = new MemoryStream(a); + Stream decompressor = new ZlibStream(ms2, CompressionMode.Decompress, false); - Console.WriteLine("using decompressor: {0}", decompressor.GetType().FullName); + Console.WriteLine("using decompressor: {0}", decompressor.GetType().FullName); - var sr = new StreamReader(decompressor, System.Text.Encoding.ASCII); - string DecompressedText = sr.ReadToEnd(); - sr.Close(); + var sr = new StreamReader(decompressor, System.Text.Encoding.ASCII); + string DecompressedText = sr.ReadToEnd(); + sr.Close(); - Console.WriteLine("decompressor.CanRead = {0}",decompressor.CanRead); + Console.WriteLine("decompressor.CanRead = {0}", decompressor.CanRead); - Console.WriteLine("Read {0} characters: '{1}'", DecompressedText.Length, DecompressedText); - Console.WriteLine("\n"); - Assert.AreEqual(TextToCompress, DecompressedText); + Console.WriteLine("Read {0} characters: '{1}'", DecompressedText.Length, DecompressedText); + Console.WriteLine("\n"); + Assert.AreEqual(TextToCompress, DecompressedText); + }); } @@ -1473,7 +1477,7 @@ private void PerformTrialWi8870(byte[] buffer) Console.WriteLine("Compressed {0} bytes into {1} bytes", buffer.Length, compressedBytes.Length); - byte[] decompressed= null; + byte[] decompressed = null; using (MemoryStream ms2 = new MemoryStream()) { using (var deflateStream = new DeflateStream(ms2, CompressionMode.Decompress, false)) @@ -1494,7 +1498,7 @@ private void PerformTrialWi8870(byte[] buffer) } else { - for (int i=0; i < buffer.Length; i++) + for (int i = 0; i < buffer.Length; i++) { if (buffer[i] != decompressed[i]) { @@ -1505,7 +1509,7 @@ private void PerformTrialWi8870(byte[] buffer) } } - Assert.IsTrue(check,"Data check failed."); + Assert.IsTrue(check, "Data check failed."); } @@ -1514,9 +1518,9 @@ private void PerformTrialWi8870(byte[] buffer) private byte[] RandomizeBuffer(int length) { byte[] buffer = new byte[length]; - int mod1 = 86 + this.rnd.Next(46)/2 + 1; - int mod2 = 50 + this.rnd.Next(72)/2 + 1; - for (int i=0; i < length; i++) + int mod1 = 86 + this.rnd.Next(46) / 2 + 1; + int mod2 = 50 + this.rnd.Next(72) / 2 + 1; + for (int i = 0; i < length; i++) { if (i > 200) buffer[i] = (byte)(i % mod1); @@ -1524,7 +1528,7 @@ private byte[] RandomizeBuffer(int length) buffer[i] = (byte)(i % mod2); else if (i > 42) buffer[i] = (byte)(i % 33); - else buffer[i]= (byte)i; + else buffer[i] = (byte)i; } return buffer; } @@ -1536,7 +1540,7 @@ public void Zlib_DeflateStream_wi8870() { for (int j = 0; j < 1000; j++) { - byte[] buffer = RandomizeBuffer(117+(this.rnd.Next(3)*100)); + byte[] buffer = RandomizeBuffer(117 + (this.rnd.Next(3) * 100)); PerformTrialWi8870(buffer); } } @@ -1551,18 +1555,18 @@ public void Zlib_ParallelDeflateStream() sw.Start(); Console.WriteLine("{0}: Zlib_ParallelDeflateStream Start", sw.Elapsed); - int sz = 256*1024 + this.rnd.Next(120000); + int sz = 256 * 1024 + this.rnd.Next(120000); string FileToCompress = System.IO.Path.Combine(TopLevelDir, String.Format("Zlib_ParallelDeflateStream.{0}.txt", sz)); - CreateAndFillFileText( FileToCompress, sz); + CreateAndFillFileText(FileToCompress, sz); - Console.WriteLine("{0}: Created file: {1}", sw.Elapsed, FileToCompress ); + Console.WriteLine("{0}: Created file: {1}", sw.Elapsed, FileToCompress); byte[] original = File.ReadAllBytes(FileToCompress); int crc1 = DoCrc(FileToCompress); - Console.WriteLine("{0}: Original CRC: {1:X8}", sw.Elapsed, crc1 ); + Console.WriteLine("{0}: Original CRC: {1:X8}", sw.Elapsed, crc1); byte[] working = new byte[WORKING_BUFFER_SIZE]; int n = -1; @@ -1587,8 +1591,8 @@ public void Zlib_ParallelDeflateStream() originalLength, ms1.Length); var crc = new Ionic.Crc.CRC32(); - int crc2= 0; - byte[] decompressedBytes= null; + int crc2 = 0; + byte[] decompressedBytes = null; using (MemoryStream ms2 = new MemoryStream()) { using (var decompressor = new DeflateStream(ms1, CompressionMode.Decompress, false)) @@ -1603,11 +1607,11 @@ public void Zlib_ParallelDeflateStream() ms2.Seek(0, SeekOrigin.Begin); crc2 = crc.GetCrc32(ms2); decompressedBytes = ms2.ToArray(); - Console.WriteLine("{0}: Decompressed CRC: {1:X8}", sw.Elapsed, crc2 ); + Console.WriteLine("{0}: Decompressed CRC: {1:X8}", sw.Elapsed, crc2); } - Console.WriteLine("{0}: Checking...", sw.Elapsed ); + Console.WriteLine("{0}: Checking...", sw.Elapsed); bool check = true; if (originalLength != decompressedBytes.Length) @@ -1628,20 +1632,20 @@ public void Zlib_ParallelDeflateStream() } } - Assert.IsTrue(check,"Data check failed"); - Console.WriteLine("{0}: Done...", sw.Elapsed ); + Assert.IsTrue(check, "Data check failed"); + Console.WriteLine("{0}: Done...", sw.Elapsed); } - + private int DoCrc(string filename) { using (Stream a = File.OpenRead(filename)) - using (var crc = new Ionic.Crc.CrcCalculatorStream(a)) + using (var crc = new Ionic.Crc.CrcCalculatorStream(a)) { - byte[] working = new byte[WORKING_BUFFER_SIZE]; - int n = -1; - while (n != 0) - n = crc.Read(working, 0, working.Length); - return crc.Crc; + byte[] working = new byte[WORKING_BUFFER_SIZE]; + int n = -1; + while (n != 0) + n = crc.Read(working, 0, working.Length); + return crc.Crc; } } @@ -1705,17 +1709,18 @@ public void TestAdler32() }; uint goal = 4104380882; - var testAdler = new Action( chunk => { - var index = 0; - var adler = Adler.Adler32(0, null, 0, 0); - while (index < buffer.Length) - { - var length = Math.Min(buffer.Length - index, chunk); - adler = Adler.Adler32(adler, buffer, index, length); - index = index + chunk; - } - Assert.AreEqual(adler, goal); - }); + var testAdler = new Action(chunk => + { + var index = 0; + var adler = Adler.Adler32(0, null, 0, 0); + while (index < buffer.Length) + { + var length = Math.Min(buffer.Length - index, chunk); + adler = Adler.Adler32(adler, buffer, index, length); + index = index + chunk; + } + Assert.AreEqual(adler, goal); + }); testAdler(3979); testAdler(3980); @@ -1841,28 +1846,28 @@ I have a dream today! } - public class MySlowMemoryStream : MemoryStream - { - // ctor - public MySlowMemoryStream(byte[] bytes) : base(bytes, false) {} + public class MySlowMemoryStream : MemoryStream + { + // ctor + public MySlowMemoryStream(byte[] bytes) : base(bytes, false) { } - public override int Read(byte[] buffer, int offset, int count) - { - if (count < 0) - throw new ArgumentOutOfRangeException(); + public override int Read(byte[] buffer, int offset, int count) + { + if (count < 0) + throw new ArgumentOutOfRangeException(); - if (count == 0) - return 0; + if (count == 0) + return 0; - // force stream to read just one byte at a time - int NextByte = base.ReadByte(); - if (NextByte == -1) - return 0; + // force stream to read just one byte at a time + int NextByte = base.ReadByte(); + if (NextByte == -1) + return 0; - buffer[offset] = (byte) NextByte; - return 1; - } + buffer[offset] = (byte)NextByte; + return 1; } + } diff --git a/src/Zlib.Portable.Tests/packages.config b/src/Zlib.Portable.Tests/packages.config deleted file mode 100644 index 967502d..0000000 --- a/src/Zlib.Portable.Tests/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/src/Zlib.Portable/Properties/AssemblyInfo.cs b/src/Zlib.Portable/Properties/AssemblyInfo.cs deleted file mode 100644 index fac51f3..0000000 --- a/src/Zlib.Portable/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,29 +0,0 @@ -using System.Resources; -using System.Reflection; -using System.Runtime.CompilerServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("Zlib.Portable")] -[assembly: AssemblyDescription("Library for Deflate and ZLIB compression. http://www.codeplex.com/DotNetZip")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("Dino Chiesa")] -[assembly: AssemblyProduct("DotNetZip Library")] -[assembly: AssemblyCopyright("Copyright © 2006-2011 Dino Chiesa. Ported by Robert McLaws.")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] -[assembly: NeutralResourcesLanguage("en")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.11.0.0")] -[assembly: AssemblyFileVersion("1.11.0.0")] diff --git a/src/Zlib.Portable/Zlib.Portable.csproj b/src/Zlib.Portable/Zlib.Portable.csproj index 8111fff..aea67bf 100644 --- a/src/Zlib.Portable/Zlib.Portable.csproj +++ b/src/Zlib.Portable/Zlib.Portable.csproj @@ -1,113 +1,28 @@ - - - + - 10.0 - Debug - AnyCPU - {AD1688BF-75A9-4C42-B6D0-40AA3B28A102} - Library - Properties Ionic.Zlib - Zlib.Portable - v4.0 - Profile328 - 512 - {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - - - - - 4.0 - publish\ - true - Disk - false - Foreground - 7 - Days - false - false - true - 0 - 1.0.0.%2a - false - false - true - - - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - bin\Debug\Zlib.Portable.xml - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - bin\Release\Zlib.Portable.xml + netstandard2.0 + Zlib.Portable + Dino Chiesa + DotNetZip Library + en + Library for Deflate and ZLIB compression. http://www.codeplex.com/DotNetZip + Copyright © 2006-2011 Dino Chiesa. Ported by Robert McLaws. + 1.11.0.0 + 1.11.0.0 + bin\$(Configuration)\Zlib.Portable.xml - bin\Release-Signed\ TRACE;SIGNED - bin\Release-Signed\Zlib.Portable.xml true pdbonly - AnyCPU - prompt MinimumRecommendedRules.ruleset ..\Zlib.Portable.snk true - - - - False - .NET Framework 3.5 SP1 Client Profile - false - - - False - .NET Framework 3.5 SP1 - false - - - - - - - - - - - - - - - - - - - - Zlib.Portable.snk - - \ No newline at end of file From 95d4f0f1ab1006b6afc3c314e8a200f4eb223443 Mon Sep 17 00:00:00 2001 From: Edwin Engelen Date: Fri, 23 Jul 2021 14:39:56 +0200 Subject: [PATCH 2/2] Bump to version 1.12.0.0 --- src/Zlib.Portable.Tests/Zlib.Portable.Tests.csproj | 4 ++-- src/Zlib.Portable/Zlib.Portable.csproj | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Zlib.Portable.Tests/Zlib.Portable.Tests.csproj b/src/Zlib.Portable.Tests/Zlib.Portable.Tests.csproj index 9739993..ef9a3d1 100644 --- a/src/Zlib.Portable.Tests/Zlib.Portable.Tests.csproj +++ b/src/Zlib.Portable.Tests/Zlib.Portable.Tests.csproj @@ -9,8 +9,8 @@ DotNetZip Library test modules for Ionic's ZLIB Copyright © 2006-2011 Dino Chiesa. Ported to Portable Class Library by Robert McLaws. - 1.9.1.9000 - 1.9.1.9000 + 1.12.0.0 + 1.12.0.0 bin\$(Configuration)\ diff --git a/src/Zlib.Portable/Zlib.Portable.csproj b/src/Zlib.Portable/Zlib.Portable.csproj index aea67bf..eaf9798 100644 --- a/src/Zlib.Portable/Zlib.Portable.csproj +++ b/src/Zlib.Portable/Zlib.Portable.csproj @@ -8,8 +8,8 @@ en Library for Deflate and ZLIB compression. http://www.codeplex.com/DotNetZip Copyright © 2006-2011 Dino Chiesa. Ported by Robert McLaws. - 1.11.0.0 - 1.11.0.0 + 1.12.0.0 + 1.12.0.0 bin\$(Configuration)\Zlib.Portable.xml