-
Notifications
You must be signed in to change notification settings - Fork 126
Open
Description
RUC on type silences warnings from instance methods, but those instance methods may have attributes that should produce warnings. We incorrectly treat RUC on type as suppressing those warnings, even though reflection access to those methods can call the attribute ctor at runtime. Example:
class RequiresOnAttributeCtorAttribute : Attribute
{
[RUC("--ATTRIBUTE CTOR--")]
public RequiresOnAttributeCtorAttribute()
{
Console.WriteLine("ATTRIBUTE CTOR CALLED!");
}
}
[RequiresUnreferencedCode("--TypeWithRequires--")]
class TypeWithRequires
{
[RequiresOnAttributeCtor]
public void InstanceMethod() { }
}
public static void Test()
{
foreach (var method in typeof(TypeWithRequires).GetMethods(BindingFlags.Public | BindingFlags.Instance))
{
foreach (var a in method.GetCustomAttributes()) ;
}
}Reactions are currently unavailable