Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can Visual Studio Code work with mixed-language, .NET Core solutions?

Is there a simple fix for the following? Or is this a bug in VSCode and/or the language-specific extensions?

I created two projects and a solution like this:

dotnet new library -lang F# -o .\ClassLibrary
dotnet new console -lang C# -o .\MainProgram
dotnet new sln
dotnet sln add .\ClassLibrary\ClassLibrary.fsproj
dotnet sln add .\MainProgram\MainProgram.csproj

I added a project reference to the ClassLibrary from within the MainProgram.

dotnet add reference ..\ClassLibrary\ClassLibrary.fsproj

I updated the Program.cs to call the ClassLibrary.

static void Main(string[] args)
{
    ClassLibrary.Say.hello("world.");
}

I can restore, build, and run the program successfully.

dotnet restore
dotnet run -p .\MainProgram\MainProgram.csproj

The problem is when I open the solution folder in Visual Studio Code.

  • When I open Program.cs, the editor red-underlines the F# library types as being missing.
  • When I open Library.fs, the editor red-underlines pretty much everything. Interestingly, the errors are from a C# compiler, not an F# compiler.
  • Ctrl-Shift-B builds the projects with 0 Warning(s) and 0 Error(s).
  • VSCode's Problems windows displays 12 compiler errors.

enter image description here

enter image description here

I have also tried opening the project folders separately.

  • If I open VS Code in the F# library project, Intellisense works.
  • If I open VS Code in the C# console project, the editor still does not recognize the types from F# library.

Update

I have VS Code version 1.15.1, with five extensions installed.

  1. C#, 1.12.1
  2. Ionide-fsharp, 2.33.0
  3. Language PL/SQL, 1.0.4
  4. Mono Debug, 0.15.7
  5. XML Tools, 1.9.2
like image 881
Wallace Kelly Avatar asked Nov 08 '22 18:11

Wallace Kelly


1 Answers

Looks like we just need to wait for this fix.

And, if you have Visual Studio Build Tools 2017 installed, update to the latest version and F# compiler workload.

like image 143
Wallace Kelly Avatar answered Nov 13 '22 00:11

Wallace Kelly