-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use ReflectionOnly as serialization mode in case dynamic code runtime…
… feature is not supported (#56604)
- Loading branch information
1 parent
7f931b1
commit b3ab2eb
Showing
3 changed files
with
70 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
src/tests/FunctionalTests/iOS/Simulator/XmlSerializer_Deserialize/Program.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Runtime.InteropServices; | ||
using System.Threading.Tasks; | ||
using System.Xml; | ||
using System.Xml.Schema; | ||
using System.Xml.Serialization; | ||
|
||
public static class Program | ||
{ | ||
public static async Task<int> Main(string[] args) | ||
{ | ||
using StringReader stringReader = new StringReader(@"<?xml version=""1.0"" encoding=""UTF-8""?> | ||
<TestClass> | ||
<TestData>sample</TestData> | ||
</TestClass>"); | ||
|
||
var serializer = new XmlSerializer(typeof(TestClass)); | ||
TestClass obj = (TestClass)serializer.Deserialize(stringReader); | ||
|
||
var result = obj.TestData == "sample" ? 42 : 1; | ||
|
||
Console.WriteLine("Done!"); | ||
await Task.Delay(5000); | ||
|
||
return result; | ||
} | ||
|
||
[XmlType("TestClass", AnonymousType = true, Namespace = "")] | ||
public class TestClass | ||
{ | ||
public TestClass() | ||
{ | ||
} | ||
|
||
[XmlElement("TestData")] | ||
public string TestData { get; set; } | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
...S/Simulator/XmlSerializer_Deserialize/iOS.Simulator.XmlSerializer_Deserialize.Test.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<Project Sdk="Microsoft.NET.Sdk" TreatAsLocalProperty="MonoForceInterpreter"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<MonoForceInterpreter>false</MonoForceInterpreter> | ||
<RunAOTCompilation>true</RunAOTCompilation> | ||
<TestRuntime>true</TestRuntime> | ||
<TargetFrameworks>$(NetCoreAppCurrent)</TargetFrameworks> | ||
<TargetOS Condition="'$(TargetOS)' == ''">iOSSimulator</TargetOS> | ||
<MainLibraryFileName>iOS.Simulator.XmlSerializer_Deserialize.Test.dll</MainLibraryFileName> | ||
<IncludesTestRunner>false</IncludesTestRunner> | ||
<ExpectedExitCode>42</ExpectedExitCode> | ||
<EnableAggressiveTrimming>true</EnableAggressiveTrimming> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<Compile Include="Program.cs" /> | ||
</ItemGroup> | ||
</Project> |