-
Notifications
You must be signed in to change notification settings - Fork 128
Closed
Description
Take this example:
// Some other library
class Provider
{
public static void Register<[DynamicallyAccessedMembers.All] T>() { ... }
}
// The app
class MyFancyProvider
{
public static void Register ()
{
var a = () => {
Provider.Register<MyFancyProvider> (); // IL2118
};
a();
}
}The IL2118 produces by this code is unnecessary. The warning is meant to cover cases where the lambda contains potentially dangerous code and calling it directly via reflection could lead into analysis holes. That's not the case here, the lambda uses no external state from the outer scope (no method parameters, no closure) and as such acts basically as a normal method.
The warning is expected to be somewhat noisy in some cases, but we hoped it would not be too common. The above pattern though can prove to be problematic - especially since it's very hard for the user to figure out what happened - and we're forcing the user to suppress the warning (which is always bad).
/cc @sbomer
Metadata
Metadata
Assignees
Labels
No labels