dotnet / dotnet/linker

Add DynamicallyAccessedMemberTypes sugar members over existing members

Open
#2,488 6 comments 0 reactions 0 assignees View on GitHub
area-Linker: DataFlow
Dominant language
C#
Stars
392
Forks
128
Avg merge
2d 10h
Merged PRs (30d)
2

Description

It's fairly typical to want to preserve all properties, or all members on a type; this currently requires OR'ing together multiple enum values from DynamicallyAccessedMemberTypes:

```c#
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicProperties | DynamicallyAccessedMemberTypes.NonPublicProperties)]
```

As these annotations propagate around the codebase, things start to get verbose. This could be made nicer by introducing enum members which OR other members:

```c#
[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.AllProperties)]
```

This could be done for all public/non-public pairs, as well as maybe AllMembers for both properties and fields (there may be some other opportunities).

The trimming analyzer could even have a code fix to replace the verbose form with the shorter one.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.