views:

202

answers:

3

I used reflector to view the code of the generic dictionary collection (Dictionary<TKey, TValue>) and modified that code to make it thread safe. I want to post this code on my blog so others can review it (and tell me if I did something wrong) and also use it in their projects if they want. Legally speaking, am I allowed to do so? I modified the original code heavily (and only took a few methods from the original code not the whole thing) but the base code is still the same, could be there any potential legal issues if I do this?

Note: Just in case some will point me to implementations of a thread safe dictionary, I know that there are already implementations of a thread safe dictionary using ReaderWriterLockSlim but I don't want any locking when reading (only when writing), besides I'm using .net 2.0 not 3.5 so I can't use ReaderWriterLockSlim anyway, also I read somewhere that the performance of ReaderWriterLock in 2.0 is very poor so I don't want to use that.

+6  A: 

Unless the .NET framework is released in source form and under a license that allows you to make and distribute such modifications (typically referred to as derivative works) then, no, you are now allowed to do this.

While source to parts of the .NET framework have been released they are only available under a reference license. Straight from that page;

The Microsoft Reference Source License (Ms-RSL) is the most restrictive of the Microsoft source code licenses. The license prohibits all use of source code other than the viewing of the code for reference purposes. The intent of this license is to enable licensors to release, for review purposes only, more sensitive intellectual property assets.

If you wish to provide your own thread-safe dictionary collection than that's fine and definitely a noble goal, but you cannot base it on something that you do not have the right to modify.

Andrew Grant
+12  A: 

Microsoft's Dictionary source code is governed by a modified version of the Microsoft Reference Source License, which basically only allows you to read the code. So no, you're definitely not allowed to redistribute modified code under this license.

On the other hand, you can take Mono's implementation of Dictionary<K,V> and modify it to suite your needs, as it is licensed under the MIT/X11. It performs quite well compared to the one in .net.

Jb Evain
I was answering this one!
Romain Verdier
+1 for a nice answer that softens the blow by providing an alternative
Wim Coenen
Nice point on the Mono alternative! Also, the reference source license is only valid if you download the source specifically. If it's decompiled from the framework, the .NET Framework EULA is the license in question...
Reed Copsey
Reed: yep. In both case anyway, it's a no go :)
Jb Evain
+4  A: 
Reed Copsey