Explorar o código

2009-11-02 Miguel de Icaza <[email protected]>

        * 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
Miguel de Icaza %!s(int64=16) %!d(string=hai) anos
pai
achega
53d746c7a1
Modificáronse 29 ficheiros con 34 adicións e 512 borrados
  1. 18 60
      mcs/class/corlib/System.Text/ASCIIEncoding.cs
  2. 6 0
      mcs/class/corlib/System.Text/ChangeLog
  3. 0 6
      mcs/class/corlib/System.Text/CodePageEncoding.cs
  4. 0 7
      mcs/class/corlib/System.Text/Decoder.cs
  5. 0 4
      mcs/class/corlib/System.Text/DecoderExceptionFallback.cs
  6. 0 4
      mcs/class/corlib/System.Text/DecoderExceptionFallbackBuffer.cs
  7. 0 4
      mcs/class/corlib/System.Text/DecoderFallback.cs
  8. 0 3
      mcs/class/corlib/System.Text/DecoderFallbackBuffer.cs
  9. 0 4
      mcs/class/corlib/System.Text/DecoderFallbackException.cs
  10. 0 4
      mcs/class/corlib/System.Text/DecoderReplacementFallback.cs
  11. 0 3
      mcs/class/corlib/System.Text/DecoderReplacementFallbackBuffer.cs
  12. 0 6
      mcs/class/corlib/System.Text/Encoder.cs
  13. 0 4
      mcs/class/corlib/System.Text/EncoderExceptionFallback.cs
  14. 0 4
      mcs/class/corlib/System.Text/EncoderExceptionFallbackBuffer.cs
  15. 0 4
      mcs/class/corlib/System.Text/EncoderFallback.cs
  16. 0 3
      mcs/class/corlib/System.Text/EncoderFallbackBuffer.cs
  17. 0 4
      mcs/class/corlib/System.Text/EncoderFallbackException.cs
  18. 0 4
      mcs/class/corlib/System.Text/EncoderReplacementFallback.cs
  19. 0 3
      mcs/class/corlib/System.Text/EncoderReplacementFallbackBuffer.cs
  20. 3 67
      mcs/class/corlib/System.Text/Encoding.cs
  21. 0 3
      mcs/class/corlib/System.Text/EncodingInfo.cs
  22. 0 17
      mcs/class/corlib/System.Text/Latin1Encoding.cs
  23. 0 25
      mcs/class/corlib/System.Text/MLangCodePageEncoding.cs
  24. 0 2
      mcs/class/corlib/System.Text/NormalizationForm.cs
  25. 2 7
      mcs/class/corlib/System.Text/StringBuilder.cs
  26. 0 14
      mcs/class/corlib/System.Text/UTF32Encoding.cs
  27. 1 8
      mcs/class/corlib/System.Text/UTF7Encoding.cs
  28. 2 206
      mcs/class/corlib/System.Text/UTF8Encoding.cs
  29. 2 32
      mcs/class/corlib/System.Text/UnicodeEncoding.cs

+ 18 - 60
mcs/class/corlib/System.Text/ASCIIEncoding.cs

@@ -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

+ 6 - 0
mcs/class/corlib/System.Text/ChangeLog

@@ -1,3 +1,9 @@
+2009-11-02  Miguel de Icaza  <[email protected]>
+
+	* 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  <[email protected]>
 
 	* StringBuilder.cs (Text): Add new 4.0 method.

+ 0 - 6
mcs/class/corlib/System.Text/CodePageEncoding.cs

@@ -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;
 			}

+ 0 - 7
mcs/class/corlib/System.Text/Decoder.cs

@@ -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

+ 0 - 4
mcs/class/corlib/System.Text/DecoderExceptionFallback.cs

@@ -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

+ 0 - 4
mcs/class/corlib/System.Text/DecoderExceptionFallbackBuffer.cs

@@ -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

+ 0 - 4
mcs/class/corlib/System.Text/DecoderFallback.cs

@@ -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

+ 0 - 3
mcs/class/corlib/System.Text/DecoderFallbackBuffer.cs

@@ -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

+ 0 - 4
mcs/class/corlib/System.Text/DecoderFallbackException.cs

@@ -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

+ 0 - 4
mcs/class/corlib/System.Text/DecoderReplacementFallback.cs

@@ -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

+ 0 - 3
mcs/class/corlib/System.Text/DecoderReplacementFallbackBuffer.cs

@@ -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

+ 0 - 6
mcs/class/corlib/System.Text/Encoder.cs

@@ -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

+ 0 - 4
mcs/class/corlib/System.Text/EncoderExceptionFallback.cs

@@ -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

+ 0 - 4
mcs/class/corlib/System.Text/EncoderExceptionFallbackBuffer.cs

@@ -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

+ 0 - 4
mcs/class/corlib/System.Text/EncoderFallback.cs

@@ -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

+ 0 - 3
mcs/class/corlib/System.Text/EncoderFallbackBuffer.cs

@@ -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

+ 0 - 4
mcs/class/corlib/System.Text/EncoderFallbackException.cs

@@ -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

+ 0 - 4
mcs/class/corlib/System.Text/EncoderReplacementFallback.cs

@@ -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

+ 0 - 3
mcs/class/corlib/System.Text/EncoderReplacementFallbackBuffer.cs

@@ -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

+ 3 - 67
mcs/class/corlib/System.Text/Encoding.cs

@@ -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

+ 0 - 3
mcs/class/corlib/System.Text/EncodingInfo.cs

@@ -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

+ 0 - 17
mcs/class/corlib/System.Text/Latin1Encoding.cs

@@ -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;

+ 0 - 25
mcs/class/corlib/System.Text/MLangCodePageEncoding.cs

@@ -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;
 			}
 

+ 0 - 2
mcs/class/corlib/System.Text/NormalizationForm.cs

@@ -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

+ 2 - 7
mcs/class/corlib/System.Text/StringBuilder.cs

@@ -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;

+ 0 - 14
mcs/class/corlib/System.Text/UTF32Encoding.cs

@@ -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

+ 1 - 8
mcs/class/corlib/System.Text/UTF7Encoding.cs

@@ -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

+ 2 - 206
mcs/class/corlib/System.Text/UTF8Encoding.cs

@@ -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

+ 2 - 32
mcs/class/corlib/System.Text/UnicodeEncoding.cs

@@ -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)]