views:

89

answers:

1

Once or twice I have been running into the following issue:

Classes I want to reuse in my applications (and possibly redistribute) exist in the .NET Framework assemblies, but are marked internal or private. So it is impossible to reuse them directly. One way is to disassemble them, pick the pieces you need, put them in a different namespace, recompile (this can be some effort, but usually works quite well).

My question is: Is this legal? Is this only legal for the classes of the Framework which are available as source code anyway? Is it illegal?

I think that Microsoft marks them internal or private primarily so that they don't have to support them or can change the interfaces later. But some pieces - be it SharePoint or WCF - are almost impossible to properly extend by only using public classes from the apis. And rewriting everything from scratch generates a huge amount of effort, before you even start solving the problem you intended to solve.

This is in my eyes not a "dirty" approach per se. The classes Microsoft ships are obviously well tested, if I reuse them under a different namespace I have "control" over them. If Microsoft changes the original implementation, my code won't be affected (some internals in WCF changed quite a bit with v4).

It is not a super-clean approach. I would much prefer Microsoft making several classes public, because there are some nice classes hidden inside the framework.

+2  A: 

From wikipedia: link

The source code is made available to view for reference purposes only, mainly to be able to view Microsoft classes source code while debugging.[16] Developers may not distribute or modify the code for commercial or non-commercial purposes.[17]

Everything I have heard is paraphrased from this. You can view it, but you can't alter, repackage, etc.

I guess you could look at it as a reference if you really need to create your own thing. What I would consider, however, is should you be trying to do what you are wanting to do? Normally, if the core framework doesn't work for you, I'd say use a different language/framework. It's also possible it's a bad design smell.

Andy_Vulhop