Skip to content

GenFacades: Enrich PNSE stubs with XML doc comments from implementation sources#16624

Draft
Copilot wants to merge 2 commits intomainfrom
copilot/add-not-supported-source-generation
Draft

GenFacades: Enrich PNSE stubs with XML doc comments from implementation sources#16624
Copilot wants to merge 2 commits intomainfrom
copilot/add-not-supported-source-generation

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 25, 2026

NotSupportedAssemblyGenerator generated PNSE stubs with no useful XML docs — the shipped PNSE assemblies lacked the documentation that matched the implementation. This adds a doc-comment enrichment pass: all **/*.cs files in the project are parsed for /// docs and applied to the generated stubs.

Approach

Rather than complex cross-project source evaluation, the task does a pre-pass over @(NotSupportedAssemblyImplementationSource) (defaults to **/*.cs in the current project) to build a DocCommentIndex (API key → trivia, first-occurrence-wins), then the rewriter applies those docs when generating each stub. API definitions still come from the ContractProject reference sources; the implementation sources only contribute documentation.

Key changes

NotSupportedAssemblyGenerator.cs

  • New ImplementationSourceFiles task property
  • DocCommentIndex — lookup from FQN API key → SyntaxTriviaList of doc-comment trivia; first match across all impl files wins
  • DocCommentWalker (CSharpSyntaxWalker) — populates the index across all member kinds: types, methods, properties, events (including event-field syntax), constructors, fields, operators, conversion operators, enum members
  • ApiKey static class — shared FQN key computation used by both walker and rewriter; handles regular and file-scoped namespaces (C# 10), nested types, and top-level types
  • ReplaceDocTrivia — strips existing doc-comment trivia from the reference node's leading trivia, inserts impl docs before the final indentation whitespace
  • ApplyDocComment — called from every Visit* method; emits LogWarning for APIs not found in impl or found without docs (only when impl sources are provided)
  • Extracted CreateThrowBlock() / CreateEmptyBlock() to eliminate the repeated ParseStatement pattern

Microsoft.DotNet.GenFacades.NotSupported.targets

  • Adds NotSupportedAssemblyImplementationSource item (defaults to **/*.cs, excludes $(IntermediateOutputPath))
  • Opt-out: set IncludeNotSupportedAssemblyImplementationSources=false or remove items from NotSupportedAssemblyImplementationSource
  • Removed ImplementationProject approach from previous iteration

To double check:

Copilot AI and others added 2 commits March 25, 2026 19:59
…es via **/*.cs glob

Co-authored-by: ericstj <8918108+ericstj@users.noreply.github.com>
Agent-Logs-Url: https://github.com/dotnet/arcade/sessions/4e4d36a1-1980-4a25-bd9f-b03f132195f0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants