Open Brodersen opened 4 years ago
Hmm, this seems to be a regression with the update to 3.1. This only seems to be happening for .fsx files, not .fs files. Probably what needs to be done is for the analyzeFsx code path:
to be updated in the same way analyzeFsproj was:
was in this PR:
https://github.com/fsprojects/fsharp-language-server/pull/70
@adamnew123456 @PhilT looking at the analyzeFsx, does the answer jump out to you?
In Neovim on Windows 10 I get something slightly different.
[undefined] [E] parameter: System.IO.FileLoadException: The given assembly name or codebase was invalid. (0x80131047)
at System.Reflection.AssemblyName.nInit()
at System.Reflection.AssemblyName..ctor(String assemblyName)
at FSharp.Compiler.SimulatedMSBuildReferenceResolver.SimulatedMSBuildResolver@28.FSharp-Compiler-ReferenceResolver-Resolver-Resolve(ResolutionEnvironment resolutionEnvironment, Tuple`2[] references, String targetFrameworkVersion, FSharpList`1 targetFrameworkDirectories, String targetProcessorArchitecture, String fsharpCoreDir, FSharpList`1 explicitIncludeDirs, String implicitIncludeDir, FSharpFunc`2 logMessage, FSharpFunc`2 logWarningOrError) (Code=SR001)
I've never looked at this codebase so don't have the first clue what it could be.
@PhilT didn't you work on the changes to ProjectManager for 3.1? Or did I just get confused by the comment stream?
No, @georgewfraser I just did a bit of testing
Oh. Well, maybe @adamnew123456 will take a look soon.
Hm. While I can't reproduce this exactly, the underlying cause of the problem seems to be the same as what I'm seeing. I get something about FSharp.Data.dll not having any type providers, because of an assembly it couldn't load.
My guess is that we're having a problem finding these assemblies because we're
referencing the compiled output of FSLS itself instead of the .NET Core
assemblies themselves. Partially this is code in FSLS
(typeof<System.Object>.Assembly.Location
), but it also seems to be the behavior
of whatever provides FSharpChecker since it does the same thing with non-framework
paths.
/home/chris/Tmp/logs/main.fsx.fsproj:
ProjectFileName: "/home/chris/Tmp/logs/main.fsx.fsproj"
SourceFiles:
- /home/chris/Tmp/logs/utils.fsx
- /home/chris/Tmp/logs/main.fsx
ReferencedProjects:
OtherOptions:
- -r:/home/chris/Apps/FSharpLanguageServer/master/bin/FSharp.Core.dll
- -r:/home/chris/Apps/FSharpLanguageServer/master/bin/Microsoft.CSharp.dll
I'm thinking that we could try to detect the "fake" framework prefix (e.g.
/home/chris/Apps/FSharpLanguageServer/master/bin/
), strip it from each of the
referenced paths we get back and insert the .NET Core prefix using a similar
method to ProjectCracker.parseProjectAssets.findRuntimePaths. Of course we don't
have any way to direct our choice of framework like we would in the
project.assets file, but we can just pick the latest framework and go with it.
After that process, any file which gets substituted and doesn't exist in the framework should just get dropped, which would fix the FSharp.Data thing. Hopefully this doesn't conflict with assemblies referenced from NuGet, but I'll test that case when I've committed the change locally.
@PhilT @Brodersen could you try this with the issue-78 branch on my repo, https://github.com/adamnew123456/fsharp-language-server/tree/issue-78?
I made the changes outlined in the last comment and they seem to be working fine for both the core framework assemblies (FSharp.Core Arrays, List, etc. and System.*) as well as some assemblies currently in my ~/.nuget. I get completion and type info for everything without any spurious errors.
With an fsx file containing only
let x = 3
I get the following problems and red lines in vs code:Running
dotnet --info
I get: