I have 3 projects.
project 1 uses reference of project 2 and project 2 uses reference of project 3.Now this is what I want.
as with above scenario project 1 can also use classes of project 3 which I not want to do so. so how I can encapsulate classes of project 3 to be used only in project 2 and not in project 1.
here is example
class ABC is in project 3 which I am using in project 2 by referencing project 3 to project 2. and project 2 is referenced in project 1 and ABC class also become available in project 1 which it should not be.
all three projects are class libraries with .net core
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
There is a work-around that is to declare the classes as internal and use InternalsVisibleToAttribute on your project 3’s assembly to allow all internal types to be usable in/visible to the project 2. Of course the internal classes will not be usable in the project 1 as well as any other projects.
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0