[
  {
    "Id": "237047",
    "ThreadId": "69640",
    "Html": "<p>I've been working on using your ZLib DLL inside MS SQL Server so that I can use it in a CLR SP.&nbsp; SQL Server has some special requirements for SAFE/EXTERNAL assemblies.&nbsp; The only one that is a problem here is the use of non-readonly static variables.&nbsp; Luckily readonly appears to be compatible with all uses of static variables in Zlib.&nbsp; So here is a patch to implement that.&nbsp; The unit tests pass and my limited testing indicates that everything works OK.</p>\r\n<p>\r\n<pre>diff -u -r DotNetZip-1.8.4.23/ZLib/Crc32.cs DotNetZip-dev/ZLib/Crc32.cs\r\n--- DotNetZip-1.8.4.23/ZLib/Crc32.cs\t2009-08-18 21:04:20.000000000 -0500\r\n+++ DotNetZip-dev/ZLib/Crc32.cs\t2009-09-16 16:39:50.514842500 -0500\r\n@@ -197,7 +197,7 @@\r\n \r\n         // private member vars\r\n         private Int64 _TotalBytesRead;\r\n-        private static UInt32[] crc32Table;\r\n+        private static readonly UInt32[] crc32Table;\r\n         private const int BUFFER_SIZE = 8192;\r\n         private UInt32 _RunningCrc32Result = 0xFFFFFFFF;\r\n \r\ndiff -u -r DotNetZip-1.8.4.23/ZLib/Deflate.cs DotNetZip-dev/ZLib/Deflate.cs\r\n--- DotNetZip-1.8.4.23/ZLib/Deflate.cs\t2009-08-19 18:25:04.000000000 -0500\r\n+++ DotNetZip-dev/ZLib/Deflate.cs\t2009-09-21 10:34:14.384813900 -0500\r\n@@ -189,7 +189,7 @@\r\n                 };\r\n             }\r\n \r\n-            private static Config[] Table;\r\n+            private static readonly Config[] Table;\r\n         }\r\n \r\n \r\ndiff -u -r DotNetZip-1.8.4.23/ZLib/GZipStream.cs DotNetZip-dev/ZLib/GZipStream.cs\r\n--- DotNetZip-1.8.4.23/ZLib/GZipStream.cs\t2009-08-12 15:35:30.000000000 -0500\r\n+++ DotNetZip-dev/ZLib/GZipStream.cs\t2009-09-16 16:39:50.366827700 -0500\r\n@@ -774,8 +774,8 @@\r\n         #endregion\r\n \r\n \r\n-        internal static System.DateTime _unixEpoch = new System.DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);\r\n-        internal static System.Text.Encoding iso8859dash1 = System.Text.Encoding.GetEncoding(&quot;iso-8859-1&quot;);\r\n+        internal static readonly System.DateTime _unixEpoch = new System.DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);\r\n+        internal static readonly System.Text.Encoding iso8859dash1 = System.Text.Encoding.GetEncoding(&quot;iso-8859-1&quot;);\r\n \r\n \r\n         private int EmitHeader()\r\ndiff -u -r DotNetZip-1.8.4.23/ZLib/Inflate.cs DotNetZip-dev/ZLib/Inflate.cs\r\n--- DotNetZip-1.8.4.23/ZLib/Inflate.cs\t2009-05-31 09:15:22.000000000 -0500\r\n+++ DotNetZip-dev/ZLib/Inflate.cs\t2009-09-16 16:39:50.453836400 -0500\r\n@@ -1756,7 +1756,7 @@\r\n             return ZlibConstants.Z_OK;\r\n         }\r\n \r\n-        private static byte[] mark = new byte[] { 0, 0, 0xff, 0xff };\r\n+        private static readonly byte[] mark = new byte[] { 0, 0, 0xff, 0xff };\r\n \r\n         internal int Sync()\r\n         {\r\ndiff -u -r DotNetZip-1.8.4.23/ZLib/Zlib.cs DotNetZip-dev/ZLib/Zlib.cs\r\n--- DotNetZip-1.8.4.23/ZLib/Zlib.cs\t2009-08-14 09:51:42.000000000 -0500\r\n+++ DotNetZip-dev/ZLib/Zlib.cs\t2009-09-21 10:33:11.138489900 -0500\r\n@@ -374,13 +374,13 @@\r\n         internal static readonly short[] static_dtree = new short[] { 0, 5, 16, 5, 8, 5, 24, 5, 4, 5, 20, 5, 12, 5, 28, 5, 2, 5, 18, 5, 10, 5, 26, 5, 6, 5, 22, 5, 14, 5, 30, 5, 1, 5, 17, 5, 9, 5, 25, 5, 5, 5, 21, 5, 13, 5, 29, 5, 3, 5, 19, 5, 11, 5, 27, 5, 7, 5, 23, 5 };\r\n \r\n         //UPGRADE_NOTE: The initialization of  'static_l_desc' was moved to static method 'com.jcraft.jzlib.StaticTree'. &quot;ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&amp;keyword='jlca1005'&quot;\r\n-        internal static StaticTree static_l_desc;\r\n+        internal static readonly StaticTree static_l_desc;\r\n \r\n         //UPGRADE_NOTE: The initialization of  'static_d_desc' was moved to static method 'com.jcraft.jzlib.StaticTree'. &quot;ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&amp;keyword='jlca1005'&quot;\r\n-        internal static StaticTree static_d_desc;\r\n+        internal static readonly StaticTree static_d_desc;\r\n \r\n         //UPGRADE_NOTE: The initialization of  'static_bl_desc' was moved to static method 'com.jcraft.jzlib.StaticTree'. &quot;ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&amp;keyword='jlca1005'&quot;\r\n-        internal static StaticTree static_bl_desc;\r\n+        internal static readonly StaticTree static_bl_desc;\r\n \r\n         internal short[] static_tree; // static tree or null\r\n         internal int[] extra_bits; // extra bits for each code or null\r\n@@ -416,9 +416,9 @@\r\n     internal sealed class Adler\r\n     {\r\n         // largest prime smaller than 65536\r\n-        private static int BASE = 65521;\r\n+        private static readonly int BASE = 65521;\r\n         // NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) &lt;= 2^32-1\r\n-        private static int NMAX = 5552;\r\n+        private static readonly int NMAX = 5552;\r\n \r\n         static internal long Adler32(long adler, byte[] buf, int index, int len)\r\n         {\r\n</pre>\r\n</p>\r\n<div id=\"_mcePaste\" style=\"overflow:hidden;left:-10000px;top:0px;width:1px;height:1px\">diff -u -r DotNetZip-1.8.4.23/ZLib/Crc32.cs DotNetZip-dev/ZLib/Crc32.cs<br>--- DotNetZip-1.8.4.23/ZLib/Crc32.cs&nbsp;&nbsp; &nbsp;2009-08-18 21:04:20.000000000 -0500<br>+++ DotNetZip-dev/ZLib/Crc32.cs&nbsp;&nbsp; &nbsp;2009-09-16 16:39:50.514842500 -0500<br>@@ -197,7 +197,7 @@<br>&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // private member vars<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private Int64 _TotalBytesRead;<br>-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private static UInt32[] crc32Table;<br>+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private static readonly UInt32[] crc32Table;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private const int BUFFER_SIZE = 8192;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private UInt32 _RunningCrc32Result = 0xFFFFFFFF;<br>&nbsp;<br>diff -u -r DotNetZip-1.8.4.23/ZLib/Deflate.cs DotNetZip-dev/ZLib/Deflate.cs<br>--- DotNetZip-1.8.4.23/ZLib/Deflate.cs&nbsp;&nbsp; &nbsp;2009-08-19 18:25:04.000000000 -0500<br>+++ DotNetZip-dev/ZLib/Deflate.cs&nbsp;&nbsp; &nbsp;2009-09-21 10:34:14.384813900 -0500<br>@@ -189,7 +189,7 @@<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; };<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;<br>-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private static Config[] Table;<br>+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private static readonly Config[] Table;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;<br>&nbsp;<br>diff -u -r DotNetZip-1.8.4.23/ZLib/GZipStream.cs DotNetZip-dev/ZLib/GZipStream.cs<br>--- DotNetZip-1.8.4.23/ZLib/GZipStream.cs&nbsp;&nbsp; &nbsp;2009-08-12 15:35:30.000000000 -0500<br>+++ DotNetZip-dev/ZLib/GZipStream.cs&nbsp;&nbsp; &nbsp;2009-09-16 16:39:50.366827700 -0500<br>@@ -774,8 +774,8 @@<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; #endregion<br>&nbsp;<br>&nbsp;<br>-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; internal static System.DateTime _unixEpoch = new System.DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);<br>-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; internal static System.Text.Encoding iso8859dash1 = System.Text.Encoding.GetEncoding(&quot;iso-8859-1&quot;);<br>+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; internal static readonly System.DateTime _unixEpoch = new System.DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);<br>+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; internal static readonly System.Text.Encoding iso8859dash1 = System.Text.Encoding.GetEncoding(&quot;iso-8859-1&quot;);<br>&nbsp;<br>&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private int EmitHeader()<br>diff -u -r DotNetZip-1.8.4.23/ZLib/Inflate.cs DotNetZip-dev/ZLib/Inflate.cs<br>--- DotNetZip-1.8.4.23/ZLib/Inflate.cs&nbsp;&nbsp; &nbsp;2009-05-31 09:15:22.000000000 -0500<br>+++ DotNetZip-dev/ZLib/Inflate.cs&nbsp;&nbsp; &nbsp;2009-09-16 16:39:50.453836400 -0500<br>@@ -1756,7 +1756,7 @@<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return ZlibConstants.Z_OK;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>&nbsp;<br>-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private static byte[] mark = new byte[] { 0, 0, 0xff, 0xff };<br>+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private static readonly byte[] mark = new byte[] { 0, 0, 0xff, 0xff };<br>&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; internal int Sync()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br>diff -u -r DotNetZip-1.8.4.23/ZLib/Zlib.cs DotNetZip-dev/ZLib/Zlib.cs<br>--- DotNetZip-1.8.4.23/ZLib/Zlib.cs&nbsp;&nbsp; &nbsp;2009-08-14 09:51:42.000000000 -0500<br>+++ DotNetZip-dev/ZLib/Zlib.cs&nbsp;&nbsp; &nbsp;2009-09-21 10:33:11.138489900 -0500<br>@@ -374,13 +374,13 @@<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; internal static readonly short[] static_dtree = new short[] { 0, 5, 16, 5, 8, 5, 24, 5, 4, 5, 20, 5, 12, 5, 28, 5, 2, 5, 18, 5, 10, 5, 26, 5, 6, 5, 22, 5, 14, 5, 30, 5, 1, 5, 17, 5, 9, 5, 25, 5, 5, 5, 21, 5, 13, 5, 29, 5, 3, 5, 19, 5, 11, 5, 27, 5, 7, 5, 23, 5 };<br>&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //UPGRADE_NOTE: The initialization of&nbsp; 'static_l_desc' was moved to static method 'com.jcraft.jzlib.StaticTree'. &quot;ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&amp;keyword='jlca1005'&quot;<br>-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; internal static StaticTree static_l_desc;<br>+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; internal static readonly StaticTree static_l_desc;<br>&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //UPGRADE_NOTE: The initialization of&nbsp; 'static_d_desc' was moved to static method 'com.jcraft.jzlib.StaticTree'. &quot;ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&amp;keyword='jlca1005'&quot;<br>-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; internal static StaticTree static_d_desc;<br>+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; internal static readonly StaticTree static_d_desc;<br>&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; //UPGRADE_NOTE: The initialization of&nbsp; 'static_bl_desc' was moved to static method 'com.jcraft.jzlib.StaticTree'. &quot;ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&amp;keyword='jlca1005'&quot;<br>-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; internal static StaticTree static_bl_desc;<br>+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; internal static readonly StaticTree static_bl_desc;<br>&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; internal short[] static_tree; // static tree or null<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; internal int[] extra_bits; // extra bits for each code or null<br>@@ -416,9 +416,9 @@<br>&nbsp;&nbsp;&nbsp;&nbsp; internal sealed class Adler<br>&nbsp;&nbsp;&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // largest prime smaller than 65536<br>-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private static int BASE = 65521;<br>+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private static readonly int BASE = 65521;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) &lt;= 2^32-1<br>-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private static int NMAX = 5552;<br>+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; private static readonly int NMAX = 5552;<br>&nbsp;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; static internal long Adler32(long adler, byte[] buf, int index, int len)<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br><br></div>",
    "PostedDate": "2009-09-21T14:02:48.57-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "237156",
    "ThreadId": "69640",
    "Html": "This discussion has been copied to a work item. Click <a href=\"http://dotnetzip.codeplex.com/WorkItem/View.aspx?WorkItemId=8821\">here</a> to go to the work item and continue the discussion.",
    "PostedDate": "2009-09-21T23:51:04.123-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  },
  {
    "Id": "237157",
    "ThreadId": "69640",
    "Html": "<p>Thanks for the update.</p>\r\n<p>&nbsp;</p>",
    "PostedDate": "2009-09-21T23:51:29.637-07:00",
    "UserRole": null,
    "MarkedAsAnswerDate": null
  }
]