Skip to content

Commit 7cadf41

Browse files
committed
netcore3.1 *almost* works
1 parent 917df77 commit 7cadf41

File tree

32 files changed

+96
-49
lines changed

32 files changed

+96
-49
lines changed

.vscodeignore

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ client/bin/**
44
sample/**
55
scripts/**
66
src/**
7-
!src/FSharpLanguageServer/bin/Release/netcoreapp2.0/osx.10.11-x64/publish/**
8-
!src/FSharpLanguageServer/bin/Release/netcoreapp2.0/win10-x64/publish/**
9-
!src/FSharpLanguageServer/bin/Release/netcoreapp2.0/linux-x64/publish/**
10-
!src/FSharpLanguageServer/bin/Release/netcoreapp2.0/assembly/README.md
7+
!src/FSharpLanguageServer/bin/Release/netcoreapp3.1/osx.10.11-x64/publish/**
8+
!src/FSharpLanguageServer/bin/Release/netcoreapp3.1/win10-x64/publish/**
9+
!src/FSharpLanguageServer/bin/Release/netcoreapp3.1/linux-x64/publish/**
10+
!src/FSharpLanguageServer/bin/Release/netcoreapp3.1/assembly/README.md
1111
tests/**
1212
build.vsix
1313
fsharp-language-server.sln

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ Install [LanguageClient-neovim](https://github.com/autozimu/LanguageClient-neovi
6767
Update your vim config to point LanguageClient-neovim to the FSharp Language Server for fsharp filetypes:
6868
```
6969
let g:LanguageClient_serverCommands = {
70-
\ 'fsharp': ['dotnet', '/Users/name/code/fsharp-language-server/src/FSharpLanguageServer/bin/Release/netcoreapp2.0/target/FSharpLanguageServer.dll']
70+
\ 'fsharp': ['dotnet', '/Users/name/code/fsharp-language-server/src/FSharpLanguageServer/bin/Release/netcoreapp3.1/target/FSharpLanguageServer.dll']
7171
\ }
7272
```
7373
Open an fsharp file, move the cursor, and call functions. Mappings are up to you:
@@ -96,7 +96,7 @@ dotnet publish -c Release -r osx.10.11-x64 src/FSharpLanguageServer
9696
dotnet publish -c Release -r win10-x64 src/FSharpLanguageServer
9797
```
9898

99-
Make sure that the FSharpLanguageServer (in `src/FSharpLanguageServer/bin/Release/netcoreapp2.0/PLATFORM/publish`) is in your PATH. Alternatively, you can set the path to the server executable manually within your .spacemacs user-config:
99+
Make sure that the FSharpLanguageServer (in `src/FSharpLanguageServer/bin/Release/netcoreapp3.1/PLATFORM/publish`) is in your PATH. Alternatively, you can set the path to the server executable manually within your .spacemacs user-config:
100100

101101
```
102102
(setq fsharp2-lsp-executable "/path/to/FSharpLanguageServer")

client/extension.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ function createProgressListeners(client: LanguageClient) {
216216
}
217217

218218
function binName(): string {
219-
var baseParts = ['src', 'FSharpLanguageServer', 'bin', 'Release', 'netcoreapp2.0'];
219+
var baseParts = ['src', 'FSharpLanguageServer', 'bin', 'Release', 'netcoreapp3.1'];
220220
var pathParts = getPathParts(process.platform);
221221
var fullParts = baseParts.concat(pathParts);
222222

sample/CSharpProject.AssemblyName/CSharpProject.AssemblyName.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>netcoreapp2.1</TargetFramework>
4+
<TargetFramework>netcoreapp3.1</TargetFramework>
55
<AssemblyName>CSharpProject.AssemblyName.Modified</AssemblyName>
66
</PropertyGroup>
77

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>netcoreapp2.1</TargetFramework>
4+
<TargetFramework>netcoreapp3.1</TargetFramework>
55
</PropertyGroup>
66

77
</Project>

sample/DependsOn/DependsOn.fsproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>netcoreapp2.0</TargetFramework>
5+
<TargetFramework>netcoreapp3.1</TargetFramework>
66
</PropertyGroup>
77

88
<ItemGroup>

sample/HasLocalDll/HasLocalDll.fsproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>netcoreapp2.0</TargetFramework>
5+
<TargetFramework>netcoreapp3.1</TargetFramework>
66
</PropertyGroup>
77

88
<ItemGroup>
9-
<Reference Include="../IndirectDep/bin/Debug/netcoreapp2.0/IndirectDep.dll" />
9+
<Reference Include="../IndirectDep/bin/Debug/netcoreapp3.1/IndirectDep.dll" />
1010
</ItemGroup>
1111

1212
<ItemGroup>

sample/HasTests/HasTests.fsproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFramework>netcoreapp2.0</TargetFramework>
3+
<TargetFramework>netcoreapp3.1</TargetFramework>
44
</PropertyGroup>
55
<ItemGroup>
66
<Compile Include="MyTests.fs" />

sample/IndirectDep/IndirectDep.fsproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>netcoreapp2.0</TargetFramework>
5+
<TargetFramework>netcoreapp3.1</TargetFramework>
66
</PropertyGroup>
77

88
<ItemGroup>

sample/MainProject/MainProject.fsproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>netcoreapp2.0</TargetFramework>
5+
<TargetFramework>netcoreapp3.1</TargetFramework>
66
</PropertyGroup>
77

88
<ItemGroup>

sample/NetCoreApp3/NetCoreApp3.fsproj

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>netcoreapp3.1</TargetFramework>
5+
</PropertyGroup>
6+
7+
<ItemGroup>
8+
<Compile Include="main.fs" />
9+
</ItemGroup>
10+
11+
</Project>

sample/NetCoreApp3/main.fs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
open System
2+
3+
[<EntryPoint>]
4+
let main _ =
5+
0

sample/NotBuilt/NotBuilt.fsproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>netcoreapp2.0</TargetFramework>
5+
<TargetFramework>netcoreapp3.1</TargetFramework>
66
</PropertyGroup>
77

88
<ItemGroup>

sample/ReferenceCSharp.AssemblyName/ReferenceCSharp.AssemblyName.fsproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>netcoreapp2.1</TargetFramework>
4+
<TargetFramework>netcoreapp3.1</TargetFramework>
55
</PropertyGroup>
66

77
<ItemGroup>

sample/ReferenceCSharp/ReferenceCSharp.fsproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>netcoreapp2.1</TargetFramework>
4+
<TargetFramework>netcoreapp3.1</TargetFramework>
55
</PropertyGroup>
66

77
<ItemGroup>

sample/Signature/Signature.fsproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>netcoreapp2.0</TargetFramework>
5+
<TargetFramework>netcoreapp3.1</TargetFramework>
66
</PropertyGroup>
77

88
<ItemGroup>

sample/SlnReferences/OrphanProject.fsproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>netcoreapp2.0</TargetFramework>
5+
<TargetFramework>netcoreapp3.1</TargetFramework>
66
</PropertyGroup>
77

88
<ItemGroup>

sample/SlnReferences/ReferencedProject.fsproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>netcoreapp2.0</TargetFramework>
5+
<TargetFramework>netcoreapp3.1</TargetFramework>
66
</PropertyGroup>
77

88
<ItemGroup>

scripts/debug.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
#!/usr/bin/env bash
33
set -e
44

5-
# Builds src/FSharpLanguageServer/bin/Release/netcoreapp2.0/osx.10.11-x64/publish/FSharpLanguageServer
5+
# Builds src/FSharpLanguageServer/bin/Release/netcoreapp3.1/osx.10.11-x64/publish/FSharpLanguageServer
66
dotnet publish -c Release -r osx.10.11-x64 src/FSharpLanguageServer
77
echo 'Press F5 to debug the new build of F# language server'

src/FSharpLanguageServer/FSharpLanguageServer.fsproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>netcoreapp2.0</TargetFramework>
5+
<TargetFramework>netcoreapp3.1</TargetFramework>
66
<RuntimeIdentifiers>win10-x64;osx.10.11-x64;linux-x64</RuntimeIdentifiers>
77
</PropertyGroup>
88

@@ -18,7 +18,7 @@
1818
</ItemGroup>
1919

2020
<ItemGroup>
21-
<PackageReference Include="FSharp.Compiler.Service" Version="27.0.1" />
21+
<PackageReference Include="FSharp.Compiler.Service" Version="34.1.1" />
2222
<PackageReference Include="HtmlAgilityPack" Version="1.8.4" />
2323
</ItemGroup>
2424

src/FSharpLanguageServer/Program.fs

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ module FSharpLanguageServer.Program
22

33
open LSP.Log
44
open FSharp.Compiler
5+
open FSharp.Compiler.Text
56
open FSharp.Compiler.SourceCodeServices
67
open System
78
open System.Diagnostics
@@ -137,7 +138,12 @@ let private testFunctions(parse: FSharpParseFileResults): (string list * Ast.Syn
137138
| _ -> false
138139
let isTestFunction(binding: Ast.SynBinding): bool =
139140
let attrs = match binding with Ast.Binding(_, _, _, _, attrs, _, _, _, _, _, _, _) -> attrs
140-
List.exists isTestAttribute attrs
141+
let mutable found = false
142+
for list in attrs do
143+
for a in list.Attributes do
144+
if isTestAttribute(a) then
145+
found <- true
146+
found
141147
let name(binding: Ast.SynBinding): string list =
142148
match binding with
143149
| Ast.Binding(_, _, _, _, _, _, _, Ast.SynPat.LongIdent(Ast.LongIdentWithDots(ids, _), _, _, _, _, _), _, _, _, _) ->
@@ -222,7 +228,7 @@ type Server(client: ILanguageClient) =
222228
| None ->
223229
try
224230
let parsingOptions, _ = checker.GetParsingOptionsFromProjectOptions(projectOptions)
225-
let! parse = checker.ParseFile(file.FullName, sourceText, parsingOptions)
231+
let! parse = checker.ParseFile(file.FullName, SourceText.ofString(sourceText), parsingOptions)
226232
return Ok(parse)
227233
with e ->
228234
return Error(e.Message)
@@ -245,7 +251,7 @@ type Server(client: ILanguageClient) =
245251
| Ok(projectOptions), Some(sourceText, sourceVersion) ->
246252
let recompile = async {
247253
let timeCheck = Stopwatch.StartNew()
248-
let! force = checker.ParseAndCheckFileInProject(file.FullName, sourceVersion, sourceText, projectOptions)
254+
let! force = checker.ParseAndCheckFileInProject(file.FullName, sourceVersion, SourceText.ofString(sourceText), projectOptions)
249255
dprintfn "Checked %s in %dms" file.Name timeCheck.ElapsedMilliseconds
250256
match force with
251257
| parseResult, FSharpCheckFileAnswer.Aborted -> return Error(asDiagnostics parseResult.Errors)
@@ -484,7 +490,7 @@ type Server(client: ILanguageClient) =
484490
// Check file
485491
let sourceVersion = docs.GetVersion(sourceFile) |> Option.defaultValue 0
486492
let timeCheck = Stopwatch.StartNew()
487-
let! _, maybeCheck = checker.ParseAndCheckFileInProject(sourceFile.FullName, sourceVersion, sourceText, projectOptions)
493+
let! _, maybeCheck = checker.ParseAndCheckFileInProject(sourceFile.FullName, sourceVersion, SourceText.ofString(sourceText), projectOptions)
488494
dprintfn "Checked %s in %dms" sourceFile.Name timeCheck.ElapsedMilliseconds
489495
match maybeCheck with
490496
| FSharpCheckFileAnswer.Aborted -> dprintfn "Aborted checking %s" sourceFile.Name
@@ -744,11 +750,11 @@ type Server(client: ILanguageClient) =
744750
dprintfn "...scan %s" sourceFile.Name
745751
match maybeMatchesQuery(p.query, sourceFile) with
746752
| None -> ()
747-
| Some sourceText ->
753+
| Some(sourceText) ->
748754
try
749755
dprintfn "...parse %s" sourceFile.Name
750756
let parsingOptions, _ = checker.GetParsingOptionsFromProjectOptions(projectOptions)
751-
let! parse = checker.ParseFile(sourceFile.FullName, sourceText, parsingOptions)
757+
let! parse = checker.ParseFile(sourceFile.FullName, SourceText.ofString(sourceText), parsingOptions)
752758
for declaration, container in findDeclarations(parse) do
753759
if matchesQuery(p.query, declaration.Name) then
754760
all.Add(asSymbolInformation(declaration, container))
@@ -763,7 +769,7 @@ type Server(client: ILanguageClient) =
763769
match projects.FindProjectOptions(file), getOrRead(file) with
764770
| Ok(projectOptions), Some(sourceText) ->
765771
let parsingOptions, _ = checker.GetParsingOptionsFromProjectOptions(projectOptions)
766-
let! parse = checker.ParseFile(file.FullName, sourceText, parsingOptions)
772+
let! parse = checker.ParseFile(file.FullName, SourceText.ofString(sourceText), parsingOptions)
767773
if file.Name.EndsWith(".fs") then
768774
let fns = testFunctions(parse)
769775
let fsproj = FileInfo(projectOptions.ProjectFileName)
@@ -795,7 +801,7 @@ type Server(client: ILanguageClient) =
795801
match projects.FindProjectOptions(file), getOrRead(file) with
796802
| Ok(projectOptions), Some(sourceText) ->
797803
let parsingOptions, _ = checker.GetParsingOptionsFromProjectOptions(projectOptions)
798-
let! parse = checker.ParseFile(file.FullName, sourceText, parsingOptions)
804+
let! parse = checker.ParseFile(file.FullName, SourceText.ofString(sourceText), parsingOptions)
799805
match findSignatureImplementation(parse, name) with
800806
| [range] ->
801807
return resolveGoToImplementation(p, file, range)

src/FSharpLanguageServer/ProjectManager.fs

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ open FSharp.Data
1111
open FSharp.Data.JsonExtensions
1212
open LSP.Types
1313
open FSharp.Compiler.SourceCodeServices
14+
open FSharp.Compiler.Text
1415
open ProjectCracker
1516

1617
type private ResolvedProject = {
@@ -78,10 +79,19 @@ type ProjectManager(checker: FSharpChecker) =
7879

7980
/// Find base dlls
8081
/// Workaround of https://github.com/fsharp/FSharp.Compiler.Service/issues/847
82+
let fsharpCore =
83+
let dir = Path.GetDirectoryName(typeof<FSharp.Collections.List<_>>.Assembly.Location)
84+
let relative = [ "FSharp.Core.dll" ]
85+
[ for d in relative do
86+
let f = FileInfo(Path.Combine(dir, d))
87+
if f.Exists then
88+
yield f
89+
else
90+
dprintfn "Couldn't find %s in %s" d dir
91+
]
8192
let dotNetFramework =
8293
let dir = Path.GetDirectoryName(typeof<System.Object>.Assembly.Location)
8394
let relative = [
84-
"FSharp.Core.dll"
8595
"Microsoft.CSharp.dll"
8696
"Microsoft.VisualBasic.dll"
8797
"Microsoft.Win32.Primitives.dll"
@@ -238,11 +248,13 @@ type ProjectManager(checker: FSharpChecker) =
238248
/// Analyze a script file
239249
let analyzeFsx(fsx: FileInfo) =
240250
dprintfn "Creating project options for script %s" fsx.Name
241-
let source = File.ReadAllText(fsx.FullName)
242-
let inferred, errors = checker.GetProjectOptionsFromScript(fsx.FullName, source, fsx.LastWriteTime, assumeDotNetFramework=false) |> Async.RunSynchronously
251+
let source = SourceText.ofString(File.ReadAllText(fsx.FullName))
252+
let inferred, errors = checker.GetProjectOptionsFromScript(fsx.FullName, source, loadedTimeStamp=fsx.LastWriteTime, assumeDotNetFramework=true) |> Async.RunSynchronously
243253
let combinedOtherOptions = [|
244254
for p in dotNetFramework do
245255
yield "-r:" + p.FullName
256+
for p in fsharpCore do
257+
yield "-r:" + p.FullName
246258
for o in inferred.OtherOptions do
247259
// If a dll is included by default, skip it
248260
let matchesName(f: FileInfo) = o.EndsWith(f.Name)
@@ -253,7 +265,7 @@ type ProjectManager(checker: FSharpChecker) =
253265
let options = {inferred with OtherOptions = combinedOtherOptions}
254266
printOptions(options)
255267
{
256-
sources=[for f in inferred.SourceFiles do yield FileInfo(f)]
268+
sources=[for f in options.SourceFiles do yield FileInfo(f)]
257269
options=options
258270
target=FileInfo("NoOutputForFsx")
259271
errors=Conversions.asDiagnostics(errors)
@@ -303,7 +315,7 @@ type ProjectManager(checker: FSharpChecker) =
303315
UnresolvedReferences = None
304316
UseScriptResolutionRules = false
305317
}
306-
// Log what we inferred
318+
// Log what we options
307319
printOptions(options)
308320
{
309321
sources=cracked.sources

src/LSP/LSP.fsproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFramework>netcoreapp2.0</TargetFramework>
3+
<TargetFramework>netcoreapp3.1</TargetFramework>
44
</PropertyGroup>
55

66
<ItemGroup>

src/ProjectCracker/ProjectCracker.fs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ type JsonValue with
7676
result
7777

7878
let private frameworkPreference = [
79+
"netcoreapp3.1", ".NETCoreApp,Version=v3.1";
80+
"netcoreapp3.0", ".NETCoreApp,Version=v3.0";
7981
"netcoreapp2.2", ".NETCoreApp,Version=v2.2";
8082
"netcoreapp2.1", ".NETCoreApp,Version=v2.1";
8183
"netcoreapp2.0", ".NETCoreApp,Version=v2.0";
@@ -199,7 +201,11 @@ let private parseProjectAssets(projectAssetsJson: FileInfo): ProjectAssets =
199201
// }
200202
// }
201203
let autoReferenced = HashSet<string>()
202-
for name, dep in root?project?frameworks.[shortFramework]?dependencies.Properties do
204+
let dependencies =
205+
match root?project?frameworks.[shortFramework].TryGetProperty("dependencies") with
206+
| Some(dependencies) -> dependencies.Properties
207+
| None -> [| |]
208+
for name, dep in dependencies do
203209
if dep.TryGetProperty("autoReferenced") = Some(JsonValue.Boolean(true)) then
204210
autoReferenced.Add(name) |> ignore
205211
let version = chooseVersion(name)

src/ProjectCracker/ProjectCracker.fsproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFramework>netcoreapp2.0</TargetFramework>
3+
<TargetFramework>netcoreapp3.1</TargetFramework>
44
</PropertyGroup>
55

66
<ItemGroup>

tests/FSharpLanguageServer.Tests/FSharpLanguageServer.Tests.fsproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
3-
<TargetFramework>netcoreapp2.0</TargetFramework>
3+
<TargetFramework>netcoreapp3.1</TargetFramework>
44
</PropertyGroup>
55
<ItemGroup>
66
<Compile Include="Common.fs" />

0 commit comments

Comments
 (0)