Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
eca584a
Add a refactoring between reference and struct tuples
xperiandri Sep 14, 2026
c4880aa
Build the two-file refactoring test project as a synthetic project
xperiandri Sep 14, 2026
c80c1e5
Check the two-file tuple result as a new project
xperiandri Sep 14, 2026
a751847
Leave a method's parameter list alone and convert curried tuple argum…
xperiandri Sep 14, 2026
f470248
Link the release note to the pull request and move it to a random lin…
xperiandri Sep 14, 2026
89ac5ae
Tell argument lists by the called symbol and follow values through tr…
xperiandri Sep 29, 2026
9620d95
Follow tuples through lambdas, function aliases, named arguments and …
xperiandri Oct 11, 2026
8c36108
Compact the tuple refactoring sources
xperiandri Oct 15, 2026
7c9a82d
Share the cross-file refactoring test setup
xperiandri Oct 15, 2026
5260227
Bring the rebased branch to what it had before the rebase
xperiandri Oct 29, 2026
b77aaa7
Convert both sides of an as pattern with the tuple it takes apart
xperiandri Nov 8, 2026
4d1d452
Withhold the tuple conversion when the value passes a tuple abbreviation
xperiandri Nov 8, 2026
2fef53c
Add a refactoring between reference and struct anonymous records
xperiandri Sep 14, 2026
4cff45e
Cover as patterns and abbreviations in the anonymous record conversion
xperiandri Nov 8, 2026
ec9448b
Stop at a generic parameter reached through a function alias
xperiandri Nov 8, 2026
7ea81c9
Follow the value assigned to a mutable through the assignment
xperiandri Nov 8, 2026
28164d9
Cover a multiline tuple reached from a parameter annotation
xperiandri Nov 8, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/release-notes/.VisualStudio/18.vNext.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

* Suggest active-pattern cases from unopened modules and offer valid Add Open and qualification edits. ([PR #20719](https://github.com/dotnet/fsharp/pull/20719))
* Add maintainer-requested F# Apex Visual Studio integration tests on DartLab-1ES CloudTest, using PR pipeline definitions pinned to an explicitly requested commit SHA. ([PR #20625](https://github.com/dotnet/fsharp/pull/20625))
* Refactoring to convert an anonymous record between `{| … |}` and `struct {| … |}`, following its value through the solution the same way. A copy-and-update `{| r with … |}` has its own form and converts independently of `r`. ([PR #20549](https://github.com/dotnet/fsharp/pull/20549))
* Code-fixes for FS3888 (compiler-semantic attribute on the `.fs` but not the `.fsi`): copy the attribute into the `.fsi`, or remove it from the `.fs`. ([Issue #19560](https://github.com/dotnet/fsharp/issues/19560), [PR #19880](https://github.com/dotnet/fsharp/pull/19880))
* Refactoring to convert a tuple between a reference tuple and a struct tuple, following its value through the solution: annotations of values, parameters, record fields and results it flows through, tuple patterns that take it apart, and the arguments and values that flow into it. What cannot be followed (`fst`, `snd`, generic collections) is left for the compiler to report. ([PR #20548](https://github.com/dotnet/fsharp/pull/20548))
* Expand `<inheritdoc/>` in IDE tooltips, completion, and signature help, inheriting XML documentation from base classes, interfaces, overridden members, and constructors. ([Issue #19175](https://github.com/dotnet/fsharp/issues/19175), [PR #19188](https://github.com/dotnet/fsharp/pull/19188))
* Move F# editor and Interactive options to 43 native Unified Settings with independent roaming and a one-time import of existing settings. Preserve the legacy groupings and Interactive setting order, with restart requirements displayed by Unified Settings. Quick Info's preferred description width is a checkbox with a dependent integer control. Remove the eight legacy options pages; the user-wide compiler setting remains external. Typing and deletion completion triggers are independent. ([PR #20877](https://github.com/dotnet/fsharp/pull/20877))
* Added a **Compiler** option in F# Unified Settings, **"Use the .NET SDK F# compiler for builds"**, on by default. Visual Studio uses the .NET SDK F# compiler when the project supplies SDK paths, matching `dotnet build`. Otherwise, it uses the bundled .NET Framework compiler. Turn the option off to use the bundled compiler for all projects. Command-line builds are unaffected. ([Issue #20484](https://github.com/dotnet/fsharp/issues/20484), [PR #20485](https://github.com/dotnet/fsharp/pull/20485))
Expand Down
6 changes: 6 additions & 0 deletions vsintegration/src/FSharp.Editor/FSharp.Editor.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,12 @@
<Compile Include="Refactor\ChangeTypeofWithNameToNameofExpression.fs" />
<Compile Include="Refactor\AddExplicitTypeToParameter.fs" />
<Compile Include="Refactor\ChangeDerefToValueRefactoring.fs" />
<Compile Include="Refactor\StructConversion.fs" />
<Compile Include="Refactor\TupleConversion.fs" />
<Compile Include="Refactor\AnonymousRecordConversion.fs" />
<Compile Include="Refactor\StructPropagation.fs" />
<Compile Include="Refactor\ConvertTuple.fs" />
<Compile Include="Refactor\ConvertAnonymousRecord.fs" />
<Compile Include="CodeFixes\IFSharpCodeFix.fs" />
<Compile Include="CodeFixes\CodeFixHelpers.fs" />
<Compile Include="CodeFixes\ChangeEqualsInFieldTypeToColon.fs" />
Expand Down
12 changes: 12 additions & 0 deletions vsintegration/src/FSharp.Editor/FSharp.Editor.resx
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,18 @@
{2}</value>
<comment>Tooltip of an F# declaration in the Copilot Chat "#" picker, as Copilot shows a C# one. {0} is the kind of declaration (Class, Method, Field...), {1} the file name, {2} the declaration's name.</comment>
</data>
<data name="ConvertToStructTuple" xml:space="preserve">
<value>Convert to struct tuple</value>
</data>
<data name="ConvertToReferenceTuple" xml:space="preserve">
<value>Convert to reference tuple</value>
</data>
<data name="ConvertToStructAnonymousRecord" xml:space="preserve">
<value>Convert to struct anonymous record</value>
</data>
<data name="ConvertToReferenceAnonymousRecord" xml:space="preserve">
<value>Convert to reference anonymous record</value>
</data>
<data name="UnifiedSettingsIntelliSenseTitle" xml:space="preserve">
<value>IntelliSense</value>
</data>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.

module internal Microsoft.VisualStudio.FSharp.Editor.AnonymousRecordConversion

open Microsoft.CodeAnalysis.Text

open FSharp.Compiler.Syntax
open FSharp.Compiler.Text

open StructConversion

let private keywordChanges (sourceText: SourceText) (toStruct: bool) (isStruct: bool) (m: range) =
match isStruct, toStruct with
| true, true
| false, false -> []
| false, true ->
let start = (spanOf sourceText m).Start
[ TextChange(TextSpan(start, 0), structAt sourceText start) ]
| true, false -> [ TextChange(structKeyword sourceText m, "") ]

let kind: StructKind =
{
IsExpr =
fun _ expr _ ->
match expr with
| SynExpr.AnonRecd _ -> true
| _ -> false
IsPat = fun _ _ -> false
IsParameterList = fun _ _ -> false
IsType =
function
| SynType.AnonRecd _ -> true
| _ -> false
IsStruct =
function
| CaretNode.Expr(node = SynExpr.AnonRecd(isStruct = isStruct))
| CaretNode.Type(node = SynType.AnonRecd(isStruct = isStruct)) -> isStruct
| _ -> false
ExprChanges =
fun sourceText toStruct expr _ ->
match expr with
| SynExpr.AnonRecd(isStruct = isStruct; range = m) -> ValueSome(keywordChanges sourceText toStruct isStruct m)
| _ -> ValueNone
PatChanges = fun _ _ _ _ -> ValueNone
TypeChanges =
fun sourceText toStruct _ ty ->
match ty with
| SynType.AnonRecd(isStruct = isStruct; range = m) -> keywordChanges sourceText toStruct isStruct m
| _ -> []
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.

namespace Microsoft.VisualStudio.FSharp.Editor

open System.Composition

open Microsoft.CodeAnalysis.CodeRefactorings

open CancellableTasks

[<ExportCodeRefactoringProvider(FSharpConstants.FSharpLanguageName, Name = "ConvertAnonymousRecord"); Shared>]
type internal FSharpConvertAnonymousRecordRefactoring [<ImportingConstructor>] () =
inherit CodeRefactoringProvider()

override _.ComputeRefactoringsAsync context =
StructPropagation.registerConversion
context
AnonymousRecordConversion.kind
SR.ConvertToStructAnonymousRecord
SR.ConvertToReferenceAnonymousRecord
(nameof FSharpConvertAnonymousRecordRefactoring)
|> CancellableTask.startAsTask context.CancellationToken
22 changes: 22 additions & 0 deletions vsintegration/src/FSharp.Editor/Refactor/ConvertTuple.fs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.

namespace Microsoft.VisualStudio.FSharp.Editor

open System.Composition

open Microsoft.CodeAnalysis.CodeRefactorings

open CancellableTasks

[<ExportCodeRefactoringProvider(FSharpConstants.FSharpLanguageName, Name = "ConvertTuple"); Shared>]
type internal FSharpConvertTupleRefactoring [<ImportingConstructor>] () =
inherit CodeRefactoringProvider()

override _.ComputeRefactoringsAsync context =
StructPropagation.registerConversion
context
TupleConversion.kind
SR.ConvertToStructTuple
SR.ConvertToReferenceTuple
(nameof FSharpConvertTupleRefactoring)
|> CancellableTask.startAsTask context.CancellationToken
Loading
Loading