2009-11-02 Miguel de Icaza <miguel@novell.com>
authorMiguel de Icaza <miguel@gnome.org>
Tue, 3 Nov 2009 00:27:28 +0000 (00:27 -0000)
committerMiguel de Icaza <miguel@gnome.org>
Tue, 3 Nov 2009 00:27:28 +0000 (00:27 -0000)
        * Jumbo patch to drop support for pre-NET_2_0 code:

        Remove NET_2_0 defines assuming the value is true.

svn path=/trunk/mcs/; revision=145232

29 files changed:
mcs/class/corlib/System.Text/ASCIIEncoding.cs
mcs/class/corlib/System.Text/ChangeLog
mcs/class/corlib/System.Text/CodePageEncoding.cs
mcs/class/corlib/System.Text/Decoder.cs
mcs/class/corlib/System.Text/DecoderExceptionFallback.cs
mcs/class/corlib/System.Text/DecoderExceptionFallbackBuffer.cs
mcs/class/corlib/System.Text/DecoderFallback.cs
mcs/class/corlib/System.Text/DecoderFallbackBuffer.cs
mcs/class/corlib/System.Text/DecoderFallbackException.cs
mcs/class/corlib/System.Text/DecoderReplacementFallback.cs
mcs/class/corlib/System.Text/DecoderReplacementFallbackBuffer.cs
mcs/class/corlib/System.Text/Encoder.cs
mcs/class/corlib/System.Text/EncoderExceptionFallback.cs
mcs/class/corlib/System.Text/EncoderExceptionFallbackBuffer.cs
mcs/class/corlib/System.Text/EncoderFallback.cs
mcs/class/corlib/System.Text/EncoderFallbackBuffer.cs
mcs/class/corlib/System.Text/EncoderFallbackException.cs
mcs/class/corlib/System.Text/EncoderReplacementFallback.cs
mcs/class/corlib/System.Text/EncoderReplacementFallbackBuffer.cs
mcs/class/corlib/System.Text/Encoding.cs
mcs/class/corlib/System.Text/EncodingInfo.cs
mcs/class/corlib/System.Text/Latin1Encoding.cs
mcs/class/corlib/System.Text/MLangCodePageEncoding.cs
mcs/class/corlib/System.Text/NormalizationForm.cs
mcs/class/corlib/System.Text/StringBuilder.cs
mcs/class/corlib/System.Text/UTF32Encoding.cs
mcs/class/corlib/System.Text/UTF7Encoding.cs
mcs/class/corlib/System.Text/UTF8Encoding.cs
mcs/class/corlib/System.Text/UnicodeEncoding.cs

index 66bd6392b92da7bf179e22278b456c07a629203a..01e2692a60c92fde9580032a3aa7946d3882f677 100644 (file)
@@ -31,10 +31,8 @@ using System;
 using System.Runtime.InteropServices;
 
 [Serializable]
-#if NET_2_0
 [ComVisible (true)]
-#endif
-[MonoTODO ("Serialization format not compatible with .NET")]
+[MonoLimitation ("Serialization format not compatible with .NET")]
 public class ASCIIEncoding : Encoding
 {
        // Magic number used by Windows for "ASCII".
@@ -48,12 +46,10 @@ public class ASCIIEncoding : Encoding
                is_mail_news_save = true;
        }
 
-#if NET_2_0
        [ComVisible (false)]
        public override bool IsSingleByte {
                get { return true; }
        }
-#endif
 
        // Get the number of bytes needed to encode a character buffer.
        public override int GetByteCount (char[] chars, int index, int count)
@@ -81,14 +77,14 @@ public class ASCIIEncoding : Encoding
 
        // Get the bytes that result from encoding a character buffer.
        public override int GetBytes (char[] chars, int charIndex, int charCount,
-                                                                byte[] bytes, int byteIndex)
+                                     byte[] bytes, int byteIndex)
        {
-#if NET_2_0
-// well, yes, I know this #if is ugly, but I think it is the simplest switch.
+               // well, yes, I know this #if is ugly, but I think it is the simplest switch.
                EncoderFallbackBuffer buffer = null;
                char [] fallback_chars = null;
-               return GetBytes (chars, charIndex, charCount, bytes,
-                       byteIndex, ref buffer, ref fallback_chars);
+               
+               return GetBytes (chars, charIndex, charCount, bytes, byteIndex,
+                                ref buffer, ref fallback_chars);
        }
 
        int GetBytes (char[] chars, int charIndex, int charCount,
@@ -96,25 +92,24 @@ public class ASCIIEncoding : Encoding
                      ref EncoderFallbackBuffer buffer,
                      ref char [] fallback_chars)
        {
-#endif
-               if (chars == null) {
+               if (chars == null) 
                        throw new ArgumentNullException ("chars");
-               }
-               if (bytes == null) {
+
+               if (bytes == null) 
                        throw new ArgumentNullException ("bytes");
-               }
-               if (charIndex < 0 || charIndex > chars.Length) {
+
+               if (charIndex < 0 || charIndex > chars.Length) 
                        throw new ArgumentOutOfRangeException ("charIndex", _("ArgRange_Array"));
-               }
-               if (charCount < 0 || charCount > (chars.Length - charIndex)) {
+
+               if (charCount < 0 || charCount > (chars.Length - charIndex)) 
                        throw new ArgumentOutOfRangeException ("charCount", _("ArgRange_Array"));
-               }
-               if (byteIndex < 0 || byteIndex > bytes.Length) {
+
+               if (byteIndex < 0 || byteIndex > bytes.Length) 
                        throw new ArgumentOutOfRangeException ("byteIndex", _("ArgRange_Array"));
-               }
-               if ((bytes.Length - byteIndex) < charCount) {
+
+               if ((bytes.Length - byteIndex) < charCount) 
                        throw new ArgumentException (_("Arg_InsufficientSpace"));
-               }
+
                int count = charCount;
                char ch;
                while (count-- > 0) {
@@ -122,7 +117,6 @@ public class ASCIIEncoding : Encoding
                        if (ch < (char)0x80) {
                                bytes [byteIndex++] = (byte)ch;
                        } else {
-#if NET_2_0
                                if (buffer == null)
                                        buffer = EncoderFallback.CreateFallbackBuffer ();
                                if (Char.IsSurrogate (ch) && count > 1 &&
@@ -137,9 +131,6 @@ public class ASCIIEncoding : Encoding
                                byteIndex += GetBytes (fallback_chars, 0, 
                                        fallback_chars.Length, bytes, byteIndex,
                                        ref buffer, ref fallback_chars);
-#else
-                               bytes [byteIndex++] = (byte)'?';
-#endif
                        }
                }
                return charCount;
@@ -148,7 +139,6 @@ public class ASCIIEncoding : Encoding
        // Convenience wrappers for "GetBytes".
        public override int GetBytes (String chars, int charIndex, int charCount, byte[] bytes, int byteIndex)
        {
-#if NET_2_0
 // I know this #if is ugly, but I think it is the simplest switch.
                EncoderFallbackBuffer buffer = null;
                char [] fallback_chars = null;
@@ -161,7 +151,6 @@ public class ASCIIEncoding : Encoding
                      ref EncoderFallbackBuffer buffer,
                      ref char [] fallback_chars)
        {
-#endif
                if (chars == null) {
                        throw new ArgumentNullException ("chars");
                }
@@ -187,7 +176,6 @@ public class ASCIIEncoding : Encoding
                        if (ch < (char)0x80) {
                                bytes [byteIndex++] = (byte)ch;
                        } else {
-#if NET_2_0
                                if (buffer == null)
                                        buffer = EncoderFallback.CreateFallbackBuffer ();
                                if (Char.IsSurrogate (ch) && count > 1 &&
@@ -202,9 +190,6 @@ public class ASCIIEncoding : Encoding
                                byteIndex += GetBytes (fallback_chars, 0, 
                                        fallback_chars.Length, bytes, byteIndex,
                                        ref buffer, ref fallback_chars);
-#else
-                               bytes [byteIndex++] = (byte)'?';
-#endif
                        }
                }
                return charCount;
@@ -228,7 +213,6 @@ public class ASCIIEncoding : Encoding
        // Get the characters that result from decoding a byte buffer.
        public override int GetChars (byte[] bytes, int byteIndex, int byteCount, char[] chars, int charIndex)
        {
-#if NET_2_0
 // well, yes, I know this #if is ugly, but I think it is the simplest switch.
                DecoderFallbackBuffer buffer = null;
                return GetChars (bytes, byteIndex, byteCount, chars,
@@ -239,7 +223,6 @@ public class ASCIIEncoding : Encoding
                      char[] chars, int charIndex,
                      ref DecoderFallbackBuffer buffer)
        {
-#endif
                if (bytes == null)
                        throw new ArgumentNullException ("bytes");
                if (chars == null) 
@@ -260,15 +243,11 @@ public class ASCIIEncoding : Encoding
                        if (c < '\x80')
                                chars [charIndex++] = c;
                        else {
-#if NET_2_0
                                if (buffer == null)
                                        buffer = DecoderFallback.CreateFallbackBuffer ();
                                buffer.Fallback (bytes, byteIndex);
                                while (buffer.Remaining > 0)
                                        chars [charIndex++] = buffer.GetNextChar ();
-#else
-                               chars [charIndex++] = '?';
-#endif
                        }
                }
                return byteCount;
@@ -319,13 +298,8 @@ public class ASCIIEncoding : Encoding
                                        char* currChar = charPtr;
 
                                        while (currByte < lastByte) {
-#if NET_2_0
                                                byte b = currByte++ [0];
                                                currChar++ [0] = b <= 0x7F ? (char) b : (char) '?';
-#else
-                                               // GetString is incompatible with GetChars
-                                               currChar++ [0] = (char) (currByte++ [0] & 0x7F);
-#endif
                                        }
                                }
 
@@ -334,7 +308,6 @@ public class ASCIIEncoding : Encoding
                }
        }
 
-#if NET_2_0
        [CLSCompliantAttribute (false)]
        [ComVisible (false)]
        public unsafe override int GetBytes (char *chars, int charCount, byte *bytes, int byteCount)
@@ -394,33 +367,18 @@ public class ASCIIEncoding : Encoding
        {
                return count;
        }
-#else
-       // This routine is gone in 2.x
-       public override String GetString (byte[] bytes)
-       {
-               if (bytes == null) {
-                       throw new ArgumentNullException ("bytes");
-               }
-
-               return GetString (bytes, 0, bytes.Length);
-       }
-#endif
 
-#if NET_2_0
-       [MonoTODO ("we have simple override to match method signature.")]
        [ComVisible (false)]
        public override Decoder GetDecoder ()
        {
                return base.GetDecoder ();
        }
 
-       [MonoTODO ("we have simple override to match method signature.")]
        [ComVisible (false)]
        public override Encoder GetEncoder ()
        {
                return base.GetEncoder ();
        }
-#endif
 }; // class ASCIIEncoding
 
 }; // namespace System.Text
index 8a7c023a9df145bccf5d38c391e4d702c840da1b..4fc9556a56c7a043c5f5c67511752f5fcf98a86b 100644 (file)
@@ -1,3 +1,9 @@
+2009-11-02  Miguel de Icaza  <miguel@novell.com>
+
+       * Jumbo patch to drop support for pre-NET_2_0 code:
+
+       Remove NET_2_0 defines assuming the value is true.
+
 2009-10-22  Miguel de Icaza  <miguel@novell.com>
 
        * StringBuilder.cs (Text): Add new 4.0 method.
index 1a3c3f82cae914f12b40d9a69dada585643beb3c..36a19b4002e514bf54a19d758d5e74ac6b7c1d2e 100644 (file)
@@ -90,11 +90,9 @@ namespace System.Text
                }
 
                private int codePage;
-#if NET_2_0
                private bool isReadOnly;
                private EncoderFallback encoderFallback;
                private DecoderFallback decoderFallback;
-#endif
                private Encoding realObject;
 
                private CodePageEncoding (SerializationInfo info, StreamingContext context)
@@ -104,7 +102,6 @@ namespace System.Text
 
                        this.codePage = (int) info.GetValue ("m_codePage", typeof (int));
 
-#if NET_2_0
                        try {
                                this.isReadOnly = (bool) info.GetValue ("m_isReadOnly", typeof (bool));
                                this.encoderFallback = (EncoderFallback) info.GetValue ("encoderFallback", typeof (EncoderFallback));
@@ -113,7 +110,6 @@ namespace System.Text
                                // .NET Framework 1.x has no fallbacks
                                this.isReadOnly = true;
                        }
-#endif
                }
 
                public void GetObjectData (SerializationInfo info, StreamingContext context)
@@ -126,13 +122,11 @@ namespace System.Text
                        if (this.realObject == null) {
                                Encoding encoding = Encoding.GetEncoding (this.codePage);
 
-#if NET_2_0
                                if (!this.isReadOnly) {
                                        encoding = (Encoding) encoding.Clone ();
                                        encoding.EncoderFallback = this.encoderFallback;
                                        encoding.DecoderFallback = this.decoderFallback;
                                }
-#endif
 
                                this.realObject = encoding;
                        }
index 74062465718f4c05303dfe4d855bbcbf831dd165..fe715c33796233ea472fbb0adb2146bd10c3d931 100644 (file)
@@ -29,16 +29,13 @@ using System;
 using System.Runtime.InteropServices;
 
 [Serializable]
-#if NET_2_0
 [ComVisible (true)]
-#endif
 public abstract class Decoder
 {
 
        // Constructor.
        protected Decoder () {}
 
-#if NET_2_0
        DecoderFallback fallback = new DecoderReplacementFallback ();
        DecoderFallbackBuffer fallback_buffer;
 
@@ -61,7 +58,6 @@ public abstract class Decoder
                        return fallback_buffer;
                }
        }
-#endif
 
        // Get the number of characters needed to decode a buffer.
        public abstract int GetCharCount (byte[] bytes, int index, int count);
@@ -70,7 +66,6 @@ public abstract class Decoder
        public abstract int GetChars (byte[] bytes, int byteIndex, int byteCount,
                                                                 char[] chars, int charIndex);
 
-#if NET_2_0
        [ComVisible (false)]
        public virtual int GetCharCount (byte [] bytes, int index, int count, bool flush)
        {
@@ -199,8 +194,6 @@ public abstract class Decoder
                if (byteCount < 0)
                        throw new ArgumentOutOfRangeException ("byteCount");
        }
-#endif
-
 }; // class Decoder
 
 }; // namespace System.Text
index a2ba228f91c0efb594010296b2696dbbc92149ac..6f8aa23c78c09bb13ee817a475dcf04bfd0ddd19 100644 (file)
@@ -27,8 +27,6 @@
 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
-#if NET_2_0 || NET_2_0_BOOTSTRAP
-
 namespace System.Text
 {
        [Serializable]
@@ -58,5 +56,3 @@ namespace System.Text
                }
        }
 }
-
-#endif
index a029db0d3f617c367e45081e29cfffda7c370610..510c346c01d25283f459948fa775ae82a1351fbc 100644 (file)
@@ -28,8 +28,6 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
-#if NET_2_0 || NET_2_0_BOOTSTRAP
-
 namespace System.Text
 {
        public sealed class DecoderExceptionFallbackBuffer
@@ -59,5 +57,3 @@ namespace System.Text
                }
        }
 }
-
-#endif
index 25013138a0b4b8ebd6e2a88cea7e7e9feabb5450..f90da2624a9963acad6ee34a2967667d1bee4492 100644 (file)
@@ -28,8 +28,6 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
-#if NET_2_0
-
 namespace System.Text
 {
        [Serializable]
@@ -63,5 +61,3 @@ namespace System.Text
                public abstract DecoderFallbackBuffer CreateFallbackBuffer ();
        }
 }
-
-#endif
index 552b970573fe5624d05867c766f5e28a6f925af8..390d2508efee8673d30d2d9196aca472f6751ee8 100644 (file)
@@ -28,8 +28,6 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
-#if NET_2_0 || NET_2_0_BOOTSTRAP
-
 namespace System.Text
 {
        public abstract class DecoderFallbackBuffer
@@ -52,4 +50,3 @@ namespace System.Text
        }
 }
 
-#endif
index 73d9db2783b16157a0ba0d63a940716708034451..57fc01cc47fb874dd31f137b5432c698b2137689 100644 (file)
@@ -28,8 +28,6 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
-#if NET_2_0 || NET_2_0_BOOTSTRAP
-
 namespace System.Text
 {
        [Serializable]
@@ -75,5 +73,3 @@ namespace System.Text
                }
        }
 }
