Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ type BraceMatchingServiceTests() =
|> Async.RunImmediateExceptOnUI
with
| None -> ()
| Some (left, right) -> failwith $"Found match for brace '{marker}'"
| Some _ -> failwith $"Found match for brace '{marker}'"

member private this.VerifyBraceMatch(fileContents: string, startMarker: string, endMarker: string, ?langVersion: string) =
let sourceText = SourceText.From(fileContents)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ module CompletionProviderTests =
let caretPosition = fileContents.IndexOf(marker) + marker.Length

let document =
RoslynTestHelpers.CreateSolution(fileContents)
RoslynTestHelpers.CreateSolution(fileContents, extraFSharpProjectOtherOptions = Array.ofSeq opts)
|> RoslynTestHelpers.GetSingleDocument

let results =
Expand Down Expand Up @@ -77,7 +77,7 @@ module CompletionProviderTests =
let caretPosition = fileContents.IndexOf(marker) + marker.Length

let document =
RoslynTestHelpers.CreateSolution(fileContents)
RoslynTestHelpers.CreateSolution(fileContents, extraFSharpProjectOtherOptions = Array.ofSeq opts)
|> RoslynTestHelpers.GetSingleDocument

let actual =
Expand Down Expand Up @@ -1990,3 +1990,20 @@ match { A = 1; B = 2 } with
"""

VerifyCompletionList(fileContents, "| { f = ()", [ "A"; "B"; "C"; "D" ], [])

[<Fact>]
let ``issue #16260 [TO-BE-IMPROVED] operators are fumbling for now`` () =
let fileContents =
"""
module Ops =
let (|>>) a b = a + b
module Foo =
let (|>>) a b = a + b
Ops.Foo.()
Ops.Foo.(
Ops.(
Ops.()
"""

VerifyCompletionList(fileContents, "Ops.Foo.(", [], [ "|>>"; "(|>>)" ])
VerifyCompletionList(fileContents, "Ops.(", [], [ "|>>"; "(|>>)" ])
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ type DocumentDiagnosticAnalyzerTests() =
let startMarker = "(*start*)"
let endMarker = "(*end*)"

let getDiagnostics (fileContents: string) =
member private _.getDiagnostics(fileContents: string, ?additionalFlags) =
let task =
cancellableTask {
let document =
RoslynTestHelpers.CreateSolution(fileContents)
RoslynTestHelpers.CreateSolution(fileContents, ?extraFSharpProjectOtherOptions = additionalFlags)
|> RoslynTestHelpers.GetSingleDocument

let! syntacticDiagnostics = FSharpDocumentDiagnosticAnalyzer.GetDiagnostics(document, DiagnosticsType.Syntax)
Expand All @@ -30,14 +30,14 @@ type DocumentDiagnosticAnalyzerTests() =
task.Result

member private this.VerifyNoErrors(fileContents: string, ?additionalFlags: string[]) =
let errors = getDiagnostics fileContents
let errors = this.getDiagnostics (fileContents, ?additionalFlags = additionalFlags)

if not errors.IsEmpty then
failwith $"There should be no errors generated: {errors}"

member private this.VerifyErrorAtMarker(fileContents: string, expectedMarker: string, ?expectedMessage: string) =
let errors =
getDiagnostics fileContents
this.getDiagnostics fileContents
|> Seq.filter (fun e -> e.Severity = DiagnosticSeverity.Error)
|> Seq.toArray

Expand Down Expand Up @@ -68,7 +68,7 @@ type DocumentDiagnosticAnalyzerTests() =
expectedSeverity: DiagnosticSeverity
) =
let errors =
getDiagnostics fileContents
this.getDiagnostics fileContents
|> Seq.filter (fun e -> e.Severity = expectedSeverity)
|> Seq.toArray

Expand Down Expand Up @@ -99,7 +99,7 @@ type DocumentDiagnosticAnalyzerTests() =
) =
// TODO: once workaround (https://github.com/dotnet/fsharp/pull/15982) will not be needed, this should be reverted back to normal method (see PR)
let errors =
getDiagnostics fileContents
this.getDiagnostics fileContents
|> Seq.filter (fun e -> e.Severity = expectedSeverity)
|> Seq.toArray

Expand Down Expand Up @@ -133,7 +133,7 @@ type DocumentDiagnosticAnalyzerTests() =
?expectedMessage: string
) =
let errors =
getDiagnostics fileContents
this.getDiagnostics fileContents
|> Seq.filter (fun e -> e.Severity = DiagnosticSeverity.Error)
|> Seq.toArray

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ let def =
)marker4
"""

let pasteTemplate =
let _pasteTemplate =
"""

let foo =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
<GenerateProgramFile>false</GenerateProgramFile>
<DisableImplicitFSharpCoreReference>true</DisableImplicitFSharpCoreReference>
<NoWarn>$(NoWarn);FS3511</NoWarn> <!-- This state machine is not statically compilable. -->
<OtherFlags>$(OtherFlags) --warnon:1182</OtherFlags>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ type TestHostWorkspaceServices(hostServices: HostServices, workspace: Workspace)
with _ ->
Unchecked.defaultof<'T>

override _.FindLanguageServices(filter) = Seq.empty
override _.FindLanguageServices(_filter) = Seq.empty

override _.GetLanguageServices(languageName) =
match languageName with
Expand Down Expand Up @@ -275,7 +275,7 @@ type RoslynTestHelpers private () =
static member SetEditorOptions (solution: Solution) options =
solution.Workspace.Services.GetService<EditorOptions>().With(options)

static member CreateSolution(source, ?options: FSharpProjectOptions, ?editorOptions) =
static member CreateSolution(source, ?options: FSharpProjectOptions, ?extraFSharpProjectOtherOptions: string array, ?editorOptions) =
let projId = ProjectId.CreateNewId()

let docInfo = RoslynTestHelpers.CreateDocumentInfo projId "C:\\test.fs" source
Expand All @@ -284,9 +284,18 @@ type RoslynTestHelpers private () =
let projInfo = RoslynTestHelpers.CreateProjectInfo projId projFilePath [ docInfo ]
let solution = RoslynTestHelpers.CreateSolution [ projInfo ]

options
|> Option.defaultValue RoslynTestHelpers.DefaultProjectOptions
|> RoslynTestHelpers.SetProjectOptions projId solution
let options =
let options = options |> Option.defaultValue RoslynTestHelpers.DefaultProjectOptions

match extraFSharpProjectOtherOptions with
| None
| Some [||] -> options
| Some otherOptions ->
{ options with
OtherOptions = Array.concat [| options.OtherOptions; otherOptions |]
}

options |> RoslynTestHelpers.SetProjectOptions projId solution

if editorOptions.IsSome then
RoslynTestHelpers.SetEditorOptions solution editorOptions.Value
Expand Down Expand Up @@ -352,9 +361,7 @@ type RoslynTestHelpers private () =
}

let solution =
match customEditorOptions with
| Some o -> RoslynTestHelpers.CreateSolution(code, options, o)
| None -> RoslynTestHelpers.CreateSolution(code, options)
RoslynTestHelpers.CreateSolution(code, options, ?editorOptions = customEditorOptions)

solution |> RoslynTestHelpers.GetSingleDocument

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ module QuickInfoProviderTests =
| QuickInfo _ -> QuickInfo(desc, docs)
| _ -> Desc desc

| ToolTipElement.CompositionError (error) -> Error
| ToolTipElement.CompositionError _ -> Error

let executeQuickInfoTest (programText: string) testCases =
let document =
Expand Down