0

I had this:

using Excel = Microsoft.Office.Interop.Excel;
. . .
private Excel.Application _xlApp;
private Excel.Workbook _xlBook;
private Excel.Sheets _xlSheets;
private Excel.Worksheet _xlSheet;

CodeRush said the "Excel." for _xlBook, _xlSheets, and _xlSheet (but not _xlApp) was superfluous ("Redundant type qualifier"), so I removed them:

private Excel.Application _xlApp;
private Workbook _xlBook;
private Sheets _xlSheets;
private Worksheet _xlSheet;

Then, though, on trying to compile, I got err msgs like:

The type or namespace name 'Sheets' could not be found (are you missing a using directive or an assembly reference?)

So following CodeRush's recommendation broke the build (it was easy to revert back, of course, to a compiling state), but more interesting to me is why it didn't also recommend I remove the "Excel." from "Excel.Application _xlApp"

Why does it recognize that the "Excel." prefix is needed for Application, but not for Workbook, Sheets, and Worksheet?

UPDATE

FWIW, other recommended changes by CodeRush also broke my build (noted below); additionally, it added acres of blank spaces to various places in my code when I ran "Code Cleanup" or some such command. I have uninstalled CodeRush. For my money, Resharper is a clear and decisive prevailer when comparing the two tools.

Another instance (no pun intended) where CodeRush didn't realize when a namespace needed a prefix was with this:

namespace RoboReporter.DeliveryPerformance
{
    public class DeliveryPerformance

...it advised removal of "RoboReporter." like so:

namespace DeliveryPerformance
{
    public class DeliveryPerformance

...but when I did that it thought that a reference to DeliveryPerformance (specifically, "List<DeliveryPerformance>") was pointing, not to the class, but to the namespace.

B. Clay Shannon-B. Crow Raven
  • 8,547
  • 144
  • 472
  • 862
  • 1
    Are you using CodeRush for Roslyn - install via Tools|Extensions and updates. They're re-implementing in a very clean fashion and IME the levels of bugs of the nature you're talking about is pretty minimal (and they have always been good in fixing ones you report) – Ruben Bartelink Mar 19 '16 at 09:07
  • No, I was using the "normal" trial version; as I mentioned, R# is, in my opinion, considerably better than CodeRust, so I'll stick with it for sure. – B. Clay Shannon-B. Crow Raven Mar 19 '16 at 14:42

0 Answers0