Omnisharp-vscode: Disable "Assuming assembly reference..." warning squigglies

Created on 20 Nov 2016  Â·  18Comments  Â·  Source: OmniSharp/omnisharp-vscode

Environment data

dotnet --info output:

.NET Command Line Tools (1.0.0-preview3-004056)

Product Information:
 Version:            1.0.0-preview3-004056
 Commit SHA-1 hash:  ccc4968bc3

Runtime Environment:
 OS Name:     ubuntu
 OS Version:  16.04
 OS Platform: Linux
 RID:         ubuntu.16.04-x64

VS Code version: 1.7.1
C# Extension version: 1.5.2

Steps to reproduce

Create new ASP.NET Core application using dotnet new -t Web, run dotnet restore from command line.

Open project in VS Code.

Observe green squigglies all over the C# code, with mouseover showing a popup along the lines of:

Assuming assembly reference 'System.Runtime, Version=4.0.20.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' used by 'Microsoft.Extensions.Configuration.FileExtensions' matches identity 'System.Runtime, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' of 'System.Runtime', you may need to supply runtime policy [tmp]

It's probably right, and the assembly references are mixed up (as far as I can tell it's actually referencing 4.1.0 and 4.3.0, no reference to 4.0.20 anywhere) but the application builds and runs fine and these green squigglies are everywhere, it's meaningless and I can't see actual important warnings for all the noise.

A way to disable this warning would be great.

Backlog Resolved-Fixed

Most helpful comment

I've created a v1.6-beta2 release of the C# extension that contains this fix, among others. See this page for information on installing beta releases

All 18 comments

This was high on my list already, but I'll use this issue to to track it.

This is a warning (CS1701) that the C# compiler issues when unifying assembly references. Essentially, the problem occurs when downstream transitive assemblies reference different versions of an assembly. Most tools disable the warning, and that still needs to be done in OmniSharp. The problem is that the OmniSharp MSBuildProjectSystem doesn't properly handle <NoWarn/>. I'm intending to get this working over the next couple of days.

Fix for this issue is here: https://github.com/OmniSharp/omnisharp-roslyn/pull/667/commits/44c5bc797d0f9f91ed723c6e8cfec5c6fe6d28da. Once we update to a newer OmniSharp, we'll produce a beta release with the fix.

I've created a v1.6-beta2 release of the C# extension that contains this fix, among others. See this page for information on installing beta releases

I uninstalled the extension, installed 1.6.0-beta2, added <NoWarn>CS1701</NoWarn> to the first PropertyGroup of the .NET Core csproj, and restarted VS Code, but it didn't make a difference--I still get the warning squiggly. Is there anything else I should be doing?

VSCode 1.7.2
.NET Command Line Tools (1.0.0-preview3-004056)

Well, you shouldn't need to add that <NoWarn> as it's disabled automatically. Also, when you specify <NoWarn> in an MSBuild file, you don't add the "CS".

If you can share your project out I'll take a look.

Happens to me with Console.WriteLine in HelloWorld.

~/Projects$ mkdir HelloWorld
~/Projects$ cd HelloWorld
~/Projects/HelloWorld$ dotnet new
Created new C# project in /Users/ncook/Projects/HelloWorld.
~/Projects/HelloWorld$ dotnet restore
  Restoring packages for /Users/ncook/Projects/HelloWorld/HelloWorld.csproj...
  Writing lock file to disk. Path: /Users/ncook/Projects/HelloWorld/obj/project.assets.json
  Generating MSBuild file /Users/ncook/Projects/HelloWorld/obj/HelloWorld.csproj.nuget.g.targets.
  Generating MSBuild file /Users/ncook/Projects/HelloWorld/obj/HelloWorld.csproj.nuget.g.props.
  Restore completed in 615.6779ms for /Users/ncook/Projects/HelloWorld/HelloWorld.csproj.

  NuGet Config files used:
      /Users/ncook/.nuget/NuGet/NuGet.Config

  Feeds used:
      https://api.nuget.org/v3/index.json
~/Projects/HelloWorld$ dotnet --info
.NET Command Line Tools (1.0.0-preview3-004056)

Product Information:
 Version:            1.0.0-preview3-004056
 Commit SHA-1 hash:  ccc4968bc3

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  10.12
 OS Platform: Darwin
 RID:         osx.10.11-x64
~/Projects/HelloWorld$ dotnet run
Hello World!

screen shot 2016-11-24 at 4 45 45 pm

Hmmm... I'm not sure how to get ahold of Preview3 any longer, but I don't think that should matter. I just grabbed the latest Preview4 build from https://github.com/dotnet/cli and don't observe the problem any longer.

✔ ~/projects/HelloWorld 
11:59 $ dotnet --info
.NET Command Line Tools (1.0.0-preview4-004124)

Product Information:
 Version:            1.0.0-preview4-004124
 Commit SHA-1 hash:  eb8e0cfa40

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  10.12
 OS Platform: Darwin
 RID:         osx.10.11-x64
 Base Path:   /usr/local/share/dotnet/sdk/1.0.0-preview4-004124
✔ ~/projects/HelloWorld 
11:59 $ dotnet new
Created new C# project in /Users/dustincampbell/projects/HelloWorld.
✔ ~/projects/HelloWorld 
11:59 $ dotnet restore
  Restoring packages for /Users/dustincampbell/projects/HelloWorld/HelloWorld.csproj...
  Writing lock file to disk. Path: /Users/dustincampbell/projects/HelloWorld/obj/project.assets.json
  Generating MSBuild file /Users/dustincampbell/projects/HelloWorld/obj/HelloWorld.csproj.nuget.g.targets.
  Generating MSBuild file /Users/dustincampbell/projects/HelloWorld/obj/HelloWorld.csproj.nuget.g.props.
  Restore completed in 994.0238ms for /Users/dustincampbell/projects/HelloWorld/HelloWorld.csproj.

  NuGet Config files used:
      /Users/dustincampbell/.nuget/NuGet/NuGet.Config

  Feeds used:
      https://api.nuget.org/v3/index.json

image

Could you check ~/projects/extensions on your machine and see if you have multiple versions of the C# extension installed?

Also, please copy-paste your OmniSharp Log here. You can find this by selecting View->Output from the menu and the selecting "OmniSharp Log" from the dropdown at the top-right corner of the Output pane.

That was it! I had another version/folder sitting in ~/.vscode/extensions. (That's despite the fact that I uninstalled; weird.) Deleted that, restarted VS Code and now I'm golden.

By the way, preview 3 is here. Link was found on this blog post.

Thank you and happy thanksgiving!

I'm very glad that was it! I've seen this happen a couple of times now. Hmmm...

Anyway, have a great holiday weekend!

capture copy

@DustinCampbell I'm getting this, but I don't understand where to look for dup C# extensions. Can you provide the full path?

[EDIT] Found this: C:\Program Files (x86)\Microsoft VS Code\resources\app\extensions ... but I don't obviously see a dup C# in this folder.

On Windows, look under %UserProfile%.vscode\extensions.

Ah .... thanks ... but no dice at C:\Users\<USER>\.vscode\extensions ...

capture copy

It looks like you haven't installed the latest beta release as mentioned above: https://github.com/OmniSharp/omnisharp-vscode/issues/967#issuecomment-262639992

Gotcha ... thanks. I thought it was just going to be the dup C# extenstion prob. I'll get the beta release on here.

The dup problem can happen _after_ installing the beta.

Install with: code --install-extension csharp-1.6.0-beta2.vsix

Was this page helpful?
0 / 5 - 0 ratings