From a82f54bd51e22ec3eb14eb5d8f572f022becb8e3 Mon Sep 17 00:00:00 2001 From: Morgan Brown Date: Thu, 25 May 2017 12:38:09 -0700 Subject: ISerializable cleanup (#20220) * Changes to throw PlatformNotSupportedException from ISerializable.GetObjectData and serialization constructors on non-serializable types. Also removes private serialization constructors and some unneeded code that was used to support serializing non-serializable types. A few tests testing GetObjectData implementations are also removed. * Address code review comments. * Change exceptions' GetObjectData to just call base rather than throw. This makes them behave consistently with exceptions that didn't override GetObjectData. --- .../src/System/Xml/Linq/XName.cs | 25 +++------------------- 1 file changed, 3 insertions(+), 22 deletions(-) (limited to 'src/System.Private.Xml.Linq') diff --git a/src/System.Private.Xml.Linq/src/System/Xml/Linq/XName.cs b/src/System.Private.Xml.Linq/src/System/Xml/Linq/XName.cs index c330510dd4..efc95cbeb8 100644 --- a/src/System.Private.Xml.Linq/src/System/Xml/Linq/XName.cs +++ b/src/System.Private.Xml.Linq/src/System/Xml/Linq/XName.cs @@ -189,28 +189,9 @@ namespace System.Xml.Linq /// /// The to populate with data /// The destination for this serialization - void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context) { - if (info == null) throw new ArgumentNullException(nameof(info)); - info.AddValue("name", ToString()); - info.SetType(typeof(NameSerializer)); - } - } - - internal sealed class NameSerializer : IObjectReference, ISerializable - { - string _expandedName; - - private NameSerializer(SerializationInfo info, StreamingContext context) { - if (info == null) throw new ArgumentNullException(nameof(info)); - _expandedName = info.GetString("name"); - } - - object IObjectReference.GetRealObject(StreamingContext context) { - return XName.Get(_expandedName); - } - - void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context) { - throw new NotSupportedException(); // nop + void ISerializable.GetObjectData(SerializationInfo info, StreamingContext context) + { + throw new PlatformNotSupportedException(); } } } -- cgit v1.2.3