Looking for legacy version of System.Random from .NET 3.5

I mistakenly assumed that a seeded Random function (e.g. “new System.Random(123)”) would always return the same pseudo-random sequence. But when I upgrade to .NET 4.x equivalent, the results have changed.

As I use this function in map generation code, it creates ugly terrain seams for any players that started a map in standalone players built with the .NET 3.5 runtime version, and then load a new version built with 4.x.

Ideally I would stay on Unity 2019.1, but Unity 2019.2 has a critical bugfix I need and of course this is the version that removes support for .NET 3.5.

So is there any way to find the source code for the System.Random function that was used in the .NET 3.5 runtime that was provided with Unity 2019.1 and earlier? Then I can hardcode it in and use that instead of System.Random. I’ve trawled all over the web but there’s a huge number of different repositories of .NET, and none of them generate the results that Unity’s .NET 3.5 runtime did.

Thanks for any suggestions!

Naturally, after a week of work, I think I found it within 15 minutes of making this post.

Seems the correct System.Random source is here:

2 Likes

Next returns the same sequence as expected for me on 2019. Can you share your code that produces invalid results?