From 8901fb863cd01b60379a8998eca02fee5774445f Mon Sep 17 00:00:00 2001 From: Petr Date: Wed, 22 Feb 2023 14:33:22 +0100 Subject: [PATCH 1/4] Applied fantomas --- .../BraceMatchingServiceTests.fs | 14 +++++--- .../BreakpointResolutionServiceTests.fs | 6 ++-- .../CompletionProviderTests.fs | 8 +++-- .../DocumentDiagnosticAnalyzerTests.fs | 34 ++++++++++++++----- .../DocumentHighlightsServiceTests.fs | 2 +- .../EditorFormattingServiceTests.fs | 18 +++++++--- .../FsxCompletionProviderTests.fs | 8 +++-- .../GoToDefinitionServiceTests.fs | 1 + .../HelpContextServiceTests.fs | 17 ++++------ .../Helpers/RoslynHelpers.fs | 26 ++++++++------ .../Hints/HintTestFramework.fs | 16 ++++++--- .../Hints/InlineParameterNameHintTests.fs | 2 +- .../Hints/InlineTypeHintTests.fs | 18 +++++++--- .../IndentationServiceTests.fs | 12 ++++--- .../LanguageDebugInfoServiceTests.fs | 7 ++-- .../QuickInfoProviderTests.fs | 34 +++++++++---------- .../FSharp.Editor.Tests/QuickInfoTests.fs | 6 ++-- .../SemanticClassificationServiceTests.fs | 9 +++-- .../SignatureHelpProviderTests.fs | 7 ++-- .../SyntacticColorizationServiceTests.fs | 8 ++--- 20 files changed, 156 insertions(+), 97 deletions(-) diff --git a/vsintegration/tests/FSharp.Editor.Tests/BraceMatchingServiceTests.fs b/vsintegration/tests/FSharp.Editor.Tests/BraceMatchingServiceTests.fs index a5278a27c02..9e8bce2aba3 100644 --- a/vsintegration/tests/FSharp.Editor.Tests/BraceMatchingServiceTests.fs +++ b/vsintegration/tests/FSharp.Editor.Tests/BraceMatchingServiceTests.fs @@ -19,14 +19,15 @@ type BraceMatchingServiceTests() = let position = fileContents.IndexOf(marker) Assert.True(position >= 0, $"Cannot find marker '{marker}' in file contents") - let parsingOptions, _ = checker.GetParsingOptionsFromProjectOptions RoslynTestHelpers.DefaultProjectOptions + let parsingOptions, _ = + checker.GetParsingOptionsFromProjectOptions RoslynTestHelpers.DefaultProjectOptions match FSharpBraceMatchingService.GetBraceMatchingResult(checker, sourceText, fileName, parsingOptions, position, "UnitTest") |> Async.RunImmediateExceptOnUI with | None -> () - | Some (left, right) -> failwith $"Found match for brace '{marker}'" + | Some (left, right) -> failwith $"Found match for brace '{marker}'" member private this.VerifyBraceMatch(fileContents: string, startMarker: string, endMarker: string) = let sourceText = SourceText.From(fileContents) @@ -36,7 +37,8 @@ type BraceMatchingServiceTests() = Assert.True(startMarkerPosition >= 0, $"Cannot find start marker '{startMarkerPosition}' in file contents") Assert.True(endMarkerPosition >= 0, $"Cannot find end marker '{endMarkerPosition}' in file contents") - let parsingOptions, _ = checker.GetParsingOptionsFromProjectOptions RoslynTestHelpers.DefaultProjectOptions + let parsingOptions, _ = + checker.GetParsingOptionsFromProjectOptions RoslynTestHelpers.DefaultProjectOptions match FSharpBraceMatchingService.GetBraceMatchingResult( @@ -202,7 +204,9 @@ let main argv = [] member this.DoNotMatchOnInnerSide(fileContents: string, [] matchingPositions: int[]) = let sourceText = SourceText.From(fileContents) - let parsingOptions, _ = checker.GetParsingOptionsFromProjectOptions RoslynTestHelpers.DefaultProjectOptions + + let parsingOptions, _ = + checker.GetParsingOptionsFromProjectOptions RoslynTestHelpers.DefaultProjectOptions for position in matchingPositions do match @@ -215,4 +219,4 @@ let main argv = | 0 -> "" | _ -> fileContents.[position - 1] |> sprintf " (previous character '%c')" |> sprintf "Didn't find a matching brace at position '%d' %s" position - |> raise (exn()) + |> raise (exn ()) diff --git a/vsintegration/tests/FSharp.Editor.Tests/BreakpointResolutionServiceTests.fs b/vsintegration/tests/FSharp.Editor.Tests/BreakpointResolutionServiceTests.fs index 548991e3d5f..7322e981aba 100644 --- a/vsintegration/tests/FSharp.Editor.Tests/BreakpointResolutionServiceTests.fs +++ b/vsintegration/tests/FSharp.Editor.Tests/BreakpointResolutionServiceTests.fs @@ -45,15 +45,15 @@ let main argv = |] [] - [] + [] member this.TestBreakpointResolution(searchToken: string, expectedResolution: string option) = let searchPosition = code.IndexOf(searchToken) Assert.True(searchPosition >= 0, $"SearchToken '{searchToken}' is not found in code") let sourceText = SourceText.From(code) + let document = - RoslynTestHelpers.CreateSolution(code) - |> RoslynTestHelpers.GetSingleDocument + RoslynTestHelpers.CreateSolution(code) |> RoslynTestHelpers.GetSingleDocument let searchSpan = TextSpan.FromBounds(searchPosition, searchPosition + searchToken.Length) diff --git a/vsintegration/tests/FSharp.Editor.Tests/CompletionProviderTests.fs b/vsintegration/tests/FSharp.Editor.Tests/CompletionProviderTests.fs index b5b6685138c..11c7efbe0ac 100644 --- a/vsintegration/tests/FSharp.Editor.Tests/CompletionProviderTests.fs +++ b/vsintegration/tests/FSharp.Editor.Tests/CompletionProviderTests.fs @@ -141,7 +141,9 @@ System.Console.WriteLine(x + y) IntelliSenseOptions.Default ) - triggered |> Assert.shouldBeEqualWith shouldBeTriggered + triggered + |> Assert.shouldBeEqualWith + shouldBeTriggered "FSharpCompletionProvider.ShouldTriggerCompletionAux() should compute the correct result" [] @@ -242,7 +244,9 @@ let z = $"abc {System.Console.WriteLine(x + y)} def" IntelliSenseOptions.Default ) - triggered |> Assert.shouldBeEqualWith shouldBeTriggered + triggered + |> Assert.shouldBeEqualWith + shouldBeTriggered $"FSharpCompletionProvider.ShouldTriggerCompletionAux() should compute the correct result for marker '{marker}" [] diff --git a/vsintegration/tests/FSharp.Editor.Tests/DocumentDiagnosticAnalyzerTests.fs b/vsintegration/tests/FSharp.Editor.Tests/DocumentDiagnosticAnalyzerTests.fs index 51fdf2be248..f5a3bd134fe 100644 --- a/vsintegration/tests/FSharp.Editor.Tests/DocumentDiagnosticAnalyzerTests.fs +++ b/vsintegration/tests/FSharp.Editor.Tests/DocumentDiagnosticAnalyzerTests.fs @@ -36,17 +36,25 @@ type DocumentDiagnosticAnalyzerTests() = |> Seq.filter (fun e -> e.Severity = DiagnosticSeverity.Error) |> Seq.toArray - errors.Length |> Assert.shouldBeEqualWith 1 "There should be exactly one error generated" + errors.Length + |> Assert.shouldBeEqualWith 1 "There should be exactly one error generated" + let actualError = errors.[0] if expectedMessage.IsSome then - actualError.GetMessage() |> Assert.shouldBeEqualWith expectedMessage.Value "Error messages should match" + actualError.GetMessage() + |> Assert.shouldBeEqualWith expectedMessage.Value "Error messages should match" Assert.Equal(DiagnosticSeverity.Error, actualError.Severity) let expectedStart = fileContents.IndexOf(expectedMarker) - actualError.Location.SourceSpan.Start |> Assert.shouldBeEqualWith expectedStart "Error start positions should match" + + actualError.Location.SourceSpan.Start + |> Assert.shouldBeEqualWith expectedStart "Error start positions should match" + let expectedEnd = expectedStart + expectedMarker.Length - actualError.Location.SourceSpan.End |> Assert.shouldBeEqualWith expectedEnd "Error end positions should match" + + actualError.Location.SourceSpan.End + |> Assert.shouldBeEqualWith expectedEnd "Error end positions should match" member private this.VerifyDiagnosticBetweenMarkers ( @@ -59,14 +67,24 @@ type DocumentDiagnosticAnalyzerTests() = |> Seq.filter (fun e -> e.Severity = expectedSeverity) |> Seq.toArray - errors.Length |> Assert.shouldBeEqualWith 1 "There should be exactly one error generated" + errors.Length + |> Assert.shouldBeEqualWith 1 "There should be exactly one error generated" + let actualError = errors.[0] Assert.Equal(expectedSeverity, actualError.Severity) - actualError.GetMessage() |> Assert.shouldBeEqualWith expectedMessage "Error messages should match" + + actualError.GetMessage() + |> Assert.shouldBeEqualWith expectedMessage "Error messages should match" + let expectedStart = fileContents.IndexOf(startMarker) + startMarker.Length - actualError.Location.SourceSpan.Start |> Assert.shouldBeEqualWith expectedStart "Error start positions should match" + + actualError.Location.SourceSpan.Start + |> Assert.shouldBeEqualWith expectedStart "Error start positions should match" + let expectedEnd = fileContents.IndexOf(endMarker) - actualError.Location.SourceSpan.End |> Assert.shouldBeEqualWith expectedEnd "Error end positions should match" + + actualError.Location.SourceSpan.End + |> Assert.shouldBeEqualWith expectedEnd "Error end positions should match" member private this.VerifyErrorBetweenMarkers(fileContents: string, expectedMessage: string) = this.VerifyDiagnosticBetweenMarkers(fileContents, expectedMessage, DiagnosticSeverity.Error) diff --git a/vsintegration/tests/FSharp.Editor.Tests/DocumentHighlightsServiceTests.fs b/vsintegration/tests/FSharp.Editor.Tests/DocumentHighlightsServiceTests.fs index f590c76df1b..08a61bfcd9c 100644 --- a/vsintegration/tests/FSharp.Editor.Tests/DocumentHighlightsServiceTests.fs +++ b/vsintegration/tests/FSharp.Editor.Tests/DocumentHighlightsServiceTests.fs @@ -15,7 +15,7 @@ module DocumentHighlightsServiceTests = let filePath = "C:\\test.fs" let private getSpans (fileContents: string) (caretPosition: int) = - let document = + let document = RoslynTestHelpers.CreateSolution(fileContents) |> RoslynTestHelpers.GetSingleDocument diff --git a/vsintegration/tests/FSharp.Editor.Tests/EditorFormattingServiceTests.fs b/vsintegration/tests/FSharp.Editor.Tests/EditorFormattingServiceTests.fs index 2e917447cdf..12d0369a4b2 100644 --- a/vsintegration/tests/FSharp.Editor.Tests/EditorFormattingServiceTests.fs +++ b/vsintegration/tests/FSharp.Editor.Tests/EditorFormattingServiceTests.fs @@ -66,7 +66,8 @@ marker4""" let lineNumber = sourceText.Lines |> Seq.findIndex (fun line -> line.Span.Contains position) - let parsingOptions, _ = checker.GetParsingOptionsFromProjectOptions RoslynTestHelpers.DefaultProjectOptions + let parsingOptions, _ = + checker.GetParsingOptionsFromProjectOptions RoslynTestHelpers.DefaultProjectOptions let changesOpt = FSharpEditorFormattingService.GetFormattingChanges( @@ -93,7 +94,9 @@ marker4""" [] member this.TestPasteChanges_PastingOntoIndentedLine(enabled: bool, prefix: string) = let checker = FSharpChecker.Create() - let parsingOptions, _ = checker.GetParsingOptionsFromProjectOptions RoslynTestHelpers.DefaultProjectOptions + + let parsingOptions, _ = + checker.GetParsingOptionsFromProjectOptions RoslynTestHelpers.DefaultProjectOptions let clipboard = prefix @@ -149,14 +152,17 @@ somethingElseHere Assert.Equal(expected, changedText) | _ -> failwithf "Expected text changes, but got %+A" changesOpt else - changesOpt |> Assert.shouldBeEqualWith None "Expected no changes as FormatOnPaste is disabled" + changesOpt + |> Assert.shouldBeEqualWith None "Expected no changes as FormatOnPaste is disabled" [] [] [] member this.TestPasteChanges_PastingOntoEmptyLine(prefix: string) = let checker = FSharpChecker.Create() - let parsingOptions, _ = checker.GetParsingOptionsFromProjectOptions RoslynTestHelpers.DefaultProjectOptions + + let parsingOptions, _ = + checker.GetParsingOptionsFromProjectOptions RoslynTestHelpers.DefaultProjectOptions let clipboard = prefix @@ -214,7 +220,9 @@ somethingElseHere [] member this.TestPasteChanges_PastingWithAutoIndentationInPasteSpan() = let checker = FSharpChecker.Create() - let parsingOptions, _ = checker.GetParsingOptionsFromProjectOptions RoslynTestHelpers.DefaultProjectOptions + + let parsingOptions, _ = + checker.GetParsingOptionsFromProjectOptions RoslynTestHelpers.DefaultProjectOptions let clipboard = """[] diff --git a/vsintegration/tests/FSharp.Editor.Tests/FsxCompletionProviderTests.fs b/vsintegration/tests/FSharp.Editor.Tests/FsxCompletionProviderTests.fs index 1cbe5025735..48276422bdd 100644 --- a/vsintegration/tests/FSharp.Editor.Tests/FsxCompletionProviderTests.fs +++ b/vsintegration/tests/FSharp.Editor.Tests/FsxCompletionProviderTests.fs @@ -17,7 +17,11 @@ type Worker() = member _.VerifyCompletionListExactly(fileContents: string, marker: string, expected: List) = let caretPosition = fileContents.IndexOf(marker) + marker.Length - let options = { RoslynTestHelpers.DefaultProjectOptions with SourceFiles = [|filePath|] } + let options = + { RoslynTestHelpers.DefaultProjectOptions with + SourceFiles = [| filePath |] + } + let document = RoslynTestHelpers.CreateSolution(fileContents, options = options) |> RoslynTestHelpers.GetSingleDocument @@ -49,7 +53,7 @@ module FsxCompletionProviderTests = let getWorker () = Worker() #if RELEASE - [] + [] #else [] #endif diff --git a/vsintegration/tests/FSharp.Editor.Tests/GoToDefinitionServiceTests.fs b/vsintegration/tests/FSharp.Editor.Tests/GoToDefinitionServiceTests.fs index f4f534743a1..87abb259e0d 100644 --- a/vsintegration/tests/FSharp.Editor.Tests/GoToDefinitionServiceTests.fs +++ b/vsintegration/tests/FSharp.Editor.Tests/GoToDefinitionServiceTests.fs @@ -55,6 +55,7 @@ module GoToDefinitionServiceTests = let caretPosition = fileContents.IndexOf(caretMarker) + caretMarker.Length - 1 // inside the marker let sourceText = SourceText.From(fileContents) + let document = RoslynTestHelpers.CreateSolution(fileContents) |> RoslynTestHelpers.GetSingleDocument diff --git a/vsintegration/tests/FSharp.Editor.Tests/HelpContextServiceTests.fs b/vsintegration/tests/FSharp.Editor.Tests/HelpContextServiceTests.fs index 4f93b1e0ef7..c48506c78b3 100644 --- a/vsintegration/tests/FSharp.Editor.Tests/HelpContextServiceTests.fs +++ b/vsintegration/tests/FSharp.Editor.Tests/HelpContextServiceTests.fs @@ -27,6 +27,7 @@ type HelpContextServiceTests() = let fileContents = fileContentsWithMarkers.Replace("$", "") let sourceText = SourceText.From(fileContents) + let document = RoslynTestHelpers.CreateSolution(fileContents) |> RoslynTestHelpers.GetSingleDocument @@ -57,7 +58,7 @@ type HelpContextServiceTests() = TestF1KeywordsWithOptions(expectedKeywords, lines) #if RELEASE - [] + [] #else [] #endif @@ -209,7 +210,7 @@ type HelpContextServiceTests() = TestF1Keywords(keywords, file) #if RELEASE - [] + [] #else [] #endif @@ -218,13 +219,10 @@ type HelpContextServiceTests() = let file = [ "open N$1" ] let keywords = [ Some "N1" ] - TestF1KeywordsWithOptions( - keywords, - file - ) + TestF1KeywordsWithOptions(keywords, file) #if RELEASE - [] + [] #else [] #endif @@ -239,10 +237,7 @@ type HelpContextServiceTests() = let keywords = [ Some "N1.T" ] - TestF1KeywordsWithOptions( - keywords, - file - ) + TestF1KeywordsWithOptions(keywords, file) [] member _.``F1 help keyword EndOfLine``() = diff --git a/vsintegration/tests/FSharp.Editor.Tests/Helpers/RoslynHelpers.fs b/vsintegration/tests/FSharp.Editor.Tests/Helpers/RoslynHelpers.fs index 331a812ddd7..9efa3ecc055 100644 --- a/vsintegration/tests/FSharp.Editor.Tests/Helpers/RoslynHelpers.fs +++ b/vsintegration/tests/FSharp.Editor.Tests/Helpers/RoslynHelpers.fs @@ -219,8 +219,9 @@ type RoslynTestHelpers private () = Stamp = None } - static member private GetSourceCodeKind filePath = + static member private GetSourceCodeKind filePath = let extension = Path.GetExtension(filePath) + match extension with | ".fsx" -> SourceCodeKind.Script | ".fsi" -> SourceCodeKind.Regular @@ -232,7 +233,7 @@ type RoslynTestHelpers private () = let id = SolutionId.CreateNewId() let versionStamp = VersionStamp.Create(DateTime.UtcNow) let slnPath = "test.sln" - + let solutionInfo = SolutionInfo.Create(id, versionStamp, slnPath, projects) let solution = workspace.AddSolution(solutionInfo) solution @@ -243,7 +244,8 @@ type RoslynTestHelpers private () = filePath, loader = TextLoader.From(SourceText.From(code).Container, VersionStamp.Create(DateTime.UtcNow)), filePath = filePath, - sourceCodeKind = RoslynTestHelpers.GetSourceCodeKind filePath) + sourceCodeKind = RoslynTestHelpers.GetSourceCodeKind filePath + ) static member CreateProjectInfo id filePath documents = ProjectInfo.Create( @@ -253,9 +255,10 @@ type RoslynTestHelpers private () = "test.dll", LanguageNames.FSharp, documents = documents, - filePath = filePath) + filePath = filePath + ) - static member SetProjectOptions projId (solution: Solution) (options: FSharpProjectOptions) = + static member SetProjectOptions projId (solution: Solution) (options: FSharpProjectOptions) = solution .Workspace .Services @@ -264,18 +267,19 @@ type RoslynTestHelpers private () = .SetCommandLineOptions( projId, options.SourceFiles, - options.OtherOptions |> ImmutableArray.CreateRange) + options.OtherOptions |> ImmutableArray.CreateRange + ) - static member CreateSolution (source, ?options: FSharpProjectOptions) = + static member CreateSolution(source, ?options: FSharpProjectOptions) = let projId = ProjectId.CreateNewId() let docInfo = RoslynTestHelpers.CreateDocumentInfo projId "C:\\test.fs" source let projFilePath = "C:\\test.fsproj" - let projInfo = RoslynTestHelpers.CreateProjectInfo projId projFilePath [docInfo] - let solution = RoslynTestHelpers.CreateSolution [projInfo] + let projInfo = RoslynTestHelpers.CreateProjectInfo projId projFilePath [ docInfo ] + let solution = RoslynTestHelpers.CreateSolution [ projInfo ] - options + options |> Option.defaultValue RoslynTestHelpers.DefaultProjectOptions |> RoslynTestHelpers.SetProjectOptions projId solution @@ -284,4 +288,4 @@ type RoslynTestHelpers private () = static member GetSingleDocument(solution: Solution) = let project = solution.Projects |> Seq.exactlyOne let document = project.Documents |> Seq.exactlyOne - document \ No newline at end of file + document diff --git a/vsintegration/tests/FSharp.Editor.Tests/Hints/HintTestFramework.fs b/vsintegration/tests/FSharp.Editor.Tests/Hints/HintTestFramework.fs index 7f9a8be3cbf..70f06bb0940 100644 --- a/vsintegration/tests/FSharp.Editor.Tests/Hints/HintTestFramework.fs +++ b/vsintegration/tests/FSharp.Editor.Tests/Hints/HintTestFramework.fs @@ -30,7 +30,11 @@ module HintTestFramework = let getFsDocument code = // I don't know, without this lib some symbols are just not loaded - let options = { RoslynTestHelpers.DefaultProjectOptions with OtherOptions = [| "--targetprofile:netcore" |] } + let options = + { RoslynTestHelpers.DefaultProjectOptions with + OtherOptions = [| "--targetprofile:netcore" |] + } + RoslynTestHelpers.CreateSolution(code, options = options) |> RoslynTestHelpers.GetSingleDocument @@ -38,11 +42,15 @@ module HintTestFramework = let projectId = ProjectId.CreateNewId() let projFilePath = "C:\\test.fsproj" - let fsiDocInfo = RoslynTestHelpers.CreateDocumentInfo projectId "C:\\test.fsi" fsiCode + let fsiDocInfo = + RoslynTestHelpers.CreateDocumentInfo projectId "C:\\test.fsi" fsiCode + let fsDocInfo = RoslynTestHelpers.CreateDocumentInfo projectId "C:\\test.fs" fsCode - let projInfo = RoslynTestHelpers.CreateProjectInfo projectId projFilePath [fsiDocInfo; fsDocInfo] - let solution = RoslynTestHelpers.CreateSolution [projInfo] + let projInfo = + RoslynTestHelpers.CreateProjectInfo projectId projFilePath [ fsiDocInfo; fsDocInfo ] + + let solution = RoslynTestHelpers.CreateSolution [ projInfo ] let project = solution.Projects |> Seq.exactlyOne project.Documents diff --git a/vsintegration/tests/FSharp.Editor.Tests/Hints/InlineParameterNameHintTests.fs b/vsintegration/tests/FSharp.Editor.Tests/Hints/InlineParameterNameHintTests.fs index d9da400e4ad..7a44467afcf 100644 --- a/vsintegration/tests/FSharp.Editor.Tests/Hints/InlineParameterNameHintTests.fs +++ b/vsintegration/tests/FSharp.Editor.Tests/Hints/InlineParameterNameHintTests.fs @@ -448,7 +448,7 @@ type MyType() = let actual = getParameterNameHints document Assert.Empty(actual) - + [] let ``Hints are shown correctly for inner bindings`` () = let code = diff --git a/vsintegration/tests/FSharp.Editor.Tests/Hints/InlineTypeHintTests.fs b/vsintegration/tests/FSharp.Editor.Tests/Hints/InlineTypeHintTests.fs index a8219a3c53a..d995223fbd3 100644 --- a/vsintegration/tests/FSharp.Editor.Tests/Hints/InlineTypeHintTests.fs +++ b/vsintegration/tests/FSharp.Editor.Tests/Hints/InlineTypeHintTests.fs @@ -204,6 +204,7 @@ let func = fun () -> 3 """ let x """ + let document = getFsDocument code let result = getTypeHints document @@ -211,11 +212,12 @@ let x Assert.Empty(result) [] - let ``Hints are not shown for unsolved types in _for_ expressions in collections`` () = + let ``Hints are not shown for unsolved types in _for_ expressions in collections`` () = let code = """ let _ = [ for x ] """ + let document = getFsDocument code let result = getTypeHints document @@ -223,7 +225,7 @@ let _ = [ for x ] Assert.Empty(result) [] - let ``Hints are not shown for unsolved types in _for_ expressions within computational expressions`` () = + let ``Hints are not shown for unsolved types in _for_ expressions within computational expressions`` () = let code = """ do task { @@ -232,6 +234,7 @@ do task { do! Task.Delay 0 } """ + let document = getFsDocument code let result = getTypeHints document @@ -250,12 +253,19 @@ type Number<'T when IAddition<'T>>(value: 'T) = interface IAddition> with static member op_Addition(a, b) = Number(a.Value + b.Value) """ + let document = getFsDocument code let expected = [ - { Content = ": Number<'T>"; Location = (7, 36) } - { Content = ": Number<'T>"; Location = (7, 39) } + { + Content = ": Number<'T>" + Location = (7, 36) + } + { + Content = ": Number<'T>" + Location = (7, 39) + } ] let actual = getTypeHints document diff --git a/vsintegration/tests/FSharp.Editor.Tests/IndentationServiceTests.fs b/vsintegration/tests/FSharp.Editor.Tests/IndentationServiceTests.fs index 3ef331544c3..81f2bfc7f09 100644 --- a/vsintegration/tests/FSharp.Editor.Tests/IndentationServiceTests.fs +++ b/vsintegration/tests/FSharp.Editor.Tests/IndentationServiceTests.fs @@ -165,7 +165,8 @@ while true do for (expectedIndentation, lineNumber, template) in testCases do let sourceText = SourceText.From(template) - let parsingOptions, _ = checker.GetParsingOptionsFromProjectOptions RoslynTestHelpers.DefaultProjectOptions + let parsingOptions, _ = + checker.GetParsingOptionsFromProjectOptions RoslynTestHelpers.DefaultProjectOptions let actualIndentation = FSharpIndentationService.GetDesiredIndentation( @@ -181,7 +182,8 @@ while true do match expectedIndentation with | None -> Assert.True(actualIndentation.IsNone, $"No indentation was expected at line {lineNumber}") | Some indentation -> - actualIndentation.Value |> Assert.shouldBeEqualWith indentation $"Indentation on line {lineNumber} doesn't match" + actualIndentation.Value + |> Assert.shouldBeEqualWith indentation $"Indentation on line {lineNumber} doesn't match" [] member this.TestAutoIndentation() = @@ -189,7 +191,8 @@ while true do let sourceText = SourceText.From(template) - let parsingOptions, _ = checker.GetParsingOptionsFromProjectOptions RoslynTestHelpers.DefaultProjectOptions + let parsingOptions, _ = + checker.GetParsingOptionsFromProjectOptions RoslynTestHelpers.DefaultProjectOptions let actualIndentation = FSharpIndentationService.GetDesiredIndentation( @@ -205,4 +208,5 @@ while true do match expectedIndentation with | None -> Assert.True(actualIndentation.IsNone, $"No indentation was expected at line {lineNumber}") | Some indentation -> - actualIndentation.Value |> Assert.shouldBeEqualWith indentation $"Indentation on line {lineNumber} doesn't match" + actualIndentation.Value + |> Assert.shouldBeEqualWith indentation $"Indentation on line {lineNumber} doesn't match" diff --git a/vsintegration/tests/FSharp.Editor.Tests/LanguageDebugInfoServiceTests.fs b/vsintegration/tests/FSharp.Editor.Tests/LanguageDebugInfoServiceTests.fs index 30a6c8ab79a..e24c4e93d30 100644 --- a/vsintegration/tests/FSharp.Editor.Tests/LanguageDebugInfoServiceTests.fs +++ b/vsintegration/tests/FSharp.Editor.Tests/LanguageDebugInfoServiceTests.fs @@ -44,7 +44,7 @@ let main argv = |] [] - [] + [] member this.TestDebugInfo(searchToken: string, expectedDataTip: string option) = let searchPosition = code.IndexOf(searchToken) Assert.True(searchPosition >= 0, $"SearchToken '{searchToken}' is not found in code") @@ -70,9 +70,6 @@ let main argv = | Some (actualDataTipSpan) -> let actualDataTipText = sourceText.GetSubText(actualDataTipSpan).ToString() - Assert.True( - expectedDataTip.IsSome, - $"LanguageDebugInfoService produced a data tip while it shouldn't at: {actualDataTipText}" - ) + Assert.True(expectedDataTip.IsSome, $"LanguageDebugInfoService produced a data tip while it shouldn't at: {actualDataTipText}") Assert.Equal(expectedDataTip.Value, actualDataTipText) diff --git a/vsintegration/tests/FSharp.Editor.Tests/QuickInfoProviderTests.fs b/vsintegration/tests/FSharp.Editor.Tests/QuickInfoProviderTests.fs index ed7ed67d85e..f39c0a748d2 100644 --- a/vsintegration/tests/FSharp.Editor.Tests/QuickInfoProviderTests.fs +++ b/vsintegration/tests/FSharp.Editor.Tests/QuickInfoProviderTests.fs @@ -197,93 +197,93 @@ let res8 = abs 5.0 Some "(extension) System.Collections.Generic.IEnumerable.GroupBy<'TSource,'TKey>(keySelector: System.Func<'TSource,'TKey>) : System.Collections.Generic.IEnumerable> 'TSource is int * string -'TKey is int"); +'TKey is int") ("Sort", Some "System.Array.Sort<'T>(array: 'T array) : unit -'T is int"); +'T is int") ("let test4 x = C().FSharpGenericMethodExplitTypeParams", Some "member C.FSharpGenericMethodExplitTypeParams: a: 'T0 * y: 'T0 -> 'T0 * 'T0 -'T is 'a list"); +'T is 'a list") ("let test5<'U> (x: 'U) = C().FSharpGenericMethodExplitTypeParams", Some "member C.FSharpGenericMethodExplitTypeParams: a: 'T0 * y: 'T0 -> 'T0 * 'T0 -'T is 'U list"); +'T is 'U list") ("let test6 = C().FSharpGenericMethodExplitTypeParams", Some "member C.FSharpGenericMethodExplitTypeParams: a: 'T0 * y: 'T0 -> 'T0 * 'T0 -'T is int"); +'T is int") ("let test7 x = C().FSharpGenericMethodInferredTypeParams", Some "member C.FSharpGenericMethodInferredTypeParams: a: 'a1 * y: 'b2 -> 'a1 * 'b2 'a is 'a0 list -'b is 'a0 list"); +'b is 'a0 list") ("let test8 = C().FSharpGenericMethodInferredTypeParams", Some "member C.FSharpGenericMethodInferredTypeParams: a: 'a0 * y: 'b1 -> 'a0 * 'b1 'a is int -'b is int"); +'b is int") ("let test9<'U> (x: 'U) = C().FSharpGenericMethodInferredTypeParams", Some "member C.FSharpGenericMethodInferredTypeParams: a: 'a0 * y: 'b1 -> 'a0 * 'b1 'a is 'U list -'b is 'U list"); +'b is 'U list") ("let res3 = [1] |>", Some "val (|>) : arg: 'T1 -> func: ('T1 -> 'U) -> 'U Full name: Microsoft.FSharp.Core.Operators.(|>) 'T1 is int list -'U is int list"); +'U is int list") ("let res3 = [1] |> List.map id", Some "val id: x: 'T -> 'T Full name: Microsoft.FSharp.Core.Operators.id -'T is int"); +'T is int") ("let res4 = (1.0,[1]) ||>", Some "val (||>) : arg1: 'T1 * arg2: 'T2 -> func: ('T1 -> 'T2 -> 'U) -> 'U Full name: Microsoft.FSharp.Core.Operators.(||>) 'T1 is float 'T2 is int list -'U is float"); +'U is float") ("let res4 = (1.0,[1]) ||> List.fold", Some "val fold: folder: ('State -> 'T -> 'State) -> state: 'State -> list: 'T list -> 'State Full name: Microsoft.FSharp.Collections.List.fold 'T is int -'State is float"); +'State is float") ("let res4 = (1.0,[1]) ||> List.fold (fun s x -> string s +", Some "val (+) : x: 'T1 -> y: 'T2 -> 'T3 (requires member (+)) Full name: Microsoft.FSharp.Core.Operators.(+) 'T1 is string 'T2 is string -'T3 is float"); +'T3 is float") ("let res5 = 1 +", Some "val (+) : x: 'T1 -> y: 'T2 -> 'T3 (requires member (+)) Full name: Microsoft.FSharp.Core.Operators.(+) 'T1 is int 'T2 is int -'T3 is int"); +'T3 is int") ("let res6 = System.DateTime.Now +", Some "val (+) : x: 'T1 -> y: 'T2 -> 'T3 (requires member (+)) Full name: Microsoft.FSharp.Core.Operators.(+) 'T1 is System.DateTime 'T2 is System.TimeSpan -'T3 is System.DateTime"); +'T3 is System.DateTime") ("let res7 = sin", Some "val sin: value: 'T -> 'T (requires member Sin) Full name: Microsoft.FSharp.Core.Operators.sin -'T is float"); +'T is float") ("let res8 = abs", Some "val abs: value: 'T -> 'T (requires member Abs) Full name: Microsoft.FSharp.Core.Operators.abs -'T is int"); +'T is int") ] executeQuickInfoTest fileContents testCases diff --git a/vsintegration/tests/FSharp.Editor.Tests/QuickInfoTests.fs b/vsintegration/tests/FSharp.Editor.Tests/QuickInfoTests.fs index a68e1530847..e1d07740620 100644 --- a/vsintegration/tests/FSharp.Editor.Tests/QuickInfoTests.fs +++ b/vsintegration/tests/FSharp.Editor.Tests/QuickInfoTests.fs @@ -26,7 +26,9 @@ module QuickInfo = let internal GetQuickInfo (code: string) caretPosition = async { - let document = RoslynTestHelpers.CreateSolution(code) |> RoslynTestHelpers.GetSingleDocument + let document = + RoslynTestHelpers.CreateSolution(code) |> RoslynTestHelpers.GetSingleDocument + return! FSharpAsyncQuickInfoSource.ProvideQuickInfo(document, caretPosition) } |> Async.RunSynchronously @@ -621,7 +623,7 @@ exception SomeError of ``thing wi$$th space``: string """ type R = {| ``thing wi$$th space``: string |} """ - + let expected = "``thing with space``" let actual = GetQuickInfoTextFromCode code diff --git a/vsintegration/tests/FSharp.Editor.Tests/SemanticClassificationServiceTests.fs b/vsintegration/tests/FSharp.Editor.Tests/SemanticClassificationServiceTests.fs index 47c6edac8dc..38a7490b552 100644 --- a/vsintegration/tests/FSharp.Editor.Tests/SemanticClassificationServiceTests.fs +++ b/vsintegration/tests/FSharp.Editor.Tests/SemanticClassificationServiceTests.fs @@ -14,9 +14,8 @@ open FSharp.Test type SemanticClassificationServiceTests() = let getRanges (source: string) : SemanticClassificationItem list = asyncMaybe { - let document = - RoslynTestHelpers.CreateSolution(source) - |> RoslynTestHelpers.GetSingleDocument + let document = + RoslynTestHelpers.CreateSolution(source) |> RoslynTestHelpers.GetSingleDocument let! _, checkFileResults = document.GetFSharpParseAndCheckResultsAsync("SemanticClassificationServiceTests") @@ -41,8 +40,8 @@ type SemanticClassificationServiceTests() = match ranges |> List.tryFind (fun item -> Range.rangeContainsPos item.Range markerPos) with | None -> failwith "Cannot find colorization data for end of marker" | Some item -> - FSharpClassificationTypes.getClassificationTypeName item.Type |> Assert.shouldBeEqualWith classificationType - "Classification data doesn't match for end of marker" + FSharpClassificationTypes.getClassificationTypeName item.Type + |> Assert.shouldBeEqualWith classificationType "Classification data doesn't match for end of marker" let verifyNoClassificationDataAtEndOfMarker (fileContents: string, marker: string, classificationType: string) = let text = SourceText.From(fileContents) diff --git a/vsintegration/tests/FSharp.Editor.Tests/SignatureHelpProviderTests.fs b/vsintegration/tests/FSharp.Editor.Tests/SignatureHelpProviderTests.fs index abec8f8b142..a96c2374333 100644 --- a/vsintegration/tests/FSharp.Editor.Tests/SignatureHelpProviderTests.fs +++ b/vsintegration/tests/FSharp.Editor.Tests/SignatureHelpProviderTests.fs @@ -23,7 +23,6 @@ module SignatureHelpProvider = let filePath = "C:\\test.fs" - let GetSignatureHelp (project: FSharpProject) (fileName: string) (caretPosition: int) = async { let triggerChar = None @@ -146,6 +145,7 @@ module SignatureHelpProvider = let caretPosition = fileContents.LastIndexOf(marker) + marker.Length let sourceText = SourceText.From(fileContents) + let document = RoslynTestHelpers.CreateSolution(fileContents) |> RoslynTestHelpers.GetSingleDocument @@ -371,7 +371,7 @@ let _ = System.DateTime(1L, assertSignatureHelpForMethodCalls fileContents marker (Some("[10..31)", 1, 2, None)) #if RELEASE - [] + [] #else [] #endif @@ -486,6 +486,7 @@ M.f let caretPosition = fileContents.IndexOf(marker) + marker.Length let sourceText = SourceText.From(fileContents) + let document = RoslynTestHelpers.CreateSolution(fileContents) |> RoslynTestHelpers.GetSingleDocument @@ -617,6 +618,6 @@ let f (derp: int -> int -> int) x = derp x " - + let expected = [| [| "System.Int32"; "System.Int32" |] |] Assert.Equal(expected, completionNames) diff --git a/vsintegration/tests/FSharp.Editor.Tests/SyntacticColorizationServiceTests.fs b/vsintegration/tests/FSharp.Editor.Tests/SyntacticColorizationServiceTests.fs index 7d988259d33..6fcb469ff89 100644 --- a/vsintegration/tests/FSharp.Editor.Tests/SyntacticColorizationServiceTests.fs +++ b/vsintegration/tests/FSharp.Editor.Tests/SyntacticColorizationServiceTests.fs @@ -51,8 +51,8 @@ type SyntacticClassificationServiceTests() = match tokens |> Seq.tryFind (fun token -> token.TextSpan.Contains(markerPosition)) with | None -> failwith "Cannot find colorization data for start of marker" | Some classifiedSpan -> - classifiedSpan.ClassificationType |> Assert.shouldBeEqualWith classificationType - "Classification data doesn't match for start of marker" + classifiedSpan.ClassificationType + |> Assert.shouldBeEqualWith classificationType "Classification data doesn't match for start of marker" member private this.VerifyColorizerAtEndOfMarker ( @@ -71,8 +71,8 @@ type SyntacticClassificationServiceTests() = with | None -> failwith "Cannot find colorization data for end of marker" | Some classifiedSpan -> - classifiedSpan.ClassificationType |> Assert.shouldBeEqualWith classificationType - "Classification data doesn't match for end of marker" + classifiedSpan.ClassificationType + |> Assert.shouldBeEqualWith classificationType "Classification data doesn't match for end of marker" [] member this.Comment_SingleLine() = From b2035ec20fb418032c244002a22d66f9fbce22c1 Mon Sep 17 00:00:00 2001 From: Petr Date: Wed, 22 Feb 2023 14:36:43 +0100 Subject: [PATCH 2/4] Updating CI --- .github/workflows/commands.yml | 2 +- DEVGUIDE.md | 4 +- azure-pipelines.yml | 4 +- .../QuickInfoProviderTests.fs | 96 +++++++++---------- 4 files changed, 53 insertions(+), 53 deletions(-) diff --git a/.github/workflows/commands.yml b/.github/workflows/commands.yml index d6d3deaeb65..1d6c28646c8 100644 --- a/.github/workflows/commands.yml +++ b/.github/workflows/commands.yml @@ -75,7 +75,7 @@ jobs: - name: Process fantomas command if: steps.command-extractor.outputs.result == 'fantomas' id: fantomas - run: dotnet fantomas src -r + run: dotnet fantomas . -r - name: Process fantomas command if: steps.command-extractor.outputs.result == 'xlf' id: xlf diff --git a/DEVGUIDE.md b/DEVGUIDE.md index 70ab27d36d1..9ac366f5ab2 100644 --- a/DEVGUIDE.md +++ b/DEVGUIDE.md @@ -188,13 +188,13 @@ or Some of the code in this repository is formatted automatically by [Fantomas](https://github.com/fsprojects/fantomas). To format all files use: ```cmd -dotnet fantomas src -r +dotnet fantomas . -r ``` The formatting is checked automatically by CI: ```cmd -dotnet fantomas src -r --check +dotnet fantomas . -r --check ``` At the time of writing only a subset of signature files (`*.fsi`) are formatted. See the settings in `.fantomasignore` and `.editorconfig`. diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 9a7b19618fd..c9cb8e2a6f4 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -268,10 +268,10 @@ stages: env: DOTNET_ROLL_FORWARD_TO_PRERELEASE: 1 displayName: Install tools - - script: dotnet fantomas src -r --check + - script: dotnet fantomas . -r --check env: DOTNET_ROLL_FORWARD_TO_PRERELEASE: 1 - displayName: Check code formatting (run 'dotnet fantomas src -r' to fix) + displayName: Check code formatting (run 'dotnet fantomas . -r' to fix) # Check whether package with current version has been published to nuget.org # We will try to restore both FSharp.Core and FCS and if restore is _successful_, package version needs to be bumped. diff --git a/vsintegration/tests/FSharp.Editor.Tests/QuickInfoProviderTests.fs b/vsintegration/tests/FSharp.Editor.Tests/QuickInfoProviderTests.fs index f39c0a748d2..a8bb21a3573 100644 --- a/vsintegration/tests/FSharp.Editor.Tests/QuickInfoProviderTests.fs +++ b/vsintegration/tests/FSharp.Editor.Tests/QuickInfoProviderTests.fs @@ -198,90 +198,90 @@ let res8 = abs 5.0 "(extension) System.Collections.Generic.IEnumerable.GroupBy<'TSource,'TKey>(keySelector: System.Func<'TSource,'TKey>) : System.Collections.Generic.IEnumerable> 'TSource is int * string 'TKey is int") - ("Sort", - Some - "System.Array.Sort<'T>(array: 'T array) : unit + ("Sort", + Some + "System.Array.Sort<'T>(array: 'T array) : unit 'T is int") - ("let test4 x = C().FSharpGenericMethodExplitTypeParams", - Some - "member C.FSharpGenericMethodExplitTypeParams: a: 'T0 * y: 'T0 -> 'T0 * 'T0 + ("let test4 x = C().FSharpGenericMethodExplitTypeParams", + Some + "member C.FSharpGenericMethodExplitTypeParams: a: 'T0 * y: 'T0 -> 'T0 * 'T0 'T is 'a list") - ("let test5<'U> (x: 'U) = C().FSharpGenericMethodExplitTypeParams", - Some - "member C.FSharpGenericMethodExplitTypeParams: a: 'T0 * y: 'T0 -> 'T0 * 'T0 + ("let test5<'U> (x: 'U) = C().FSharpGenericMethodExplitTypeParams", + Some + "member C.FSharpGenericMethodExplitTypeParams: a: 'T0 * y: 'T0 -> 'T0 * 'T0 'T is 'U list") - ("let test6 = C().FSharpGenericMethodExplitTypeParams", - Some - "member C.FSharpGenericMethodExplitTypeParams: a: 'T0 * y: 'T0 -> 'T0 * 'T0 + ("let test6 = C().FSharpGenericMethodExplitTypeParams", + Some + "member C.FSharpGenericMethodExplitTypeParams: a: 'T0 * y: 'T0 -> 'T0 * 'T0 'T is int") - ("let test7 x = C().FSharpGenericMethodInferredTypeParams", - Some - "member C.FSharpGenericMethodInferredTypeParams: a: 'a1 * y: 'b2 -> 'a1 * 'b2 + ("let test7 x = C().FSharpGenericMethodInferredTypeParams", + Some + "member C.FSharpGenericMethodInferredTypeParams: a: 'a1 * y: 'b2 -> 'a1 * 'b2 'a is 'a0 list 'b is 'a0 list") - ("let test8 = C().FSharpGenericMethodInferredTypeParams", - Some - "member C.FSharpGenericMethodInferredTypeParams: a: 'a0 * y: 'b1 -> 'a0 * 'b1 + ("let test8 = C().FSharpGenericMethodInferredTypeParams", + Some + "member C.FSharpGenericMethodInferredTypeParams: a: 'a0 * y: 'b1 -> 'a0 * 'b1 'a is int 'b is int") - ("let test9<'U> (x: 'U) = C().FSharpGenericMethodInferredTypeParams", - Some - "member C.FSharpGenericMethodInferredTypeParams: a: 'a0 * y: 'b1 -> 'a0 * 'b1 + ("let test9<'U> (x: 'U) = C().FSharpGenericMethodInferredTypeParams", + Some + "member C.FSharpGenericMethodInferredTypeParams: a: 'a0 * y: 'b1 -> 'a0 * 'b1 'a is 'U list 'b is 'U list") - ("let res3 = [1] |>", - Some - "val (|>) : arg: 'T1 -> func: ('T1 -> 'U) -> 'U + ("let res3 = [1] |>", + Some + "val (|>) : arg: 'T1 -> func: ('T1 -> 'U) -> 'U Full name: Microsoft.FSharp.Core.Operators.(|>) 'T1 is int list 'U is int list") - ("let res3 = [1] |> List.map id", - Some - "val id: x: 'T -> 'T + ("let res3 = [1] |> List.map id", + Some + "val id: x: 'T -> 'T Full name: Microsoft.FSharp.Core.Operators.id 'T is int") - ("let res4 = (1.0,[1]) ||>", - Some - "val (||>) : arg1: 'T1 * arg2: 'T2 -> func: ('T1 -> 'T2 -> 'U) -> 'U + ("let res4 = (1.0,[1]) ||>", + Some + "val (||>) : arg1: 'T1 * arg2: 'T2 -> func: ('T1 -> 'T2 -> 'U) -> 'U Full name: Microsoft.FSharp.Core.Operators.(||>) 'T1 is float 'T2 is int list 'U is float") - ("let res4 = (1.0,[1]) ||> List.fold", - Some - "val fold: folder: ('State -> 'T -> 'State) -> state: 'State -> list: 'T list -> 'State + ("let res4 = (1.0,[1]) ||> List.fold", + Some + "val fold: folder: ('State -> 'T -> 'State) -> state: 'State -> list: 'T list -> 'State Full name: Microsoft.FSharp.Collections.List.fold 'T is int 'State is float") - ("let res4 = (1.0,[1]) ||> List.fold (fun s x -> string s +", - Some - "val (+) : x: 'T1 -> y: 'T2 -> 'T3 (requires member (+)) + ("let res4 = (1.0,[1]) ||> List.fold (fun s x -> string s +", + Some + "val (+) : x: 'T1 -> y: 'T2 -> 'T3 (requires member (+)) Full name: Microsoft.FSharp.Core.Operators.(+) 'T1 is string 'T2 is string 'T3 is float") - ("let res5 = 1 +", - Some - "val (+) : x: 'T1 -> y: 'T2 -> 'T3 (requires member (+)) + ("let res5 = 1 +", + Some + "val (+) : x: 'T1 -> y: 'T2 -> 'T3 (requires member (+)) Full name: Microsoft.FSharp.Core.Operators.(+) 'T1 is int 'T2 is int 'T3 is int") - ("let res6 = System.DateTime.Now +", - Some - "val (+) : x: 'T1 -> y: 'T2 -> 'T3 (requires member (+)) + ("let res6 = System.DateTime.Now +", + Some + "val (+) : x: 'T1 -> y: 'T2 -> 'T3 (requires member (+)) Full name: Microsoft.FSharp.Core.Operators.(+) 'T1 is System.DateTime 'T2 is System.TimeSpan 'T3 is System.DateTime") - ("let res7 = sin", - Some - "val sin: value: 'T -> 'T (requires member Sin) + ("let res7 = sin", + Some + "val sin: value: 'T -> 'T (requires member Sin) Full name: Microsoft.FSharp.Core.Operators.sin 'T is float") - ("let res8 = abs", - Some - "val abs: value: 'T -> 'T (requires member Abs) + ("let res8 = abs", + Some + "val abs: value: 'T -> 'T (requires member Abs) Full name: Microsoft.FSharp.Core.Operators.abs 'T is int") ] From cd22c575b9ce549d3ca7b1f759cf79b76eb61229 Mon Sep 17 00:00:00 2001 From: Petr Date: Wed, 22 Feb 2023 16:18:44 +0100 Subject: [PATCH 3/4] Reverting breaking code --- .../QuickInfoProviderTests.fs | 130 +++++++++--------- 1 file changed, 65 insertions(+), 65 deletions(-) diff --git a/vsintegration/tests/FSharp.Editor.Tests/QuickInfoProviderTests.fs b/vsintegration/tests/FSharp.Editor.Tests/QuickInfoProviderTests.fs index a8bb21a3573..ed7ed67d85e 100644 --- a/vsintegration/tests/FSharp.Editor.Tests/QuickInfoProviderTests.fs +++ b/vsintegration/tests/FSharp.Editor.Tests/QuickInfoProviderTests.fs @@ -197,93 +197,93 @@ let res8 = abs 5.0 Some "(extension) System.Collections.Generic.IEnumerable.GroupBy<'TSource,'TKey>(keySelector: System.Func<'TSource,'TKey>) : System.Collections.Generic.IEnumerable> 'TSource is int * string -'TKey is int") - ("Sort", - Some - "System.Array.Sort<'T>(array: 'T array) : unit -'T is int") - ("let test4 x = C().FSharpGenericMethodExplitTypeParams", - Some - "member C.FSharpGenericMethodExplitTypeParams: a: 'T0 * y: 'T0 -> 'T0 * 'T0 -'T is 'a list") - ("let test5<'U> (x: 'U) = C().FSharpGenericMethodExplitTypeParams", - Some - "member C.FSharpGenericMethodExplitTypeParams: a: 'T0 * y: 'T0 -> 'T0 * 'T0 -'T is 'U list") - ("let test6 = C().FSharpGenericMethodExplitTypeParams", - Some - "member C.FSharpGenericMethodExplitTypeParams: a: 'T0 * y: 'T0 -> 'T0 * 'T0 -'T is int") - ("let test7 x = C().FSharpGenericMethodInferredTypeParams", - Some - "member C.FSharpGenericMethodInferredTypeParams: a: 'a1 * y: 'b2 -> 'a1 * 'b2 +'TKey is int"); + ("Sort", + Some + "System.Array.Sort<'T>(array: 'T array) : unit +'T is int"); + ("let test4 x = C().FSharpGenericMethodExplitTypeParams", + Some + "member C.FSharpGenericMethodExplitTypeParams: a: 'T0 * y: 'T0 -> 'T0 * 'T0 +'T is 'a list"); + ("let test5<'U> (x: 'U) = C().FSharpGenericMethodExplitTypeParams", + Some + "member C.FSharpGenericMethodExplitTypeParams: a: 'T0 * y: 'T0 -> 'T0 * 'T0 +'T is 'U list"); + ("let test6 = C().FSharpGenericMethodExplitTypeParams", + Some + "member C.FSharpGenericMethodExplitTypeParams: a: 'T0 * y: 'T0 -> 'T0 * 'T0 +'T is int"); + ("let test7 x = C().FSharpGenericMethodInferredTypeParams", + Some + "member C.FSharpGenericMethodInferredTypeParams: a: 'a1 * y: 'b2 -> 'a1 * 'b2 'a is 'a0 list -'b is 'a0 list") - ("let test8 = C().FSharpGenericMethodInferredTypeParams", - Some - "member C.FSharpGenericMethodInferredTypeParams: a: 'a0 * y: 'b1 -> 'a0 * 'b1 +'b is 'a0 list"); + ("let test8 = C().FSharpGenericMethodInferredTypeParams", + Some + "member C.FSharpGenericMethodInferredTypeParams: a: 'a0 * y: 'b1 -> 'a0 * 'b1 'a is int -'b is int") - ("let test9<'U> (x: 'U) = C().FSharpGenericMethodInferredTypeParams", - Some - "member C.FSharpGenericMethodInferredTypeParams: a: 'a0 * y: 'b1 -> 'a0 * 'b1 +'b is int"); + ("let test9<'U> (x: 'U) = C().FSharpGenericMethodInferredTypeParams", + Some + "member C.FSharpGenericMethodInferredTypeParams: a: 'a0 * y: 'b1 -> 'a0 * 'b1 'a is 'U list -'b is 'U list") - ("let res3 = [1] |>", - Some - "val (|>) : arg: 'T1 -> func: ('T1 -> 'U) -> 'U +'b is 'U list"); + ("let res3 = [1] |>", + Some + "val (|>) : arg: 'T1 -> func: ('T1 -> 'U) -> 'U Full name: Microsoft.FSharp.Core.Operators.(|>) 'T1 is int list -'U is int list") - ("let res3 = [1] |> List.map id", - Some - "val id: x: 'T -> 'T +'U is int list"); + ("let res3 = [1] |> List.map id", + Some + "val id: x: 'T -> 'T Full name: Microsoft.FSharp.Core.Operators.id -'T is int") - ("let res4 = (1.0,[1]) ||>", - Some - "val (||>) : arg1: 'T1 * arg2: 'T2 -> func: ('T1 -> 'T2 -> 'U) -> 'U +'T is int"); + ("let res4 = (1.0,[1]) ||>", + Some + "val (||>) : arg1: 'T1 * arg2: 'T2 -> func: ('T1 -> 'T2 -> 'U) -> 'U Full name: Microsoft.FSharp.Core.Operators.(||>) 'T1 is float 'T2 is int list -'U is float") - ("let res4 = (1.0,[1]) ||> List.fold", - Some - "val fold: folder: ('State -> 'T -> 'State) -> state: 'State -> list: 'T list -> 'State +'U is float"); + ("let res4 = (1.0,[1]) ||> List.fold", + Some + "val fold: folder: ('State -> 'T -> 'State) -> state: 'State -> list: 'T list -> 'State Full name: Microsoft.FSharp.Collections.List.fold 'T is int -'State is float") - ("let res4 = (1.0,[1]) ||> List.fold (fun s x -> string s +", - Some - "val (+) : x: 'T1 -> y: 'T2 -> 'T3 (requires member (+)) +'State is float"); + ("let res4 = (1.0,[1]) ||> List.fold (fun s x -> string s +", + Some + "val (+) : x: 'T1 -> y: 'T2 -> 'T3 (requires member (+)) Full name: Microsoft.FSharp.Core.Operators.(+) 'T1 is string 'T2 is string -'T3 is float") - ("let res5 = 1 +", - Some - "val (+) : x: 'T1 -> y: 'T2 -> 'T3 (requires member (+)) +'T3 is float"); + ("let res5 = 1 +", + Some + "val (+) : x: 'T1 -> y: 'T2 -> 'T3 (requires member (+)) Full name: Microsoft.FSharp.Core.Operators.(+) 'T1 is int 'T2 is int -'T3 is int") - ("let res6 = System.DateTime.Now +", - Some - "val (+) : x: 'T1 -> y: 'T2 -> 'T3 (requires member (+)) +'T3 is int"); + ("let res6 = System.DateTime.Now +", + Some + "val (+) : x: 'T1 -> y: 'T2 -> 'T3 (requires member (+)) Full name: Microsoft.FSharp.Core.Operators.(+) 'T1 is System.DateTime 'T2 is System.TimeSpan -'T3 is System.DateTime") - ("let res7 = sin", - Some - "val sin: value: 'T -> 'T (requires member Sin) +'T3 is System.DateTime"); + ("let res7 = sin", + Some + "val sin: value: 'T -> 'T (requires member Sin) Full name: Microsoft.FSharp.Core.Operators.sin -'T is float") - ("let res8 = abs", - Some - "val abs: value: 'T -> 'T (requires member Abs) +'T is float"); + ("let res8 = abs", + Some + "val abs: value: 'T -> 'T (requires member Abs) Full name: Microsoft.FSharp.Core.Operators.abs -'T is int") +'T is int"); ] executeQuickInfoTest fileContents testCases From 25557c744c547a07d40a64cf5c228df21ca10e90 Mon Sep 17 00:00:00 2001 From: Petr Date: Wed, 22 Feb 2023 16:23:22 +0100 Subject: [PATCH 4/4] Ignoring broken file --- .fantomasignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.fantomasignore b/.fantomasignore index 1dbc12d4d73..e9a4262105f 100644 --- a/.fantomasignore +++ b/.fantomasignore @@ -90,6 +90,9 @@ src/Compiler/TypedTree/TypedTreeOps.fs src/Compiler/TypedTree/TypedTreePickle.fs src/Compiler/TypedTree/TypeProviders.fs +# https://github.com/fsprojects/fantomas/issues/2779 +vsintegration/tests/FSharp.Editor.Tests/QuickInfoProviderTests.fs + # Explicitly unformatted file that needs more care to get it to format well src/Compiler/SyntaxTree/LexFilter.fs