Skip to content

CodeLens constructor reference not working with target-typed new across projects #67956

@vsfeedback

Description

@vsfeedback

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

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions