Open DFVSQY opened 1 year ago
I suspect this is related to https://github.com/OmniSharp/omnisharp-vscode/pull/5400 because it refactored some stuff around codelens provider - cc @willl @dibarbet @JoeRobich
I can see this happening for any new class (not even nested) just making class Foo {}
does not trigger code lens (no outgoing request to server) until I, for example, add a constructor.
This is also a problem for any file containing any code which isn't detected as a test class.
This is fine
[TestClass]
public class ClassTest
{
[TestMethod]
public async Task MethodTest()
{
}
}
The code below doesn't work
[TestClass]
public class ClassTest
{
[TestMethod]
public async Task MethodTest()
{
}
}
[TestClass]
public class Class2Test
{
// because there's no test method here the test code lens stops showing
}
The code below doesn't work
[TestClass]
public class ClassTest
{
// nested classes break code lens support as well
// this is where we put test releated stuff
class Utilties {}
[TestMethod]
public async Task MethodTest()
{
}
}
I have to create additional files and spread out my test code to work around this issue. It's very problematic. Please make this a priority.
@filipw This bug is important, please fix it quickly, thank you very much!
Found out some more about this bizarre behavior.
Here we see code lens working
And if we add a nested class Z it is no longer working
But if we add a method W to the nested class Z it starts working again.
So apart from being really confusing this isn't that big of a deal if all you need to do is to add a method.
This patterns also appears to repeat itself. Code lens will stop working again if we add a another empty nested class and then start working again if we add a method to that empty class. It also doesn't matter where in the file this empty class is located. An empty class is what breaks the testing code lens. Adding anything to the class, field, method, constructor makes the testing code lens come back.
Is there a plan to fix this bug? @filipw
@DFVSQY FYI You can work around this by putting a static constructor that does nothing inside any member that doesn't have any other members.
But yes... this is annoying...
Environment data
dotnet --info
output:VS Code version:
C# Extension version:
v1.25.2
OmniSharp log
Steps to reproduce
dotnet new console
command create a simple projectCopy below code to
Program.cs
file:public class FillContentEvent : A { }
line, codelens appear again:This bug exists in v1.25.2 and v1.25.1, It works well in v1.25.0.