Skip to content

[Repo Assist] fix: show default parameter values concisely in signature help#1512

Merged
Krzysztof-Cieslak merged 3 commits intomainfrom
repo-assist/fix-issue-1310-concise-param-attrs-2026-03-24-fcef81dc83432505
Mar 24, 2026
Merged

[Repo Assist] fix: show default parameter values concisely in signature help#1512
Krzysztof-Cieslak merged 3 commits intomainfrom
repo-assist/fix-issue-1310-concise-param-attrs-2026-03-24-fcef81dc83432505

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

🤖 Repo Assist — automated AI assistant

Closes #1310

Problem

When a method has C#-style optional parameters with [(System.Runtime.InteropServices.Optional; System.Runtime.InteropServices.DefaultParameterValue(...))] attributes, the signature help parameter documentation showed the full verbose attribute syntax:

[(System.Runtime.InteropServices.Optional; System.Runtime.InteropServices.DefaultParameterValue(""))] args: string
```

## Fix

Add `TipFormatter.cleanParameterDisplay` which:
1. Detects `[<...>]` attribute blocks in the parameter display text
2. Extracts any `DefaultParameterValue(value)` argument
3. Strips the attribute block and appends the default value as `= value`

The result for the example above becomes:
```
args: string = ""

If no DefaultParameterValue is present (only [(Optional)]), the attribute block is removed cleanly.

The fix applies to TextDocumentSignatureHelp parameter documentation, which is what editors display to highlight each parameter as the user types arguments.

Changes

  • src/FsAutoComplete.Core/TipFormatter.fs — add cleanParameterDisplay : TaggedText[] -> string
  • src/FsAutoComplete.Core/TipFormatter.fsi — expose in the module signature
  • src/FsAutoComplete/LspServers/AdaptiveFSharpLspServer.fs — use cleanParameterDisplay in TextDocumentSignatureHelp

Trade-offs

The regex \[<[^\]]*>\] handles the common case of simple attribute arguments (string/number/bool literals). Pathological cases where attribute constructor arguments contain ] (extremely rare in practice for DefaultParameterValue) would not be transformed, leaving the original verbose text as a safe fallback.

Test Status

  • dotnet build src/FsAutoComplete.Core/FsAutoComplete.Core.fsproj -f net8.0Build succeeded (0 errors, 0 warnings)
  • Full solution build hit memory limits in this CI environment (infrastructure OOM, not a code issue — consistent with other recent PRs in this repo)

Generated by Repo Assist

Generated by Repo Assist ·

To install this agentic workflow, run

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

When a C#-style optional parameter is decorated with
[<Optional; DefaultParameterValue(value)>], signature help previously
showed the full verbose attribute syntax, e.g.:

  [<System.Runtime.InteropServices.Optional;
    System.Runtime.InteropServices.DefaultParameterValue("")>] args: string

Now the attribute block is stripped and the default value is shown inline:

  args: string = ""

If no DefaultParameterValue is present (only [<Optional>]), the attribute
is silently removed leaving just the clean name: type display.

Implementation: add TipFormatter.cleanParameterDisplay which uses a regex
to detect [<...>] blocks, extract any DefaultParameterValue argument, and
reconstruct the parameter string. Use it in TextDocumentSignatureHelp
parameter documentation.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@Krzysztof-Cieslak
Copy link
Copy Markdown
Member

/repo-assist add tests

@github-actions
Copy link
Copy Markdown
Contributor Author

github-actions bot commented Mar 24, 2026

Repo Assist completed successfully!

Cover the following scenarios:
- Full verbose C# interop attributes (Optional + DefaultParameterValue) with string default
- Short-form Optional+DefaultParameterValue with string default
- Numeric default value
- Boolean default value
- Optional-only (no DefaultParameterValue) — attribute stripped, no suffix
- Plain parameter with no attribute — returned unchanged
- Multiple tagged-text segments concatenated before processing

All 7 new tests pass alongside the 8 pre-existing TipFormatter tests.

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

Commit pushed: 9c262da

Generated by Repo Assist

@github-actions
Copy link
Copy Markdown
Contributor Author

🤖 Repo Assist — automated AI assistant

Added 7 unit tests for TipFormatter.cleanParameterDisplay to test/FsAutoComplete.Tests.Lsp/TipFormatterTests.fs:

Test case Input Expected output
Full verbose C# interop attributes [(System.Runtime.InteropServices.Optional; System.Runtime.InteropServices.DefaultParameterValue(""))] args: string args: string = ""
Short-form with string default [(Optional; DefaultParameterValue(""))] args: string args: string = ""
Numeric default [(Optional; DefaultParameterValue(42))] count: int count: int = 42
Boolean default [(Optional; DefaultParameterValue(false))] flag: bool flag: bool = false
Optional-only (no default) [(Optional)] args: string args: string
No attribute block args: string args: string
Multiple TaggedText segments split across 3 tokens flag: bool = true

All 15 TipFormatter tests (8 pre-existing + 7 new) pass. ✅

Generated by Repo Assist for issue #1512 ·

To install this agentic workflow, run

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

@Krzysztof-Cieslak Krzysztof-Cieslak marked this pull request as ready for review March 24, 2026 22:12
@Krzysztof-Cieslak Krzysztof-Cieslak merged commit 239ce92 into main Mar 24, 2026
25 checks passed
github-actions bot added a commit that referenced this pull request Mar 25, 2026
…#1512); update date

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.

More concise completion info with OptionalAttribute/DefaultParameterValueAttribute

1 participant