Linker should recognize GetType() on sealed local variables
- Dominant language
- C#
- Stars
- 392
- Forks
- 128
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 2
Description
When passing in `variable.GetType()` into a method that is annotated with `DynamicallyAccessedMembers`, the linker should be able to statically infer the Type if the Type of the variable is sealed. However, the linker is not preserving the correct members on the Type in this situation.
For example,
```C#
public class TraceLoggingEventTypes
{
internal TraceLoggingEventTypes(
string name,
EventTags tags,
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties)] Type type)
...
```
```C#
var msg = new { message = msgString };
var tlet = new TraceLoggingEventTypes(EventName, EventTags.None, msg.GetType());
```
When linking code like the above, the `message` property is getting trimmed from the anonymous type.
See my [attempted code change](https://github.com/eerhardt/runtime/commit/587833e46cea3f5ce16159565b267152b5ba68e0) for this scenario in EventSource.
cc @vitek-karas @MichalStrehovsky
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.