Skip to content

Commit 3319fa8

Browse files
Make LambdaCompiler prefer interpretation to compilation on iOS (#54970)
This is an attempt to address #47112 based on Egor's suggestion. The changes: - set IsInterpreting MSBuild property to 'true' in case of iOS; - made System.Linq.Expressions.ExpressionCreator class internal static in order not to introduce new public type; otherwise it throws Type 'System.Linq.Expressions.ExpressionCreator<TDelegate>' does not exist in the reference but it does exist in the implementation. -updated the iOS simulator functional test for AOT to verify the fix - added PlatformDetection.IsLinqExpressionsBuiltWithIsInterpretingOnly which checks whether the System.Linq.Expressions is built with IsInterpreting property set to true. To do so, it uses reflection to verify the Expression.Accept method doesn't exist. - disabled some failing library tests using ActiveIssue + PlatformDetection. - updated the invariant functional test for the iOS simulator (b/c of Allow restricting cultures creation with any arbitrary names in Globalization Invariant Mode #54247) Co-authored-by: Stephen Toub <[email protected]>
1 parent cb1beaa commit 3319fa8

31 files changed

+142
-19
lines changed

src/libraries/Common/tests/TestUtilities/System/PlatformDetection.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
using System.Diagnostics;
55
using System.IO;
6+
using System.Linq.Expressions;
67
using System.Security;
78
using System.Security.Authentication;
89
using System.Reflection;
@@ -66,6 +67,22 @@ public static partial class PlatformDetection
6667
public static bool IsUsingLimitedCultures => !IsNotMobile;
6768
public static bool IsNotUsingLimitedCultures => IsNotMobile;
6869

70+
public static bool IsLinqExpressionsBuiltWithIsInterpretingOnly => s_LinqExpressionsBuiltWithIsInterpretingOnly.Value;
71+
public static bool IsNotLinqExpressionsBuiltWithIsInterpretingOnly => !IsLinqExpressionsBuiltWithIsInterpretingOnly;
72+
private static readonly Lazy<bool> s_LinqExpressionsBuiltWithIsInterpretingOnly = new Lazy<bool>(GetLinqExpressionsBuiltWithIsInterpretingOnly);
73+
private static bool GetLinqExpressionsBuiltWithIsInterpretingOnly()
74+
{
75+
Type type = typeof(LambdaExpression);
76+
if (type != null)
77+
{
78+
// The "Accept" method is under FEATURE_COMPILE conditional so it should not exist
79+
MethodInfo methodInfo = type.GetMethod("Accept", BindingFlags.NonPublic | BindingFlags.Static);
80+
return methodInfo == null;
81+
}
82+
83+
return false;
84+
}
85+
6986
// Please make sure that you have the libgdiplus dependency installed.
7087
// For details, see https://docs.microsoft.com/dotnet/core/install/dependencies?pivots=os-macos&tabs=netcore31#libgdiplus
7188
public static bool IsDrawingSupported

src/libraries/Microsoft.VisualBasic.Core/tests/NewLateBindingTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public static IEnumerable<object[]> LateCall_OptionalValues_Data()
9494
static object[] CreateData(string memberName, object[] arguments, Type[] typeArguments, string expectedValue) => new object[] { memberName, arguments, typeArguments, expectedValue };
9595
}
9696

97-
[Theory]
97+
[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsNotLinqExpressionsBuiltWithIsInterpretingOnly))]
9898
[ActiveIssue("https://github.com/dotnet/runtime/issues/51834", typeof(PlatformDetection), nameof(PlatformDetection.IsBuiltWithAggressiveTrimming), nameof(PlatformDetection.IsBrowser))]
9999
[MemberData(nameof(LateCall_OptionalValues_Data))]
100100
public void LateCall_OptionalValues(string memberName, object[] arguments, Type[] typeArguments, string expectedValue)

