Skip to content

RequiresUnreferencedCode does not produce warning if the method is not seen in a call instruction #1607

@vitek-karas

Description

@vitek-karas

Linker can mark methods through various means, only one of which is seeing a direct call instruction. Some of other cases:

  • Using reflection like GetMethod via intrinsic handling
  • Through DynamicallyAccessedMembers annotation which ends up marking methods sometimes
  • Marking of virtual methods on instantiated types
  • Marking of interface methods for instantiated types
  • several other cases

Currently the linker only recognizes the RequiresUnreferencedCode attribute when analyzing method body instructions, then it reports a warning for calls to method with such attribute. If the method with such attribute is marked for any other reason linker will not produce the warning.

But if linker decides to keep the method (that is, the method is marked) and it is also annotated with RequiresUnreferencedCode attribute, linker should always report a warning since such method is potentially reachable.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions