In the last couple of weeks, I’ve been noticing more and more cases where a C# file I’m working on will suddenly have an unexpected “using ;” statement at the top of the file. In most cases, the namespace getting added is “Leap.Unity;”, but a couple of other times it was a different namespace. Today I finally tracked down a compiler error that produces, as its Quick Fix, the suggestion to add Leap.Unity, but I don’t understand why this quick fix is being suggested, since it doesn’t seem to do anything useful.
(As a side note, it seem the reason I was mostly running into this is because of VS 2022’s default behavior of automatically including missing ‘using’ statements when pasting into a C# file. So, in any cases where VS comes up with a suspect ‘using’ statement, that will automatically get added just by pasting code. Fortunately, that option can be disabled.)
Anyway, I’m still suspicious of why Visual Studio is producing this quick fix suggestion. To get this Quick Fix suggestion, all I need to do is try to add an object to a List where the type isn’t compatible. Here’s a minimal repro:
public class ClassA
{
public string Val;
}
public class ClassB
{
public void Add()
{
var items = new List<ClassA>();
items.Add(new string('s', 8)); // This is the problem line
}
}
With this code, Visual Studio will complain that I’m trying to pass a string into a list of something else:

That’s reasonable. But the Quick Fix is to import ‘Leap.Unity’.
Importing that namespace doesn’t fix the error though (not that I would have expected it to). I’m just tired of seeing this namespace getting added when it makes no sense for it to be added.
Anyone have any ideas what could cause that quick fix to be suggested?