diff options
Diffstat (limited to 'src/mscorlib/src/System/Text/Encoding.cs')
-rw-r--r-- | src/mscorlib/src/System/Text/Encoding.cs | 100 |
1 files changed, 6 insertions, 94 deletions
diff --git a/src/mscorlib/src/System/Text/Encoding.cs b/src/mscorlib/src/System/Text/Encoding.cs index 159123495b..88eeb19d24 100644 --- a/src/mscorlib/src/System/Text/Encoding.cs +++ b/src/mscorlib/src/System/Text/Encoding.cs @@ -8,7 +8,6 @@ namespace System.Text using System.Collections; using System.Collections.Generic; using System.Runtime; - using System.Runtime.Remoting; using System.Runtime.Serialization; using System.Globalization; using System.Security; @@ -82,7 +81,6 @@ namespace System.Text // generally executes faster. // - [Serializable] public abstract class Encoding : ICloneable { // For netcore we use UTF8 as default encoding since ANSI isn't available @@ -1409,7 +1407,6 @@ namespace System.Text decoder.ClearMustFlush(); } - [Serializable] internal sealed class DefaultEncoder : Encoder, IObjectReference, ISerializable { private Encoding m_encoding; @@ -1422,60 +1419,16 @@ namespace System.Text m_encoding = encoding; m_hasInitializedEncoding = true; } - - // Constructor called by serialization, have to handle deserializing from Everett - internal DefaultEncoder(SerializationInfo info, StreamingContext context) - { - if (info == null) throw new ArgumentNullException(nameof(info)); - Contract.EndContractBlock(); - - // All we have is our encoding - m_encoding = (Encoding)info.GetValue("encoding", typeof(Encoding)); - - try - { - this.m_fallback = (EncoderFallback)info.GetValue("m_fallback", typeof(EncoderFallback)); - this.charLeftOver = (Char)info.GetValue("charLeftOver", typeof(Char)); - } - catch (SerializationException) - { - } - } - - // Just get it from GetEncoding + public Object GetRealObject(StreamingContext context) { - // upon deserialization since the DefaultEncoder implement IObjectReference the - // serialization code tries to do the fixup. The fixup returns another - // IObjectReference (the DefaultEncoder) class and hence so on and on. - // Finally the deserialization logics fails after following maximum references - // unless we short circuit with the following - if (m_hasInitializedEncoding) - { - return this; - } - - Encoder encoder = m_encoding.GetEncoder(); - if (m_fallback != null) - encoder.m_fallback = m_fallback; - if (charLeftOver != (char)0) - { - EncoderNLS encoderNls = encoder as EncoderNLS; - if (encoderNls != null) - encoderNls.charLeftOver = charLeftOver; - } - return encoder; + throw new PlatformNotSupportedException(); } // ISerializable implementation, get data for this object void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context) { - // Any info? - if (info == null) throw new ArgumentNullException(nameof(info)); - Contract.EndContractBlock(); - - // All we have is our encoding - info.AddValue("encoding", m_encoding); + throw new PlatformNotSupportedException(); } // Returns the number of bytes the next call to GetBytes will @@ -1531,7 +1484,6 @@ namespace System.Text } } - [Serializable] internal sealed class DefaultDecoder : Decoder, IObjectReference, ISerializable { private Encoding m_encoding; @@ -1544,55 +1496,15 @@ namespace System.Text m_hasInitializedEncoding = true; } - // Constructor called by serialization, have to handle deserializing from Everett - internal DefaultDecoder(SerializationInfo info, StreamingContext context) - { - // Any info? - if (info == null) throw new ArgumentNullException(nameof(info)); - Contract.EndContractBlock(); - - // All we have is our encoding - m_encoding = (Encoding)info.GetValue("encoding", typeof(Encoding)); - - try - { - this.m_fallback = (DecoderFallback)info.GetValue("m_fallback", typeof(DecoderFallback)); - } - catch (SerializationException) - { - m_fallback = null; - } - } - - // Just get it from GetEncoding public Object GetRealObject(StreamingContext context) { - // upon deserialization since the DefaultEncoder implement IObjectReference the - // serialization code tries to do the fixup. The fixup returns another - // IObjectReference (the DefaultEncoder) class and hence so on and on. - // Finally the deserialization logics fails after following maximum references - // unless we short circuit with the following - if (m_hasInitializedEncoding) - { - return this; - } - - Decoder decoder = m_encoding.GetDecoder(); - if (m_fallback != null) - decoder.m_fallback = m_fallback; - - return decoder; + throw new PlatformNotSupportedException(); } - // ISerializable implementation, get data for this object + // ISerializable implementation void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context) { - // Any info? - if (info == null) throw new ArgumentNullException(nameof(info)); - Contract.EndContractBlock(); - - // All we have is our encoding - info.AddValue("encoding", m_encoding); + throw new PlatformNotSupportedException(); } // Returns the number of characters the next call to GetChars will |