Compiler Warning CS0067 : The event is never used

Since the class Actor<T> is abstract, and no code inside Actor<T> raises the event, you can make the event abstract:

public abstract event Action Dead;

Then in subclass(es) which inherit from Actor<T>, you override the event:

public override event Action Dead;

If a subclass doesn't actually raise the event, then you can suppress the warning by giving the event empty add and remove methods (see this blog post).

public override event Action Dead
{
    add { }
    remove { }
}

The real problem is that I am using Unity and Mono 2.6 and its still a bug. Therefore, I attempted to use the suggestion that Blorgbeard said, however; it worked for Visual Studio but not for the compiler.

So there are two solutions throwing #pragma warning disable around the event, or passing the generic type.

like so:

public abstract class Actor<T> : Visual<T> where T : ActorDescription
{
    #region Events
    /// <summary>
    /// Event occurs when the actor is dead
    /// </summary>
    public event Action<Actor<T>> Dead;
    #endregion

    ...

    private void SomeFunc()
    {
        if (Dead != null)
            Dead();
    }
}

Tags:

C#

Events