-
-#endif
index c60e7ac0d184b56f8436850632001bba67ad7722..9d4cea52cf6e0ec0f90031e779d301b02af5b6d6 100644 (file)
@@ -28,8 +28,6 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
-#if NET_2_0 || NET_2_0_BOOTSTRAP
-
 namespace System.Text
 {
        [Serializable]
@@ -77,5 +75,3 @@ namespace System.Text
                }
        }
 }
-
-#endif
index 101bc9a62b9ac394735f62c2ab238470a86b2a06..38eff7631fd81d10b58c802486b9762918e9d50f 100644 (file)
@@ -28,7 +28,6 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
-#if NET_2_0 || NET_2_0_BOOTSTRAP
 
 namespace System.Text
 {
@@ -94,5 +93,3 @@ namespace System.Text
                }
        }
 }
-
-#endif
index 1bac4240e9fc98f058d9f3a9e609e19bac0b589d..683444b16bc577e0745ca91da1269cbdaae8a08e 100644 (file)
@@ -29,16 +29,13 @@ using System;
 using System.Runtime.InteropServices;
 
 [Serializable]
-#if NET_2_0
 [ComVisible (true)]
-#endif
 public abstract class Encoder
 {
 
        // Constructor.
        protected Encoder() {}
 
-#if NET_2_0
        EncoderFallback fallback = new EncoderReplacementFallback ();
        EncoderFallbackBuffer fallback_buffer;
 
@@ -61,7 +58,6 @@ public abstract class Encoder
                        return fallback_buffer;
                }
        }
-#endif
 
        // Get the number of bytes needed to encode a buffer.
        public abstract int GetByteCount(char[] chars, int index,
@@ -71,7 +67,6 @@ public abstract class Encoder
        public abstract int GetBytes(char[] chars, int charIndex, int charCount,
                                                                 byte[] bytes, int byteIndex, bool flush);
 
-#if NET_2_0
        [CLSCompliant (false)]
        [ComVisible (false)]
        public unsafe virtual int GetByteCount (char* chars, int count, bool flush)
@@ -170,7 +165,6 @@ public abstract class Encoder
                if (byteCount < 0)
                        throw new ArgumentOutOfRangeException ("byteCount");
        }
-#endif
 }; // class Encoder
 
 }; // namespace System.Text
index 9d97636579aff0f7e2b77e0f124bc0cf6855d0eb..51372fd14c9f1efcb6b89b9b9d4fa646b50663f4 100644 (file)
@@ -27,8 +27,6 @@
 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
-#if NET_2_0 || NET_2_0_BOOTSTRAP
-
 namespace System.Text
 {
        [Serializable]
@@ -58,5 +56,3 @@ namespace System.Text
                }
        }
 }
-
-#endif
index 9d71878fc30645839ddfb8e3598325f7a9ea8295..16fa37e4f6ee8f2ed9c8fe74842b564c84f3f327 100644 (file)
@@ -28,8 +28,6 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
-#if NET_2_0 || NET_2_0_BOOTSTRAP
-
 namespace System.Text
 {
        public sealed class EncoderExceptionFallbackBuffer
@@ -64,5 +62,3 @@ namespace System.Text
                }
        }
 }
-
-#endif
index 55a8224540a0bd32526e3d4dceda7569d14012df..818b51de37fbbbcf3b09f187e892bf6ab0b5d59b 100644 (file)
@@ -28,8 +28,6 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
-#if NET_2_0 || NET_2_0_BOOTSTRAP
-
 namespace System.Text
 {
        [Serializable]
@@ -63,5 +61,3 @@ namespace System.Text
                public abstract EncoderFallbackBuffer CreateFallbackBuffer ();
        }
 }
-
-#endif
index 82348f9b7e22e61cac3c58fd418e267487abfc69..28d7a6800288b3ca9be109004641a1ef520906e7 100644 (file)
@@ -28,8 +28,6 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
-#if NET_2_0 || NET_2_0_BOOTSTRAP
-
 namespace System.Text
 {
        public abstract class EncoderFallbackBuffer
@@ -56,4 +54,3 @@ namespace System.Text
        }
 }
 
-#endif
index 2a1b7f123e87cbd001bde03fcd56a4388b1de4a0..a14beabdd79d3ba54a63950331cd1078c27a58c9 100644 (file)
@@ -28,8 +28,6 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
-#if NET_2_0 || NET_2_0_BOOTSTRAP
-
 namespace System.Text
 {
        [Serializable]
@@ -96,5 +94,3 @@ namespace System.Text
                }
        }
 }
-
-#endif
index 5a66d5c581e1cdb824d73385ebc06d77aa33743c..51f5f58b2b80c2bd4775715aec6a5224fa3df927 100644 (file)
@@ -28,8 +28,6 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
-#if NET_2_0 || NET_2_0_BOOTSTRAP
-
 namespace System.Text
 {
        [Serializable]
@@ -77,5 +75,3 @@ namespace System.Text
                }
        }
 }
-
-#endif
index bef71861d6c60975ec629a41acfb731c7945c5ed..82beb9ad7f9b8f471f3eb0cf2ab4ab069eaf8bd6 100644 (file)
@@ -28,8 +28,6 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
-#if NET_2_0 || NET_2_0_BOOTSTRAP
-
 namespace System.Text
 {
        // This EncoderFallbackBuffer is simple. It ignores the input buffers.
@@ -101,4 +99,3 @@ namespace System.Text
        }
 }
 
-#endif
index be86cc2dab6c999778a11a3ac561b44890956978..7c9173423215dbfd5f077087a280758be4a0741e 100644 (file)
@@ -35,20 +35,13 @@ using System.Runtime.CompilerServices;
 using System.Runtime.InteropServices;
 
 [Serializable]
-#if NET_2_0
 [ComVisible (true)]
-#endif
-public abstract class Encoding
-#if NET_2_0
-       : ICloneable
-#endif
+public abstract class Encoding : ICloneable
 {
        // Code page used by this encoding.
        internal int codePage;
        internal int windows_code_page;
-#if NET_2_0
        bool is_readonly = true;
-#endif
 
        // Constructor.
        protected Encoding ()
@@ -64,7 +57,6 @@ public abstract class Encoding
        {
                this.codePage = windows_code_page = codePage;
 
-#if NET_2_0
                switch (codePage) {
                default:
                        // MS has "InternalBestFit{Decoder|Encoder}Fallback
@@ -87,7 +79,6 @@ public abstract class Encoding
                        encoder_fallback = EncoderFallback.StandardSafeFallback;
                        break;
                }
-#endif
        }
 
        // until we change the callers:
@@ -95,7 +86,6 @@ public abstract class Encoding
                return arg;
        }
 
-#if NET_2_0
        DecoderFallback decoder_fallback;
        EncoderFallback encoder_fallback;
 
@@ -140,7 +130,6 @@ public abstract class Encoding
                if (d != null)
                        decoder_fallback = d;
        }
-#endif
 
        // Convert between two encodings.
        public static byte[] Convert (Encoding srcEncoding, Encoding dstEncoding,
@@ -185,13 +174,9 @@ public abstract class Encoding
        {
                Encoding enc = (value as Encoding);
                if (enc != null) {
-#if NET_2_0
                        return codePage == enc.codePage &&
                                DecoderFallback.Equals (enc.DecoderFallback) &&
                                EncoderFallback.Equals (enc.EncoderFallback);
-#else
-                       return (codePage == enc.codePage);
-#endif
                } else {
                        return false;
                }
@@ -208,16 +193,11 @@ public abstract class Encoding
 
                if (s.Length == 0)
                        return 0;
-#if NET_2_0
                unsafe {
                        fixed (char* cptr = s) {
                                return GetByteCount (cptr, s.Length);
                        }
                }
-#else
-               char[] chars = s.ToCharArray ();
-               return GetByteCount (chars, 0, chars.Length);
-#endif
        }
        public virtual int GetByteCount (char[] chars)
        {
@@ -238,7 +218,6 @@ public abstract class Encoding
        {
                if (s == null)
                        throw new ArgumentNullException ("s");
-#if NET_2_0
                if (charIndex < 0 || charIndex > s.Length)
                        throw new ArgumentOutOfRangeException ("charIndex", _("ArgRange_Array"));
                if (charCount < 0 || charIndex > (s.Length - charCount))
@@ -258,16 +237,12 @@ public abstract class Encoding
                                }
                        }
                }
