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

Disable "Assuming assembly reference..." warning squigglies #967

Closed
ThatRendle opened this issue Nov 20, 2016 · 21 comments
Closed

Disable "Assuming assembly reference..." warning squigglies #967

ThatRendle opened this issue Nov 20, 2016 · 21 comments
Assignees
Milestone

Comments

@ThatRendle
Copy link

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.

@DustinCampbell
Copy link
Member

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.

@DustinCampbell
Copy link
Member

Fix for this issue is here: OmniSharp/omnisharp-roslyn@44c5bc7. Once we update to a newer OmniSharp, we'll produce a beta release with the fix.

@DustinCampbell
Copy link
Member

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

@nathanielcook
Copy link

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)

@DustinCampbell
Copy link
Member

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.

@nathanielcook
Copy link

nathanielcook commented Nov 24, 2016

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

@DustinCampbell
Copy link
Member

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

@DustinCampbell
Copy link
Member

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.

@nathanielcook
Copy link

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!

@DustinCampbell
Copy link
Member

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

Anyway, have a great holiday weekend!

@guardrex
Copy link

guardrex commented Dec 9, 2016

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.

@DustinCampbell
Copy link
Member

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

@guardrex
Copy link

guardrex commented Dec 9, 2016

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

capture copy

@DustinCampbell
Copy link
Member

It looks like you haven't installed the latest beta release as mentioned above: #967 (comment)

@guardrex
Copy link

guardrex commented Dec 9, 2016

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

@DustinCampbell
Copy link
Member

The dup problem can happen after installing the beta.

@dbeattie71
Copy link

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

@DustinCampbell
Copy link
Member

@mdkincaid
Copy link

Hi I am still running into this issue as of April 2021. My C# extension version is 1.23.9. It sounds like back in 2016 a fix went out, but every time I open a C# file in vscode, I get a whole slew of the "Assuming assembly reference..." errors. I can provide any information that might help.

@JoeRobich
Copy link
Member

@mdkincaid Can you open a new issue and provide the requested logs? It is likely that the underlying issue is different from this one.

@mdkincaid
Copy link

@JoeRobich Sure thing!!

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

7 participants