Skip to content

Fix link resolution in symbols converter#4574

Open
pepone wants to merge 1 commit intoicerpc:mainfrom
pepone:fix/symbol-converter-link-resolution
Open

Fix link resolution in symbols converter#4574
pepone wants to merge 1 commit intoicerpc:mainfrom
pepone:fix/symbol-converter-link-resolution

Conversation

@pepone
Copy link
Copy Markdown
Member

@pepone pepone commented Apr 30, 2026

This PR reworks how doc comment links are handled in the symbols converter. We cannot resolve links until all symbols are converted, the eager resolution assume that there were not circular dependencies which is true for Slice definitions but not for links in the doc copmments.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes doc-comment link resolution in ZeroC.Slice.Symbols by deferring link resolution until after all symbols have been converted and cached, avoiding missed forward/self/cyclic references in doc comments.

Changes:

  • Reworked doc-comment conversion to record links as UnresolvedCommentLink during symbol conversion and resolve them in a second pass once _cache is fully populated.
  • Added recursive traversal to resolve comments across nested entities (operations/fields/variants/enumerators).
  • Introduced small supporting API/internal changes (mutable Entity.Comment internally; BasicEnum.EnumeratorEntities for traversal; minor refactors/collection expressions).

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/ZeroC.Slice.Symbols/SymbolConverter.cs Implements two-phase doc-comment link handling and resolves links after symbol table population.
src/ZeroC.Slice.Symbols/Entity.cs Allows internal post-construction updates of Comment so links can be resolved in phase 2.
src/ZeroC.Slice.Symbols/BasicEnum.cs Exposes enumerators as entities internally so comment resolution can traverse and fix enumerator comments.

Comment on lines +63 to +81
// Phase 1: convert all named symbols in dependency order. Doc-comment links are recorded as
// UnresolvedCommentLink and resolved in phase 2 — eager resolution here would miss any reference
// that targets a symbol not yet in _cache (forward references, self-references, or cycles between
// entities that aren't related by type dependencies).
foreach (string typeId in TopologicalSort())
{
(Compiler.SliceFile file, Compiler.Symbol symbol) = _named[typeId];
Module module = ConvertModule(file.ModuleDeclaration);
_cache[typeId] = ConvertSymbol(symbol, file, module);
}

// Phase 2: resolve doc-comment links now that the symbol table is fully populated.
foreach (ISymbol symbol in _cache.Values)
{
if (symbol is Entity entity)
{
ResolveEntityComments(entity);
}
}
Copy link

Copilot AI Apr 30, 2026

Choose a reason for hiding this comment

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

The new two-phase doc-comment link resolution logic (record unresolved links during conversion, then resolve after the symbol table is populated) doesn’t appear to have any regression tests that validate resolved vs unresolved links (e.g., forward/self/cyclic links, and links to sub-entities like operations/fields/enumerators). Consider adding a generator/symbols test that asserts these links become ResolvedCommentLink where appropriate so future refactors don’t silently revert to unresolved links.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Member

@externl externl left a comment

Choose a reason for hiding this comment

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

Looks good to me!

Copy link
Copy Markdown
Member

@InsertCreativityHere InsertCreativityHere left a comment

Choose a reason for hiding this comment

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

All looks good to me!

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.

4 participants