nessos/FsPickler — pull request #14 by t0yv0 (2014-03-31 19:47:30+00:00)
Title: Feature-detect .NET45 extensions on BinaryReader/BinaryWriter

How about this? With this commit, it only builds "lib/net40/FsPickler.dll" for .NET 4.0. The only functionality the project needs is extra constructors on BinaryReader/BinaryWriter with leaveOpen. With the latest commit, the following happens:

1. Detect if these constructors are defined at runtime, and if yes, use them;
2. If not available, use a shim that wraps Stream to ignore the .Close method

So the interface is the same, and unlike previous solution, there's only one assembly, and the new constructors get used on .NET 4.5.

I was not sure how to run tests, could you look into it? Running tests on .NET 4.0 especially would be important.

Other possible problems I can think of:

* in restricted contexts this may fail if code generation is not allowed (Linq Expression trees)