diff --git a/dotnet/targets/Xamarin.Shared.Sdk.targets b/dotnet/targets/Xamarin.Shared.Sdk.targets index 09596f634805..81a584898293 100644 --- a/dotnet/targets/Xamarin.Shared.Sdk.targets +++ b/dotnet/targets/Xamarin.Shared.Sdk.targets @@ -467,7 +467,7 @@ <_ExtraTrimmerArgs>$(_ExtraTrimmerArgs) --disable-opt unusedtypechecks - <_ExtraTrimmerArgs Condition="'$(_BundlerDebug)' != 'true' And '$(MtouchInterpreter)' == '' And '$(_PlatformName)' != 'macOS'">$(_ExtraTrimmerArgs) --enable-opt sealer + <_ExtraTrimmerArgs Condition="'$(_BundlerDebug)' != 'true' And '$(MtouchInterpreter)' == '' And '$(_RunAotCompiler)' == 'true' And '$(_PlatformName)' != 'macOS'">$(_ExtraTrimmerArgs) --enable-opt sealer false diff --git a/tests/linker/ios/link all/SealerTest.cs b/tests/linker/ios/link all/SealerTest.cs index 571e3b669d82..329beb67c3dd 100644 --- a/tests/linker/ios/link all/SealerTest.cs +++ b/tests/linker/ios/link all/SealerTest.cs @@ -36,6 +36,17 @@ public class Subclass : Base, Interface { [Preserve (AllMembers = true)] public class SealerTest { +#if NET + [SetUp] + public void SetUp () + { + // XML serialization mechanism is controlled by RuntimeFeature.IsDynamicCodeSupported + // which will be true for simulator / JIT builds + // so the optimization is disabled unless AOT is used + TestRuntime.AssertDevice (); + } +#endif + [Test] public void Sealed () {