dotnet / vscode-csharp

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

Getting incorrect ambiguity errors in project #2706

Open motor75 opened 5 years ago

motor75 commented 5 years ago

Environment data

dotnet --info output: .NET Core SDK (reflecting any global.json): Version: 2.1.403 Commit: 04e15494b6

Runtime Environment: OS Name: Windows OS Version: 10.0.15063 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\2.1.403\

Host (useful for support): Version: 2.1.5 Commit: 290303f510

.NET Core SDKs installed: 2.1.4 [C:\Program Files\dotnet\sdk] 2.1.103 [C:\Program Files\dotnet\sdk] 2.1.201 [C:\Program Files\dotnet\sdk] 2.1.202 [C:\Program Files\dotnet\sdk] 2.1.400 [C:\Program Files\dotnet\sdk] 2.1.403 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed: Microsoft.AspNetCore.All 2.1.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.1.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.1.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.App 2.1.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.1.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.1.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 2.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.0.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.0.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.0.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]

To install additional .NET Core runtimes or SDKs: https://aka.ms/dotnet-download VS Code version: 1.29.1 C# Extension version: 1.17.1

Steps to reproduce

1) I've been working on a C# project for a while - up until a couple weeks ago, I haven't had any issues. However, in the last 2 weeks, each time I add a new file I keep getting ambiguity errors during the real-time compiling of the project. The errors go away as soon as I debug the project and the compiler re-compiles the project. As shown in the attached screen shot, it seems to think that there are two different folders with the same files in it - the only difference is the case of the folders (one is in all caps where the other one is not). I circled what I'm referring to in the screen shot. Is there a setting somewhere to tell it to ignore case of the folder? I thought this was the default on Windows OS.

Expected behavior

No errors

Actual behavior

Getting Ambiguity Errors capture

motor75 commented 5 years ago

Just to clarify - there is only one folder and the MessageType.cs file is only there once...see attached screen shots... capture capture

akshita31 commented 5 years ago

@motor75 Is it possible to share a sample folder that would help us analyze the issue ?

motor75 commented 5 years ago

@akshita31 - I have attached a zip file with any sensitive connection strings in the JSON files removed (just the values, not the keys).

Also - as seems to be the case when OmniSharp stops compiling altogether as I noted in my other issue, I closed VS Code and reopened it and everything is fine. I was thinking of uninstalling and reinstalling Omnisharp - but I don't want to adjust my environment if these are true issues that need to be fixed. cdmrest.zip

akshita31 commented 5 years ago

@motor75 I opened your project and tried to add a file as well but everything seems to work fine for me.

akshita31 commented 5 years ago

I faced a similar issue in vscode when once I renamed a folder and changed the case, somehow it was thinking I still have the old folder as well as the new one. Not sure though if that might be the case here. Maybe something messing with git ?

Does this problem happen if you do a new dotnet console project.

motor75 commented 5 years ago

I don't specifically recall renaming the file above "MessageType.cs" - but after I did get all the ambiguity errors, I did rename the directory from "CDMRest" to "cdmrest". That seemed to have no effect on the errors. I'll see if I can recreate the issue by renaming a file and report back.

rchande commented 5 years ago

@motor75 I believe this was fixed with https://github.com/OmniSharp/omnisharp-roslyn/pull/1357. Can you try setting the option omnisharp.path to latest to and see if that helps?

motor75 commented 5 years ago

@rchande I made the setting change and will let you know; although before the change I haven't noticed this issue lately. I have had a couple VS Code updates since so maybe that fixed it? I'll keep you posted. Thx!

rchande commented 5 years ago

@motor75 We also created a beta release of the C# extension itself if you want to try that: https://github.com/OmniSharp/omnisharp-vscode/releases/tag/v1.18.0-beta5

jeet0007 commented 4 years ago

Here is how i got the problem I cloned a project. Then it had few errors so i had to clone again. Thats the problem i used the same name and saved in the same location as the previous one. Here is how I fixed it Step 1: Open vs code and remove all the Recent open projects. Step 2: I removed all the repos from my device that had the same location. In my case was the folder. I deleted the folder Step 3: Create a new folder and clone again.

icavalheiro commented 3 years ago

Any updates on this issue? I just added a "@inject" at my document and now I can't get rid of this annoying message (project compiles just fine, btw) image

hero3616 commented 2 years ago

Is there any update on this I'm having the same issue with Chillicream's Strawberry Shake code generation in VS Code. Visual Studio 2022 doesn't show the errors, only VS Code. image

amirihusayn commented 2 years ago

This problem also happens for me when i develop game in unity game engine. When adding new C# file inside vs code, unity compiles scripts and there is no error with scripts inside engine console; But vs code code completion doesn't work in that new added file and this error occurs. Renaming C# file or adding new C# file makes this error to happen. Every time I have to reload the workspace again for solving this issue.