feat: add BinaryView.AddAnalysisCompletionEvent (Python parity)#31
Merged
Conversation
The C# binding declared the BNAddAnalysisCompletionEvent P/Invoke but never exposed it: AnalysisCompletionEvent had only an internal handle ctor and a Cancel() method, and BinaryView had no way to register an analysis-completion callback. Headless automation therefore could not be notified when a (possibly async) analysis pass finished. Mirror Python BinaryView.add_analysis_completion_event (binaryview.py:8068): add BinaryView.AddAnalysisCompletionEvent(Action) returning an AnalysisCompletionEvent whose lifetime roots the native callback delegate (the Activity/PR #15 delegate-marshaling pattern), so the GC cannot free the function pointer while the core still holds it. The caller must keep the returned event alive; disposing or collecting it cancels the event (documented).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes a HIGH-severity parity gap: the binding declared
BNAddAnalysisCompletionEventbut never exposed it, so managed callers had no way to be notified when an analysis pass completes — essential for headless automation (the primary use case for a C# binding).Mirrors Python
BinaryView.add_analysis_completion_event(binaryview.py:8068).Changes
BinaryView.AddAnalysisCompletionEvent(Action)— registers a callback that fires once when the next analysis pass completes.AnalysisCompletionEvent.Create(view, callback)— wraps the userActioninto the nativevoid(*)(void*)shape and roots the wrapper delegate on the event instance for its lifetime (same delegate-marshaling pattern asActivity.Create, PR fix: root registered-callback delegates and fix metadata handle ownership #15), so the GC cannot reclaim the function pointer while the core still holds it.AnalysisCompletionEventCallbackDelegate+AnalysisCompletionEventContext(new fileDelegate/AnalysisCompletionEventCallbackDelegate.cs) — the native delegate and a no-lambda named-method adapter, matching the repo's existingActivityActionDelegate.csstructure.Lifetime contract
The caller must keep the returned
AnalysisCompletionEventalive (e.g. in a field) for as long as the callback should remain armed; disposing or GC-collecting it cancels the event and frees the delegate. This matches the existingActivitymodel. Documented on the public method.E2E tests (harness repo, not this repo)
AddAnalysisCompletionEventReturnsNonNullEventCallbackFiresAfterUpdateAnalysisAndWait(sync path)CallbackFiresAfterAsyncUpdateAnalysis(async path — the primary use case)All 3 pass; full harness regression 49/49.