Is Resharper confused by Aliases used for Assemblies in Using directives?

97 Views Asked by At

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?

1

There are 1 best solutions below

0
On BEST ANSWER

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.