dotnet / roslyn

The Roslyn .NET compiler provides C# and Visual Basic languages with rich code analysis APIs.
https://docs.microsoft.com/dotnet/csharp/roslyn-sdk/
MIT License
19.09k stars 4.04k forks source link

When generating a class from an anonymous object, implicitly-named properties are ignored #75980

Closed vsfeedback closed 2 days ago

vsfeedback commented 2 days ago

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


[severity:It bothers me. A fix would be nice] if I have an anonymous object (e.g. in a select) like this:

new 
{
   SomeProperty1 = a.SomeProperty1,
   a.SomeProperty2
};

When I use the "create class" refactor option to turn this into a class, the implicitly-named properties (e.g. SomeProperty2 in the above example) are ignored.

Ideally they would be included in the new class with the same names, and the "new" statement updated to reflect this (e.g. SomeProperty2 = a.SomeProperty2)


Original Comments

Feedback Bot on 11/5/2024, 05:42 PM:

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.

Feedback Bot on 11/19/2024, 00:56 PM:

This issue is currently being investigated. Our team will get back to you if either more information is needed, a workaround is available, or the issue is resolved.

CyrusNajmabadi commented 2 days ago

I don't repro this. I get:

Image