roslyn icon indicating copy to clipboard operation
roslyn copied to clipboard

IDE0072: Add missing cases to enum takes extremely long time for enums with many values.

Open vsfeedback opened this issue 3 years ago • 1 comments

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


[severity:It's more difficult to complete my work] In an application with a shared DLL across projects, an enum with many values (in my test case - 406 values - admittedly beyond the use of a typical enum), the switch expression IDE0072 refactor "add missing cases" takes extremely long - both attempts so far have gone >30 minutes before I killed the application.

Please consider a review of this feature - it's great, but the implementation smells a little bit like O(n^2) :)


Original Comments

Feedback Bot on 12/8/2022, 02:44 AM:

(private comment, text removed)

Sam Harwell [MSFT] on 12/8/2022, 01:38 PM:

(private comment, text removed)

Chris Danek on 12/9/2022, 05:40 PM:

(private comment, text removed)

Feedback Bot on 12/12/2022, 08:23 AM:

(private comment, text removed)


Original Solutions

(no solutions)

vsfeedback avatar Dec 12 '22 14:12 vsfeedback

@CyrusNajmabadi copying my comment from ADO to here:

The bulk of the work here is running the simplifier on all the switch expression cases. I believe the refactoring is generating fully-qualified references to the enum type, and then running the simplifier on them to reduce it to the simple enum name. I'm wondering if we could optimize this case by showing that if A.B.C.D simplified to C.D in a given context, then a later reference to A.B.C.E in the same context could simplify to C.E without running all the simplifier checks (specifically the speculative binding).

sharwell avatar Dec 12 '22 14:12 sharwell