-#else
-               return GetBytes (s.ToCharArray(), charIndex, charCount, bytes, byteIndex);
-#endif
        }
        public virtual byte[] GetBytes (String s)
        {
                if (s == null)
                        throw new ArgumentNullException ("s");
 
-#if NET_2_0
                if (s.Length == 0)
                        return new byte [0];
                int byteCount = GetByteCount (s);
@@ -283,14 +258,8 @@ public abstract class Encoding
                                }
                        }
                }
-#else
-               char[] chars = s.ToCharArray ();
-               int numBytes = GetByteCount (chars, 0, chars.Length);
-               byte[] bytes = new byte [numBytes];
-               GetBytes (chars, 0, chars.Length, bytes, 0);
-               return bytes;
-#endif
        }
+
        public virtual byte[] GetBytes (char[] chars, int index, int count)
        {
                int numBytes = GetByteCount (chars, index, count);
@@ -463,13 +432,11 @@ public abstract class Encoding
                        case UTF8Encoding.UTF8_CODE_PAGE:
                                return UTF8;
 
-#if NET_2_0
                        case UTF32Encoding.UTF32_CODE_PAGE:
                                return UTF32;
 
                        case UTF32Encoding.BIG_UTF32_CODE_PAGE:
                                return BigEndianUTF32;
-#endif
 
                        case UnicodeEncoding.UNICODE_CODE_PAGE:
                                return Unicode;
@@ -487,9 +454,7 @@ public abstract class Encoding
                // Try to obtain a code page handler from the I18N handler.
                Encoding enc = (Encoding)(InvokeI18N ("GetEncoding", codepage));
                if (enc != null) {
-#if NET_2_0
                        enc.is_readonly = true;
-#endif
                        return enc;
                }
 
@@ -501,9 +466,7 @@ public abstract class Encoding
                Type type = assembly.GetType (cpName);
                if (type != null) {
                        enc = (Encoding)(Activator.CreateInstance (type));
-#if NET_2_0
                        enc.is_readonly = true;
-#endif
                        return enc;
                }
 
@@ -512,9 +475,7 @@ public abstract class Encoding
                type = Type.GetType (cpName);
                if (type != null) {
                        enc = (Encoding)(Activator.CreateInstance (type));
-#if NET_2_0
                        enc.is_readonly = true;
-#endif
                        return enc;
                }
 #endif // !NET_2_1
@@ -525,7 +486,6 @@ public abstract class Encoding
 
 #if !ECMA_COMPAT
 
-#if NET_2_0
        [ComVisible (false)]
        public virtual object Clone ()
        {
@@ -620,8 +580,6 @@ public abstract class Encoding
        }
 #endif // NET_2_1
 
-#endif
-
        // Table of builtin web encoding names and the corresponding code pages.
        private static readonly object[] encodings =
                {
@@ -645,13 +603,12 @@ public abstract class Encoding
 
                        UnicodeEncoding.BIG_UNICODE_CODE_PAGE,
                        "unicodefffe", "utf_16be",
-#if NET_2_0
+
                        UTF32Encoding.UTF32_CODE_PAGE,
                        "utf_32", "UTF_32LE", "ucs_4",
 
                        UTF32Encoding.BIG_UTF32_CODE_PAGE,
                        "UTF_32BE",
-#endif
 
 #if !NET_2_1
                        Latin1Encoding.ISOLATIN_CODE_PAGE,
@@ -717,11 +674,7 @@ public abstract class Encoding
        // Get a hash code for this instance.
        public override int GetHashCode ()
        {
-#if NET_2_0
                return DecoderFallback.GetHashCode () << 24 + EncoderFallback.GetHashCode () << 16 + codePage;
-#else
-               return codePage;
-#endif
        }
 
        // Get the maximum number of bytes needed to encode a
@@ -855,11 +808,9 @@ public abstract class Encoding
        static volatile Encoding utf8EncodingWithoutMarkers;
        static volatile Encoding unicodeEncoding;
        static volatile Encoding isoLatin1Encoding;
-#if NET_2_0
        static volatile Encoding utf8EncodingUnsafe;
        static volatile Encoding utf32Encoding;
        static volatile Encoding bigEndianUTF32Encoding;
-#endif
 
        static readonly object lockobj = new object ();
 
@@ -938,9 +889,7 @@ public abstract class Encoding
                                                        // not supported by underlying OS
                                                        defaultEncoding = UTF8Unmarked;
                                                }
-#if NET_2_0
                                                defaultEncoding.is_readonly = true;
-#endif                                         
                                        }
                                }
                        }
@@ -1032,7 +981,6 @@ public abstract class Encoding
        //
        internal static Encoding UTF8UnmarkedUnsafe {
                get {
-#if NET_2_0
                        if (utf8EncodingUnsafe == null) {
                                lock (lockobj){
                                        if (utf8EncodingUnsafe == null){
@@ -1045,9 +993,6 @@ public abstract class Encoding
                        }
 
                        return utf8EncodingUnsafe;
-#else
-                       return UTF8Unmarked;
-#endif
                }
        }
        
@@ -1068,7 +1013,6 @@ public abstract class Encoding
                }
        }
 
-#if NET_2_0
        // Get the standard little-endian UTF-32 encoding object.
        public static Encoding UTF32
        {
@@ -1102,7 +1046,6 @@ public abstract class Encoding
                        return bigEndianUTF32Encoding;
                }
        }
-#endif
 
        // Forwarding decoder implementation.
        private sealed class ForwardingDecoder : Decoder
@@ -1113,11 +1056,9 @@ public abstract class Encoding
                public ForwardingDecoder (Encoding enc)
                {
                        encoding = enc;
-#if NET_2_0
                        DecoderFallback fallback = encoding.DecoderFallback;
                        if (fallback != null)
                                Fallback = fallback;
-#endif
                }
 
                // Override inherited methods.
@@ -1143,11 +1084,9 @@ public abstract class Encoding
                public ForwardingEncoder (Encoding enc)
                {
                        encoding = enc;
-#if NET_2_0
                        EncoderFallback fallback = encoding.EncoderFallback;
                        if (fallback != null)
                                Fallback = fallback;
-#endif
                }
 
                // Override inherited methods.
@@ -1164,7 +1103,6 @@ public abstract class Encoding
 
        } // class ForwardingEncoder
 
-#if NET_2_0
        [CLSCompliantAttribute(false)]
        [ComVisible (false)]
        public unsafe virtual int GetByteCount (char *chars, int count)
@@ -1251,8 +1189,6 @@ public abstract class Encoding
                
                return b.Length;
        }
-#endif
-
 }; // class Encoding
 
 }; // namespace System.Text
index 262dfe8451e7f32b07ce911b751f9e28b1d49138..fd2b7a19de3c7d31391c0d5512d429dd5d00d74c 100644 (file)
@@ -28,7 +28,6 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
-#if NET_2_0
 
 namespace System.Text
 {
@@ -78,5 +77,3 @@ namespace System.Text
                }
        }
 }
-
-#endif
index ce8dcb2508b8eb175b1df303dc8fa59384f22b6b..612b7795ee318d941196f0e772327396de9fcca2 100644 (file)
@@ -40,7 +40,6 @@ internal class Latin1Encoding : Encoding
                // Nothing to do here.
        }
 
-#if NET_2_0
        public override bool IsSingleByte {
                get { return true; }
        }
@@ -49,7 +48,6 @@ internal class Latin1Encoding : Encoding
        {
                return form == NormalizationForm.FormC;
        }
-#endif
 
        // Get the number of bytes needed to encode a character buffer.
        public override int GetByteCount (char[] chars, int index, int count)
