I am making a refactoring tool that automates several more trivial styles of code related to StyleCop. One of the things that I would like to receive with the add-in (as an additional function that the developer can enable / disable) automatically calls the "Arrange usage → Delete and sort" function. This is a simple macro call.
However, my problem is that when I scan and recursively call a macro in each file without the .cs constructor in the solution, this particular macro checks for errors before executing. If there is a syntax error, and my add-in starts to call this functionality, it gives a dialog for each file.
What I would like to do is use the same method that the function uses to check for errors on the fly, and then if an error occurs that causes a dialog to appear, just pull out a one-time notification and skip calls for each file.
I know that my add-in can check the list of errors, however, I have found many times that errors that cause problems in "Delete and Sort" do not always appear in the list. I had a list empty, then I try to "Delete and Sort" and it tells me that there are problems. Then I create a solution and, of course, it fails and errors are populated. The only solution that I see is to use the same functions as Delete and Sort to check in advance.
Does anyone know how I can detect compiler errors before creating it in the same way as "Delete and Sort Uses"?
source share