dotnet / vscode-csharp

Official C# support for Visual Studio Code
MIT License
2.86k stars 670 forks source link

Fake (non-existent) problems/bugs reported by c# extension in VSCode. #3806

Open StasD opened 4 years ago

StasD commented 4 years ago

Environment data

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

Runtime Environment: OS Name: Mac OS X OS Version: 10.15 OS Platform: Darwin RID: osx.10.15-x64 Base Path: /usr/local/share/dotnet/sdk/3.1.300/

Host (useful for support): Version: 3.1.4 Commit: 0c2e69caa6

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

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

VS Code version: 1.45.1 C# Extension version: 1.21.18, 1.22.0

Actual behavior

I'm working on new asp.net application created with dotnet new react.

There are fake (non-existent) problems/bugs reported by c# extension in VSCode.

They are fake, because dotnet build, and even running the app with ".NET Core Launch (web)" in the RUN panel works perfectly fine.

Example 1) Feature 'using declarations' is not available in C# 7.3. Please use language version 8.0 or greater. (for code e.g. using var cnn = DefaultCnn();) This one disappears if I add <LangVersion>8.0</LangVersion> to .csproj file, but it shouldn't be necessary.

Example 2) Duplicate 'global::System.Runtime.Versioning.TargetFrameworkAttribute' attribute (for code in obj/Debug/netcoreapp3.1/.NETCoreApp,Version=v3.1.AssemblyAttributes.cs)

Also several of these (after building release): Duplicate 'System.Reflection.AssemblyCompanyAttribute' attribute (for code in obj/Release/netcoreapp3.1/[MyProjectName].AssemblyInfo.cs)

Expected behavior

No fake warnings. All warnings should be consistent with what dotnet build does.

StasD commented 4 years ago

I managed to fix it, I think... Had standalone Mono installed. Version 6.4. So I decided to upgrade it to the latest version, 6.8. After I did that, all those fake warnings in VSCode suddenly disappeared. Still... This means there is still a problem with the c# extension. Why would it even look at standalone Mono if it ships with (or downloads on first run) its own? Especially when the installed Mono had older version... You need to fix this or update the documentation about the impact of having standalone Mono installed.

Update: Warnings about duplicate attributes re-appeared again... But at least those about 'Feature is not available in C# 7.3' seem to be gone for good.

ghost commented 4 years ago

This also happens in the normal mcr.microsoft.com/dotnet/core/sdk:3.1 docker image. That image has no mono in it whatsoever.