Reputation: 9478
I've searched around a bit for this and tried a few things and can't get it to work without turning some stuff off that I want on.
Normally I let Resharper have its way with namespace optimizations. In a Service implementation that's mapping DTO's to Domain Model objects it's a nice visual to create an alias for each. That way when it's late and you're sleep deprived seeing Dtos.Customer
and DomainModel.Customer
helps.
using DomainModel = MyProduct.Core.Domain.Model;
using Dtos = MyProduct.ServiceModel.Dtos;
When I run code cleanup it changes those to:
using DomainModel = MyProduct.Core.Domain.Model;
using Customer = MyProduct.Core.Domain.Model.Customer;
Does anyone do this or something similar and keep R# from whacking it?
Upvotes: 5
Views: 827
Reputation: 6249
This is something ReSharper will do when you let it: shorten references, on code cleanup.
Even though this behavior might be unwanted for you, it's technically seen correct. Because in your code it'll shorten something. And that's what the algorithm is supposed to do.
This is how the algorithm works that causes this result:
using Customer = MyProduct.Core.Domain.Model.Customer;
in your case).using Dtos = MyProduct.ServiceModel.Dtos;
is no longer in use (after all, the other using covers your shortened reference). And removes it.This is what I suspect is causing this. I cannot be 100% certain without seeing the actual usages in code. But this is most likely the cause of the refactoring.
Upvotes: 3