Skip to content

[Repo Assist] Strip parameter attribute annotations from hover tooltips#1057

Open
github-actions[bot] wants to merge 7 commits intomainfrom
repo-assist/fix-issue-858-tooltip-attributes-c373c4c6a2e6d80b
Open

[Repo Assist] Strip parameter attribute annotations from hover tooltips#1057
github-actions[bot] wants to merge 7 commits intomainfrom
repo-assist/fix-issue-858-tooltip-attributes-c373c4c6a2e6d80b

Conversation

@github-actions
Copy link
Contributor

🤖 This is an automated PR from Repo Assist, created at the request of @dsyme.

Closes #858

Problem

After an FCS NicePrint change, parameter attribute annotations like [(Optional)] and [(DefaultParameterValue(null))] started appearing verbatim in method signature tooltips. For libraries that use these attributes heavily (e.g. Plotly.NET, which uses them for C# interop on methods that can have 100+ optional parameters), the tooltips became essentially unreadable.

Root cause

The F# compiler's NicePrint.fs started including parameter attributes in the tagged text it returns for member signatures. ToolTipReader.fs faithfully converts this tagged text to strings without filtering.

The upstream fix (adding a flag to DisplayEnvironment in dotnet/fsharp to suppress parameter attributes for tooltips) would be cleaner but requires a compiler PR and a corresponding FCS bump. This PR provides a practical fsdocs-side workaround.

Fix

In ToolTipReader.formatElement, after converting tagged text to string lines via linesFromTaggedText, apply a regex post-processing step that:

  1. Strips [<...>] attribute annotation blocks from each line
  2. Filters out lines that become empty after stripping (i.e. lines that were only an attribute annotation)

The regex \s*\[<[^>]*>\] matches F# attribute syntax, which never contains a > character inside the [< >] delimiters for the common parameter attributes (Optional, DefaultParameterValue, etc.).

Changes

  • src/FSharp.Formatting.CodeFormat/ToolTipReader.fs: add stripParameterAttributes and apply it in formatElement
  • RELEASE_NOTES.md: add entry under ### Fixed

Test Status

  • Build: dotnet build — succeeded, 0 warnings, 0 errors
  • Tests: dotnet test tests/FSharp.CodeFormat.Tests — 20 passed, 0 failed

Trade-offs

  • This is a client-side filter rather than an upstream fix. If the compiler adds a proper way to suppress attribute annotations from tooltips, this workaround can be removed.
  • The regex is conservative and only removes [<...>] blocks. It does not affect other bracket syntax (e.g. array types int[]).
  • Generic attributes with > in their content (e.g. [(SomeAttr<int)>]) would not be fully stripped, but such attributes are extremely uncommon on parameters.

Generated by Repo Assist for issue #858

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@afb00b92a9514fee9a14c583f059a03d05738f70

Attributes like [<Optional>] and [<DefaultParameterValue(null)>] started
appearing in method signature tooltips after an FCS NicePrint change, making
tooltips for methods with many attributed optional parameters (e.g. Plotly.NET)
essentially unreadable.

Apply a regex post-processing step in ToolTipReader.formatElement to remove
[<...>] annotation blocks from each tooltip line, and filter out any lines that
become empty after stripping.

Fixes #858

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@dsyme dsyme marked this pull request as ready for review March 1, 2026 14:09
@dsyme
Copy link
Contributor

dsyme commented Mar 1, 2026

/repo-assist please add testing for this

- Expose stripParameterAttributes as internal so it can be unit-tested
- Add 6 unit tests covering the stripping regex logic
- Add integration test verifying attribute annotations do not appear in rendered HTML tooltips

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions
Copy link
Contributor Author

github-actions bot commented Mar 1, 2026

Commit pushed: b49aff8

Generated by Repo Assist

@nojaf
Copy link
Collaborator

nojaf commented Mar 2, 2026

/repo-assist fix "Seq.map |> Seq.filter can be combined into Seq.choose"

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions
Copy link
Contributor Author

github-actions bot commented Mar 2, 2026

Commit pushed: 16f68d7

Generated by Repo Assist

@github-actions
Copy link
Contributor Author

github-actions bot commented Mar 2, 2026

🤖 This is an automated response from Repo Assist.

Done! I've combined the Seq.map |> Seq.filter into a single Seq.choose call in ToolTipReader.fs:

// Before
|> Seq.map stripParameterAttributes
|> Seq.filter (fun s -> s.Trim() <> "")

// After
|> Seq.choose (fun s ->
    let stripped = stripParameterAttributes s
    if stripped.Trim() <> "" then Some stripped else None)

The commit has been pushed to this PR's branch.

Generated by Repo Assist for issue #1057

To install this agentic workflow, run

gh aw add githubnext/agentics/workflows/repo-assist.md@da02dddebe71d9a937665abdcd1f5214dab852a7

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Function signature tooltips include attributes for arguments that make the tooltip unreadable

2 participants