Missing warnings for dynamically accessed members in presence of interfaces
- Dominant language
- C#
- Stars
- 392
- Forks
- 128
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 2
Description
```csharp
using System;
using System.Diagnostics.CodeAnalysis;
using DAM = System.Diagnostics.CodeAnalysis.DynamicallyAccessedMembersAttribute;
using RUC = System.Diagnostics.CodeAnalysis.RequiresUnreferencedCodeAttribute;
public class Program {
public static void Main() => CallMethod(typeof(Foo), new Foo());
static void CallMethod([DAM(DynamicallyAccessedMemberTypes.PublicMethods)] Type t, object i) {
t.GetMethod("Method").Invoke(i, null);
}
}
public interface I {
[RUC("RUC")]
void Method();
}
public class Foo : I {
[RUC("RUC")]
public void Method() {
throw new Exception();
}
}
```
This doesn't produce any warnings for the dynamic call to the RUC method. Note that it does warn if you remove Foo's implementation of I. I think this check should be modified to warn on reflection access to newslot virtuals: https://github.com/mono/linker/blob/6eae01980dc694107bdee0bc723d75a0dd601f0e/src/linker/Linker.Steps/MarkStep.cs#L2787-L2792
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.