summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMorgan Brown <morganbr@users.noreply.github.com>2017-05-27 21:07:32 -0700
committerGitHub <noreply@github.com>2017-05-27 21:07:32 -0700
commit68570e183b2dc53682079d8ab4dac24f893aebfa (patch)
treeb5d66b181ec53c27890bbf162eda3889c0e04dea /src
parenta90081b1d83f0447cace40b18ee908117d12b645 (diff)
downloadcoreclr-68570e183b2dc53682079d8ab4dac24f893aebfa.tar.gz
coreclr-68570e183b2dc53682079d8ab4dac24f893aebfa.tar.bz2
coreclr-68570e183b2dc53682079d8ab4dac24f893aebfa.zip
IDeserializationCallback cleanup
Throws PlatformNotSupportedException from IDeserializationCallback and IObjectReference implementations on types that are no longer serializable.
Diffstat (limited to 'src')
-rw-r--r--src/mscorlib/shared/System/Reflection/ParameterInfo.cs41
-rw-r--r--src/mscorlib/shared/System/Reflection/StrongNameKeyPair.cs5
-rw-r--r--src/mscorlib/src/System/Collections/Hashtable.cs2
-rw-r--r--src/mscorlib/src/System/Globalization/TextInfo.cs31
-rw-r--r--src/mscorlib/src/System/Reflection/AssemblyName.cs33
-rw-r--r--src/mscorlib/src/System/Text/Encoding.cs41
-rw-r--r--src/mscorlib/src/System/TimeZoneInfo.cs19
7 files changed, 12 insertions, 160 deletions
diff --git a/src/mscorlib/shared/System/Reflection/ParameterInfo.cs b/src/mscorlib/shared/System/Reflection/ParameterInfo.cs
index 94bfffaa53..fd130e569b 100644
--- a/src/mscorlib/shared/System/Reflection/ParameterInfo.cs
+++ b/src/mscorlib/shared/System/Reflection/ParameterInfo.cs
@@ -54,46 +54,7 @@ namespace System.Reflection
public object GetRealObject(StreamingContext context)
{
- // Once all the serializable fields have come in we can set up the real
- // instance based on just two of them (MemberImpl and PositionImpl).
-
- if (MemberImpl == null)
- throw new SerializationException(SR.Serialization_InsufficientState);
-
- ParameterInfo[] args = null;
-
- switch (MemberImpl.MemberType)
- {
- case MemberTypes.Constructor:
- case MemberTypes.Method:
- if (PositionImpl == -1)
- {
- if (MemberImpl.MemberType == MemberTypes.Method)
- return ((MethodInfo)MemberImpl).ReturnParameter;
- else
- throw new SerializationException(SR.Serialization_BadParameterInfo);
- }
- else
- {
- args = ((MethodBase)MemberImpl).GetParametersNoCopy();
-
- if (args != null && PositionImpl < args.Length)
- return args[PositionImpl];
- else
- throw new SerializationException(SR.Serialization_BadParameterInfo);
- }
-
- case MemberTypes.Property:
- args = ((PropertyInfo)MemberImpl).GetIndexParameters();
-
- if (args != null && PositionImpl > -1 && PositionImpl < args.Length)
- return args[PositionImpl];
- else
- throw new SerializationException(SR.Serialization_BadParameterInfo);
-
- default:
- throw new SerializationException(SR.Serialization_NoParameterInfo);
- }
+ throw new PlatformNotSupportedException();
}
public override string ToString() => ParameterType.FormatTypeName() + " " + Name;
diff --git a/src/mscorlib/shared/System/Reflection/StrongNameKeyPair.cs b/src/mscorlib/shared/System/Reflection/StrongNameKeyPair.cs
index c11ee42864..6efa626946 100644
--- a/src/mscorlib/shared/System/Reflection/StrongNameKeyPair.cs
+++ b/src/mscorlib/shared/System/Reflection/StrongNameKeyPair.cs
@@ -62,6 +62,9 @@ namespace System.Reflection
throw new PlatformNotSupportedException();
}
- void IDeserializationCallback.OnDeserialization(object sender) { }
+ void IDeserializationCallback.OnDeserialization(object sender)
+ {
+ throw new PlatformNotSupportedException();
+ }
}
}
diff --git a/src/mscorlib/src/System/Collections/Hashtable.cs b/src/mscorlib/src/System/Collections/Hashtable.cs
index fb5034fbe5..0c89632828 100644
--- a/src/mscorlib/src/System/Collections/Hashtable.cs
+++ b/src/mscorlib/src/System/Collections/Hashtable.cs
@@ -1274,7 +1274,7 @@ namespace System.Collections
==============================================================================*/
public override void OnDeserialization(Object sender)
{
- return;
+ throw new PlatformNotSupportedException();
}
}
diff --git a/src/mscorlib/src/System/Globalization/TextInfo.cs b/src/mscorlib/src/System/Globalization/TextInfo.cs
index 3b567b9f20..dd542579d9 100644
--- a/src/mscorlib/src/System/Globalization/TextInfo.cs
+++ b/src/mscorlib/src/System/Globalization/TextInfo.cs
@@ -92,38 +92,9 @@ namespace System.Globalization
FinishInitialization(_textInfoName);
}
- [OnSerializing]
- private void OnSerializing(StreamingContext ctx) { }
-
- [OnDeserializing]
- private void OnDeserializing(StreamingContext ctx)
- {
- // Clear these so we can check if we've fixed them yet
- _cultureData = null;
- _cultureName = null;
- }
-
- [OnDeserialized]
- private void OnDeserialized(StreamingContext ctx)
- {
- OnDeserialized();
- }
-
void IDeserializationCallback.OnDeserialization(Object sender)
{
- OnDeserialized();
- }
-
- private void OnDeserialized()
- {
- // this method will be called twice because of the support of IDeserializationCallback
- if (_cultureData == null)
- {
- // Get the text info name belonging to that culture
- _cultureData = CultureInfo.GetCultureInfo(_cultureName)._cultureData;
- _textInfoName = _cultureData.STEXTINFO;
- FinishInitialization(_textInfoName);
- }
+ throw new PlatformNotSupportedException();
}
//
diff --git a/src/mscorlib/src/System/Reflection/AssemblyName.cs b/src/mscorlib/src/System/Reflection/AssemblyName.cs
index 8ba4152df2..fe9a2b1268 100644
--- a/src/mscorlib/src/System/Reflection/AssemblyName.cs
+++ b/src/mscorlib/src/System/Reflection/AssemblyName.cs
@@ -303,38 +303,7 @@ namespace System.Reflection
public void OnDeserialization(Object sender)
{
- // Deserialization has already been performed
- if (m_siInfo == null)
- return;
-
- _Name = m_siInfo.GetString("_Name");
- _PublicKey = (byte[])m_siInfo.GetValue("_PublicKey", typeof(byte[]));
- _PublicKeyToken = (byte[])m_siInfo.GetValue("_PublicKeyToken", typeof(byte[]));
-#if FEATURE_USE_LCID
- int lcid = (int)m_siInfo.GetInt32("_CultureInfo");
- if (lcid != -1)
- _CultureInfo = new CultureInfo(lcid);
-#endif
-
- _CodeBase = m_siInfo.GetString("_CodeBase");
- _Version = (Version)m_siInfo.GetValue("_Version", typeof(Version));
- _HashAlgorithm = (AssemblyHashAlgorithm)m_siInfo.GetValue("_HashAlgorithm", typeof(AssemblyHashAlgorithm));
- _StrongNameKeyPair = (StrongNameKeyPair)m_siInfo.GetValue("_StrongNameKeyPair", typeof(StrongNameKeyPair));
- _VersionCompatibility = (AssemblyVersionCompatibility)m_siInfo.GetValue("_VersionCompatibility", typeof(AssemblyVersionCompatibility));
- _Flags = (AssemblyNameFlags)m_siInfo.GetValue("_Flags", typeof(AssemblyNameFlags));
-
- try
- {
- _HashAlgorithmForControl = (AssemblyHashAlgorithm)m_siInfo.GetValue("_HashAlgorithmForControl", typeof(AssemblyHashAlgorithm));
- _HashForControl = (byte[])m_siInfo.GetValue("_HashForControl", typeof(byte[]));
- }
- catch (SerializationException)
- { // RTM did not have these defined
- _HashAlgorithmForControl = AssemblyHashAlgorithm.None;
- _HashForControl = null;
- }
-
- m_siInfo = null;
+ throw new PlatformNotSupportedException();
}
public AssemblyName(String assemblyName)
diff --git a/src/mscorlib/src/System/Text/Encoding.cs b/src/mscorlib/src/System/Text/Encoding.cs
index 5f55fd1b00..88eeb19d24 100644
--- a/src/mscorlib/src/System/Text/Encoding.cs
+++ b/src/mscorlib/src/System/Text/Encoding.cs
@@ -1419,30 +1419,10 @@ namespace System.Text
m_encoding = encoding;
m_hasInitializedEncoding = true;
}
-
- // 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
@@ -1516,24 +1496,9 @@ namespace System.Text
m_hasInitializedEncoding = true;
}
- // 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
diff --git a/src/mscorlib/src/System/TimeZoneInfo.cs b/src/mscorlib/src/System/TimeZoneInfo.cs
index 8ed7e229c0..3450311835 100644
--- a/src/mscorlib/src/System/TimeZoneInfo.cs
+++ b/src/mscorlib/src/System/TimeZoneInfo.cs
@@ -1012,24 +1012,7 @@ namespace System
void IDeserializationCallback.OnDeserialization(object sender)
{
- try
- {
- bool adjustmentRulesSupportDst;
- ValidateTimeZoneInfo(_id, _baseUtcOffset, _adjustmentRules, out adjustmentRulesSupportDst);
-
- if (adjustmentRulesSupportDst != _supportsDaylightSavingTime)
- {
- throw new SerializationException(SR.Format(SR.Serialization_CorruptField, "SupportsDaylightSavingTime"));
- }
- }
- catch (ArgumentException e)
- {
- throw new SerializationException(SR.Serialization_InvalidData, e);
- }
- catch (InvalidTimeZoneException e)
- {
- throw new SerializationException(SR.Serialization_InvalidData, e);
- }
+ throw new PlatformNotSupportedException();
}
void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context)