You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
XmlSerializer tries to use Reflection.Emit even if RuntimeFeature.IsDynamicCodeSupported is false #59167
We have a test case that fails with when IsDynamicCodeSupported=false (when executing in a FullAOT scenario on an iOS device):
[FAIL] Bug1820_GenericList : System.TypeLoadException : Could not load type 'Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializer1' from assembly 'Microsoft.GeneratedCode, Version=1.0.0.0' because the parent type is sealed.
at System.Reflection.Emit.TypeBuilder.CreateTypeInfo()
at System.Xml.Serialization.XmlSerializationILGen.GenerateBaseSerializer(String , String , String , CodeIdentifiers )
at System.Xml.Serialization.TempAssembly.GenerateRefEmitAssembly(XmlMapping[] , Type[] , String )
at System.Xml.Serialization.TempAssembly..ctor(XmlMapping[] , Type[] , String , String )
at System.Xml.Serialization.XmlSerializer.GenerateTempAssembly(XmlMapping xmlMapping, Type type, String defaultNamespace, String location)
at System.Xml.Serialization.XmlSerializer.GenerateTempAssembly(XmlMapping xmlMapping, Type type, String defaultNamespace)
at System.Xml.Serialization.XmlSerializer..ctor(Type type, String defaultNamespace)
at System.Xml.Serialization.XmlSerializer..ctor(Type type)
at LinkSdk.Serialization.XmlSerializationTest.Response.get_Serializer()
at LinkSdk.Serialization.XmlSerializationTest.Response.Deserialize(String xml)
at LinkSdk.Serialization.XmlSerializationTest.Bug1820_GenericList()
at System.Reflection.RuntimeMethodInfo.Invoke(Object , BindingFlags , Binder , Object[] , CultureInfo )
the actual test failure message is misleading: the problem is that RuntimeFeature.IsDynamicCodeSupported is false, so XmlSerializer shouldn't try to use Reflection.Emit in the first place.
@marek-safar Do we need an issue making sure we run libraries tests with the interpreter disabled? This feels like something that should have been caught in libs tests.
@eerhardt could you help with getting this fixed for 6.0?
@MichalStrehovsky I agree that ideally this should be uncovered in libraries AOT mode run but right now we can run only the runtime tests in this mode. Running all libraries tests under AOT won't be trivial as there is a lot of tests and a lot of assumptions to fix.
Looks like I can port the changes of XmlSerializer from runtimelab / NativeAOT to runtime.
My biggest question is: how can I test this to ensure it works? @rolfbjarne - Do you have instructions on how to run your test that is failing? So I can ensure my change fixes it?
@eerhardt AFAIK the only way to be sure this works is to actually run in a FullAOT scenario (i.e. on an iOS device), but I don't know how to make that happen inside dotnet/runtime (I'm guessing there already are FullAOT tests somewhere in dotnet/runtime?)
Activity
MichalStrehovsky commentedon Sep 16, 2021
@marek-safar Do we need an issue making sure we run libraries tests with the interpreter disabled? This feels like something that should have been caught in libs tests.
marek-safar commentedon Sep 16, 2021
@eerhardt could you help with getting this fixed for 6.0?
@MichalStrehovsky I agree that ideally this should be uncovered in libraries AOT mode run but right now we can run only the runtime tests in this mode. Running all libraries tests under AOT won't be trivial as there is a lot of tests and a lot of assumptions to fix.
/cc @SamMonoRT
jkotas commentedon Sep 17, 2021
We have a fix for this in the NativeAOT experiment that worked fine for us so far.
Look for the XmlSerializer.cs delta in dotnet/runtimelab@runtime-main...feature/NativeAOT
eerhardt commentedon Sep 20, 2021
Looking now.
eerhardt commentedon Sep 20, 2021
Looks like I can port the changes of XmlSerializer from runtimelab / NativeAOT to runtime.
My biggest question is: how can I test this to ensure it works? @rolfbjarne - Do you have instructions on how to run your test that is failing? So I can ensure my change fixes it?
XmlSerializer support for IsDynamicCodeSupported=false
rolfbjarne commentedon Sep 21, 2021
@eerhardt AFAIK the only way to be sure this works is to actually run in a FullAOT scenario (i.e. on an iOS device), but I don't know how to make that happen inside dotnet/runtime (I'm guessing there already are FullAOT tests somewhere in dotnet/runtime?)
SamMonoRT commentedon Sep 21, 2021
@imhameed - please can you verify if the newly enabled FullAOT lane has similar tests running ?
XmlSerializer support for IsDynamicCodeSupported=false (#59386)
XmlSerializer support for IsDynamicCodeSupported=false
eerhardt commentedon Sep 23, 2021
Re-opening to backport to 6.0.
[release/6.0-rc2] XmlSerializer support for IsDynamicCodeSupported=fa…