The proper way to generate delegates?

I’m trying to figure out how to generate C# delegates from Haxe, and so far I have tried the following code:

@:delegate
public function myDelegate():Void; //Generates -> public virtual void myDelegate();

@:delegate
public var myDelegate:Function; //Generates -> public object myDelegate;

@:delegate
public var myDelegate:Object -> EventArgs -> Void; //Generates -> public global::haxe.lang.Function myDelegate;

None of which are the results I expect. I have a two part question:

Does the @:delegate metadata actually do anything?
And how best do you go about creating an actual delegate definition, like the following:

public delegate void myDelegate(object sender, EventArgs e);

Or is the above just not possible?

There’s a good chance it does nothing. Based on this page, most of the metadata tags that are automatically added are just for informational purposes, and have no effect on Haxe’s output.

Notably, the page doesn’t explicitly state that @:delegate is useless, whereas it states that for other tags. This could mean that @:delegate does something, or it could mean that they forgot to mention it.


One other thing to try:

untyped __cs__("public delegate void myDelegate(object sender, EventArgs e);");

In theory, this will insert the C# code verbatim. I have no idea if it works, though. All I’ve seen are JavaScript and C++ examples, and the examples were for code inside a function.