@@ -79,8 +77,6 @@ internal class Latin1Encoding : Encoding
        public override int GetBytes (char[] chars, int charIndex, int charCount,
                                                                 byte[] bytes, int byteIndex)
        {
-#if NET_2_0
-// well, yes, I know this #if is ugly, but I think it is the simplest switch.
                EncoderFallbackBuffer buffer = null;
                char [] fallback_chars = null;
                return GetBytes (chars, charIndex, charCount, bytes,
@@ -92,7 +88,6 @@ internal class Latin1Encoding : Encoding
                      ref EncoderFallbackBuffer buffer,
                      ref char [] fallback_chars)
        {
-#endif
                if (chars == null) {
                        throw new ArgumentNullException ("chars");
                }
@@ -120,7 +115,6 @@ internal class Latin1Encoding : Encoding
                        } else if (ch >= '\uFF01' && ch <= '\uFF5E') {
                                bytes [byteIndex++] = (byte)(ch - 0xFEE0);
                        } else {
-#if NET_2_0
                                if (buffer == null)
                                        buffer = EncoderFallback.CreateFallbackBuffer ();
                                if (Char.IsSurrogate (ch) && count > 1 &&
@@ -135,9 +129,6 @@ internal class Latin1Encoding : Encoding
                                byteIndex += GetBytes (fallback_chars, 0, 
                                        fallback_chars.Length, bytes, byteIndex,
                                        ref buffer, ref fallback_chars);
-#else
-                               bytes [byteIndex++] = (byte)'?';
-#endif
                        }
                }
                return charCount;
@@ -147,8 +138,6 @@ internal class Latin1Encoding : Encoding
        public override int GetBytes (String s, int charIndex, int charCount,
                                                                 byte[] bytes, int byteIndex)
        {
-#if NET_2_0
-// I know this #if is ugly, but I think it is the simplest switch.
                EncoderFallbackBuffer buffer = null;
                char [] fallback_chars = null;
                return GetBytes (s, charIndex, charCount, bytes, byteIndex,
@@ -160,7 +149,6 @@ internal class Latin1Encoding : Encoding
                      ref EncoderFallbackBuffer buffer,
                      ref char [] fallback_chars)
        {
-#endif
                if (s == null) {
                        throw new ArgumentNullException ("s");
                }
@@ -188,8 +176,6 @@ internal class Latin1Encoding : Encoding
                        } else if (ch >= '\uFF01' && ch <= '\uFF5E') {
                                bytes [byteIndex++] = (byte)(ch - 0xFEE0);
                        } else {
-
-#if NET_2_0
                                if (buffer == null)
                                        buffer = EncoderFallback.CreateFallbackBuffer ();
                                if (Char.IsSurrogate (ch) && count > 1 &&
@@ -204,9 +190,6 @@ internal class Latin1Encoding : Encoding
                                byteIndex += GetBytes (fallback_chars, 0, 
                                        fallback_chars.Length, bytes, byteIndex,
                                        ref buffer, ref fallback_chars);
-#else
-                               bytes [byteIndex++] = (byte)'?';
-#endif
                        }
                }
                return charCount;
index 4e9ab136c997213c114a0738f751a01990593a56..a1aad60e94d9af91499880b550843ed3d04be30f 100644 (file)
@@ -62,7 +62,6 @@ namespace System.Text
                // This class supports serialization compatibility.
                //
 
-#if NET_2_0
                [Serializable]
                private sealed class MLangEncoder : ISerializable, IObjectReference
                {
@@ -90,14 +89,6 @@ namespace System.Text
                                return this.realObject;
                        }
                }
-#else
-               private sealed class MLangEncoder
-               {
-                       private MLangEncoder ()
-                       {
-                       }
-               }
-#endif
 
                //
                // .NET Framework 1.x uses this class for internal decoders.
@@ -106,7 +97,6 @@ namespace System.Text
                // This class supports serialization compatibility.
                //
 
-#if NET_2_0
                [Serializable]
                private sealed class MLangDecoder : ISerializable, IObjectReference
                {
@@ -134,21 +124,11 @@ namespace System.Text
                                return this.realObject;
                        }
                }
-#else
-               private sealed class MLangDecoder
-               {
-                       private MLangDecoder ()
-                       {
-                       }
-               }
-#endif
 
                private int codePage;
-#if NET_2_0
                private bool isReadOnly;
                private EncoderFallback encoderFallback;
                private DecoderFallback decoderFallback;
-#endif
                private Encoding realObject;
 
                private MLangCodePageEncoding (SerializationInfo info, StreamingContext context)
@@ -158,7 +138,6 @@ namespace System.Text
 
                        this.codePage = (int) info.GetValue ("m_codePage", typeof (int));
 
-#if NET_2_0
                        try {
                                this.isReadOnly = (bool) info.GetValue ("m_isReadOnly", typeof (bool));
                                this.encoderFallback = (EncoderFallback) info.GetValue ("encoderFallback", typeof (EncoderFallback));
@@ -167,7 +146,6 @@ namespace System.Text
                                // .NET Framework 1.x has no fallbacks
                                this.isReadOnly = true;
                        }
-#endif
                }
 
                public void GetObjectData (SerializationInfo info, StreamingContext context)
@@ -180,14 +158,11 @@ namespace System.Text
                        if (this.realObject == null) {
                                Encoding encoding = Encoding.GetEncoding (this.codePage);
 
-#if NET_2_0
                                if (!this.isReadOnly) {
                                        encoding = (Encoding) encoding.Clone ();
                                        encoding.EncoderFallback = this.encoderFallback;
                                        encoding.DecoderFallback = this.decoderFallback;
                                }
-#endif
-
                                this.realObject = encoding;
                        }
 
index f55ac5ef34e865544be8ed8a5b562730634249c1..67b49d58d052331c3cdef7fccbc44a59b05a9f71 100644 (file)
@@ -27,7 +27,6 @@
 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
-#if NET_2_0
 
 using System.Runtime.InteropServices;
 
@@ -41,4 +40,3 @@ namespace System.Text
                FormKD = 6
        }
 }
-#endif
index 734a943c6781cc08d0bbdea906c5dd54767e38c2..236d67edbca8424856983d9927d2a421c09c119c 100644 (file)
@@ -43,14 +43,9 @@ using System.Runtime.InteropServices;
 namespace System.Text {
        
        [Serializable]
-#if NET_2_0
        [ComVisible (true)]
-#endif
-        [MonoTODO ("Serialization format not compatible with .NET")]
-       public sealed class StringBuilder
-#if NET_2_0
-               : ISerializable
-#endif
+        [MonoLimitation ("Serialization format not compatible with .NET")]
+       public sealed class StringBuilder : ISerializable
        {
                private int _length;
                private string _str;
index 8e27f2ade65219106c57fd3c01e08973a946e8d3..9e97f6aefab42b81c3f2a581748b5db47d4d2b56 100644 (file)
@@ -31,8 +31,6 @@
  * OTHER DEALINGS IN THE SOFTWARE.
  */
 
-#if NET_2_0
-
 namespace System.Text
 {
 
@@ -469,7 +467,6 @@ public sealed class UTF32Encoding : Encoding
 
        } // class UTF32Decoder
        
-#if NET_2_0
        [CLSCompliantAttribute(false)]
        public unsafe override int GetByteCount (char *chars, int count)
        {
@@ -477,14 +474,7 @@ public sealed class UTF32Encoding : Encoding
                        throw new ArgumentNullException ("chars");
                return count * 4;
        }
-#else
-       public override byte [] GetBytes (String s)
-       {
-               return base.GetBytes (s);
-       }
-#endif
 
-#if NET_2_0
        // a bunch of practically missing implementations (but should just work)
 
        public override int GetByteCount (string s)
@@ -524,10 +514,6 @@ public sealed class UTF32Encoding : Encoding
        {
                return base.GetEncoder ();
        }
-#endif
-
 }; // class UTF32Encoding
 
 }; // namespace System.Text
-
-#endif
index 00eb0cdd46303af9d34888e3c3e1ccf320bd1386..60f716fad54f5e450bb6b776fc836886330a5b25 100644 (file)
@@ -31,10 +31,8 @@ using System;
 using System.Runtime.InteropServices;
 
 [Serializable]
-#if NET_2_0
 [ComVisible (true)]
-#endif
-[MonoTODO ("Serialization format not compatible with .NET")]
+[MonoLimitation ("Serialization format not compatible with .NET")]
 #if ECMA_COMPAT
 internal
 #else
@@ -109,7 +107,6 @@ class UTF7Encoding : Encoding
                windows_code_page = UnicodeEncoding.UNICODE_CODE_PAGE;
        }
 
-#if NET_2_0
        [ComVisible (false)]
        public override int GetHashCode ()
        {
@@ -127,7 +124,6 @@ class UTF7Encoding : Encoding
                        EncoderFallback.Equals (e.EncoderFallback) &&
                        DecoderFallback.Equals (e.DecoderFallback);
        }
-#endif
 
        // Internal version of "GetByteCount" that can handle
        // a rolling state between calls.
@@ -674,7 +670,6 @@ class UTF7Encoding : Encoding
 
        } // class UTF7Encoder
 
-#if NET_2_0
        // a bunch of practically missing implementations (but should just work)
 
        [CLSCompliantAttribute (false)]
@@ -723,8 +718,6 @@ class UTF7Encoding : Encoding
                return base.GetString (bytes, index, count);
        }
 
