Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLR event support #1141

Closed
2 of 3 tasks
jakubmisek opened this issue May 6, 2024 · 1 comment
Closed
2 of 3 tasks

CLR event support #1141

jakubmisek opened this issue May 6, 2024 · 1 comment
Assignees
Labels

Comments

@jakubmisek
Copy link
Member

jakubmisek commented May 6, 2024

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:

  • treat event as a fake object with add() and remove() methods: $x->e->add( function() {} ).
  • handle += and -= operators: $x-> e += function () {}
  • event will be callable as well (the fake object will have __invoke method)

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 jakubmisek self-assigned this May 6, 2024
@jakubmisek jakubmisek added this to TODO in .NET interop via automation May 6, 2024
jakubmisek added a commit to peachpiecompiler/peachpie-docs that referenced this issue May 6, 2024
@jakubmisek
Copy link
Member Author

add/close implemented in 232f292

.NET interop automation moved this from TODO to done May 6, 2024
jakubmisek added a commit that referenced this issue May 6, 2024
jakubmisek added a commit that referenced this issue May 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
.NET interop
  
done
Development

No branches or pull requests

1 participant