代码之家  ›  专栏  ›  技术社区  ›  Wallace

Visual Studio代码可以使用混合语言吗。NET核心解决方案?

  •  5
  • Wallace  · 技术社区  · 8 年前

    以下问题有简单的解决方法吗?或者这是VSCode和/或特定于语言的扩展中的错误?

    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
    

    我在主程序中添加了对类库的项目引用。

    dotnet add reference ..\ClassLibrary\ClassLibrary.fsproj
    

    我更新了程序。cs调用类库。

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

    我可以成功地恢复、构建和运行程序。

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

    • 当我打开程序时。cs,编辑器红色下划线F#库类型缺失。
    • 当我打开图书馆的时候。编辑红色强调了几乎所有内容。有趣的是,错误来自C编译器,而不是F编译器。
    • Ctrl-Shift-B生成具有0个警告和0个错误的项目。

    enter image description here

    enter image description here

    我还尝试单独打开项目文件夹。

    • 如果我在F库项目中打开VS代码,Intellisense就会工作。
    • 如果我在C控制台项目中打开VS代码,编辑器仍然无法识别F库中的类型。

    使现代化

    1. Ionide fsharp,2.33.0
    2. 单声道调试,0.15.7
    3. XML工具,1.9.2
    1 回复  |  直到 8 年前
        1
  •  1
  •   Wallace    8 年前

    看起来我们只需要等待 this fix

    并且,如果已安装Visual Studio Build Tools 2017,请更新到 the latest version and F# compiler workload .