-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Closed
Labels
Area-IDECodeLensFeature - Target-Typed New`new (args)` gets the created type inferred from context`new (args)` gets the created type inferred from contextNavigation-FARFind all referencesFind all references
Milestone
Description
This issue has been moved from a ticket on Developer Community.
CodeLens constructor reference not working with target-typed new
If you have a public class with a public constructor in a class library targeting netstandard2.0, CodeLens fails to accurately report any references to that constructor from any call-site using implicit (target-typed) new.
For example:
In ClassLibrary1, targeting netstandard2.0:
namespace ClassLibrary1
{
public class Class1
{
public Class1()
{
}
}
}In ClassLibrary2, targeting net6.0:
using ClassLibrary1;
namespace ClassLibrary2;
public class Class2
{
static Class1 x = new Class1(); // OK
static Class1 y = new(); // CodeLens doesn't see this
}Now, back in Class1, look at the CodeLens indicators on the Class1 constructor. It shows only 1 reference when it should show 2.
Original Comments
Feedback Bot on 4/25/2023, 03:45 AM:
(private comment, text removed)
Original Solutions
(no solutions)
Metadata
Metadata
Assignees
Labels
Area-IDECodeLensFeature - Target-Typed New`new (args)` gets the created type inferred from context`new (args)` gets the created type inferred from contextNavigation-FARFind all referencesFind all references