Skip to content

Basic tracking of MethodInfo and use it to improve Expression.Property and MakeGenericMethod#1880

Merged
vitek-karas merged 4 commits intodotnet:mainfrom
vitek-karas:MethodBaseTracking
Mar 11, 2021
Merged

Basic tracking of MethodInfo and use it to improve Expression.Property and MakeGenericMethod#1880
vitek-karas merged 4 commits intodotnet:mainfrom
vitek-karas:MethodBaseTracking

Conversation

@vitek-karas
Copy link
Member

Adds the ability to track some basic patterns around MethodBase/MethodInfo. Linker now recognizes ldtoken for a method as well as tracks return value of Type.GetMethod.

With this, the change implements two improvements:

#1814 - Mark property as accessed via reflection when using Expression.Property(Expression,MethodInfo)

Added a new warning to report cases where the intrinsic handling of the Property call doesn't work.

#1727 - Ability to handle simple MakeGenericMethod calls without generating a warning

If the generic method has no annotations on the generic arguments, linker will no longer warn.

Added tests for all the new behaviors.
Improved tests for MakeGenericMethod and MakeGenericType.
Implement checking for new constraint in MakeGenericType - it now behaves the same as if the generic argument is annotated.

…y and MakeGenericMethod

Adds the ability to track some basic patterns around `MethodBase`/`MethodInfo`. Linker now recognizes `ldtoken` for a method as well as tracks return value of `Type.GetMethod`.

With this, the change implements two improvements:

dotnet#1814 - Mark property as accessed via reflection when using Expression.Property(Expression,MethodInfo)

Added a new warning to report cases where the intrinsic handling of the Property call doesn't work.

dotnet#1727 - Ability to handle simple MakeGenericMethod calls without generating a warning

If the generic method has no annotations on the generic arguments, linker will no longer warn.

Added tests for all the new behaviors.
Improved tests for MakeGenericMethod and MakeGenericType.
Implement checking for new constraint in MakeGenericType - it now behaves the same as if the generic argument is annotated.
@vitek-karas
Copy link
Member Author

/cc @eerhardt

@vitek-karas vitek-karas merged commit 9192a2d into dotnet:main Mar 11, 2021
@vitek-karas vitek-karas deleted the MethodBaseTracking branch March 11, 2021 13:04
vitek-karas added a commit to vitek-karas/runtime that referenced this pull request Jun 16, 2021
…sors

This mostly a linker test as this effectively validates linker feature from dotnet/linker#1880.

But having a clean trimming tests here is better validation for this specific case.
eerhardt pushed a commit to dotnet/runtime that referenced this pull request Jun 17, 2021
…sors (#54279)

* Add a test for Expression.Property and its handling of property accessors

This mostly a linker test as this effectively validates linker feature from dotnet/linker#1880.

But having a clean trimming tests here is better validation for this specific case.

* Add one more test case as per feedback

* Remove debugging leftover
agocke pushed a commit to dotnet/runtime that referenced this pull request Nov 16, 2022
…y and MakeGenericMethod (dotnet/linker#1880)

Adds the ability to track some basic patterns around `MethodBase`/`MethodInfo`. Linker now recognizes `ldtoken` for a method as well as tracks return value of `Type.GetMethod`.

With this, the change implements two improvements:

dotnet/linker#1814 - Mark property as accessed via reflection when using Expression.Property(Expression,MethodInfo)

Added a new warning to report cases where the intrinsic handling of the Property call doesn't work.

dotnet/linker#1727 - Ability to handle simple MakeGenericMethod calls without generating a warning

If the generic method has no annotations on the generic arguments, linker will no longer warn.

Added tests for all the new behaviors.
Improved tests for MakeGenericMethod and MakeGenericType.
Implement checking for new constraint in MakeGenericType - it now behaves the same as if the generic argument is annotated.

Commit migrated from dotnet/linker@9192a2d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants