peachpiecompiler / peachpie

PeachPie - the PHP compiler and runtime for .NET and .NET Core
https://www.peachpie.io
Apache License 2.0
2.31k stars 201 forks source link

CLR event support #1141

Closed jakubmisek closed 1 month ago

jakubmisek commented 1 month ago

Allow add/remove callable to the .NET/C# event

for example having C# class X as below:

class X {
  public event e;
}

suggesting to allow two syntax approaches in PeachPie:

Note, remove of callables from .NET event might not work (since the instance of the delegate won't be the same), so the on() method should return an instance of a special class with "Dispose" or "Close" methods which would remove the delegate from the event as it's more common in other languages.

jakubmisek commented 1 month ago

add/close implemented in https://github.com/peachpiecompiler/peachpie/commit/232f2921390d99bd513810c381426072afa5f170