cleverla.blogg.se

Visual studio code cleanup
Visual studio code cleanup






In the previous examples we saw one of the more common tiny flaws that can appear in our code: unused using statements. Now let´s move into how we can make use of the cleanup code feature to increase our productivity. This is a very simple example of how the Visual Studio code analysis works to help us to produce better quality code.

visual studio code cleanup

As shown in the following picture VS is offering us the option to Remove Unnecesary Usings. When we move the mouse cursor over them a light bulb appears: if we click the light bulb, we are given some suggestions about how to deal with the problem. The code analysis feature of Visual Studio helps us by first identifying and signalling the issue: the unused using sentences are greyed out, and second by providing useful fixes.

visual studio code cleanup

Notice also that if Visual Studio were not to automatically warn us about such details, many of those style flaws would be easily overlooked and therefore not fixed. We could manually remove the superfluous using statements: doable but tedious.

visual studio code cleanup

Naturally, that won’t break our code, but nonetheless those lines of code are utterly unnecessary, and from a point of view of legibility they are not doing us any favours. After spending hours tweaking a particular part of the code, we are left with group of unused using sentences. That image represents an everyday situation for a. Take a look at this picture: It seems we do not really need System.Text and Let’s see a basic example of what Visual Studio code analysis can do for us.

visual studio code cleanup

Well, Visual Studio includes some of that functionality out of the box: code styles and cleanup code. You are probably familiar with tools like Re-sharper, and know how useful they are not only to automatically detect code smells, but to suggest fixes. In this post we are going to see how some of the Visual Studio 2019 code analysis features can help us to improve the quality of our code and save us a lot of time in the process of cleaning up and organising our code.








Visual studio code cleanup