-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
It generates the same string being called in a sequence #26
Comments
This looks like a bug in Xeger.cs which has been ported from here. It's been a long-long time since I did all this, and I currently don't have Java installed on my local to compare with the Java version. I'd be curious to see if the problem persists if one could port the new Xeger stuff from this repo instead. |
Also, I can't remember if Xeger guarantees that the generated strings should be unique, but from what I see in the source code, the issue might be here, and I'd start by comparing it with the this one. (These are just notes for me, so I can remember where to start looking at. I'm not asking you to do the work―pull requests are always welcome, though.) |
Thanks you, it's ok for now. |
This issue remains in .NET framework. The underlying cause for this is the behaviour of Because of this, if you rapidly do
I've created an issue in the Autofixture Repo: AutoFixture/AutoFixture#1183 |
Perhaps we can fix this in .NET Framework by specifying the seed value. |
Maybe by shamelessly using the implementation in System.Random in .net core? The implementation can be seen here: Random.cs ... and the PR with the improvement and considerations here: dotnet/coreclr#2192 In short it uses an internal Would this implementation be overkill? It even ensures that different appdomains do not get the same sequences. |
Thank you for investigating 👍 💯 Random.cs is licensed under MIT license, so I think it should be OK to copy some parts from that file and use them here. Options→ One option would be to change private static unsafe int GenerateGlobalSeed()
{
int result;
Interop.GetRandomBytes((byte*)&result, sizeof(int));
return result;
} (Note that → Another option would be to do it exactly as they're doing it, having (Even if making the seed creation thread-safe, I'm not entirely sure that all the other Xeger/Fare parts are thread-safe...) Feel free to pick any option you want though. Happy to look into your PR 🚀 |
Will do. I've started off with the failing test, and will push an implementation to my fork later. |
Document workaround for issue #26 It generates the same string being called in a sequence
One improvement is to use the following (already released) overload: Line 42 in 703c5e2
It's then up to the caller to supply a |
As discussed in moodmosaic/Fare#26
run 1
run 2
run 3
The text was updated successfully, but these errors were encountered: