C# 14: Support for partial event declarations.#21325
Open
michaelnebel wants to merge 5 commits intogithub:mainfrom
Open
C# 14: Support for partial event declarations.#21325michaelnebel wants to merge 5 commits intogithub:mainfrom
event declarations.#21325michaelnebel wants to merge 5 commits intogithub:mainfrom
Conversation
a37011f to
c29bac2
Compare
Contributor
Author
|
DCA looks good
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds support for C# 14 partial event declarations by ensuring that only accessors from the implementation declaration are extracted, not from the declaring declaration. The implementation follows the established pattern used for partial properties and indexers.
Changes:
- Added extractor support for partial events using
BodyDeclaringSymbolpattern (similar to partial properties/indexers) - Added
NeedsPopulationoverride inEventAccessorto skip extraction of accessors from partial declaring declarations - Added comprehensive test coverage for partial events including AST, accessor detection, and dispatch tests
Reviewed changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| csharp/extractor/Semmle.Extraction.CSharp/Entities/Event.cs | Implements BodyDeclaringSymbol and ReportingLocation to use implementation part for partial events; gets accessors from implementation declaration only; modernizes null check pattern |
| csharp/extractor/Semmle.Extraction.CSharp/Entities/EventAccessor.cs | Overrides NeedsPopulation to skip extraction of accessors from partial declaring declarations |
| csharp/ql/test/library-tests/partial/Partial.cs | Adds test cases for partial event declarations |
| csharp/ql/test/library-tests/partial/PartialEvents.ql | New query to test isPartial() predicate on events |
| csharp/ql/test/library-tests/partial/PartialEvents.expected | Expected output for partial events test |
| csharp/ql/test/library-tests/partial/PartialAccessors.expected | Updated to include partial event accessors |
| csharp/ql/test/library-tests/partial/Partial1.expected | Updated with partial event entries |
| csharp/ql/test/library-tests/partial/PrintAst.expected | Updated AST output showing partial event structure |
| csharp/ql/test/library-tests/partial/PartialProperties.expected | Line number updates due to added code |
| csharp/ql/test/library-tests/partial/PartialMethodBody.expected | Line number updates due to added code |
| csharp/ql/test/library-tests/partial/PartialIndexers.expected | Line number updates due to added code |
| csharp/ql/test/library-tests/partial/PartialConstructors.expected | Line number updates due to added code |
| csharp/ql/test/library-tests/partial/Partial2.expected | Line number updates due to added code |
| csharp/ql/test/library-tests/partial/MethodIsPartial.expected | Line number updates due to added code |
| csharp/ql/test/library-tests/dispatch/ViableCallable.cs | Adds test cases for partial event dispatch |
| csharp/ql/test/library-tests/dispatch/GetADynamicTarget.expected | Updated with partial event accessor dispatch targets |
| csharp/ql/test/library-tests/dispatch/CallGraph.expected | Updated call graph with partial event accessors |
| csharp/ql/lib/change-notes/2026-02-16-partial-events.md | Change note documenting C# 14 partial events support |
event declarations.
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.
In this PR we make support for partial event declarations.
That is, we support event declarations like.
The default
add/removeevent accessors from the declaring declaration are not extracted. Only the explicitadd/removefrom the implementation declaration are extracted. Note that a partial event always need to have an implementation declaration.