Getting warning 'ClassXYZ conflicts with imported type ClassXYZ'

I occasionally get the following warning. It’s basically saying that a type conflicts with itself.

Warning code is CS0436.
Warning Message: The type ‘ClassXYZ’ in ‘…path…/ClassXYZ.cs’ conflicts with the imported type ‘ClassXYZ’ in ‘Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null’. Using the type defined in ‘…path…/ClassXYZ.cs’.

There’s only one file for the class in the project: ClassXYZ.cs.

This problem started when I upgraded to 2019.2.6f1.
Any ideas?

Do you have assembly definitions files in your project?

Not as far as I know. I didn’t create any such thing explicitly / deliberately.

This just cropped up this morning on a project I’ve been working on for months. Now I’m seeing the warning with every new class I create. The warning shows up in code that references the “problem” class.

maybe its some kind of cache conflict ? try closing unity and deleting Library folder, it will be recreated at next run

Well, deleting the Libary folder didn’t have any effect.

What did fix the problem was changing the access modifier on the newly created class from public to internal. The warning goes away.

It appears that all new classes I define going forward will have to be internal, not public, to avoid these warnings.

(Update: changing the access modifier to internal created its own set of problems. e.g., classes in the “Test” folder, which are part of the CSharp-Testing assembly, couldn’t access my internal classes. So, not a good solution!)

All classes in the project (150+) created before today are marked “public” and they don’t have this problem.

Something somewhere in the bowels of the project changed (some setting?); I have no idea what. It’s not related to the source code itself.

Hmmmm…
So one thing I notice is this:

In Visual Studio, on the ribbon along the top, below the bar of tabs (open files), what’s NORMALLY displayed is className → methodName.

Now, however, when I create a new class, the ribbon displays "Assembly-CSharp-Editor → className → methodName. Clicking on “Assembly-CSharp-Editor” allows me to switch to “Assembly-CSharp”.

The assembly info isn’t there for any other (older) classes. This leads me to believe that these newly created files aren’t being associated with the right assembly (?). Is there a way to check the assembly a file is associated with?

After wrestling with this for a while, and a few stops and starts of Unity and VS, the problem simply went away.
Bizarre.

Had the exact same problem, with mirror asset.
It was about having wrong files in .csproj generated for VSCode.
my solution: