Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit d421196

Browse files
committed
Merge pull request #2128 from dotnet-bot/from-tfs
Merge changes from TFS
2 parents df881ff + 612855b commit d421196

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

src/System.Xml.XmlSerializer/src/System/Xml/Serialization/XmlSerializer.cs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ public class XmlSerializer
5959
private XmlMapping _mapping;
6060
private XmlDeserializationEvents _events = new XmlDeserializationEvents();
6161
#if NET_NATIVE
62+
public string DefaultNamespace = null;
6263
private XmlSerializer innerSerializer;
6364
private readonly Type rootType;
6465
#endif
@@ -156,13 +157,7 @@ public XmlSerializer(Type type, string defaultNamespace)
156157
throw new ArgumentNullException("type");
157158

158159
#if NET_NATIVE
159-
// The ctor is not supported, but we cannot throw PNSE unconditionally
160-
// because the ctor is used by ctor(Type) which passes in a null defaultNamespace.
161-
if (!string.IsNullOrEmpty(defaultNamespace))
162-
{
163-
throw new PlatformNotSupportedException();
164-
}
165-
160+
this.DefaultNamespace = defaultNamespace;
166161
rootType = type;
167162
#endif
168163
_mapping = GetKnownMapping(type, defaultNamespace);
@@ -344,6 +339,11 @@ internal void Serialize(XmlWriter xmlWriter, object o, XmlSerializerNamespaces n
344339
throw new InvalidOperationException(SR.Format(SR.Xml_MissingSerializationCodeException, this.rootType, typeof(XmlSerializer).Name));
345340
}
346341

342+
if (!string.IsNullOrEmpty(this.DefaultNamespace))
343+
{
344+
this.innerSerializer.DefaultNamespace = this.DefaultNamespace;
345+
}
346+
347347
XmlSerializationWriter writer = this.innerSerializer.CreateWriter();
348348
writer.Init(xmlWriter, namespaces == null || namespaces.Count == 0 ? DefaultNamespaces : namespaces, encodingStyle, id);
349349
try
@@ -459,6 +459,11 @@ internal object Deserialize(XmlReader xmlReader, string encodingStyle, XmlDeseri
459459
throw new InvalidOperationException(SR.Format(SR.Xml_MissingSerializationCodeException, this.rootType, typeof(XmlSerializer).Name));
460460
}
461461

462+
if (!string.IsNullOrEmpty(this.DefaultNamespace))
463+
{
464+
this.innerSerializer.DefaultNamespace = this.DefaultNamespace;
465+
}
466+
462467
XmlSerializationReader reader = this.innerSerializer.CreateReader();
463468
reader.Init(xmlReader, encodingStyle);
464469
try

0 commit comments

Comments
 (0)