1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

VSCodeでC#とF#混在プロジェクトでインテリセンスを効かせる

1
Posted at

結論

VSCode OmniSharp/C# intellisense does not see Ionide/F# lib modules/namespaces参照

はじめに

VSCodeにて、F#で作成した型を、C#から参照またはインテリセンスを効かせようと思ったんですけど

dotnet add ~~.csproj reference ~~.fsproj

で単純に追加しただけでは見れませんでした。
方法について日本語での記事がなかったので紹介してみます。
手順の原典は
VSCode OmniSharp/C# intellisense does not see Ionide/F# lib modules/namespaces
を見てください。

試した環境

  • .NET Core SDK (global.json を反映): Version: 3.1.100
  • VSCode バージョン: 1.41.1 (system setup)

方法

ビルドしたfsprojのdllの位置をReferenceとしてcsprojに追加する

例を記載すると

csprojの例
  <ItemGroup>
    <Reference Include="domain.dll"> <HintPath>..\domain\bin\Debug\netstandard2.1\win10-x86\domain.dll</HintPath></Reference>
    <ProjectReference Include="..\domain\domain.fsproj" />
  </ItemGroup>

VSCodeで使用しているOmniSharpがF#を理解してくれないので中間言語にしてから理解させている認識です。
なので参照先はF#のコードそのものではなくC#風に変換された型になります。
またF#のコードを修正した場合は、F#単品でビルドしてからOmniSharpを再起動させないと反映されません。

まとめ

インテリセンスが効くのと効かないのでは天地の違いがあるため、この方法を知ることができて大変助かりました。

1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?