Skip to content

Rename a parameter together with its XML doc param tags - #20638

Open
xperiandri wants to merge 7 commits into
dotnet:mainfrom
xperiandri:fix/rename-xmldoc-param-tags
Open

xperiandri wants to merge 7 commits into
dotnet:mainfrom
xperiandri:fix/rename-xmldoc-param-tags

Conversation

@xperiandri

Copy link
Copy Markdown
Contributor

Fixes #20630
Stacked on #20637

Renaming a parameter or type parameter in Visual Studio left <param name="x">, <paramref>, <typeparam> and <typeparamref> in the declaration's /// comment untouched. Rename now asks the checker for every related use, so the names #20637 reports inside the comment are rewritten together with the parameter, as C# does; a name on a /// line gets the bare text — U for 'U, a b for ``a b``. Document highlights show the tag name when the caret is on the parameter.

Find All References and the refactorings that collect uses pass the new SymbolHelpers.codeSymbolUseKinds, which leaves the doc names out, so a reference list stays code-only.

🤖 Generated with Claude Code

xperiandri and others added 3 commits September 26, 2026 03:22
`XmlDoc` keeps the range of every `///` line and lists the `name` and
`cref` attribute values it contains with their source ranges. The
checker reports each `<param>`, `<paramref>`, `<typeparam>` and
`<typeparamref>` name that matches a parameter or type parameter of
the documented declaration as a `RelatedSymbolUseKind.XmlDocParameter`
use, for let-bound functions, members, primary constructors, union
case fields and signature-file vals.

The kind is opt-in: `GetUsesOfSymbolInFile` returns it only when asked
for, the `ItemKeyStore` behind Find All References never receives it,
and semantic classification ignores it.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Rename asks for every related use, so the `<param>`, `<paramref>`,
`<typeparam>` and `<typeparamref>` names the checker now reports are
rewritten with the parameter; a name inside a `///` line gets the bare
text, without the type-parameter tick or backticks. Find All References
passes `SymbolHelpers.codeSymbolUseKinds`, which leaves the doc names
out, and document highlights keep showing them.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Copilot AI lite review requested due to automatic review settings September 26, 2026 02:08
@xperiandri
xperiandri requested a review from a team as a code owner September 26, 2026 02:08
@github-actions

github-actions Bot commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

✅ Release notes checked


✅ Found changes and release notes in following paths:

Warning

No PR link found in some release notes, please consider adding it.

