dotnet / roslynator

Roslynator is a set of code analysis tools for C#, powered by Roslyn.
https://josefpihrt.github.io/docs/roslynator
Other
3.09k stars 258 forks source link

FixFormattingOfBinaryExpressionChainAnalyzer takes >1min to complete #740

Open rekna1 opened 4 years ago

rekna1 commented 4 years ago

Product and Version Used: VS2019 enterprise, 16.7.6 Roslynator version 3.0.1 Steps to Reproduce: often when I add a parameter to a constructor, press ALT-ENTER to get refactor suggestions :

VS2019 display a progress dialog that takes quite long to finish (eg. 1min20secs) image

josefpihrt commented 4 years ago

Hi, I would appreciate if you could provide sample code that causes this issue. Thanks.

rekna1 commented 4 years ago

It is a rather large code base and not open source ... It does not seems to happen in smaller projects. Also in same solution, e.g. in a simple model class it does not occur. In a MVC controller it's happens almost all the time. (There are +- 170 controllers and also T4MVC generates a lot of code for these controllers in a single file about 55000lines, maybe this has something to do with it ?).

josefpihrt commented 4 years ago

Are you saying that the issue occurs in the big file or that the issue occurs in the project that contains some big file?

rekna1 commented 4 years ago

It occurs in the project that contains some big file (if this is the cause, I don't know, but this big file contains generated partial classes for all controllers so it thought it might be of importance that I mention this...)

josefpihrt commented 4 years ago

I'm not sure if some very big file could case the delay but still it seems odd to me that it would cause 1+ min delay. Moreover, generated files are skipped during code analysis (provided that they are properly marked as generated).

I know if you have any experience with debugging VS extension but if you would like to help you could try to debug your project. I added file https://github.com/JosefPihrt/Roslynator/blob/master/docs/HowToDebugRoslynator.md that describes this process.

rekna1 commented 4 years ago

I have now same project with and without T4 template. In both solutions, I than created a simple class with a constructor with 2 arguments and then invoking the refactoring suggestions on the arguments (to create instance fields from the argument). Solution with T4 template: substantial delay, popup showing gathering suggestions. Solution without T4 template : no delays, suggestions show up immediately. So the large file T4 template has generated definitely has some to do with the delays.

josefpihrt commented 3 years ago

I believe you that the bug occurs in your code but it is very hard to fix the bug without having the code that causes the issue and without being able to reproduce the bug on my machine.

I would really appreciate if you would try to debug your project yourself if you cannot provide the code. Thanks.