[Repo Assist] Strip parameter attribute annotations from hover tooltips#1057
Open
github-actions[bot] wants to merge 7 commits intomainfrom
Open
[Repo Assist] Strip parameter attribute annotations from hover tooltips#1057github-actions[bot] wants to merge 7 commits intomainfrom
github-actions[bot] wants to merge 7 commits intomainfrom
Conversation
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>
9 tasks
…-c373c4c6a2e6d80b
Contributor
|
/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>
Contributor
Author
|
Commit pushed:
|
Collaborator
|
/repo-assist fix "Seq.map |> Seq.filter can be combined into Seq.choose" |
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
Author
|
Commit pushed:
|
Contributor
Author
|
🤖 This is an automated response from Repo Assist. Done! I've combined the // 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.
|
nojaf
approved these changes
Mar 2, 2026
7 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 This is an automated PR from Repo Assist, created at the request of @dsyme.
Closes #858
Problem
After an FCS
NicePrintchange, 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.fsstarted including parameter attributes in the tagged text it returns for member signatures.ToolTipReader.fsfaithfully converts this tagged text to strings without filtering.The upstream fix (adding a flag to
DisplayEnvironmentindotnet/fsharpto 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 vialinesFromTaggedText, apply a regex post-processing step that:[<...>]attribute annotation blocks from each lineThe 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: addstripParameterAttributesand apply it informatElementRELEASE_NOTES.md: add entry under### FixedTest Status
dotnet build— succeeded, 0 warnings, 0 errorsdotnet test tests/FSharp.CodeFormat.Tests— 20 passed, 0 failedTrade-offs
[<...>]blocks. It does not affect other bracket syntax (e.g. array typesint[]).>in their content (e.g.[(SomeAttr<int)>]) would not be fully stripped, but such attributes are extremely uncommon on parameters.