diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml
index 2442a0e8910..beaf438ff25 100644
--- a/eng/Version.Details.xml
+++ b/eng/Version.Details.xml
@@ -3,9 +3,9 @@
-
+
https://github.com/dotnet/arcade
- 298c72b33f6f7b742b11f7b1c0ae77a043789fcf
+ ee0a6a7d9acc6f5886ae214b935f3e3d989235e4
diff --git a/eng/common/templates/post-build/post-build.yml b/eng/common/templates/post-build/post-build.yml
index bd776c7675b..375e91acdf3 100644
--- a/eng/common/templates/post-build/post-build.yml
+++ b/eng/common/templates/post-build/post-build.yml
@@ -147,6 +147,9 @@ stages:
pipeline: $(AzDOPipelineId)
buildId: $(AzDOBuildId)
artifactName: PackageArtifacts
+ itemPattern: |
+ **
+ !**/Microsoft.SourceBuild.Intermediate.*.nupkg
# This is necessary whenever we want to publish/restore to an AzDO private feed
# Since sdk-task.ps1 tries to restore packages we need to do this authentication here
diff --git a/global.json b/global.json
index 9c1a1af8218..f6d7cd11c3e 100644
--- a/global.json
+++ b/global.json
@@ -13,7 +13,7 @@
}
},
"msbuild-sdks": {
- "Microsoft.DotNet.Arcade.Sdk": "6.0.0-beta.21068.2",
+ "Microsoft.DotNet.Arcade.Sdk": "6.0.0-beta.21069.2",
"Microsoft.DotNet.Helix.Sdk": "2.0.0-beta.19069.2"
}
}
diff --git a/vsintegration/tests/UnitTests/SignatureHelpProviderTests.fs b/vsintegration/tests/UnitTests/SignatureHelpProviderTests.fs
index 928ccea9b4b..8daf94328e7 100644
--- a/vsintegration/tests/UnitTests/SignatureHelpProviderTests.fs
+++ b/vsintegration/tests/UnitTests/SignatureHelpProviderTests.fs
@@ -1,38 +1,15 @@
-// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.
-//
-// To run the tests in this file:
-//
-// Technique 1: Compile VisualFSharp.UnitTests.dll and run it as a set of unit tests
-//
-// Technique 2:
-//
-// Enable some tests in the #if EXE section at the end of the file,
-// then compile this file as an EXE that has InternalsVisibleTo access into the
-// appropriate DLLs. This can be the quickest way to get turnaround on updating the tests
-// and capturing large amounts of structured output.
-(*
- cd Debug\net40\bin
- .\fsc.exe --define:EXE -r:.\Microsoft.Build.Utilities.Core.dll -o VisualFSharp.UnitTests.exe -g --optimize- -r .\FSharp.Compiler.Service.dll -r .\FSharp.Editor.dll -r nunit.framework.dll ..\..\..\tests\service\FsUnit.fs ..\..\..\tests\service\Common.fs /delaysign /keyfile:..\..\..\src\fsharp\msft.pubkey ..\..\..\vsintegration\tests\UnitTests\SignatureHelpProviderTests.fs
- .\VisualFSharp.UnitTests.exe
-*)
-// Technique 3:
-//
-// Use F# Interactive. This only works for FSharp.Compiler.Service.dll which has a public API
[]
module Microsoft.VisualStudio.FSharp.Editor.Tests.Roslyn.SignatureHelpProvider
open System
open System.IO
-open System.Text
open NUnit.Framework
-open Microsoft.CodeAnalysis.Text
+open Microsoft.VisualStudio.FSharp.Editor
open VisualFSharp.UnitTests.Roslyn
-open Microsoft.VisualStudio.FSharp.Editor
-
open UnitTests.TestLib.LanguageService
open FSharp.Compiler.Text
@@ -120,158 +97,16 @@ let GetCompletionTypeNamesFromXmlString (xml:string) =
use project = CreateProject xml
GetCompletionTypeNamesFromCursorPosition project
-[]
-let ShouldGiveSignatureHelpAtCorrectMarkers() =
- let manyTestCases =
- [ ("""
-//1
-System.Console.WriteLine(format="Hello, {0}",arg0="World")
-""",
- [(".", None);
- ("System", None);
- ("WriteLine", None);
- ("(", Some ("[7..64)", 0, 2, Some "format"));
- ("format", Some ("[7..64)", 0, 2, Some "format"));
- (",", None);
- ("""",""", Some ("[7..64)", 1, 2, Some "arg0"));
- ("arg0", Some ("[7..64)", 1, 2, Some "arg0"));
- ("arg0=", Some ("[7..64)", 1, 2, Some "arg0"));
- ("World", Some ("[7..64)", 1, 2, Some "arg0"));
- (")", Some("[7..64)", 0, 2, Some "format"))]);
- ( """
-//2
-open System
-Console.WriteLine([(1,2)])
-""",
- [
- ("WriteLine(", Some ("[20..45)", 0, 0, None));
- (",", None);
- ("[(", Some ("[20..45)", 0, 1, None))
- ]);
- ( """
-//3
-type foo = N1.T<
-type foo2 = N1.T
-type foo2 = N1.T
-type foo3 = N1.T
-type foo4 = N1.T
-type foo5 = N1.T
-""",
- [("type foo = N1.T<", Some ("[18..24)", 0, 0, None));
- ("type foo2 = N1.T<", Some ("[40..53)", 0, 0, Some "Param1"));
- ("type foo2 = N1.T Async.RunSynchronously
-
- if x.IsNone then
- Assert.Fail("Could not parse and check document.")
- x.Value
-
- let actual =
- let paramInfoLocations = parseResults.FindNoteworthyParamInfoLocations(Pos.fromZ caretLinePos.Line caretLineColumn)
- match paramInfoLocations with
- | None -> None
- | Some paramInfoLocations ->
- let triggered =
- FSharpSignatureHelpProvider.ProvideMethodsAsyncAux(
- caretLinePos,
- caretLineColumn,
- paramInfoLocations,
- checkFileResults,
- DefaultDocumentationProvider,
- sourceText,
- caretPosition,
- triggerChar)
- |> Async.RunSynchronously
-
- checker.ClearLanguageServiceRootCachesAndCollectAndFinalizeAllTransients()
- match triggered with
- | None -> None
- | Some data -> Some (data.ApplicableSpan.ToString(),data.ArgumentIndex,data.ArgumentCount,data.ArgumentName)
-
- if expected <> actual then
- sb.AppendLine(sprintf "FSharpCompletionProvider.ProvideMethodsAsyncAux() gave unexpected results, expected %A, got %A" expected actual) |> ignore
- yield (marker, actual) ]
-
- printfn "(\"\"\"%s\n\"\"\",\n%s)" fileContents ((sprintf "%A" actual).Replace("null","None"))
-
-
- match sb.ToString() with
- | "" -> ()
- | errorText -> Assert.Fail errorText
-
-[]
-let ``single argument function application``() =
- let fileContents = """
-sqrt
-"""
- let marker = "sqrt "
+let assertSignatureHelpForMethodCalls (fileContents: string) (marker: string) (expected: (string * int * int * string option) option) =
let caretPosition = fileContents.IndexOf(marker) + marker.Length
+ let triggerChar = if marker ="," then Some ',' elif marker = "(" then Some '(' elif marker = "<" then Some '<' else None
let sourceText = SourceText.From(fileContents)
+ let textLines = sourceText.Lines
+ let caretLinePos = textLines.GetLinePosition(caretPosition)
+ let caretLineColumn = caretLinePos.Character
let perfOptions = LanguageServicePerformanceOptions.Default
let textVersionHash = 0
- let documentId = DocumentId.CreateNewId(ProjectId.CreateNewId())
-
+
let parseResults, _, checkFileResults =
let x =
checker.ParseAndCheckDocument(filePath, textVersionHash, sourceText, projectOptions, perfOptions, "TestSignatureHelpProvider")
@@ -281,50 +116,32 @@ sqrt
Assert.Fail("Could not parse and check document.")
x.Value
-
- let adjustedColumnInSource =
- let rec loop s c =
- if String.IsNullOrWhiteSpace(s.ToString()) then
- loop (sourceText.GetSubText(c - 1)) (c - 1)
- else
- c
- let startText =
- if caretPosition = sourceText.Length then
- sourceText.GetSubText(caretPosition)
- else
- sourceText.GetSubText(TextSpan(caretPosition, 1))
-
- loop startText caretPosition
-
- let sigHelp =
- FSharpSignatureHelpProvider.ProvideParametersAsyncAux(
- parseResults,
- checkFileResults,
- documentId,
- [],
- DefaultDocumentationProvider,
- sourceText,
- caretPosition,
- adjustedColumnInSource,
- filePath)
- |> Async.RunSynchronously
-
- checker.ClearLanguageServiceRootCachesAndCollectAndFinalizeAllTransients()
+ let actual =
+ let paramInfoLocations = parseResults.FindNoteworthyParamInfoLocations(Pos.fromZ caretLinePos.Line caretLineColumn)
+ match paramInfoLocations with
+ | None -> None
+ | Some paramInfoLocations ->
+ let triggered =
+ FSharpSignatureHelpProvider.ProvideMethodsAsyncAux(
+ caretLinePos,
+ caretLineColumn,
+ paramInfoLocations,
+ checkFileResults,
+ DefaultDocumentationProvider,
+ sourceText,
+ caretPosition,
+ triggerChar)
+ |> Async.RunSynchronously
+
+ checker.ClearLanguageServiceRootCachesAndCollectAndFinalizeAllTransients()
+ match triggered with
+ | None -> None
+ | Some data -> Some (data.ApplicableSpan.ToString(),data.ArgumentIndex,data.ArgumentCount,data.ArgumentName)
- match sigHelp with
- | None -> Assert.Fail("Expected signature help")
- | Some sigHelp ->
- Assert.AreEqual(1, sigHelp.ArgumentCount)
- Assert.AreEqual(0, sigHelp.ArgumentIndex)
+ Assert.AreEqual(expected, actual)
-[]
-let ``multi-argument function application``() =
- let fileContents = """
-let add2 x y = x + y
-add2 1
-"""
- let marker = "add2 1 "
- let caretPosition = fileContents.IndexOf(marker) + marker.Length
+let assertSignatureHelpForFunctionApplication (fileContents: string) (marker: string) expectedArgumentCount expectedArgumentIndex =
+ let caretPosition = fileContents.LastIndexOf(marker) + marker.Length
let sourceText = SourceText.From(fileContents)
let perfOptions = LanguageServicePerformanceOptions.Default
let textVersionHash = 0
@@ -340,18 +157,12 @@ add2 1
x.Value
let adjustedColumnInSource =
- let rec loop s c =
- if String.IsNullOrWhiteSpace(s.ToString()) then
- loop (sourceText.GetSubText(c - 1)) (c - 1)
+ let rec loop ch pos =
+ if Char.IsWhiteSpace(ch) then
+ loop sourceText.[pos - 1] (pos - 1)
else
- c
- let startText =
- if caretPosition = sourceText.Length then
- sourceText.GetSubText(caretPosition)
- else
- sourceText.GetSubText(TextSpan(caretPosition, 1))
-
- loop startText caretPosition
+ pos
+ loop sourceText.[caretPosition - 1] (caretPosition - 1)
let sigHelp =
FSharpSignatureHelpProvider.ProvideParametersAsyncAux(
@@ -371,289 +182,319 @@ add2 1
match sigHelp with
| None -> Assert.Fail("Expected signature help")
| Some sigHelp ->
- Assert.AreEqual(2, sigHelp.ArgumentCount)
- Assert.AreEqual(1, sigHelp.ArgumentIndex)
-
-[]
-let ``qualified function application``() =
- let fileContents = """
-module M =
- let f x = x
-M.f
-"""
- let marker = "M.f "
- let caretPosition = fileContents.IndexOf(marker) + marker.Length
- let sourceText = SourceText.From(fileContents)
- let perfOptions = LanguageServicePerformanceOptions.Default
- let textVersionHash = 0
- let documentId = DocumentId.CreateNewId(ProjectId.CreateNewId())
-
- let parseResults, _, checkFileResults =
- let x =
- checker.ParseAndCheckDocument(filePath, textVersionHash, sourceText, projectOptions, perfOptions, "TestSignatureHelpProvider")
- |> Async.RunSynchronously
+ Assert.AreEqual(expectedArgumentCount, sigHelp.ArgumentCount)
+ Assert.AreEqual(expectedArgumentIndex, sigHelp.ArgumentIndex)
- if x.IsNone then
- Assert.Fail("Could not parse and check document.")
- x.Value
+[]
+module ``Gives signature help in method calls`` =
- let adjustedColumnInSource =
- let rec loop s c =
- if String.IsNullOrWhiteSpace(s.ToString()) then
- loop (sourceText.GetSubText(c - 1)) (c - 1)
- else
- c
- let startText =
- if caretPosition = sourceText.Length then
- sourceText.GetSubText(caretPosition)
- else
- sourceText.GetSubText(TextSpan(caretPosition, 1))
-
- loop startText caretPosition
+ []
+ let ``dot``() =
+ let fileContents = """
+//1
+System.Console.WriteLine(format="Hello, {0}",arg0="World")
+"""
+ let marker = "."
+ assertSignatureHelpForMethodCalls fileContents marker None
- let sigHelp =
- FSharpSignatureHelpProvider.ProvideParametersAsyncAux(
- parseResults,
- checkFileResults,
- documentId,
- [],
- DefaultDocumentationProvider,
- sourceText,
- caretPosition,
- adjustedColumnInSource,
- filePath)
- |> Async.RunSynchronously
+ []
+ let ``System``() =
+ let fileContents = """
+//1
+System.Console.WriteLine(format="Hello, {0}",arg0="World")
+"""
+ let marker = "System"
+ assertSignatureHelpForMethodCalls fileContents marker None
- checker.ClearLanguageServiceRootCachesAndCollectAndFinalizeAllTransients()
+ []
+ let ``WriteLine``() =
+ let fileContents = """
+//1
+System.Console.WriteLine(format="Hello, {0}",arg0="World")
+"""
+ let marker = "WriteLine"
+ assertSignatureHelpForMethodCalls fileContents marker None
- match sigHelp with
- | None -> Assert.Fail("Expected signature help")
- | Some sigHelp ->
- Assert.AreEqual(1, sigHelp.ArgumentCount)
- Assert.AreEqual(0, sigHelp.ArgumentIndex)
+ []
+ let ``open paren``() =
+ let fileContents = """
+//1
+System.Console.WriteLine(format="Hello, {0}",arg0="World")
+"""
+ let marker = "("
+ assertSignatureHelpForMethodCalls fileContents marker (Some ("[7..64)", 0, 2, Some "format"))
-[]
-let ``function application in single pipeline with no additional args``() =
- let fileContents = """
-[1..10] |> id
+ []
+ let ``named arg``() =
+ let fileContents = """
+//1
+System.Console.WriteLine(format="Hello, {0}",arg0="World")
"""
- let marker = "id "
- let caretPosition = fileContents.IndexOf(marker) + marker.Length
- let sourceText = SourceText.From(fileContents)
- let perfOptions = LanguageServicePerformanceOptions.Default
- let textVersionHash = 0
- let documentId = DocumentId.CreateNewId(ProjectId.CreateNewId())
-
- let parseResults, _, checkFileResults =
- let x =
- checker.ParseAndCheckDocument(filePath, textVersionHash, sourceText, projectOptions, perfOptions, "TestSignatureHelpProvider")
- |> Async.RunSynchronously
+ let marker = "format"
+ assertSignatureHelpForMethodCalls fileContents marker (Some ("[7..64)", 0, 2, Some "format"))
- if x.IsNone then
- Assert.Fail("Could not parse and check document.")
- x.Value
-
- let adjustedColumnInSource =
- let rec loop s c =
- if String.IsNullOrWhiteSpace(s.ToString()) then
- loop (sourceText.GetSubText(c - 1)) (c - 1)
- else
- c
- let startText =
- if caretPosition = sourceText.Length then
- sourceText.GetSubText(caretPosition)
- else
- sourceText.GetSubText(TextSpan(caretPosition, 1))
-
- loop startText caretPosition
+ []
+ let ``comma``() =
+ let fileContents = """
+//1
+System.Console.WriteLine(format="Hello, {0}",arg0="World")
+"""
+ let marker = ","
+ assertSignatureHelpForMethodCalls fileContents marker None
- let sigHelp =
- FSharpSignatureHelpProvider.ProvideParametersAsyncAux(
- parseResults,
- checkFileResults,
- documentId,
- [],
- DefaultDocumentationProvider,
- sourceText,
- caretPosition,
- adjustedColumnInSource,
- filePath)
- |> Async.RunSynchronously
+ []
+ let ``second comma``() =
+ let fileContents = """
+//1
+System.Console.WriteLine(format="Hello, {0}",arg0="World")
+"""
+ assertSignatureHelpForMethodCalls fileContents """",""" (Some ("[7..64)", 1, 2, Some "arg0"))
- checker.ClearLanguageServiceRootCachesAndCollectAndFinalizeAllTransients()
+ []
+ let ``second named arg``() =
+ let fileContents = """
+//1
+System.Console.WriteLine(format="Hello, {0}",arg0="World")
+"""
+ let marker = "arg0"
+ assertSignatureHelpForMethodCalls fileContents marker (Some ("[7..64)", 1, 2, Some "arg0"))
- Assert.True(sigHelp.IsNone, "No signature help is expected because there are no additional args to apply.")
+ []
+ let ``second named arg equals``() =
+ let fileContents = """
+//1
+System.Console.WriteLine(format="Hello, {0}",arg0="World")
+"""
+ let marker = "arg0="
+ assertSignatureHelpForMethodCalls fileContents marker (Some ("[7..64)", 1, 2, Some "arg0"))
-[]
-let ``function application in single pipeline with an additional argument``() =
- let fileContents = """
-[1..10] |> List.map
+ []
+ let ``World``() =
+ let fileContents = """
+//1
+System.Console.WriteLine(format="Hello, {0}",arg0="World")
"""
- let marker = "List.map "
- let caretPosition = fileContents.IndexOf(marker) + marker.Length
- let sourceText = SourceText.From(fileContents)
- let perfOptions = LanguageServicePerformanceOptions.Default
- let textVersionHash = 0
- let documentId = DocumentId.CreateNewId(ProjectId.CreateNewId())
-
- let parseResults, _, checkFileResults =
- let x =
- checker.ParseAndCheckDocument(filePath, textVersionHash, sourceText, projectOptions, perfOptions, "TestSignatureHelpProvider")
- |> Async.RunSynchronously
+ let marker = "World"
+ assertSignatureHelpForMethodCalls fileContents marker (Some ("[7..64)", 1, 2, Some "arg0"))
- if x.IsNone then
- Assert.Fail("Could not parse and check document.")
- x.Value
-
- let adjustedColumnInSource =
- let rec loop s c =
- if String.IsNullOrWhiteSpace(s.ToString()) then
- loop (sourceText.GetSubText(c - 1)) (c - 1)
- else
- c
- let startText =
- if caretPosition = sourceText.Length then
- sourceText.GetSubText(caretPosition)
- else
- sourceText.GetSubText(TextSpan(caretPosition, 1))
-
- loop startText caretPosition
+ []
+ let ``end paren``() =
+ let fileContents = """
+//1
+System.Console.WriteLine(format="Hello, {0}",arg0="World")
+ """
+ let marker = ")"
+ assertSignatureHelpForMethodCalls fileContents marker (Some("[7..64)", 0, 2, Some "format"))
+
+[]
+module ``Signature help with list literals, parens, etc`` =
+ []
+ let ``Open paren``() =
+ let fileContents = """
+//2
+open System
+Console.WriteLine([(1,2)])
+"""
+ let marker = "WriteLine("
+ assertSignatureHelpForMethodCalls fileContents marker (Some ("[20..45)", 0, 0, None))
- let sigHelp =
- FSharpSignatureHelpProvider.ProvideParametersAsyncAux(
- parseResults,
- checkFileResults,
- documentId,
- [],
- DefaultDocumentationProvider,
- sourceText,
- caretPosition,
- adjustedColumnInSource,
- filePath)
- |> Async.RunSynchronously
+ []
+ let ``comma``() =
+ let fileContents = """
+//2
+open System
+Console.WriteLine([(1,2)])
+"""
+ let marker = ","
+ assertSignatureHelpForMethodCalls fileContents marker None
- checker.ClearLanguageServiceRootCachesAndCollectAndFinalizeAllTransients()
+ []
+ let ``list and tuple bracket pair start``() =
+ let fileContents = """
+//2
+open System
+Console.WriteLine([(1,2)])
+"""
+ let marker = "[("
+ assertSignatureHelpForMethodCalls fileContents marker (Some ("[20..45)", 0, 1, None))
+
+[]
+module ``Unfinished parentheses`` =
+ []
+ let ``Unfinished parentheses``() =
+ let fileContents = """
+let _ = System.DateTime(
+"""
+ let marker = "let _ = System.DateTime("
+ assertSignatureHelpForMethodCalls fileContents marker (Some ("[10..26)", 0, 0, None))
- match sigHelp with
- | None -> Assert.Fail("Expected signature help")
- | Some sigHelp ->
- Assert.AreEqual(1, sigHelp.ArgumentCount)
- Assert.AreEqual(0, sigHelp.ArgumentIndex)
+ []
+ let ``Unfinished parentheses with comma``() =
+ let fileContents = """
+let _ = System.DateTime(1L,
+"""
+ let marker = "let _ = System.DateTime(1L,"
+ assertSignatureHelpForMethodCalls fileContents marker (Some ("[10..31)", 1, 2, None ))
[]
-let ``function application in middle of pipeline with an additional argument``() =
- let fileContents = """
-[1..10]
-|> List.map
-|> List.filer (fun x -> x > 3)
-"""
- let marker = "List.map "
- let caretPosition = fileContents.IndexOf(marker) + marker.Length
- let sourceText = SourceText.From(fileContents)
- let perfOptions = LanguageServicePerformanceOptions.Default
- let textVersionHash = 0
- let documentId = DocumentId.CreateNewId(ProjectId.CreateNewId())
-
- let parseResults, _, checkFileResults =
- let x =
- checker.ParseAndCheckDocument(filePath, textVersionHash, sourceText, projectOptions, perfOptions, "TestSignatureHelpProvider")
- |> Async.RunSynchronously
+let ``type provider static parameter tests``() =
+ // This is old code and I'm too lazy to move it all out. - Phillip Carter
+ let manyTestCases =
+ [
+ ( """
+//3
+type foo = N1.T<
+type foo2 = N1.T
+type foo2 = N1.T
+type foo3 = N1.T
+type foo4 = N1.T
+type foo5 = N1.T
+""",
+ [("type foo = N1.T<", Some ("[18..24)", 0, 0, None));
+ ("type foo2 = N1.T<", Some ("[40..53)", 0, 0, Some "Param1"));
+ ("type foo2 = N1.T]
+module ``Function argument applications`` =
+ []
+ let ``single argument function application``() =
+ let fileContents = """
+sqrt
+ """
+ let marker = "sqrt "
+ assertSignatureHelpForFunctionApplication fileContents marker 1 0
- let sigHelp =
- FSharpSignatureHelpProvider.ProvideParametersAsyncAux(
- parseResults,
- checkFileResults,
- documentId,
- [],
- DefaultDocumentationProvider,
- sourceText,
- caretPosition,
- adjustedColumnInSource,
- filePath)
- |> Async.RunSynchronously
+ []
+ let ``multi-argument function application``() =
+ let fileContents = """
+let add2 x y = x + y
+add2 1
+ """
+ let marker = "add2 1 "
+ assertSignatureHelpForFunctionApplication fileContents marker 2 1
- checker.ClearLanguageServiceRootCachesAndCollectAndFinalizeAllTransients()
+ []
+ let ``qualified function application``() =
+ let fileContents = """
+module M =
+ let f x = x
+M.f
+ """
+ let marker = "M.f "
+ assertSignatureHelpForFunctionApplication fileContents marker 1 0
- match sigHelp with
- | None -> Assert.Fail("Expected signature help")
- | Some sigHelp ->
- Assert.AreEqual(1, sigHelp.ArgumentCount)
- Assert.AreEqual(0, sigHelp.ArgumentIndex)
+ []
+ let ``function application in single pipeline with no additional args``() =
+ let fileContents = """
+[1..10] |> id
+ """
+ let marker = "id "
+ let caretPosition = fileContents.IndexOf(marker) + marker.Length
+ let sourceText = SourceText.From(fileContents)
+ let perfOptions = LanguageServicePerformanceOptions.Default
+ let textVersionHash = 0
+ let documentId = DocumentId.CreateNewId(ProjectId.CreateNewId())
+
+ let parseResults, _, checkFileResults =
+ let x =
+ checker.ParseAndCheckDocument(filePath, textVersionHash, sourceText, projectOptions, perfOptions, "TestSignatureHelpProvider")
+ |> Async.RunSynchronously
-[]
-let ``function application with function as parameter``() =
- let fileContents = """
-let derp (f: int -> int -> int) x = f x 1
-derp
-"""
- let marker = "derp "
- let caretPosition = fileContents.LastIndexOf(marker) + marker.Length
- let sourceText = SourceText.From(fileContents)
- let perfOptions = LanguageServicePerformanceOptions.Default
- let textVersionHash = 0
- let documentId = DocumentId.CreateNewId(ProjectId.CreateNewId())
+ if x.IsNone then
+ Assert.Fail("Could not parse and check document.")
+ x.Value
- let parseResults, _, checkFileResults =
- let x =
- checker.ParseAndCheckDocument(filePath, textVersionHash, sourceText, projectOptions, perfOptions, "TestSignatureHelpProvider")
+ let adjustedColumnInSource =
+ let rec loop ch pos =
+ if Char.IsWhiteSpace(ch) then
+ loop sourceText.[pos - 1] (pos - 1)
+ else
+ pos
+ loop sourceText.[caretPosition - 1] (caretPosition - 1)
+
+ let sigHelp =
+ FSharpSignatureHelpProvider.ProvideParametersAsyncAux(
+ parseResults,
+ checkFileResults,
+ documentId,
+ [],
+ DefaultDocumentationProvider,
+ sourceText,
+ caretPosition,
+ adjustedColumnInSource,
+ filePath)
|> Async.RunSynchronously
- if x.IsNone then
- Assert.Fail("Could not parse and check document.")
- x.Value
-
- let adjustedColumnInSource =
- let rec loop s c =
- if String.IsNullOrWhiteSpace(s.ToString()) then
- loop (sourceText.GetSubText(c - 1)) (c - 1)
- else
- c
- let startText =
- if caretPosition = sourceText.Length then
- sourceText.GetSubText(caretPosition)
- else
- sourceText.GetSubText(TextSpan(caretPosition, 1))
-
- loop startText caretPosition
+ checker.ClearLanguageServiceRootCachesAndCollectAndFinalizeAllTransients()
- let sigHelp =
- FSharpSignatureHelpProvider.ProvideParametersAsyncAux(
- parseResults,
- checkFileResults,
- documentId,
- [],
- DefaultDocumentationProvider,
- sourceText,
- caretPosition,
- adjustedColumnInSource,
- filePath)
- |> Async.RunSynchronously
+ Assert.True(sigHelp.IsNone, "No signature help is expected because there are no additional args to apply.")
- checker.ClearLanguageServiceRootCachesAndCollectAndFinalizeAllTransients()
+ []
+ let ``function application in single pipeline with an additional argument``() =
+ let fileContents = """
+[1..10] |> List.map
+ """
+ let marker = "List.map "
+ assertSignatureHelpForFunctionApplication fileContents marker 1 0
- match sigHelp with
- | None -> Assert.Fail("Expected signature help")
- | Some sigHelp ->
- Assert.AreEqual(2, sigHelp.ArgumentCount)
- Assert.AreEqual(0, sigHelp.ArgumentIndex)
+ []
+ let ``function application in middle of pipeline with an additional argument``() =
+ let fileContents = """
+[1..10]
+|> List.map
+|> List.filer (fun x -> x > 3)
+ """
+ let marker = "List.map "
+ assertSignatureHelpForFunctionApplication fileContents marker 1 0
+
+ []
+ let ``function application with function as parameter``() =
+ let fileContents = """
+let derp (f: int -> int -> int) x = f x 1
+derp
+"""
+ let marker = "derp "
+ assertSignatureHelpForFunctionApplication fileContents marker 2 0
// migrated from legacy test
[]