src/libraries/System.Dynamic.Runtime/tests/Dynamic.Context/Conformance.dynamic.context.indexer.genclass.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -774,6 +774,7 @@ namespace ManagedTests.DynamicCSharp.Conformance.dynamic.context.indexer.genclas
774774
public class Test
775775
{
776776
[Fact]
777+
[ActiveIssue("https://github.com/dotnet/runtime/issues/55118", typeof(PlatformDetection), nameof(PlatformDetection.IsLinqExpressionsBuiltWithIsInterpretingOnly))]
777778
public static void TryCatchFinally()
778779
{
779780
dynamic dy = new MemberClass<int>();

src/libraries/System.Dynamic.Runtime/tests/Dynamic.Context/Conformance.dynamic.context.operator.compound.basic.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,10 +239,12 @@ namespace ManagedTests.DynamicCSharp.Conformance.dynamic.context.operate.compoun
239239
// <RelatedBugs></RelatedBugs>
240240
// <Expects Status=success></Expects>
241241
// <Code>
242+
using System;
242243

243244
public class Test
244245
{
245246
[Fact]
247+
[ActiveIssue("https://github.com/dotnet/runtime/issues/55117", typeof(PlatformDetection), nameof(PlatformDetection.IsLinqExpressionsBuiltWithIsInterpretingOnly))]
246248
public static void DynamicCSharpRunTest()
247249
{
248250
Assert.Equal(0, MainMethod(null));

src/libraries/System.Dynamic.Runtime/tests/Dynamic.Declarations/Conformance.dynamic.declarations.formalParameter.Methods.cs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ public static int MainMethod(string[] args)
9898

9999
namespace ManagedTests.DynamicCSharp.Conformance.dynamic.declarations.formalParameter.Methods.extensionmethod006.extensionmethod006
100100
{
101+
using System;
102+
101103
static // <Title>Extension method that extends dynamic</Title>
102104
// <Description>
103105
// </Description>
@@ -115,6 +117,7 @@ public static string Foo(this object x, dynamic d)
115117
public class Test
116118
{
117119
[Fact]
120+
[ActiveIssue("https://github.com/dotnet/runtime/issues/55117", typeof(PlatformDetection), nameof(PlatformDetection.IsLinqExpressionsBuiltWithIsInterpretingOnly))]
118121
public static void DynamicCSharpRunTest()
119122
{
120123
Assert.Equal(0, MainMethod(null));
@@ -189,6 +192,8 @@ public static int Method(this Test t, int value)
189192

190193
namespace ManagedTests.DynamicCSharp.Conformance.dynamic.declarations.formalParameter.Methods.method001.method001
191194
{
195+
using System;
196+
192197
public class Test
193198
{
194199
private static bool s_ok = false;
@@ -203,6 +208,7 @@ public void Foo(dynamic d)
203208
}
204209

205210
[Fact]
211+
[ActiveIssue("https://github.com/dotnet/runtime/issues/55117", typeof(PlatformDetection), nameof(PlatformDetection.IsLinqExpressionsBuiltWithIsInterpretingOnly))]
206212
public static void DynamicCSharpRunTest()
207213
{
208214
Assert.Equal(0, MainMethod(null));
@@ -260,6 +266,8 @@ public static int MainMethod(string[] args)
260266

261267
namespace ManagedTests.DynamicCSharp.Conformance.dynamic.declarations.formalParameter.Methods.method003.method003
262268
{
269+
using System;
270+
263271
public class Test
264272
{
265273
private static bool s_ok = false;
@@ -273,6 +281,7 @@ public void Foo(dynamic d)
273281
}
274282

275283
[Fact]
284+
[ActiveIssue("https://github.com/dotnet/runtime/issues/55117", typeof(PlatformDetection), nameof(PlatformDetection.IsLinqExpressionsBuiltWithIsInterpretingOnly))]
276285
public static void DynamicCSharpRunTest()
277286
{
278287
Assert.Equal(0, MainMethod(null));
@@ -294,6 +303,8 @@ public static int MainMethod(string[] args)
294303

295304
namespace ManagedTests.DynamicCSharp.Conformance.dynamic.declarations.formalParameter.Methods.method004.method004
296305
{
306+
using System;
307+
297308
public class Test
298309
{
299310
private static bool s_ok = false;
@@ -306,6 +317,7 @@ public void Foo(ref dynamic d)
306317
}
307318

308319
[Fact]
320+
[ActiveIssue("https://github.com/dotnet/runtime/issues/55117", typeof(PlatformDetection), nameof(PlatformDetection.IsLinqExpressionsBuiltWithIsInterpretingOnly))]
309321
public static void DynamicCSharpRunTest()
310322
{
311323
Assert.Equal(0, MainMethod(null));
@@ -330,6 +342,8 @@ public static int MainMethod(string[] args)
330342

331343
namespace ManagedTests.DynamicCSharp.Conformance.dynamic.declarations.formalParameter.Methods.method005.method005
332344
{
345+
using System;
346+
333347
public class Test
334348
{
335349
private static bool s_ok = false;
@@ -345,6 +359,7 @@ public void Foo(params dynamic[] d)
345359
}
346360

347361
[Fact]
362+
[ActiveIssue("https://github.com/dotnet/runtime/issues/55117", typeof(PlatformDetection), nameof(PlatformDetection.IsLinqExpressionsBuiltWithIsInterpretingOnly))]
348363
public static void DynamicCSharpRunTest()
349364
{
350365
Assert.Equal(0, MainMethod(null));
@@ -367,6 +382,8 @@ public static int MainMethod(string[] args)
367382

368383
namespace ManagedTests.DynamicCSharp.Conformance.dynamic.declarations.formalParameter.Methods.method007.method007
369384
{
385+
using System;
386+
370387
public class Test
371388
{
372389
private static bool s_ok = false;
@@ -380,6 +397,7 @@ public void Foo(dynamic d, dynamic d2)
380397
}
381398

382399
[Fact]
400+
[ActiveIssue("https://github.com/dotnet/runtime/issues/55117", typeof(PlatformDetection), nameof(PlatformDetection.IsLinqExpressionsBuiltWithIsInterpretingOnly))]
383401
public static void DynamicCSharpRunTest()
384402
{
385403
Assert.Equal(0, MainMethod(null));
@@ -403,6 +421,8 @@ public static int MainMethod(string[] args)
403421

404422
namespace ManagedTests.DynamicCSharp.Conformance.dynamic.declarations.formalParameter.Methods.method008.method008
405423
{
424+
using System;
425+
406426
public class Test
407427
{
408428
private static bool s_ok = false;
@@ -416,6 +436,7 @@ public void Foo(dynamic d, int d2)
416436
}
417437

418438
[Fact]
439+
[ActiveIssue("https://github.com/dotnet/runtime/issues/55117", typeof(PlatformDetection), nameof(PlatformDetection.IsLinqExpressionsBuiltWithIsInterpretingOnly))]
419440
public static void DynamicCSharpRunTest()
420441
{
421442
Assert.Equal(0, MainMethod(null));
@@ -438,6 +459,8 @@ public static int MainMethod(string[] args)
438459

439460
namespace ManagedTests.DynamicCSharp.Conformance.dynamic.declarations.formalParameter.Methods.method009.method009
440461
{
462+
using System;
463+
441464
public class Test
442465
{
443466
private static bool s_ok = false;
@@ -451,6 +474,7 @@ public void Foo(dynamic d, dynamic d2, dynamic d3)
451474
}
452475

453476
[Fact]
477+
[ActiveIssue("https://github.com/dotnet/runtime/issues/55117", typeof(PlatformDetection), nameof(PlatformDetection.IsLinqExpressionsBuiltWithIsInterpretingOnly))]
454478
public static void DynamicCSharpRunTest()
455479
{
456480
Assert.Equal(0, MainMethod(null));
@@ -473,6 +497,8 @@ public static int MainMethod(string[] args)
473497

474498
namespace ManagedTests.DynamicCSharp.Conformance.dynamic.declarations.formalParameter.Methods.method010.method010
475499
{
500+
using System;
501+
476502
public class Test
477503
{
478504
private static bool s_ok = false;
@@ -488,6 +514,7 @@ public MyClass(params dynamic[] d)
488514
}
489515

490516
[Fact]
517+
[ActiveIssue("https://github.com/dotnet/runtime/issues/55117", typeof(PlatformDetection), nameof(PlatformDetection.IsLinqExpressionsBuiltWithIsInterpretingOnly))]
491518
public static void DynamicCSharpRunTest()
492519
{
493520
Assert.Equal(0, MainMethod(null));
@@ -509,6 +536,8 @@ public static int MainMethod(string[] args)
509536

510537
namespace ManagedTests.DynamicCSharp.Conformance.dynamic.declarations.formalParameter.Methods.method011.method011
511538
{
539+
using System;
540+
512541
public class Test
513542
{
514543
private static bool s_ok = false;
@@ -523,6 +552,7 @@ public static void Foo(dynamic d)
523552
}
524553

525554
[Fact]
555+
[ActiveIssue("https://github.com/dotnet/runtime/issues/55117", typeof(PlatformDetection), nameof(PlatformDetection.IsLinqExpressionsBuiltWithIsInterpretingOnly))]
526556
public static void DynamicCSharpRunTest()
527557
{
528558
Assert.Equal(0, MainMethod(null));
@@ -543,6 +573,8 @@ public static int MainMethod(string[] args)
543573

544574
namespace ManagedTests.DynamicCSharp.Conformance.dynamic.declarations.formalParameter.Methods.method012.method012
545575
{
576+
using System;
577+
546578
public class Test
547579
{
548580
private static bool s_ok = false;
@@ -555,6 +587,7 @@ public void Foo<T>(ref dynamic d)
555587
}
556588

557589
[Fact]
590+
[ActiveIssue("https://github.com/dotnet/runtime/issues/55117", typeof(PlatformDetection), nameof(PlatformDetection.IsLinqExpressionsBuiltWithIsInterpretingOnly))]
558591
public static void DynamicCSharpRunTest()
559592
{
560593
Assert.Equal(0, MainMethod(null));
@@ -579,6 +612,8 @@ public static int MainMethod(string[] args)
579612

580613
namespace ManagedTests.DynamicCSharp.Conformance.dynamic.declarations.formalParameter.Methods.method013.method013
581614
{
615+
using System;
616+
582617
public class Test
583618
{
584619
private static bool s_ok = false;
@@ -591,6 +626,7 @@ public void Foo<T>(T d)
591626
}
592627

593628
[Fact]
629+
[ActiveIssue("https://github.com/dotnet/runtime/issues/55117", typeof(PlatformDetection), nameof(PlatformDetection.IsLinqExpressionsBuiltWithIsInterpretingOnly))]
594630
public static void DynamicCSharpRunTest()
595631
{
596632
Assert.Equal(0, MainMethod(null));

src/libraries/System.Dynamic.Runtime/tests/Dynamic.Declarations/Conformance.dynamic.declarations.localVariable.blockVariable.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1189,9 +1189,12 @@ from d in numbers
11891189

11901190
namespace ManagedTests.DynamicCSharp.Conformance.dynamic.declarations.localVariable.blockVariable.trycatch002.trycatch002
11911191
{
1192+
using System;
1193+
11921194
public class Test
11931195
{
11941196
[Fact]
1197+
[ActiveIssue("https://github.com/dotnet/runtime/issues/55117", typeof(PlatformDetection), nameof(PlatformDetection.IsLinqExpressionsBuiltWithIsInterpretingOnly))]
11951198
public static void DynamicCSharpRunTest()
11961199
{
11971200
Assert.Equal(0, MainMethod(null));

src/libraries/System.Dynamic.Runtime/tests/Dynamic.DynamicType/Conformance.dynamic.dynamicType.conversions.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4356,6 +4356,8 @@ public static int MainMethod()
43564356

43574357
namespace ManagedTests.DynamicCSharp.Conformance.dynamic.dynamicType.conversions.dlgate003.dlgate003
43584358
{
4359+
using System;
4360+
43594361
// <Title>Delegate conversions</Title>
43604362
// <Description>
43614363
// Tests to figure out if the right conversion from method groups to delegates are applied
@@ -4375,6 +4377,7 @@ public static object Foo()
43754377
}
43764378

43774379
[Fact]
4380+
[ActiveIssue("https://github.com/dotnet/runtime/issues/55117", typeof(PlatformDetection), nameof(PlatformDetection.IsLinqExpressionsBuiltWithIsInterpretingOnly))]
43784381
public static void DynamicCSharpRunTest()
43794382
{
43804383
Assert.Equal(0, MainMethod());

src/libraries/System.Dynamic.Runtime/tests/Dynamic.OverloadResolution/Conformance.dynamic.overloadResolution.Indexers.1class2indexers.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -665,6 +665,8 @@ public static int MainMethod(string[] args)
665665

666666
namespace ManagedTests.DynamicCSharp.Conformance.dynamic.overloadResolution.Indexers.Oneclass2indexers.onedynamicparam004.onedynamicparam004
667667
{
668+
using System;
669+
668670
// <Title> Tests overload resolution for 1 class and 2 methods</Title>
669671
// <Description>
670672
// </Description>
@@ -720,6 +722,7 @@ public object this[object x]
720722
public class Test
721723
{
722724
[Fact]
725+
[ActiveIssue("https://github.com/dotnet/runtime/issues/55117", typeof(PlatformDetection), nameof(PlatformDetection.IsLinqExpressionsBuiltWithIsInterpretingOnly))]
723726
public static void DynamicCSharpRunTest()
724727
{
725728
Assert.Equal(0, MainMethod(null));

src/libraries/System.Dynamic.Runtime/tests/Dynamic.OverloadResolution/Conformance.dynamic.overloadResolution.Methods.1class2methods.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,8 @@ public static int MainMethod(string[] args)
501501

502502
namespace ManagedTests.DynamicCSharp.Conformance.dynamic.overloadResolution.Methods.Oneclass2methods.onedynamicparam004.onedynamicparam004
503503
{
504+
using System;
505+
504506
// <Title> Tests overload resolution for 1 class and 2 methods</Title>
505507
// <Description>
506508
// </Description>
@@ -530,6 +532,7 @@ public void Method(object x)
530532
public class Test
531533
{
532534
[Fact]
535+
[ActiveIssue("https://github.com/dotnet/runtime/issues/55117", typeof(PlatformDetection), nameof(PlatformDetection.IsLinqExpressionsBuiltWithIsInterpretingOnly))]
533536
public static void DynamicCSharpRunTest()
534537
{
535538
Assert.Equal(0, MainMethod(null));

src/libraries/System.Dynamic.Runtime/tests/Dynamic.Variance/Conformance.dynamic.Variance.assign.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,8 @@ public static int MainMethod()
476476

477477
namespace ManagedTests.DynamicCSharp.Conformance.dynamic.Variance.assign.assignment07.assignment07
478478
{
479+
using System;
480+
479481
// <Area>variance</Area>
480482
// <Title> assignment Contravariant delegates</Title>
481483
// <Description> contravariance on delegates assigned to arrays</Description>
@@ -499,6 +501,7 @@ public class C
499501
private static dynamic s_array3;
500502

501503
[Fact]
504+
[ActiveIssue("https://github.com/dotnet/runtime/issues/55119", typeof(PlatformDetection), nameof(PlatformDetection.IsLinqExpressionsBuiltWithIsInterpretingOnly))]
502505
public static void DynamicCSharpRunTest()
503506
{
504507
Assert.Equal(0, MainMethod());

0 commit comments

Comments
 (0)