dotnet / dotnet/linker

Implementing interfaces can introduce warnings in other libraries

Open
#2,216 0 comments 1 reaction 0 assignees View on GitHub
Dominant language
C#
Stars
392
Forks
128
Avg merge
2d 10h
Merged PRs (30d)
2

Description

```csharp
interface I {
void M();
}

class Base {
[RUC("RUC")]
public virtual void M() {}
}

class Derived : Base, I {
}
```

Here, the base class and interface are unrelated until `Derived` implements the interface via the base method:

`ILLink : Trim analysis warning IL2046: Base.M(): Member 'Base.M()' with 'RequiresUnreferencedCodeAttribute' implements interface member 'I.M()' without 'RequiresUnreferencedCodeAttribute'. 'RequiresUnreferencedCodeAttribute' annotations must match across all interface implementations or overrides.`

The warning should point to `Derived` since it is responsible for introducing the link between the base/interface methods. Otherwise this allows one library to introduce trim analysis warnings in a different library that is already annotated.

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.