XmlSerializer support for IsDynamicCodeSupported=false (#59386)
authorEric Erhardt <eric.erhardt@microsoft.com>
Thu, 23 Sep 2021 01:10:40 +0000 (19:10 -0600)
committerGitHub <noreply@github.com>
Thu, 23 Sep 2021 01:10:40 +0000 (20:10 -0500)
commit9114f773aa754f4888d0aace2d8a51a173220e51
treeb51d79b9a2fef1e37373e5b51facc4ed7e495e0d
parent19adeff2108cf4131df677919968627a16da02cb
XmlSerializer support for IsDynamicCodeSupported=false (#59386)

* XmlSerializer support for IsDynamicCodeSupported=false

Add more checks to XmlSerializer to check the SerializationMode. Don't try to use Reflection.Emit if the SerializationMode is ReflectionOnly.

These changes were ported from
* https://github.com/dotnet/runtimelab/pull/593
* https://github.com/dotnet/runtimelab/pull/600

Fix #59167

* Fix a bug in XmlSerializer.CanDeserialize when in ReflectionOnly mode.

* Port UAP code for CanDeserialize

* PR feedback

* Add a linker test to ensure linker option '--enable-opt sealer' works when IsDynamicCodeSupported==false.
src/libraries/System.Private.Xml/src/System/Xml/Serialization/XmlSerializer.cs
src/libraries/System.Private.Xml/tests/TrimmingTests/System.Private.Xml.TrimmingTests.proj
src/libraries/System.Private.Xml/tests/TrimmingTests/XmlSerializer.Deserialize.SealerOpt.cs [new file with mode: 0644]