File tree Expand file tree Collapse file tree 3 files changed +70
-1
lines changed 
libraries/System.Private.Xml/src/System/Xml/Serialization 
tests/FunctionalTests/iOS/Simulator/XmlSerializer_Deserialize Expand file tree Collapse file tree 3 files changed +70
-1
lines changed Original file line number Diff line number Diff line change 99using  System . Globalization ; 
1010using  System . IO ; 
1111using  System . Reflection ; 
12+ using  System . Runtime . CompilerServices ; 
1213using  System . Runtime . Versioning ; 
1314using  System . Security ; 
1415using  System . Text ; 
@@ -109,7 +110,13 @@ internal enum SerializationMode
109110
110111    public  class  XmlSerializer 
111112    { 
112-         internal  static SerializationMode  Mode  {  get ;  set ;  }  =  SerializationMode . ReflectionAsBackup ; 
113+         private  static SerializationMode  s_mode  =  SerializationMode . ReflectionAsBackup ; 
114+ 
115+         internal  static SerializationMode  Mode 
116+         { 
117+             get  =>  RuntimeFeature . IsDynamicCodeSupported  ?  s_mode  :  SerializationMode . ReflectionOnly ; 
118+             set  =>  s_mode  =  value ; 
119+         } 
113120
114121        private  static bool  ReflectionMethodEnabled 
115122        { 
Original file line number Diff line number Diff line change 1+ // Licensed to the .NET Foundation under one or more agreements. 
2+ // The .NET Foundation licenses this file to you under the MIT license. 
3+ 
4+ using  System ; 
5+ using  System . Collections . Generic ; 
6+ using  System . IO ; 
7+ using  System . Runtime . InteropServices ; 
8+ using  System . Threading . Tasks ; 
9+ using  System . Xml ; 
10+ using  System . Xml . Schema ; 
11+ using  System . Xml . Serialization ; 
12+ 
13+ public  static class  Program 
14+ { 
15+     public  static async  Task < int >  Main ( string [ ]  args ) 
16+     { 
17+         using  StringReader  stringReader  =  new  StringReader ( @"<?xml version=""1.0"" encoding=""UTF-8""?> 
18+             <TestClass> 
19+                 <TestData>sample</TestData>  
20+             </TestClass>" ) ; 
21+ 
22+         var  serializer  =  new  XmlSerializer ( typeof ( TestClass ) ) ; 
23+         TestClass  obj  =  ( TestClass ) serializer . Deserialize ( stringReader ) ; 
24+ 
25+         var  result  =  obj . TestData  ==  "sample"  ?  42  :  1 ; 
26+ 
27+         Console . WriteLine ( "Done!" ) ; 
28+         await  Task . Delay ( 5000 ) ; 
29+ 
30+         return  result ; 
31+     } 
32+ 
33+     [ XmlType ( "TestClass" ,  AnonymousType  =  true ,  Namespace  =  "" ) ] 
34+     public  class  TestClass 
35+     { 
36+         public  TestClass ( ) 
37+         { 
38+         } 
39+ 
40+         [ XmlElement ( "TestData" ) ] 
41+         public  string  TestData  {  get ;  set ;  } 
42+     } 
43+ } 
Original file line number Diff line number Diff line change 1+ <Project  Sdk =" Microsoft.NET.Sdk" TreatAsLocalProperty =" MonoForceInterpreter" 
2+ 
3+   <PropertyGroup >
4+     <OutputType >Exe</OutputType >
5+     <MonoForceInterpreter >false</MonoForceInterpreter >
6+     <RunAOTCompilation >true</RunAOTCompilation >
7+     <TestRuntime >true</TestRuntime >
8+     <TargetFrameworks >$(NetCoreAppCurrent)</TargetFrameworks >
9+     <TargetOS  Condition =" '$(TargetOS)' == ''" TargetOS >
10+     <MainLibraryFileName >iOS.Simulator.XmlSerializer_Deserialize.Test.dll</MainLibraryFileName >
11+     <IncludesTestRunner >false</IncludesTestRunner >
12+     <ExpectedExitCode >42</ExpectedExitCode >
13+     <EnableAggressiveTrimming >true</EnableAggressiveTrimming >
14+   </PropertyGroup >
15+ 
16+   <ItemGroup >
17+     <Compile  Include =" Program.cs" 
18+   </ItemGroup >
19+ </Project >
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments