Add a refactoring between F# and .NET-compatible optional parameters - #20547
Open
xperiandri wants to merge 4 commits into
Open
xperiandri wants to merge 4 commits into
xperiandri wants to merge 4 commits into
Conversation
…meters ?x: T is optional for F# callers and gives the body an option; [<Optional; DefaultParameterValue(c)>] x: T is optional for C# and VB callers too and gives the body the value. The refactoring moves the default between defaultArg x c in the body and the attribute, adds the InteropServices open when it is missing, and leaves call sites alone: F# accepts both forms the same way. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Contributor
❗ Release notes requiredYou can open this PR in browser to add release notes: open in github.dev
|
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…form [<Optional; DefaultParameterValue(c)>] x: T now converts back to either ?x: T with let x = defaultArg x c, or, from F# 10, [<Struct>] ?x: T with let x = defaultValueArg x c. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…e of its section Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
xperiandri
marked this pull request as ready for review
September 14, 2026 19:40
Contributor
|
🔍 Tooling Safety Check — Affects-Design-Time
|
Contributor
Author
Covered casesConverts
Not offered
|
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.
Offers
Ctrl+.to switch between?x: TwithdefaultArg x cin the body and[<Optional; DefaultParameterValue(c)>] x: T, which C# and VB callers can omit too. Converting back offers?xwithdefaultArgand, from F# 10,[<Struct>] ?xwithdefaultValueArg. F# call sites compile against both forms, so only the member is edited.Not offered unless every use is
defaultArg x cwith one constant of the parameter's type, or for overrides, abstract slots, constructors, or a file with a paired.fsi.🤖 Generated with Claude Code