Automatically fix fixable errors
Some errors in the error list could be automatically fixed. For instance, you build your code and the error "The type 'bla' is not referenced. You must add a reference to assembly 'System.Data.Entity'" appears in the error pane. This error is easily fixed by adding the correct reference to the project, but since Studio already knows what it's looking for, it knows where it's located (GAC), why isn't there an option to fix it?
It would be nice if the error pane would have a column "Autoresolve" with for each error which migh be fixable a link "Try resolving". Studio would then try to autoresolve the problem, for instance by adding the correct reference to the project and all would be well. If there was a problem resolving the problem, Studio could display an error message telling the user the autofix didn't work and he should correct the problem himself.
In the same category, auto fixes could be applied for things like missing/extra parentheses, ; characters, etc. etc. I think the list of autoresolvable things is actually pretty long.
But please note: VS should NEVER do this on it's own. It should always be the developers action to perform an autoresolve.
5 comments
-
Benjamin Howarth commented
Also add missing using; statements. I'm walking through 200 build errors simply adding one line to each and every single file, and the IDE knows where to find the class already.
-
Philippe
commented
Add missing included in C++ code. In that case, it could be added at the end by default and the line be automatically selected so that we can move it elsewhere easily if desired.
-
Madushan Siriwardena
commented
remove unused using statements when building.. (They're pretty easy to add ... just CTRL+. but normally forget to remove and gets the top of the file cluttered.)
Also, 'fix ';' expected' compile error automatically..
-
ChrisS
commented
Also remove unused references automatically (or add that option in the tools) upon pre-release builds.
-
David Ledbetter
commented
In VB some some references are given, others you have to figure them out on your own.