Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebSharper doesn't work with Visual Studio Code #1103

Closed
mjarosie opened this issue Jun 4, 2020 · 12 comments
Closed

WebSharper doesn't work with Visual Studio Code #1103

mjarosie opened this issue Jun 4, 2020 · 12 comments

Comments

@mjarosie
Copy link

mjarosie commented Jun 4, 2020

I'm still not sure if that's WebSharper, VSCode or Ionide-fsharp extension issue that I'm dealing with, I'd appreciate if someone tried it out to see if my problem is reproducible.

I'm developing with VSCode (most examples from https://github.com/websharper-samples recommend it, so maybe it's some kind of a regression error). When I open any code that uses WebSharper - VSCode features are reduced. For example, no errors are highlighted, unused imports are not detected, no tooltips appear.

Steps to reproduce:

dotnet new websharper-web -lang f# -n ws-test
cd ws-test
dotnet restore
code .

(Moving) picture is worth thousand words:

vscode-websharper

Compare it to say console app:

vscode-console

or SAFE:

vscode-SAFE

Different projects work, which proves that it's not an issue with my VSCode setup, I've been trying to figure out what's the difference between these projects, but not even sure what to look at...

$ dotnet --info
.NET Core SDK (reflecting any global.json):
 Version:   3.1.300
 Commit:    b2475c1295

Runtime Environment:
 OS Name:     ubuntu
 OS Version:  20.04
 OS Platform: Linux
 RID:         linux-x64
 Base Path:   /usr/share/dotnet/sdk/3.1.300/

Host (useful for support):
  Version: 3.1.4
  Commit:  0090613580

.NET Core SDKs installed:
  2.1.806 [/usr/share/dotnet/sdk]
  3.1.300 [/usr/share/dotnet/sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.All 2.1.18 [/usr/share/dotnet/shared/Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.18 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 3.1.4 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.1.18 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.4 [/usr/share/dotnet/shared/Microsoft.NETCore.App]

Visual Studio Code:

Version: 1.45.1 (system setup)
Commit: 5763d909d5f12fe19f215cbfdd29a91c0fa9208a
Date: 2020-05-14T08:27:35.169Z
Electron: 7.2.4
Chrome: 78.0.3904.130
Node.js: 12.8.1
V8: 7.8.279.23-electron.0
OS: Windows_NT x64 10.0.19041

Ionide-fsharp extension version: 4.11.1

I'm using WSL2 Ubuntu if that makes any difference.

@granicz
Copy link
Member

granicz commented Jun 4, 2020

I wonder if the Sdk in the project file has to do with it: the WebSharper client-server app template uses Sdk="Microsoft.NET.Sdk.Web" - perhaps Ionide can't deal with it anymore?

@granicz
Copy link
Member

granicz commented Jun 4, 2020

Regardless, this is annoying indeed. The Getting Started video on the WebSharper home page uses VSC (although with C#, but should also work and did work with F#/Ionide). @Krzysztof-Cieslak any idea about why the code service could be broken in a WS project inside Ionide? Are we missing something in the project file?

@Krzysztof-Cieslak
Copy link

Hmm... it's something weird going on - it seems that project is loaded correctly as it's shown in Ionide solution explorer, and initial line lenses are displayed correctly. Also, it seems line lenses are getting updated - they lose exact type information after you removed a bunch of code.

@mjarosie can you try to reproduce it outside of WSL - we had reports of some issues when using Ionide with it.

@isaacabraham
Copy link

I'm pretty sure that Sdk.Web isn't the issue, because that's what we use with all of our web projects these days.

@Krzysztof-Cieslak
Copy link

If SDK.Web was an issue project wouldn't load at all. Here it seems everything is fine but errors are not populating. Which suggest some issue with file URIs, likely due to mishandling of WSL paths.

@granicz
Copy link
Member

granicz commented Jun 5, 2020

I just tried on a fresh Windows box with latest VSC and Ionide, same issue there :( I am getting hover info, but no errors/warnings.

@Jand42
Copy link
Member

Jand42 commented Jun 5, 2020

The problem does seem to be caused by WebSharper.Fsharp.targets whichs appends arguments to OtherFlags then redirects the F# compiler tool to be the WS one instead of regular fsc.exe. So then this causes a problem with FsAutoComplete, its backend project cracker+checker fails on the unexpected flags instead of ignoring them.

@Krzysztof-Cieslak Do you know any way how these <OtherFlags>... setters could be made so that they do not apply for Ionide/FsAutoComplete but run when built? Thanks!

Options to resolve on the WebSharper architecture side:

  1. Revert to WS build task being one running after standard CoreCompile instead of replacing it (as WebSharper for C# does). Some performance loss is possible as project is double-checked, although fsc.exe build is more efficient than FCS due to not needing to keep as much assembly contents information for observing.
  2. Pass extra arguments to wsfsc.exe in some other way. My idea would be to use a --resource:obj/wsconfig.json that is generated with a build task before CoreCompile and contains all resolved WebSharper build configs (resolved from hand-written wsconfig.json, and project MSBuild properties). This is just an embedded resource file as far as FsAutoComplete cares, but wsfsc.exe can parse it instead.

@granicz
Copy link
Member

granicz commented Jun 6, 2020

@Jand42 Can you paste in a full set of OtherFlags we are using?

@Krzysztof-Cieslak
Copy link

It’s surprising that other features seems to be working in such case. Maybe you could set this additional other flag only if MsBuild is not in DesignTimeBuild?

@Jand42
Copy link
Member

Jand42 commented Jun 7, 2020

@Krzysztof-Cieslak Thanks a lot for the suggestion, I am testing added DesignTimeBuild/BuildingProject checks.

@Jand42
Copy link
Member

Jand42 commented Jun 7, 2020

@mjarosie @Krzysztof-Cieslak Hi, this is now released with https://github.com/dotnet-websharper/core/releases/tag/4.6.4.404

@Jand42 Jand42 closed this as completed Jun 8, 2020
@granicz
Copy link
Member

granicz commented Aug 3, 2023

(Tracking a similar issue... FYI, the original fix was mistagged - here is the commit.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants