c# - Fine-grained visibility for 'internal' members -


recently reading partitioning code .net assemblies , stumbled upon nice suggestion this post: "reduce number of .net assemblies strict minimum".

i couldn't agree more! , 1 of reasons see often, people want isolate piece of code, make types/methods internal , put them separate project.

there many other reasons (valid , not) splitting code several assemblies, if want isolate components/apis while still having them located in 1 library, how can that?

namespace myassembly.someapiinternals {      //methods class should not       //be used outside myassembly.someapiinternals      internal class foo      {                         internal void boo() { }      } }  namespace myassembly.anotherpart {      public class program      {                         public void test()            {                var foo = myassembly.someapiinternals.foo();                foo.boo(); //ok, not compiler error red flag @ least            }      } }              

how can 1 restrict type/method being used other types/methods in same assembly outside namespace?

(i'm going give few answers myself , see how people vote.)

thanks!

you put code in different assemblies, merge assemblies ilmerge in post-build step...


Comments

Popular posts from this blog

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

c++ - Convert big endian to little endian when reading from a binary file -

openssl - Load PKCS#8 binary key into Ruby -