Duplicate warnings for Expression.Property
- Dominant language
- C#
- Stars
- 392
- Forks
- 128
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 2
Description
I'm not sure if this is expected, but it surprised me. From one of our testcases:
```csharp
using System;
using System.Linq.Expressions;
using System.Diagnostics.CodeAnalysis;
AccessThroughLdToken.Test();
class AccessThroughLdToken
{
public virtual Type PropertyWithLdToken {
[return: DynamicallyAccessedMembers (DynamicallyAccessedMemberTypes.PublicMethods)]
get {
return null;
}
}
// ILLink : Trim analysis warning IL2111: AccessThroughLdToken.Test(): Method 'AccessThroughLdToken.PropertyWithLdToken.get' with parameters or return value with `DynamicallyAccessedMembersAttribute` is accessed via reflection. Trimmer can't guarantee availability of the requirements of the method.
// ILLink : Trim analysis warning IL2111: AccessThroughLdToken.Test(): Method 'AccessThroughLdToken.PropertyWithLdToken.get' with parameters or return value with `DynamicallyAccessedMembersAttribute` is accessed via reflection. Trimmer can't guarantee availability of the requirements of the method.
public static void Test ()
{
Expression> getter = () => (new AccessThroughLdToken ()).PropertyWithLdToken;
}
}
```
The linq expression compiles down to a ldtoken instruction and an Expression.Property(..., token). One warning comes from the ldtoken:
https://github.com/mono/linker/blob/66fd7119cd5744dd8bd37442ac74d2a326085406/src/linker/Linker.Steps/MarkStep.cs#L3405-L3406
and the other comes from the intrinsic for Expression.Property:
https://github.com/mono/linker/blob/66fd7119cd5744dd8bd37442ac74d2a326085406/src/linker/Linker.Dataflow/ReflectionMethodBodyScanner.cs#L900-L902
where `MarkProperty` also marks the get method.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.