Re: [Mono-dev] Issues with System.Random

2010-03-20 Thread Adrian Willenbücher
Here is the revised version. It now contains a unit test for Random() as well as code for deserializing from old and new Random object. One deserialization test loads an object serialized with the current version from Test/resources/Random.old. I used BinaryFormatter for the tests, as

Re: [Mono-dev] Issues with System.Random

2010-03-17 Thread Adrian Willenbücher
Kornél Pál wrote: You can use the OnDeserializedAttribute and NonSerializedAttribute attributes. Unfortunately that doesn't allow me to incorporate the serialized state. Instead, I think I found a better solution by explicitly (de)serializing the object. It first tries to deserialize the

Re: [Mono-dev] Issues with System.Random

2010-03-17 Thread Adrian Willenbücher
Andreas Nahr wrote: + throw new ArgumentNullException (buffer is null.); is clearly an error. First parameter is the argument name, not some descriptive text. That shouldn't be so hard to fix. Besides, the current implementation has the same error in Next(int)

Re: [Mono-dev] Issues with System.Random

2010-03-17 Thread Adrian Willenbücher
Robert Jordan wrote: Implementing an interface is a breaking change of the API. That's why Konél was mentioning OnDeserializedAttribute. Thanks for the info, I didn't know that (I'm pretty new to C#, Mono and .NET). The only alternative I could come up with is this: [Serializable]

Re: [Mono-dev] Issues with System.Random

2010-03-16 Thread Adrian Willenbücher
Andreas Nahr wrote: I won't comment on the algorithm itself (keep in mind that the existing one already was replaced once with a better one which failed miserably in real world apps, so had to be reverted). I tested a sequence of 68 million 32-bit values for randomness using the Diehard test

[Mono-dev] Issues with System.Random

2010-03-15 Thread Adrian Willenbücher
...@thestuff.net) // Ben Maurer (bmau...@users.sourceforge.net) +// Adrian Willenbücher (awillenbuec...@gmx.de) // // (C) 2001 Bob Smith. http://www.thestuff.net // (C) 2003 Ben Maurer // - -// // Copyright (C) 2004 Novell, Inc (http://www.novell.com) // // Permission is hereby