-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Closed
Labels
area-Tools-ILLink.NET linker development as well as trimming analyzers.NET linker development as well as trimming analyzers
Milestone
Description
Found by @MichalStrehovsky
interface IBase
{
[RequriesUnreferencedCode("")]
void DoSomethingDangerous();
}
class Implementation : IBase
{
[RequiresUnreferencedCode("")]
public void DoSomethingDangerous() { Console.WriteLine("!!!DANGER!!!"); }
}
void CallMethodOnInstance<[DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.PublicMethods)] T>(T instance)
{
typeof(T).GetMethod("DoSomethingDangerous").Invoke(instance, Array.Empty<object>());
}
static void Main()
{
CallMethodOnInstance(new Implementation);
}The above will not produce any warning when trimmed, but when executed it will print out !!!DANGER!!!.
The bug is that ILLink will not warn if a method is an override and is in RUC scope and is marked due to annotation (so broader marking like PublicMethods).
This was done assuming that the same broad marking will also mark the base method which will warn. But that's not always true. Reflection doesn't return base interface methods when usual GetMethod is called. ILLink doesn't enumerate the base interface methods in this case either.
ShreyasJejurkar
Metadata
Metadata
Assignees
Labels
area-Tools-ILLink.NET linker development as well as trimming analyzers.NET linker development as well as trimming analyzers