Skip to content

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

Description

@xperiandri
/// <summary>Adds two numbers.</summary>
/// <typeparam name="T">The number type.</typeparam>
/// <param name="x">The first number.</param>
/// <param name="y">Added to <paramref name="x"/>.</param>
let add<'T when 'T :> System.Numerics.INumber<'T>> (x: 'T) (y: 'T) = x + y

Renaming x (F2 in Visual Studio) rewrites the parameter and its uses in the body, but leaves name="x" in both <param> and <paramref> untouched, so the doc now documents a parameter that no longer exists. Renaming 'T likewise leaves <typeparam name="T"> behind.

Expected: the rename also updates the name attribute of every <param>, <paramref>, <typeparam> and <typeparamref> that refers to the renamed parameter, as it does in C#. This applies to let-bound functions, members, primary constructors and union case fields, and to type parameters.

Two things to keep in mind for the fix:

  • The compiler does not know where name="x" sits in the source: PreXmlDoc.ToXmlDoc merges the per-line ranges of the /// lines into one, and FS3390 reports on the whole block. This is what Have PreXmlDoc/XmlDoc track names and ranges for param/paramref children #15134 asks to change.
  • The new text differs from the code: 'T renamed to 'U must become U in name="U", and a backticked name must be written without the backticks.

Related: #15134

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions