Nota
El acceso a esta página requiere autorización. Puede intentar iniciar sesión o cambiar directorios.
El acceso a esta página requiere autorización. Puede intentar cambiar los directorios.
Causa
Hay una discrepancia en las anotaciones RequiresUnreferencedCodeAttribute entre una interfaz y su implementación o un método virtual y su invalidación.
Ejemplo
Un miembro base tiene el atributo, pero el miembro derivado no tiene el atributo.
public class Base
{
[RequiresUnreferencedCode("Message")]
public virtual void TestMethod() {}
}
public class Derived : Base
{
// IL2046: Base member 'Base.TestMethod' with 'RequiresUnreferencedCodeAttribute' has a derived member 'Derived.TestMethod()' without 'RequiresUnreferencedCodeAttribute'. For all interfaces and overrides the implementation attribute must match the definition attribute.
public override void TestMethod() {}
}
Un miembro derivado tiene el atributo, pero el miembro base invalidado no lo tiene.
public class Base
{
public virtual void TestMethod() {}
}
public class Derived : Base
{
// IL2046: Member 'Derived.TestMethod()' with 'RequiresUnreferencedCodeAttribute' overrides base member 'Base.TestMethod()' without 'RequiresUnreferencedCodeAttribute'. For all interfaces and overrides the implementation attribute must match the definition attribute.
[RequireUnreferencedCode("Message")]
public override void TestMethod() {}
}
Un miembro de interfaz tiene el atributo, pero su implementación no tiene el atributo.
interface IRUC
{
[RequiresUnreferencedCode("Message")]
void TestMethod();
}
class Implementation : IRUC
{
// IL2046: Interface member 'IRUC.TestMethod()' with 'RequiresUnreferencedCodeAttribute' has an implementation member 'Implementation.TestMethod()' without 'RequiresUnreferencedCodeAttribute'. For all interfaces and overrides the implementation attribute must match the definition attribute.
public void TestMethod () { }
}
Un miembro de implementación tiene el atributo, pero la interfaz que implementa no tiene el atributo.
interface IRUC
{
void TestMethod();
}
class Implementation : IRUC
{
[RequiresUnreferencedCode("Message")]
// IL2046: Member 'Implementation.TestMethod()' with 'RequiresUnreferencedCodeAttribute' implements interface member 'IRUC.TestMethod()' without 'RequiresUnreferencedCodeAttribute'. For all interfaces and overrides the implementation attribute must match the definition attribute.
public void TestMethod () { }
}