I have an interface written in C # defined as follows:
public interface IWidget { object Evaluate(); event EventHandler Invalidated; }
When I try to implement this interface in F #, I see that F # considers the IWidget interface (hover over it) and I see
type IWidget = interface member Evaluate : unit -> obj end
It seems that the Invalidated event has been ignored completely ... is this a known issue with F #, and if there is a way around it? When implementing my version of F # IWidget, can I just implement this event outside the IWidget section or what? It seems really nasty that f # handles the keyword "event" so badly ...
UPDATE: After further messing around, the studio then said things like:
'implementation is not implemented for IWidget.remove_Invalidate (value: EventHandler): unit'
then, when I added these methods, it all looked like this:
interface IWidget with member w.Evaluate() = new obj() member w.add_Invalidated(value:EventHandler) = () member w.remove_Invalidated(value:EventHandler) = () end
it compiled fine, although the tooltip still said that the only member of IWidget was Evaluate () ... it looks like the F # method (or at least the IDE) is handling this stuff, really shy ...
OTHER UPDATE: According to the prompt in the IDE, the [] tag allows you to compile the event as a CLI metadata event, converting it into a pair of add_ / remove _... methods just FYI for everyone who was just as embarrassed by this as I was. In short, either the implementation of these two methods or the use of this tag work fine, although the fact that the IWdiget interface tooltip view does not mention the Invalidate event, and the need to implement such an event is observed only when the compiler throws an error, still is a clear mistake and rather confusing. Anyone curious that the following code works fine:
let invalidated = new DelegateEvent<System.EventHandler>() interface IWidget with member w.Evaluate() = new obj() [<CLIEvent>] member w.Invalidated = invalidated.Publish end
Thanks for helping everyone!