mbraceproject / FsPickler

A fast multi-format message serializer for .NET
http://mbraceproject.github.io/FsPickler/
MIT License
326 stars 52 forks source link

Feature-detect .NET45 extensions on BinaryReader/BinaryWriter #14

Closed t0yv0 closed 10 years ago

t0yv0 commented 10 years ago

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:

t0yv0 commented 10 years ago

In the end I actually don't know which is better - so feel free to ignore this PR if you prefer #13.

Advantages of #14:

Advantages of #13:

eiriktsarpalis commented 10 years ago

Ok, I'll just go ahead and close this. I will update nuget as soon as I test this with .NET 4.0

t0yv0 commented 10 years ago

Would be much appreciated!

As I suggest in the #14 thread, you might get away with testing on .NET 4.5 by "emulating" 4.0 - forcing the shims to run. Not as good as testing on .NET 4.0 but should be good enough, I don't expect problems here..