LambdaExpression.CanCompileToIL should respect IsDynamicCodeSupported (#80759)
authorEric Erhardt <eric.erhardt@microsoft.com>
Thu, 19 Jan 2023 15:10:49 +0000 (09:10 -0600)
committerGitHub <noreply@github.com>
Thu, 19 Jan 2023 15:10:49 +0000 (09:10 -0600)
commit29075ba7b7d06c4d5c3d40618bb1ebe360b19c37
tree9294a47296e15634b9ef9738a5214d0bbb0c4ad1
parent620099d9f3ab0032832e03a10c732839fc1beadb
LambdaExpression.CanCompileToIL should respect IsDynamicCodeSupported (#80759)

* LambdaExpression.CanCompileToIL should respect IsDynamicCodeSupported

With the new feature switch added in https://github.com/dotnet/runtime/issues/39806, calling LambdaExpression.Compile is throwing a PlatformNotSupportedException. Instead, LambdaExpression should respect IsDynamicCodeSupported and switch to using the interpreter when IsDynamicCodeSupported is false.

* Add tests
src/libraries/System.Linq.Expressions/src/System/Linq/Expressions/LambdaExpression.cs
src/libraries/System.Linq.Expressions/tests/CompilerTests.cs
src/libraries/System.Linq.Expressions/tests/System.Linq.Expressions.Tests.csproj