I am iteratively developing support libraries in C#, to be put inside a local NuGet repository which resides in my filesystem. I have noticed that whenever I add a NuGet dependency in one of my libraries, and then I reference that library in one of my projects, this automatically gains visibility to all the NuGet dependencies of my library.
This is not always wanted, because the names in my library could collide with the ones in their dependencies. Is there a way to hide dependencies of a referenced library?
Example: I am developing a function named foo() in my library Lib, and this library references a NuGet dependency Dep which also contains a foo() function. Now, if I reference Lib inside a project Proj, what will happen by default is that Proj gains visibility to both Lib and Dep and it could use the foo() from either one of them. The preferred behavior is that Proj only sees Lib.foo()
UPDATE
Maybe this could serve as an example of dependency problem: I have imported both iTextSharp and BouncyCastle in a project, and this lines of code give a compile error:
Org.BouncyCastle.X509.X509CertificateParser cp;
Org.BouncyCastle.X509.X509Certificate[] chain;
It says that both iTextSharp and BouncyCastle contain the fully qualified names of X509CertificateParser
and X509Certificate
, which means that iTextSharp refers to BouncyCastle and it is visible to anyone who refers iTextSharp in turn, even though it is not listed in the References dropdown in Visual Studio.