The AutoComplete Function in VS2017 suggests me fully qualified using statements. I have two projects with following (simplified) structure:
Company.Contracts
IMyExample.cs
Company.Core
MyExample.cs
Now when I use IMyExample
in Class MyExample
, VS2017 suggests me a using statement like
using Company.Contracts
But I think that there was a time when VS2017 suggested me:
using Contracts
which is sufficient as the projects share the same main namespace.
How can I configure VS2017 so that it prefers simplified instead of fully qualified namespaces? In fact this is the opposite of StyleCop Rule SA1135.
Hint: I was using VS2019 before but switchted back to VS2017 because the test licence ended and I'm pretty sure, that I didn't have to correct my using statements. Maybe in VS2019 this is possible?
Maybe in VS2019 this is possible?
Sorry but the answer could be negative, I test it in VS2019 release 16.3.4 and confirm this behavior is not supported for now.
In your situation, instead of using full qualified names, you can also use the format like Contracts.ClassName
.
And for the reason why full qualified namespace is more preferred in this situation, assuming your current project Company.Core
references one assembly whose root namespace is also named Contracts
, now if VS do what you suggested, add the using Contracts
when you use functions from Company.Contracts
project, the intellisense would be confused about this. See:
In that situation you suggested, VS intellisense may get confused about what the using Contracts
really mean, another assembly whose root namespace is Contracts
or Company.Contracts
project? So I think this could be one possible reason why it suggests full qualified namespace.
And if you do need one option which supports this behavior, I suggest you can send a feature request here.The team would consider about it if this request gets enough votes.
Hope my answer makes some help:)