Skip to content

[bgen] Emit XML documentation for generated events - #26299

Merged
rolfbjarne merged 4 commits into
mainfrom
dev/rolf/jubilant-guacamole
Jul 27, 2026
Merged

[bgen] Emit XML documentation for generated events#26299
rolfbjarne merged 4 commits into
mainfrom
dev/rolf/jubilant-guacamole

Conversation

@rolfbjarne

Copy link
Copy Markdown
Member

The binding generator synthesizes C# event members from the [BaseType]
delegate/EventArgs wiring, but never emitted any XML documentation for them. As a
result every generated event showed up as an undocumented, publicly-visible member
and had to be allow-listed in the documentation known-failures list.

This PR makes bgen emit a generated <summary> for each synthesized event (guarded
by BindingTouch.SupportsXmlDocumentation), for both the non-generic EventHandler
and the generic EventHandler<T> branches. When the binding already provides docs
via [EventArgs (XmlDocs = ...)], those are used instead and no generated summary is
emitted. The generic branch adds a <see cref=...> to the generated EventArgs type;
crefs resolve correctly (verified against the VerifyNoUnresolvedCrefs test).

With the events now documented, 67 generated-event E: entries are removed from
tests/cecil-tests/Documentation.KnownFailures.txt. The remaining 38 E: entries in
that file are hand-written events (not produced by bgen) and are intentionally left
allow-listed; documenting those is a separate follow-up.

Test coverage: tests/bgen/tests/xmldocs.cs gains a single-parameter delegate method
(DidFinish) so both the non-generic and generic event branches are exercised, and
the four ExpectedXmlDocs.*.xml baselines are regenerated accordingly. The bgen
XmlDocs test passes on all four platforms.

🤖 Pull request created by Copilot

rolfbjarne and others added 4 commits July 24, 2026 16:40
The binding generator synthesizes 'event' members from the [BaseType]
delegate/EventArgs wiring, but emitted no XML documentation for them unless
an [EventArgs (..., XmlDocs = ...)] was supplied in the binding. This left
105 generated events undocumented and allow-listed in the documentation
known-failures list.

Emit a generic <summary> (guarded by BindingTouch.SupportsXmlDocumentation)
for both the EventHandler and EventHandler<T> event branches when no explicit
XmlDocs are provided.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 42129f24-b8fb-46cc-a816-e6430769fbfb
Add a single-parameter delegate method (DidFinish) to the bgen XmlDocs test's
'xmldocs.cs' so both event branches are exercised:

 * DidChangeUtteringSpeed (two parameters) covers the generic EventHandler<T>
   branch.
 * DidFinish (one parameter) covers the non-generic EventHandler branch.

Regenerate the ExpectedXmlDocs.*.xml files, which now include the generated
<summary> for both events.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 42129f24-b8fb-46cc-a816-e6430769fbfb
…wn failures.

The binding generator now emits XML documentation for the events it
synthesizes, so the 67 generated events that were previously allow-listed as
undocumented are removed from the documentation known-failures list.

The remaining event entries correspond to hand-written (non-generated) events
in the manual API surface, which are unaffected by this change.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 42129f24-b8fb-46cc-a816-e6430769fbfb
Keep the original inline 'string.IsNullOrEmpty (xmlDocs)' check so the compiler's
flow analysis knows xmlDocs is non-null, instead of using the banned postfix '!'
operator.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 42129f24-b8fb-46cc-a816-e6430769fbfb
@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2

This comment has been minimized.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Updates bgen to emit XML documentation for synthesized C# event members generated from delegate/EventArgs wiring, reducing the need for documentation known-failure allow-list entries.

Changes:

  • Emit a default generated <summary> for synthesized events when XML documentation is supported and no [EventArgs (XmlDocs=...)] docs are provided.
  • Extend the xmldocs bgen test to exercise both non-generic (EventHandler) and generic (EventHandler<T>) event documentation paths.
  • Remove now-documented generated events from tests/cecil-tests/Documentation.KnownFailures.txt and refresh XML doc baselines.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/bgen/Generator.cs Emits default XML <summary> docs for synthesized events (generic and non-generic) when no explicit event XmlDocs are provided.
tests/bgen/tests/xmldocs.cs Adds a single-parameter delegate method to exercise non-generic event doc generation.
tests/bgen/tests/ExpectedXmlDocs.iOS.xml Updates baseline with new synthesized event summaries.
tests/bgen/tests/ExpectedXmlDocs.tvOS.xml Updates baseline with new synthesized event summaries.
tests/bgen/tests/ExpectedXmlDocs.macOS.xml Updates baseline with new synthesized event summaries.
tests/bgen/tests/ExpectedXmlDocs.MacCatalyst.xml Updates baseline with new synthesized event summaries.
tests/cecil-tests/Documentation.KnownFailures.txt Removes generated-event entries that are now documented.

@rolfbjarne
rolfbjarne marked this pull request as ready for review July 27, 2026 17:30
@rolfbjarne
rolfbjarne enabled auto-merge (squash) July 27, 2026 17:30
@rolfbjarne rolfbjarne added the ready-to-review This PR is ready to review/merge. label Jul 27, 2026
@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

✅ API diff for current PR / commit

NET (empty diffs)

✅ API diff vs stable

NET (empty diffs)

ℹ️ Generator diff

Generator Diff: vsdrops (html) vsdrops (raw diff) gist (raw diff) - Please review changes)

Pipeline on Agent
Hash: 0b836df5f3caffa40a9fb76e669ab980786f77fd [PR build]

@vs-mobiletools-engineering-service2

Copy link
Copy Markdown
Collaborator

🚀 [CI Build #0b836df] Test results 🚀

Test results

✅ All tests passed on VSTS: test results.

🎉 All 203 tests passed 🎉

Tests counts

✅ assembly-processing: All 1 tests passed. Html Report (VSDrops) Download
✅ cecil: All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (iOS): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (MacCatalyst): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (macOS): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (Multiple platforms): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (tvOS): All 1 tests passed. Html Report (VSDrops) Download
✅ framework: All 2 tests passed. Html Report (VSDrops) Download
✅ fsharp: All 4 tests passed. Html Report (VSDrops) Download
✅ generator: All 5 tests passed. Html Report (VSDrops) Download
✅ interdependent-binding-projects: All 4 tests passed. Html Report (VSDrops) Download
✅ introspection: All 4 tests passed. Html Report (VSDrops) Download
✅ linker (iOS): All 15 tests passed. Html Report (VSDrops) Download
✅ linker (MacCatalyst): All 15 tests passed. Html Report (VSDrops) Download
✅ linker (macOS): All 21 tests passed. Html Report (VSDrops) Download
✅ linker (tvOS): All 15 tests passed. Html Report (VSDrops) Download
✅ monotouch (iOS): All 19 tests passed. Html Report (VSDrops) Download
✅ monotouch (MacCatalyst): All 18 tests passed. Html Report (VSDrops) Download
✅ monotouch (macOS): All 19 tests passed. Html Report (VSDrops) Download
✅ monotouch (tvOS): All 19 tests passed. Html Report (VSDrops) Download
✅ msbuild: All 2 tests passed. Html Report (VSDrops) Download
✅ sharpie: All 1 tests passed. Html Report (VSDrops) Download
✅ windows: All 3 tests passed. Html Report (VSDrops) Download
✅ xcframework: All 4 tests passed. Html Report (VSDrops) Download
✅ xtro: All 1 tests passed. Html Report (VSDrops) Download

macOS tests

✅ Tests on macOS Monterey (12): All 5 tests passed. Html Report (VSDrops) Download
✅ Tests on macOS Ventura (13): All 5 tests passed. Html Report (VSDrops) Download
✅ Tests on macOS Sonoma (14): All 5 tests passed. Html Report (VSDrops) Download
✅ Tests on macOS Sequoia (15): All 5 tests passed. Html Report (VSDrops) Download
✅ Tests on macOS Tahoe (26): All 5 tests passed. Html Report (VSDrops) Download

Linux Build Verification

Linux build succeeded

Pipeline on Agent
Hash: 0b836df5f3caffa40a9fb76e669ab980786f77fd [PR build]

@rolfbjarne
rolfbjarne merged commit b21baa2 into main Jul 27, 2026
57 checks passed
@rolfbjarne
rolfbjarne deleted the dev/rolf/jubilant-guacamole branch July 27, 2026 20:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

copilot ready-to-review This PR is ready to review/merge.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants