Ionide-vscode-fsharp: Intellisense breaks when targeting multiple frameworks

Created on 23 Apr 2017  路  7Comments  路  Source: ionide/ionide-vscode-fsharp

When working in a .NET core app with multiple target frameworks:

  <PropertyGroup>
    <TargetFrameworks>netstandard1.6;net40</TargetFrameworks>
  </PropertyGroup>

dotnet restore -> dotnet build compiles successfully, but Ionide doesn't recognize any other files. It recognizes any types/modules/functions defined within the same file, but when opening a module in another file, I get "namespace or module Xyz is not defined".

If I then replace my target framework in the fsproj as follows:

  <PropertyGroup>
    <!--<TargetFrameworks>netstandard1.6;net40</TargetFrameworks>-->
    <TargetFramework>netstandard1.6</TargetFramework>
  </PropertyGroup>

delete my obj folder, dotnet restore -> dotnet build then all the intellisense starts working again.

Environment: Win10, Ionide 2.25.9, VS Code 1.11.2

related issues: #278

bug language services

Most helpful comment

Initial support for multi-targeting released in 2.27.5 - at the moment we just default to first target.

All 7 comments

Cc: @enricosada

@Krzysztof-Cieslak problem is, fsc args are specific to a target framework.
ionide should ask fsac for a specific framework ihmo (ref https://github.com/ionide/ionide-vscode-fsharp/issues/278), that's really needed moving forward.

meanwhile dunno, i can try read that property, and use the first netstandard* or netcoreapp* if nothing is specified.
I think is a sensible default.

added https://github.com/fsharp/FsAutoComplete/issues/162 to track that

Oh yeah, I do realize that choosing target etc should be real fix for that. But I still don't know how to handle it well from UX point of view.

I think that choosing first target framework from the list should be sensible default and decent workaround for now

I'll do that, like linked issue.

But how the others extensions do something similar? Config file? Where is s good place for transitory config?

I'd say it's probably some config file, UX wise it could just be a command like ctrl/cmd+shift+P > Choose TargetFramework > (scan all fsproj for possible frameworks) present list to choose from > update config

support in FSAC will be implemented by https://github.com/fsharp/FsAutoComplete/pull/168

atm will be used the first, so if <TargetFrameworks>netcoreapp1.0;net461</TargetFrameworks> => netcoreapp1.0
Starting from that, FSAC will use the correct (same as Build target) framework for all project references.

I dont have found yet a satifying hipotetical way to specifiy my preference in vscode (settings, env var in tasks.json, etc), but FSAC is ready to accept the choice, if we want to improve the UX.
Two possible:

  • a settings somewhere to choose the initial target framework.
  • better to paired with the choosen starting project becase matter a lot of project ref resolution. Guessing like now based on first .fs file open is bad and cause bugs
  • with workaround disabled (a setting? passed to FSAC in initialization?), a flow like:

    1. vscode ask FSAC to parse the fsproj
    2. FSAC reply with error, saying is crossgen and giving the list of avaiable targets frmeworks (FSAC know that)
    3. vscode ask used (with a combo?) what use
    4. vscode retry ask FSAC to parse of fsproj with the choosen target framework

Initial support for multi-targeting released in 2.27.5 - at the moment we just default to first target.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

isaacabraham picture isaacabraham  路  5Comments

isaacabraham picture isaacabraham  路  5Comments

draganjovanovic1 picture draganjovanovic1  路  3Comments

MangelMaxime picture MangelMaxime  路  4Comments

sergey-tihon picture sergey-tihon  路  6Comments