SimpleStubs icon indicating copy to clipboard operation
SimpleStubs copied to clipboard

Unused using directive when exculding interfaces

Open Portikus opened this issue 6 years ago • 3 comments

I referenced a project with a nuget package. The referenced project contains one interface with at least one method that returns types from the nuget package. I excluded this interface and the interface is successfully ignored by SimpleStubs. However, the using directive to the nuget package is still there and I cannot build the UnitTest project. I have to reference the nuget package to make it build.

Portikus avatar Jul 30 '18 10:07 Portikus

Does the file containing the excluded interface contain any other interfaces? SimpleStubs will copy the using directives from a given file if there is at least one interface in that file that is not ignored.

nehmebilal avatar Jul 31 '18 18:07 nehmebilal

No that's not the case. The ignored interface is the only one with a using of a type of that nuget package.

Portikus avatar Aug 01 '18 10:08 Portikus

Ok thanks. I suspect that this is copying the usings from the whole namespace, not just from the files containing non-ignored interfaces.

If the ignored interface was in a different namespace, I believe the using would not be copied. We should probably just copy the usings from the files containing used interfaces instead of resolving all usings in the namespace.

nehmebilal avatar Aug 01 '18 17:08 nehmebilal