Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AOT] Remove usage of Linq.Expressions and especially lambda compilation #4695

Merged
merged 6 commits into from Jul 28, 2023

Commits on Jul 26, 2023

  1. [AOT] Remove usage of Linq.Expressions and especially lambda compilation

    In AOT `Expression.Lambda.Compile` method is implemented via an interpreter. So it does work, but it's relatively slow. Additionally it's not fully NativeAOT compatible yet.
    
    There are two places where it's used in the source code:
    * `ExceptionProcessor` uses it to access `Marshal.GetExceptionPointers` method which is not part of netstandard API. So in this case simply ifdef and on net6.0+ access the method directly (as it's visible in the net6.0 APIs) and fallback to the Expression.Lambda solution on down-level platforms. Since AOT/trimming is net6.0+ this fixes the problem.
    * `ActivityInstrumentationHelper` uses it to access two setters on the `Activity` class which are internal. Using reflection and then `CreateDelegate` will provide basically the same performance (a delegate which directly calls the setter) without a need for `Expression.Lambda` - so the code is simpler. Since the reflection is statically analyzable (all types are known, the property names are known) this code is fully trim and AOT compatible.
    
    There's no impact on warning count because the .NET 7 ASP.NET has Linq.Expression dependency as well. On .NET 8 though this removes all warnings from Linq.Expressions.
    vitek-karas committed Jul 26, 2023
    Configuration menu
    Copy the full SHA
    5120526 View commit details
    Browse the repository at this point in the history

Commits on Jul 28, 2023

  1. Configuration menu
    Copy the full SHA
    1fdd8ee View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    d041885 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    132003d View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    0a2a105 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    4985d8d View commit details
    Browse the repository at this point in the history