-#endif
-
 }; // class UTF7Encoding
 
 }; // namespace System.Text
index 19c43a2d47dbb6a914c9f9d8317042d7bf1a1b82..768ed0fe52d256dfa7962356d815820a9711b0be 100644 (file)
@@ -30,11 +30,9 @@ using System;
 using System.Runtime.InteropServices;
 
 [Serializable]
-[MonoTODO ("Serialization format not compatible with .NET")]
-#if NET_2_0
-[MonoTODO ("EncoderFallback is not handled")]
+[MonoLimitation ("Serialization format not compatible with .NET")]
+[MonoLimitation ("EncoderFallback is not handled")]
 [ComVisible (true)]
-#endif
 public class UTF8Encoding : Encoding
 {
        // Magic number used by Windows for UTF-8.
@@ -42,9 +40,6 @@ public class UTF8Encoding : Encoding
 
        // Internal state.
        private bool emitIdentifier;
-#if !NET_2_0
-       private bool throwOnInvalid;
-#endif
 
        // Constructors.
        public UTF8Encoding () : this (false, false) {}
@@ -55,14 +50,10 @@ public class UTF8Encoding : Encoding
                : base (UTF8_CODE_PAGE)
        {
                emitIdentifier = encoderShouldEmitUTF8Identifier;
-#if NET_2_0
                if (throwOnInvalidBytes)
                        SetFallbackInternal (null, DecoderFallback.ExceptionFallback);
                else
                        SetFallbackInternal (null, DecoderFallback.StandardSafeFallback);
-#else
-               throwOnInvalid = throwOnInvalidBytes;
-#endif
 
                web_name = body_name = header_name = "utf-8";
                encoding_name = "Unicode (UTF-8)";
@@ -172,25 +163,7 @@ public class UTF8Encoding : Encoding
                return InternalGetByteCount (chars, index, count, ref dummy, true);
        }
 
-#if !NET_2_0
-       // Convenience wrappers for "GetByteCount".
-       public override int GetByteCount (String chars)
-       {
-               // Validate the parameters.
-               if (chars == null) {
-                       throw new ArgumentNullException ("chars");
-               }
 
-               unsafe {
-                       fixed (char* cptr = chars) {
-                               char dummy = '\0';
-                               return InternalGetByteCount (cptr, chars.Length, ref dummy, true);
-                       }
-               }
-       }
-#endif
-
-#if NET_2_0
        [CLSCompliant (false)]
        [ComVisible (false)]
        public unsafe override int GetByteCount (char* chars, int count)
@@ -202,7 +175,6 @@ public class UTF8Encoding : Encoding
                char dummy = '\0';
                return InternalGetByteCount (chars, count, ref dummy, true);
        }
-#endif
 
        #endregion
 
@@ -234,21 +206,10 @@ public class UTF8Encoding : Encoding
 
                if (charIndex == chars.Length) {
                        if (flush && leftOver != '\0') {
-#if NET_2_0
                                // FIXME: use EncoderFallback.
                                //
                                // By default it is empty, so I do nothing for now.
                                leftOver = '\0';
-#else
-                               // Flush the left-over surrogate pair start.
-                               if (byteIndex >= bytes.Length - 3)
-                                       throw new ArgumentException (_("Arg_InsufficientSpace"), "bytes");
-                               bytes [byteIndex++] = 0xEF;
-                               bytes [byteIndex++] = 0xBB;
-                               bytes [byteIndex++] = 0xBF;
-                               leftOver = '\0';
-                               return 3;
-#endif
                        }
                        return 0;
                }
@@ -411,7 +372,6 @@ fail_no_space:
                }
        }
 
-#if NET_2_0
        [CLSCompliant (false)]
        [ComVisible (false)]
        public unsafe override int GetBytes (char* chars, int charCount, byte* bytes, int byteCount)
@@ -434,22 +394,15 @@ fail_no_space:
                else
                        return InternalGetBytes (chars, charCount, bytes, byteCount, ref dummy, true);
        }
-#endif
 
        #endregion
 
        // Internal version of "GetCharCount" which can handle a rolling
        // state between multiple calls to this method.
-#if NET_2_0
        private unsafe static int InternalGetCharCount (
                byte[] bytes, int index, int count, uint leftOverBits,
                uint leftOverCount, object provider,
                ref DecoderFallbackBuffer fallbackBuffer, ref byte [] bufferArg, bool flush)
-#else
-       private unsafe static int InternalGetCharCount (
-               byte[] bytes, int index, int count, uint leftOverBits,
-               uint leftOverCount, bool throwOnInvalid, bool flush)
-#endif
        {
                // Validate the parameters.
                if (bytes == null) {
@@ -465,25 +418,14 @@ fail_no_space:
                if (count == 0)
                        return 0;
                fixed (byte *bptr = bytes)
-#if NET_2_0
                        return InternalGetCharCount (bptr + index, count,
                                leftOverBits, leftOverCount, provider, ref fallbackBuffer, ref bufferArg, flush);
-#else
-                       return InternalGetCharCount (bptr + index, count,
-                               leftOverBits, leftOverCount, throwOnInvalid, flush);
-#endif
        }
 
-#if NET_2_0
        private unsafe static int InternalGetCharCount (
                byte* bytes, int count, uint leftOverBits,
                uint leftOverCount, object provider,
                ref DecoderFallbackBuffer fallbackBuffer, ref byte [] bufferArg, bool flush)
-#else
-       private unsafe static int InternalGetCharCount (
-               byte* bytes, int count, uint leftOverBits,
-               uint leftOverCount, bool throwOnInvalid, bool flush)
-#endif
        {
                int index = 0;
 
@@ -539,12 +481,7 @@ fail_no_space:
                                        leftSize = 6;
                                } else {
                                        // Invalid UTF-8 start character.
-#if NET_2_0
                                        length += Fallback (provider, ref fallbackBuffer, ref bufferArg, bytes, index - 1, 1);
-#else
-                                       if (throwOnInvalid)
-                                               throw new ArgumentException (_("Arg_InvalidUTF8"), "bytes");
-#endif
                                }
                        } else {
                                // Process an extra byte in a multi-byte sequence.
@@ -573,44 +510,24 @@ fail_no_space:
                                                                break;
                                                        }
                                                        if (overlong) {
-#if NET_2_0
                                                                length += Fallback (provider, ref fallbackBuffer, ref bufferArg, bytes, index - leftSoFar, leftSoFar);
-#else
-                                                               if (throwOnInvalid)
-                                                                       throw new ArgumentException (_("Overlong"), leftBits.ToString ());
-#endif
                                                        }
                                                        else if ((leftBits & 0xF800) == 0xD800) {
                                                                // UTF-8 doesn't use surrogate characters
-#if NET_2_0
                                                                length += Fallback (provider, ref fallbackBuffer, ref bufferArg, bytes, index - leftSoFar, leftSoFar);
-#else
-                                                               if (throwOnInvalid)
-                                                                       throw new ArgumentException (_("Arg_InvalidUTF8"), "bytes");
-#endif
                                                        }
                                                        else
                                                                ++length;
                                                } else if (leftBits < (uint)0x110000) {
                                                        length += 2;
                                                } else {
-#if NET_2_0
                                                        length += Fallback (provider, ref fallbackBuffer, ref bufferArg, bytes, index - leftSoFar, leftSoFar);
-#else
-                                                       if (throwOnInvalid)
-                                                               throw new ArgumentException (_("Arg_InvalidUTF8"), "bytes");
-#endif
                                                }
                                                leftSize = 0;
                                        }
                                } else {
                                        // Invalid UTF-8 sequence: clear and restart.
-#if NET_2_0
                                        length += Fallback (provider, ref fallbackBuffer, ref bufferArg, bytes, index - leftSoFar, leftSoFar);
-#else
-                                       if (throwOnInvalid)
-                                               throw new ArgumentException (_("Arg_InvalidUTF8"), "bytes");
-#endif
                                        leftSize = 0;
                                        --index;
                                        ++count;
@@ -620,19 +537,13 @@ fail_no_space:
                if (flush && leftSize != 0) {
                        // We had left-over bytes that didn't make up
                        // a complete UTF-8 character sequence.
-#if NET_2_0
                        length += Fallback (provider, ref fallbackBuffer, ref bufferArg, bytes, index - leftSoFar, leftSoFar);
-#else
-                       if (throwOnInvalid)
-                               throw new ArgumentException (_("Arg_InvalidUTF8"), "bytes");
-#endif
                }
 
                // Return the final length to the caller.
                return length;
        }
 
