diff options
author | Morgan Brown <morganbr@users.noreply.github.com> | 2017-05-25 22:38:09 +0300 |
---|---|---|
committer | Dan Moseley <danmose@microsoft.com> | 2017-05-25 22:38:09 +0300 |
commit | a82f54bd51e22ec3eb14eb5d8f572f022becb8e3 (patch) | |
tree | f6b2b5497c076e4222ae4bbca64d37d34727ccba /src/System.Private.Xml.Linq | |
parent | 5391ceb55562c785446b176f242e4c67258a5072 (diff) |
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.
Diffstat (limited to 'src/System.Private.Xml.Linq')
-rw-r--r-- | src/System.Private.Xml.Linq/src/System/Xml/Linq/XName.cs | 25 |
1 files changed, 3 insertions, 22 deletions
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 /// </summary> /// <param name="info">The <see cref="SerializationInfo"/> to populate with data</param> /// <param name="context">The destination for this serialization</param> - 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(); } } } |