Skip to content

Commit

Permalink
Add empty, disabled tests for go-to-def on C# symbol scenario
Browse files Browse the repository at this point in the history
  • Loading branch information
Krzysztof-Cieslak committed Apr 12, 2024
1 parent 9c91c2c commit bc827fb
Show file tree
Hide file tree
Showing 7 changed files with 88 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information.
#-------------------------------------------------------------------------------------------------------------

ARG DOTNETCORE_VERSION=7.0.201
ARG DOTNETCORE_VERSION=7.0.400
FROM mcr.microsoft.com/dotnet/sdk:${DOTNETCORE_VERSION}

# Avoid warnings by switching to noninteractive
Expand Down
39 changes: 39 additions & 0 deletions test/FsAutoComplete.Tests.Lsp/GoToTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,32 @@ open Utils.Utils
open Utils.TextEdit
open Helpers.Expecto.ShadowedTimeouts

let executeProcess (wd: string) (processName: string) (processArgs: string) =
let psi = new Diagnostics.ProcessStartInfo(processName, processArgs)
psi.UseShellExecute <- false
psi.RedirectStandardOutput <- true
psi.RedirectStandardError <- true
psi.CreateNoWindow <- true
psi.WorkingDirectory <- wd
let proc = Diagnostics.Process.Start(psi)
let output = new Text.StringBuilder()
let error = new Text.StringBuilder()
proc.OutputDataReceived.Add(fun args -> output.Append(args.Data) |> ignore)
proc.ErrorDataReceived.Add(fun args -> error.Append(args.Data) |> ignore)
proc.BeginErrorReadLine()
proc.BeginOutputReadLine()
proc.WaitForExit()
{| ExitCode = proc.ExitCode; StdOut = output.ToString(); StdErr = error.ToString() |}

///GoTo tests
let private gotoTest state =
let server =
async {
let path = Path.Combine(__SOURCE_DIRECTORY__, "TestCases", "GoToTests")

let csharpPath = Path.Combine(__SOURCE_DIRECTORY__, "TestCases", "GoToCSharp")
let _buildInfo = executeProcess csharpPath "dotnet" "build"

let! (server, event) = serverInitialize path defaultConfigDto state
do! waitForWorkspaceFinishedParsing event

Expand Down Expand Up @@ -266,6 +286,25 @@ let private gotoTest state =
(sprintf "File '%s' should exist locally after being downloaded" localPath)
})

ptestCaseAsync
"Go-to-definition from C# file"
(async {
let! server, _path, externalPath, _definitionPath = server

let p: TextDocumentPositionParams =
{ TextDocument = { Uri = Path.FilePathToUri externalPath }
Position = { Line = 26; Character = 23 } }

let! res = server.TextDocumentDefinition p

match res with
| Result.Error e -> failtestf "Request failed: %A" e
| Result.Ok None -> failtest "Request none"
| Result.Ok(Some _res) ->
//Do some assertions
()
})

testCaseAsync
"Go-to-type-definition"
(async {
Expand Down
7 changes: 7 additions & 0 deletions test/FsAutoComplete.Tests.Lsp/TestCases/GoToCSharp/Class1.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace GoToCSharp {

public class Class1
{

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,6 @@ let o v = Some v
type B() =
member val Value = Some "" with get,set
let b = B()
b.Value |> ignore
b.Value |> ignore

let cc = GoToCSharp.Class1()
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,7 @@
<PackageReference Include="Giraffe" Version="4.0.1" />
<PackageReference Update="FSharp.Core" Version="4.7.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\GoToCSharp\GoToCSharp.csproj" />
</ItemGroup>
</Project>
28 changes: 28 additions & 0 deletions test/FsAutoComplete.Tests.Lsp/TestCases/GoToTests/GoToTests.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.31903.59
MinimumVisualStudioVersion = 10.0.40219.1
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "GoToTests", "GoToTests.fsproj", "{6800DC59-9582-42D8-AFCC-CF37FBAB0B47}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GoToCSharp", "..\GoToCSharp\GoToCSharp.csproj", "{9983CEFF-1E39-4DCD-BCF3-025919E52871}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{6800DC59-9582-42D8-AFCC-CF37FBAB0B47}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6800DC59-9582-42D8-AFCC-CF37FBAB0B47}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6800DC59-9582-42D8-AFCC-CF37FBAB0B47}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6800DC59-9582-42D8-AFCC-CF37FBAB0B47}.Release|Any CPU.Build.0 = Release|Any CPU
{9983CEFF-1E39-4DCD-BCF3-025919E52871}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9983CEFF-1E39-4DCD-BCF3-025919E52871}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9983CEFF-1E39-4DCD-BCF3-025919E52871}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9983CEFF-1E39-4DCD-BCF3-025919E52871}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal

0 comments on commit bc827fb

Please sign in to comment.