0

I noticed this in my .cs file, which looks like I might be "mixing metaphors" or at least being redundant by having both "Microsoft.Office.Interop" and "Microsoft.Office.Interop.Excel" in my list of usings directives:

using System.Runtime.InteropServices;
using MSExcel = Microsoft.Office.Interop;
using Microsoft.Office.Interop.Excel;

Resharper, when Inspecting for Code Issues in Solution, normally flags unused using directives, but in this case it peeped not a peep regarding "using MSExcel = Microsoft.Office.Interop;" even though when I commented it out to see what would happen, the solution compiles fine - so it has fooled Resharper, I guess. So does this mean this is a known "hole in Resharper's swing" and I should suspect the necessity of any aliased using directives?

B. Clay Shannon-B. Crow Raven
  • 8,547
  • 144
  • 472
  • 862

1 Answers1

1

By default, this option in R# Options > C# > Namespace Imports is enabled:

Do not remove using alias directives if alias name differs from the imported type name

Because if the alias name is non-trivial you may have a reason outside of R#'s knowledge to have it.

Disabling the option will show the directive as redundant.

Steve Klösters
  • 9,427
  • 2
  • 42
  • 53