Analyzer handling of property access in expression trees
- Dominant language
- C#
- Stars
- 392
- Forks
- 128
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 2
Description
[Analyzer doesn't produce warnings which linker does]
When a property is accessed in an expression tree, the underlying generated code contains a call to `Expression.Property(expr, GetterMethodInfo)`. This method will actually grab the `PropertyInfo` from the getter and store it and make it possible to access the setter via reflection later on.
So for full correctness, the trimmer must keep both the getter and setter in this case. This means that there could be a warning generated if the setter is somehow problematic (for example if it has RUC).
So for example code like this:
```C#
public static int TestProperty { get; [RUC]set; }
public void Test()
{
Expression> e = () => TestProperty; // IL2026 TestProperty.set
}
```
This should produce a warning since the setter is potentially accessed through reflection.
Linker handles this implicitly because it see the call to `Expression.Property` (which is intrinsic and implements this logic).
But analyzer doesn't see this, since it looks like normal property access, which only requires the getter to be checked.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.