fsprojects / fsharp-language-server

Other
219 stars 37 forks source link

Strange transitive dependency issue #27

Open ghost opened 5 years ago

ghost commented 5 years ago

It seems references are not correctly resolved inside intellisense when project references are nested.

Repro

$ mkdir a b c 
$ cd c/ && dotnet new classlib -lang F# 
$ cd ../b/ && dotnet new classlib -lang F# && dotnet add reference ../c/c.fsproj
$ cd ../a && dotnet new console -lang F# && dotnet add reference ../b/b.fsproj
$ echo c.Say.hello \"test\" > Program.fs && dotnet build
Microsoft (R) Build Engine version 15.8.169+g1ccb72aefa for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

  Restoring packages for /tmp/test2/b/b.fsproj...
  Restoring packages for /tmp/test2/c/c.fsproj...
  Restoring packages for /tmp/test2/a/a.fsproj...
  Restore completed in 182.93 ms for /tmp/test2/b/b.fsproj.
  Restore completed in 177.36 ms for /tmp/test2/a/a.fsproj.
  Restore completed in 182.93 ms for /tmp/test2/c/c.fsproj.
  c -> /tmp/test2/c/bin/Debug/netstandard2.0/c.dll
  b -> /tmp/test2/b/bin/Debug/netstandard2.0/b.dll
  a -> /tmp/test2/a/bin/Debug/netcoreapp2.1/a.dll

Build succeeded.
    0 Warning(s)
    0 Error(s)

Time Elapsed 00:00:05.79
$ dotnet run
Hello test
$ code ../

Relevant logs indicate that the correct fsproj and dlls are loaded. However, the following does appear:

Parsing /tmp/test/b/obj/project.assets.json
Chose framework netstandard2.0 / .NETStandard,Version=v2.0
Transitive dependencies are ["FSharp.Core/4.5.2"; "NETStandard.Library/2.0.3";
 "Microsoft.NETCore.Platforms/1.1.0"; "c/1.0.0"]
Couldn't find ../c/c.fsproj/bin/placeholder/c.dll in ["/home/david/.nuget/packages/"; "/home/david/.dotnet/sdk/NuGetFallbackFolder"]
Failed loading /home/david/.dotnet/sdk/NuGetFallbackFolder/microsoft.netcore.platforms/1.1.0/lib/netstandard1.0/_._ with error Image is too small.
Cracked project.assets.json in 5ms
Analyzing c.fsproj

Expected

Once vscode is loaded, there should be no intellisense errors

Actual

Intellisense error reports: The value, namespace, type or module 'c' is not defined. Maybe you want one of the following: b

Edit:Formatting Edit2: Extra details

ghost commented 5 years ago

I tested directly against FCS, and it does not error: https://gist.github.com/abk-x/16515099261a681e1efcb213ed408d3f

georgewfraser commented 5 years ago

Could you make a minimal example of the error and put the project in https://github.com/fsprojects/fsharp-language-server/tree/master/sample ? That would make it easy to reproduce this, and to write a test that verifies the fix works.