Resolve `<see cref>` in XML doc comments like C#

Aperta
#20,640 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
35/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
fsharp

Direzione di ricerca

Start by reading the XML documentation flow at XmlDocFileWriter.WriteXmlDocFile and the XML doc ranges from #20637, then inspect XmlDocSigOfVal and the related rename work in #20638. Done means the stated first-cut cref forms resolve against the final environment, emit documentation IDs or !:Text, report FS3390 when unresolved, and support the described editor behavior.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Feature Request Needs-Triage

Is your feature request related to a problem? Please describe.

<see cref="…"/>, <seealso cref>, <exception cref> and <permission cref> in F# /// comments are plain text to the compiler and the IDE:

  • --doc copies the attribute verbatim (XmlDocFileWriter.WriteXmlDocFile), so <see cref="Parse"/> reaches the .xml file as Parse. C# writes the documentation ID (M:Ns.Parser.Parse(System.String)), and tools that read the file (DocFX, fsdocs, Visual Studio tooltips of the consuming project) resolve IDs, not source names. The unresolved-cref diagnostic already exists (xmlDocUnresolvedCrossReference, FS3390 group) but is never raised.
  • In the editor, a cref is not a symbol: Go To Definition does nothing on it, renaming the type or member leaves it stale, and the tooltip prints the raw text.

Describe the solution you'd like

The same as C#, built on the XML doc ranges from #20637:

  1. The checker resolves each cref against the file's final environment (so it can point forward, as in C#): the enclosing type's members first, then values, types and modules — the nameof resolution order. A resolved cref is reported as a related symbol use of a new kind (RelatedSymbolUseKind.XmlDocCref), opt-in like XmlDocParameter in #20637, so symbol search is not bloated.
  2. --doc writes the documentation ID of the resolved symbol; an unresolved cref is written as !:Text and reported under FS3390. A cref that already carries a prefix (T:, M:, …) is kept as is.
  3. The editor: Rename rewrites the last segment of the cref (#20638 already passes all related kinds to Rename), Go To Definition works on it, and the tooltip shows the resolved name.

A first cut would cover types, modules, union cases, fields, properties, events and non-overloaded methods, and leave M(int) overload syntax, List{T} generics and operators for later.

Describe alternatives you've considered

  • Resolving where each doc comment is converted: a type's doc is converted before the rest of its recursive group and its members exist, so forward references would not resolve.
  • Producing the IDs during checking: XmlDocSigOfVal needs the generalized type and ValReprInfo, and the IDs are cached on the Val; they have to be made when --doc writes the file.

Additional context

Questions before any code:

  1. Should Find All References list crefs? C# does; #20637/#20638 keep <param> names out of it.
  2. Is rewriting the .xml output a compiler change that can go in behind --doc, or does it need a language suggestion first?
  3. Should FS3390 for an unresolved cref stay opt-in, like the rest of that warning?

Related: #20630, #20637, #20638, #15134, #20591.

Lingua principale
F#
Stelle
4.3k
Fork
884
Merge medio
2g 11h
PR unite (30g)
73

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di dotnet/fsharp

Tutte le issue di dotnet/fsharp

Issue simili

Altre issue su Compilers

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.