I have a base class with an event and an inherited class, where I would like to add a handler, e.g.
type BaseClass() =
let event = new Event<unit>()
[<CLIEvent>]
member t.MyEvent = event.Publish
type Inherited() =
inherit BaseClass()
do base.MyEvent.Add(fun () -> ())
However I get an error on the final line:
FS0419 'base' values may only be used to make direct calls to the base implementations of overridden members.
One approach I've tried is using the this instead:
type Inherited() as this =
inherit BaseClass()
do this.MyEvent.Add(fun () -> ())
This does work, however I was wondering if there is a more appropriate solution using an override suggested in the error message?
As I thought there must be a good reason why base.MyEvent.Add... is disallowed - but I don't know the syntax that's needed.