Change path Release notes path Description
`src/Compiler` docs/release-notes/.FSharp.Compiler.Service/11.0.200.md No current pull request URL (#20638) found, please consider adding it
`vsintegration/src` docs/release-notes/.VisualStudio/18.vNext.md

@xperiandri

Copy link
Copy Markdown
Contributor Author

Covered cases, driven through InlineRenameService end to end (FSharp.Editor.Tests/InlineRenameXmlDocTests.fs, each compares the rewritten document text):

  • <param> and <paramref> of a let-bound function
  • <typeparam> and <typeparamref>: 'T → 'U writes name="U"
  • rename to ``the addend`` writes name="the addend"
  • <param> of a member, this untouched
  • <param> of a primary constructor, documented on the type

DocumentHighlightsServiceTests: the caret on x highlights the name="x" of its <param> alongside the code uses. FindReferencesTests: Find All References on a documented parameter reports the body use only.

Swapping the two masks (rename with codeSymbolUseKinds, Find All References with All) fails the five rename tests and the Find All References one.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

Unresolved moderate issues remain in XML-doc scanning and rename paths.

Review effort: Lite
Findings: 2 Medium severity

Open (2)
What changed in this PR

Adds XML documentation parameter/type-parameter references to rename and highlighting while excluding them from Find All References.

Changes:

  • Tracks and reports XML-doc references.
  • Updates rename, highlighting, and filtering behavior.
  • Adds compiler/editor tests and release notes.
File Description
vsintegration/​tests/​FSharp.Editor.Tests/​InlineRenameXmlDocTests.fs XML-doc rename tests
vsintegration/​tests/​FSharp.Editor.Tests/​FSharp.Editor.Tests.fsproj Test project updates
vsintegration/​tests/​FSharp.Editor.Tests/​FindReferencesTests.fs Reference filtering tests
vsintegration/​tests/​FSharp.Editor.Tests/​DocumentHighlightsServiceTests.fs Documentation highlighting tests
vsintegration/​src/​FSharp.Editor/​Navigation/​FindUsagesService.fs Excludes documentation uses
vsintegration/​src/​FSharp.Editor/​LanguageService/​SymbolHelpers.fs Adds use-kind filtering
vsintegration/​src/​FSharp.Editor/​InlineRename/​InlineRenameService.fs Applies doc-aware rename edits
tests/​FSharp.Compiler.Service.Tests/​XmlDocTests.fs XML-doc scanner tests
tests/​FSharp.Compiler.Service.Tests/​FSharp.Compiler.Service.SurfaceArea.netstandard20.bsl API baseline update
tests/​FSharp.Compiler.ComponentTests/​FSharpChecker/​SemanticClassificationRegressions.fs Classification regression tests
tests/​FSharp.Compiler.ComponentTests/​FSharpChecker/​FindReferences.fs Related-use tests
src/​Compiler/​SyntaxTree/​XmlDoc.fsi XML-doc API declarations
src/​Compiler/​SyntaxTree/​XmlDoc.fs XML-doc scanning and ranges
src/​Compiler/​Service/​TransparentCompiler.fs Filters documentation uses
src/​Compiler/​Service/​SemanticClassification.fs Excludes documentation classification
src/​Compiler/​Service/​IncrementalBuild.fs Filters indexed documentation uses
src/​Compiler/​Checking/​RelatedSymbolUse.fs Adds XML-doc use kind
src/​Compiler/​Checking/​NameResolution.fsi Declares documentation-use reporting
src/​Compiler/​Checking/​NameResolution.fs Reports matching documentation references
src/​Compiler/​Checking/​Expressions/​CheckExpressions.fs Reports function parameter references
src/​Compiler/​Checking/​CheckIncrementalClasses.fs Reports constructor references
src/​Compiler/​Checking/​CheckDeclarations.fs Reports declaration and union-field references
docs/​release-notes/​.VisualStudio/​18.vNext.md Documents editor behavior
docs/​release-notes/​.FSharp.Compiler.Service/​11.0.200.md Documents FCS API behavior

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/Compiler/SyntaxTree/XmlDoc.fs Outdated
Comment on lines +70 to +74
match text.IndexOf(attribute, i, StringComparison.Ordinal) with
| -1 -> ValueNone
| at when at >= close -> ValueNone
| at ->
let mutable j = at + attribute.Length

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Confirmed. This code comes from #20637 and is fixed there in 008cb20; it is brought into this branch as 2139ae0. The scanner now walks attributes as tokens, compares whole names, and scans the whole comment, so a tag that runs over several /// lines is found too.

// Rename follows a parameter into its `<param>`/`<typeparam>` tags, which Find All References leaves out
let symbolUses =
SymbolHelpers.getSymbolUsesInSolution (symbolUse, checkFileResults, document) ct
SymbolHelpers.getSymbolUsesInSolution (symbolUse, checkFileResults, document, RelatedSymbolUseKind.All) ct

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Confirmed. A public union case field is the one symbol with a <param> tag that takes the project-wide path, and the index behind that path deliberately leaves doc names out. When the caller asks for XmlDocParameter, findSymbolUses now also reads the doc uses from the check results of the files that declare the symbol (declaration and signature), keeping only ranges that are not already code uses. Added param of a public union case field follows the field; it fails without the lookup. Fixed in a605e28.

@github-actions github-actions Bot added the ⚠️ Affects-Design-Time Tooling check: PR touches type providers or dependency manager label Sep 26, 2026
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

xperiandri and others added 3 commits September 26, 2026 12:34
The scanner looked for the attribute name as a substring of each line,
so `<param notname="wrong" name="x">` reported `wrong`, and a tag whose
`name` sat on the next `///` line reported nothing. It now walks the
attributes of each tag one at a time over the whole comment, keeps a
`>` inside a quoted value from ending the tag, maps each value back to
its line, and skips a value that runs over a line break.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A public union case field is found through the project-wide index,
which leaves out names inside `///` comments, so renaming it left its
`<param>` tag behind. When the caller asks for XML doc uses, they are
now read from the check results of the files that declare the symbol,
next to the index results.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Recognizing a `///` line copied the whole line into a string for every
rename location; it now reads the characters from the source text.
The tag text no longer goes through an intermediate `TrimStart` copy.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

This comment has been minimized.

@github-actions github-actions Bot added ⚠️ Affects-Build-Infra Tooling check: PR touches build infrastructure ⚠️ Affects-Restore Tooling check: PR touches NuGet packages or feeds labels Sep 26, 2026
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

Copy link
Copy Markdown
Contributor

🔍 Tooling Safety Check — Affects-Build-Infra, Affects-Design-Time, Affects-Restore
Affects-Build-Infra: Build projects, scripts, or targets are modified.
Affects-Design-Time: Compiler-service or IDE design-time behavior changes.
Affects-Restore: Package references, feeds, or restore inputs change.

Generated by PR Tooling Safety Check · gpt56 1.7M · ◷

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

⚠️ Affects-Build-Infra Tooling check: PR touches build infrastructure ⚠️ Affects-Design-Time Tooling check: PR touches type providers or dependency manager ⚠️ Affects-Restore Tooling check: PR touches NuGet packages or feeds

Projects

Status: New

Development

Successfully merging this pull request may close these issues.

Renaming a parameter does not update <param>, <paramref>, <typeparam> and <typeparamref> in its XML doc

2 participants