roslyn icon indicating copy to clipboard operation
roslyn copied to clipboard

using the intellisense suggestion, 'collection initialized can be simplified', 'Find All References' does not report the reference.

Open vsfeedback opened this issue 1 month ago • 0 comments

This issue has been moved from a ticket on Developer Community.


[severity:It bothers me. A fix would be nice] When I define a collection class with only the default constructor then create an instance of it using 'instance = [];', right-clicking the default constructor and selecting 'Find All References', indicates no references are found.

If I instead use new() to create the instance, references are reported. The same issue arises when with an IEnumerable<T> constructor. Using the explicit new(values) constructor resolves references while [.. values] does not.

This is annoying when refactoring code since I now have to search for all references to the class to find the constructor usage.

Example:

class WordList : Collection&lt;Word&gt;
{
    public WordList()
    { }

public WordList(IEnumerable&lt;Word&gt; words)
    { }
}

class Consumer
{
    readonly WordList _guesses;

public Consumer()
    {
        // reference is not resolved.
        _guesses = [];
    }

public Consumer(IEnumerable&lt;Word&gt; words)
    {
         // reference is not resolved.
        _guesses = [.. words];
    }
}
   ...
}

Original Comments

Feedback Bot on 9/2/2025, 06:55 AM:

We have directed your feedback to the appropriate engineering team for further evaluation. The team will review the feedback and notify you about the next steps.

Shi Kang Hoe (Centific Technologies Inc) [MSFT] on 9/11/2025, 10:01 AM:

Thank you for taking the time to log this issue!
Do you still repro this issue now? I can’t repro this issue in VS2022 Enterprise (Version 17.14.14 (September 2025)).

In order to investigate your issue further, could you help to confirm several questions?

  1. Could you upgrade your VS to the latest version and try again?
  2. If the issue still exists, can you provide us a repro video using https://www.screentogif.com/ or a similar tool?

We look forward to hearing from you!

Dan.Travison on 9/11/2025, 07:08 PM:

I’ve upgraded VS to Version 17.14.14 and still see the issue.

I’ve attached a simple console app that clearly shows the issue.
ConsoleApp.zip

The problem repros consistently in both 17.14.14 and 17.14.13.

Shi Kang Hoe (Centific Technologies Inc) [MSFT] on 9/12/2025, 03:35 AM:

Thanks for your sharing the detail steps, I can reproduce the issue through your shared steps and this issue has been escalated for further investigation, if there is any process, I will inform you immediately.

vsfeedback avatar Dec 04 '25 22:12 vsfeedback