-#if NET_2_0
        // for GetCharCount()
        static unsafe int Fallback (object provider, ref DecoderFallbackBuffer buffer, ref byte [] bufferArg, byte* bytes, long index, uint size)
        {
@@ -676,21 +587,15 @@ fail_no_space:
                        buffer.Reset ();
                }
        }
-#endif
 
        // Get the number of characters needed to decode a byte buffer.
        public override int GetCharCount (byte[] bytes, int index, int count)
        {
-#if NET_2_0
                DecoderFallbackBuffer buf = null;
                byte [] bufferArg = null;
                return InternalGetCharCount (bytes, index, count, 0, 0, DecoderFallback, ref buf, ref bufferArg, true);
-#else
-               return InternalGetCharCount (bytes, index, count, 0, 0, throwOnInvalid, true);
-#endif
        }
 
-#if NET_2_0
        [CLSCompliant (false)]
        [ComVisible (false)]
        public unsafe override int GetCharCount (byte* bytes, int count)
@@ -699,21 +604,13 @@ fail_no_space:
                byte [] bufferArg = null;
                return InternalGetCharCount (bytes, count, 0, 0, DecoderFallback, ref buf, ref bufferArg, true);
        }
-#endif
 
        // Get the characters that result from decoding a byte buffer.
-#if NET_2_0
        private unsafe static int InternalGetChars (
                byte[] bytes, int byteIndex, int byteCount, char[] chars,
                int charIndex, ref uint leftOverBits, ref uint leftOverCount,
                object provider,
                ref DecoderFallbackBuffer fallbackBuffer, ref byte [] bufferArg, bool flush)
-#else
-       private unsafe static int InternalGetChars (
-               byte[] bytes, int byteIndex, int byteCount, char[] chars,
-               int charIndex, ref uint leftOverBits, ref uint leftOverCount,
-               bool throwOnInvalid, bool flush)
-#endif
        {
                // Validate the parameters.
                if (bytes == null) {
@@ -736,34 +633,19 @@ fail_no_space:
                        return 0;
 
                fixed (char* cptr = chars) {
-#if NET_2_0
                        if (byteCount == 0 || byteIndex == bytes.Length)
                                return InternalGetChars (null, 0, cptr + charIndex, chars.Length - charIndex, ref leftOverBits, ref leftOverCount, provider, ref fallbackBuffer, ref bufferArg, flush);
                        // otherwise...
                        fixed (byte* bptr = bytes)
                                return InternalGetChars (bptr + byteIndex, byteCount, cptr + charIndex, chars.Length - charIndex, ref leftOverBits, ref leftOverCount, provider, ref fallbackBuffer, ref bufferArg, flush);
-#else
-                       if (byteCount == 0 || byteIndex == bytes.Length)
-                               return InternalGetChars (null, 0, cptr + charIndex, chars.Length - charIndex, ref leftOverBits, ref leftOverCount, throwOnInvalid, flush);
-                       // otherwise...
-                       fixed (byte* bptr = bytes)
-                               return InternalGetChars (bptr + byteIndex, byteCount, cptr + charIndex, chars.Length - charIndex, ref leftOverBits, ref leftOverCount, throwOnInvalid, flush);
-#endif
                }
        }
 
-#if NET_2_0
        private unsafe static int InternalGetChars (
                byte* bytes, int byteCount, char* chars, int charCount,
                ref uint leftOverBits, ref uint leftOverCount,
                object provider,
                ref DecoderFallbackBuffer fallbackBuffer, ref byte [] bufferArg, bool flush)
-#else
-       private unsafe static int InternalGetChars (
-               byte* bytes, int byteCount, char* chars, int charCount,
-               ref uint leftOverBits, ref uint leftOverCount,
-               bool throwOnInvalid, bool flush)
-#endif
        {
                int charIndex = 0, byteIndex = 0;
                int length = charCount;
@@ -824,12 +706,7 @@ fail_no_space:
                                        leftSize = 6;
                                } else {
                                        // Invalid UTF-8 start character.
-#if NET_2_0
                                        Fallback (provider, ref fallbackBuffer, ref bufferArg, bytes, byteIndex, 1, chars, ref posn);
-#else
-                                       if (throwOnInvalid)
-                                               throw new ArgumentException (_("Arg_InvalidUTF8"), "bytes");
-#endif
                                }
                        } else {
                                // Process an extra byte in a multi-byte sequence.
@@ -858,21 +735,11 @@ fail_no_space:
                                                                break;
                                                        }
                                                        if (overlong) {
-#if NET_2_0
                                                                Fallback (provider, ref fallbackBuffer, ref bufferArg, bytes, byteIndex - leftSoFar, leftSoFar, chars, ref posn);
-#else
-                                                               if (throwOnInvalid)
-                                                                       throw new ArgumentException (_("Overlong"), leftBits.ToString ());
-#endif
                                                        }
                                                        else if ((leftBits & 0xF800) == 0xD800) {
                                                                // UTF-8 doesn't use surrogate characters
-#if NET_2_0
                                                                Fallback (provider, ref fallbackBuffer, ref bufferArg, bytes, byteIndex - leftSoFar, leftSoFar, chars, ref posn);
-#else
-                                                               if (throwOnInvalid)
-                                                                       throw new ArgumentException (_("Arg_InvalidUTF8"), "bytes");
-#endif
                                                        }
                                                        else {
                                                                if (posn >= length) {
@@ -892,23 +759,13 @@ fail_no_space:
                                                        chars[posn++] =
                                                                (char)((leftBits & (uint)0x3FF) + (uint)0xDC00);
                                                } else {
-#if NET_2_0
                                                        Fallback (provider, ref fallbackBuffer, ref bufferArg, bytes, byteIndex - leftSoFar, leftSoFar, chars, ref posn);
-#else
-                                                       if (throwOnInvalid)
-                                                               throw new ArgumentException (_("Arg_InvalidUTF8"), "bytes");
-#endif
                                                }
                                                leftSize = 0;
                                        }
                                } else {
                                        // Invalid UTF-8 sequence: clear and restart.
-#if NET_2_0
                                        Fallback (provider, ref fallbackBuffer, ref bufferArg, bytes, byteIndex - leftSoFar, leftSoFar, chars, ref posn);
-#else
-                                       if (throwOnInvalid)
-                                               throw new ArgumentException (_("Arg_InvalidUTF8"), "bytes");
-#endif
                                        leftSize = 0;
                                        --byteIndex;
                                }
@@ -917,12 +774,7 @@ fail_no_space:
                if (flush && leftSize != 0) {
                        // We had left-over bytes that didn't make up
                        // a complete UTF-8 character sequence.
-#if NET_2_0
                        Fallback (provider, ref fallbackBuffer, ref bufferArg, bytes, byteIndex - leftSoFar, leftSoFar, chars, ref posn);
-#else
-                       if (throwOnInvalid)
-                               throw new ArgumentException (_("Arg_InvalidUTF8"), "bytes");
-#endif
                }
                leftOverBits = leftBits;
                leftOverCount = (leftSoFar | (leftSize << 4));
@@ -937,18 +789,12 @@ fail_no_space:
        {
                uint leftOverBits = 0;
                uint leftOverCount = 0;
-#if NET_2_0
                DecoderFallbackBuffer buf = null;
                byte [] bufferArg = null;
                return InternalGetChars (bytes, byteIndex, byteCount, chars, 
                                charIndex, ref leftOverBits, ref leftOverCount, DecoderFallback, ref buf, ref bufferArg, true);
-#else
-               return InternalGetChars (bytes, byteIndex, byteCount, chars, 
-                               charIndex, ref leftOverBits, ref leftOverCount, throwOnInvalid, true);
-#endif
        }
 
-#if NET_2_0
        [CLSCompliant (false)]
        [ComVisible (false)]
        public unsafe override int GetChars (byte* bytes, int byteCount, char* chars, int charCount)
@@ -960,7 +806,6 @@ fail_no_space:
                return InternalGetChars (bytes, byteCount, chars, 
                                charCount, ref leftOverBits, ref leftOverCount, DecoderFallback, ref buf, ref bufferArg, true);
        }
-#endif
 
        // Get the maximum number of bytes needed to encode a
        // specified number of characters.
@@ -985,11 +830,7 @@ fail_no_space:
        // Get a UTF8-specific decoder that is attached to this instance.
        public override Decoder GetDecoder ()
        {
-#if NET_2_0
                return new UTF8Decoder (DecoderFallback);
-#else
-               return new UTF8Decoder (throwOnInvalid);
-#endif
        }
 
        // Get a UTF8-specific encoder that is attached to this instance.
@@ -1017,16 +858,10 @@ fail_no_space:
        {
                UTF8Encoding enc = (value as UTF8Encoding);
                if (enc != null) {
-#if NET_2_0
                        return (codePage == enc.codePage &&
                                emitIdentifier == enc.emitIdentifier &&
                                DecoderFallback.Equals (enc.DecoderFallback) &&
                                EncoderFallback.Equals (enc.EncoderFallback));
-#else
-                       return (codePage == enc.codePage &&
-                                       emitIdentifier == enc.emitIdentifier &&
-                                       throwOnInvalid == enc.throwOnInvalid);
-#endif
                } else {
                        return false;
                }
@@ -1038,7 +873,6 @@ fail_no_space:
                return base.GetHashCode ();
        }
 
-#if NET_2_0
        public override int GetByteCount (string chars)
        {
                // hmm, does this override make any sense?
@@ -1051,43 +885,18 @@ fail_no_space:
                // hmm, does this override make any sense?
                return base.GetString (bytes, index, count);
        }
-#endif
-
-#if !NET_2_0
-       public override byte [] GetBytes (String s)
-       {
-               if (s == null)
-                       throw new ArgumentNullException ("s");
-               
-               int length = GetByteCount (s);
-               byte [] bytes = new byte [length];
-               GetBytes (s, 0, s.Length, bytes, 0);
-               return bytes;
-       }
-#endif
 
        // UTF-8 decoder implementation.
        [Serializable]
        private class UTF8Decoder : Decoder
        {
-#if !NET_2_0
-               private bool throwOnInvalid;
-#endif
                private uint leftOverBits;
                private uint leftOverCount;
 
                // Constructor.
-#if NET_2_0
                public UTF8Decoder (DecoderFallback fallback)
-#else
-               public UTF8Decoder (bool throwOnInvalid)
-#endif
                {
-#if NET_2_0
                        Fallback = fallback;
-#else
-                       this.throwOnInvalid = throwOnInvalid;
-#endif
                        leftOverBits = 0;
                        leftOverCount = 0;
                }
@@ -1095,28 +904,18 @@ fail_no_space:
                // Override inherited methods.
                public override int GetCharCount (byte[] bytes, int index, int count)
                {
-#if NET_2_0
                        DecoderFallbackBuffer buf = null;
                        byte [] bufferArg = null;
                        return InternalGetCharCount (bytes, index, count,
                                leftOverBits, leftOverCount, this, ref buf, ref bufferArg, false);
-#else
-                       return InternalGetCharCount (bytes, index, count,
-                                       leftOverBits, leftOverCount, throwOnInvalid, false);
-#endif
                }
                public override int GetChars (byte[] bytes, int byteIndex,
                                                 int byteCount, char[] chars, int charIndex)
                {
-#if NET_2_0
                        DecoderFallbackBuffer buf = null;
                        byte [] bufferArg = null;
                        return InternalGetChars (bytes, byteIndex, byteCount,
                                chars, charIndex, ref leftOverBits, ref leftOverCount, this, ref buf, ref bufferArg, false);
-#else
-                       return InternalGetChars (bytes, byteIndex, byteCount,
-                               chars, charIndex, ref leftOverBits, ref leftOverCount, throwOnInvalid, false);
-#endif
                }
 
        } // class UTF8Decoder
@@ -1152,7 +951,6 @@ fail_no_space:
                        return result;
                }
 
-#if NET_2_0
                public unsafe override int GetByteCount (char* chars, int count, bool flush)
                {
                        return InternalGetByteCount (chars, count, ref leftOverForCount, flush);
@@ -1166,8 +964,6 @@ fail_no_space:
 //                     emitIdentifier = false;
                        return result;
                }
-#endif
-
        } // class UTF8Encoder
 
 }; // class UTF8Encoding
index 451d1d231e93a0b832d652c3d910b9c964227a03..c0f8ab716c56a55ca5759134409f8a414ac5bffa 100644 (file)
@@ -32,10 +32,8 @@ using System;
 using System.Runtime.InteropServices;
 
 [Serializable]
-#if NET_2_0
 [ComVisible (true)]
-#endif
-[MonoTODO ("Serialization format not compatible with .NET")]
+[MonoLimitation ("Serialization format not compatible with .NET")]
 public class UnicodeEncoding : Encoding
 {
        // Magic numbers used by Windows for Unicode.
@@ -62,18 +60,13 @@ public class UnicodeEncoding : Encoding
        {
        }
 
-#if NET_2_0
-       public
-#endif
-       UnicodeEncoding (bool bigEndian, bool byteOrderMark, bool throwOnInvalidBytes)
+       public UnicodeEncoding (bool bigEndian, bool byteOrderMark, bool throwOnInvalidBytes)
                : base ((bigEndian ? BIG_UNICODE_CODE_PAGE : UNICODE_CODE_PAGE))
        {
-#if NET_2_0
                if (throwOnInvalidBytes)
                        SetFallbackInternal (null, new DecoderExceptionFallback ());
                else
                        SetFallbackInternal (null, new DecoderReplacementFallback ("\uFFFD"));
-#endif
 
                this.bigEndian = bigEndian;
                this.byteOrderMark = byteOrderMark;
@@ -120,7 +113,6 @@ public class UnicodeEncoding : Encoding
                return s.Length * 2;
        }
 
-#if NET_2_0
        [CLSCompliantAttribute (false)]
        [ComVisible (false)]
        public unsafe override int GetByteCount (char* chars, int count)
@@ -132,7 +124,6 @@ public class UnicodeEncoding : Encoding
 
                return count * 2;
        }
-#endif
 
        // Get the bytes that result from encoding a character buffer.
        public unsafe override int GetBytes (char [] chars, int charIndex, int charCount,
@@ -166,21 +157,6 @@ public class UnicodeEncoding : Encoding
                                return GetBytesInternal (charPtr + charIndex, charCount, bytePtr + byteIndex, byteCount);
        }
 
-#if !NET_2_0
-       public override byte [] GetBytes (String s)
-       {
-               if (s == null)
-                       throw new ArgumentNullException ("s");
-
-               int byteCount = GetByteCount (s);
-               byte [] bytes = new byte [byteCount];
-
-               GetBytes (s, 0, s.Length, bytes, 0);
-
-               return bytes;
-       }
-#endif
-
        public unsafe override int GetBytes (String s, int charIndex, int charCount,
                                                                                byte [] bytes, int byteIndex)
        {
@@ -213,7 +189,6 @@ public class UnicodeEncoding : Encoding
                                return GetBytesInternal (charPtr + charIndex, charCount, bytePtr + byteIndex, byteCount);
        }
 
-#if NET_2_0
        [CLSCompliantAttribute (false)]
        [ComVisible (false)]
        public unsafe override int GetBytes (char* chars, int charCount,
@@ -230,7 +205,6 @@ public class UnicodeEncoding : Encoding
 
                return GetBytesInternal (chars, charCount, bytes, byteCount);
        }
-#endif
 
        private unsafe int GetBytesInternal (char* chars, int charCount,
                                                                                byte* bytes, int byteCount)
@@ -259,7 +233,6 @@ public class UnicodeEncoding : Encoding
                return count / 2;
        }
 
-#if NET_2_0
        [CLSCompliantAttribute (false)]
        [ComVisible (false)]
        public unsafe override int GetCharCount (byte* bytes, int count)
@@ -271,7 +244,6 @@ public class UnicodeEncoding : Encoding
 
                return count / 2;
        }
-#endif
 
        // Get the characters that result from decoding a byte buffer.
        public unsafe override int GetChars (byte [] bytes, int byteIndex, int byteCount,
@@ -305,7 +277,6 @@ public class UnicodeEncoding : Encoding
                                return GetCharsInternal (bytePtr + byteIndex, byteCount, charPtr + charIndex, charCount);
 }
 
-#if NET_2_0
        [CLSCompliantAttribute (false)]
        [ComVisible (false)]
        public unsafe override int GetChars (byte* bytes, int byteCount,
@@ -322,7 +293,6 @@ public class UnicodeEncoding : Encoding
 
                return GetCharsInternal (bytes, byteCount, chars, charCount);
        }
-#endif
 
        // Decode a buffer of bytes into a string.
        [ComVisible (false)]