Skip to content

Add APIs for allocation-free delegate invocation list inspection #97683

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

Merged
merged 9 commits into from
Jan 31, 2024

Conversation

jkotas
Copy link
Member

@jkotas jkotas commented Jan 30, 2024

Fixes #41849

Copy link

Note regarding the new-api-needs-documentation label:

This serves as a reminder for when your PR is modifying a ref *.cs file and adding/modifying public APIs, please make sure the API implementation in the src *.cs file is documented with triple slash comments, so the PR reviewers can sign off that change.

@ghost ghost assigned jkotas Jan 30, 2024
@ghost
Copy link

ghost commented Jan 30, 2024

Tagging subscribers to this area: @dotnet/area-system-runtime
See info in area-owners.md if you want to be subscribed.

Issue Details

Fixes #41849

Author: jkotas
Assignees: -
Labels:

area-System.Runtime, new-api-needs-documentation

Milestone: -

Copy link
Member

@stephentoub stephentoub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice.

@stephentoub
Copy link
Member

Looks like there are a few places we could use HasSingleTarget, e.g.


private bool AddingNewHandled => _onAddingNew != null && _onAddingNew.GetInvocationList().Length > 0;

(though I don't understand that second one... won't _onAddingNew.GetInvocationList().Length > 0 always be true?)

@stephentoub
Copy link
Member

And a few places we could enumerate more cheaply?

foreach (Func<AssemblyLoadContext, AssemblyName, Assembly> handler in resolvingHandler.GetInvocationList())

foreach (ResolveEventHandler handler in eventHandler.GetInvocationList())

foreach (Func<Assembly, string, IntPtr> handler in dllResolveHandler.GetInvocationList())

Co-authored-by: Stephen Toub <stoub@microsoft.com>
@jkotas jkotas requested a review from stephentoub January 30, 2024 19:33
jkotas and others added 2 commits January 30, 2024 18:13
…/MulticastDelegateTests.cs

Co-authored-by: Stephen Toub <stoub@microsoft.com>
@jkotas
Copy link
Member Author

jkotas commented Jan 31, 2024

All failures are known according to the build analysis

@jkotas jkotas merged commit d2e51ee into dotnet:main Jan 31, 2024
@jkotas jkotas deleted the delegate-enumerator branch January 31, 2024 13:47
@github-actions github-actions bot locked and limited conversation to collaborators Mar 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Get InvocationList of MulticastDelegate without any allocation
2 participants