dotnet / dotnet/linker

MarkExplicitInterfaceImplementation doesn't work for generic interfaces

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

Description

https://github.com/mono/linker/blob/9e3191cad279e945a4e2c99340454959fec637b0/src/linker/Linker.Steps/MarkStep.cs#L2469-L2492

This code is trying to ensure that if an explicit interface implementation method was marked, the appropriate member of the interface list is also preserved.

The code falls victim to Cecil's behavior where the act of resolving a TypeRef/MethodRef strips away the genericness information.

As a result, for code like this:

```csharp
class Foo : IFoo, IFoo
{
int IFoo Frob() => 0;
int IFoo Frob() => 0;
}
```

Will end up preserving the first IFoo entry in the interface list, irrespective of whether `IFoo.Frob` or `IFoo.Frob` was the one responsible for `MarkExplicitInterfaceImplementation` getting called.

I think this is low impact, since we can only get there if the explicit impl was rooted through ILLinkTrim, but ILLinkTrim was the motivating factor why `MarkExplicitInterfaceImplementation` was added in the first place, so YMMV.

Found while investigating #1421. This issue gives the other issue a more weird failure mode.

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.