Skip to content

Commit e01e64f

Browse files
xperiandriclaude
andcommitted
Take the shared test fixture as #20462 lands it
The multi-project and multi-target helpers now match the ones #20462 adds, struct results included, so this branch rebases onto it without reconciling two copies. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 97a806f commit e01e64f

2 files changed

Lines changed: 15 additions & 9 deletions

File tree

‎vsintegration/tests/FSharp.Editor.Tests/Helpers/RoslynHelpers.fs‎

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ type TestHostServices() =
208208

209209
/// One Roslyn project instance of a multi-targeted F# project: its extra defines and the
210210
/// synthetic files left out of it, as VS does per target framework.
211+
[<Struct>]
211212
type TargetInstance =
212213
{
213214
Defines: string list
@@ -410,8 +411,8 @@ type RoslynTestHelpers private () =
410411
let projects =
411412
syntheticProject.GetAllProjects()
412413
|> Seq.distinctBy _.Name
413-
|> Seq.map (fun project -> project, ProjectId.CreateNewId())
414-
|> Seq.toList
414+
|> Seq.map (fun project -> struct (project, ProjectId.CreateNewId()))
415+
|> Seq.toArray
415416

416417
let projectIds = dict [ for project, id in projects -> project.Name, id ]
417418

@@ -441,10 +442,15 @@ type RoslynTestHelpers private () =
441442
project.GetProjectOptions checker
442443
|> RoslynTestHelpers.SetProjectOptions id solution
443444

444-
solution, checker
445+
struct (solution, checker)
445446

447+
/// <summary>
446448
/// One Roslyn project per target instance, all sharing the .fsproj path and the document file
447449
/// paths, like the per-target-framework projects VS creates for a multi-targeted project.
450+
/// </summary>
451+
/// <param name="syntheticProject">The project every instance is made from; it must not depend on other projects.</param>
452+
/// <param name="instances">One Roslyn project per entry: its extra defines and the synthetic files left out of it.</param>
453+
/// <returns>The solution and the id of each instance's project, in the order of <paramref name="instances"/>.</returns>
448454
static member CreateMultiTargetSolution(syntheticProject: SyntheticProject, instances: TargetInstance list) =
449455
assert (syntheticProject.DependsOn = [])
450456

@@ -457,13 +463,13 @@ type RoslynTestHelpers private () =
457463
for instance in instances ->
458464
let excludedPaths =
459465
HashSet(
460-
[
466+
seq {
461467
for fileId in instance.ExcludedFileIds do
462468
syntheticProject.GetFilePath fileId
463469

464470
if (syntheticProject.Find fileId).HasSignatureFile then
465471
syntheticProject.GetSignatureFilePath fileId
466-
],
472+
},
467473
StringComparer.OrdinalIgnoreCase
468474
)
469475

@@ -495,7 +501,7 @@ type RoslynTestHelpers private () =
495501
|]
496502
}
497503

498-
id, projectInfo, instanceOptions
504+
struct (id, projectInfo, instanceOptions)
499505
]
500506

501507
let solution =
@@ -504,7 +510,7 @@ type RoslynTestHelpers private () =
504510
for id, _, instanceOptions in instances do
505511
RoslynTestHelpers.SetProjectOptions id solution instanceOptions
506512

507-
solution, [ for id, _, _ in instances -> id ]
513+
struct (solution, [ for id, _, _ in instances -> id ])
508514

509515
static member GetFsDocument(code, ?customProjectOption: string, ?customEditorOptions) =
510516
let customProjectOptions =

‎vsintegration/tests/FSharp.Editor.Tests/MultiTargetFindReferencesTests.fs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ let private project =
3838
)
3939

4040
let private solution, plainId, fooId =
41-
let solution, instances =
41+
let struct (solution, instances) =
4242
RoslynTestHelpers.CreateMultiTargetSolution(
4343
project,
4444
[
@@ -174,7 +174,7 @@ let private inferredProject =
174174
)
175175

176176
let private inferredSolution, inferredPlainId =
177-
let solution, instances =
177+
let struct (solution, instances) =
178178
RoslynTestHelpers.CreateMultiTargetSolution(
179179
inferredProject,
180180
[

0 commit comments

Comments
 (0)