-
Notifications
You must be signed in to change notification settings - Fork 183
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
Optimize creation of string and value-type Dummies #1354
Comments
For sure, and this means that people could return whatever string they want. However, without any special consideration for string, we're currently finding one of the constructors and using it. On .NET Framework, I think it's
I'm not against it, but I think we'd have to do research. #1345 arose because our naive attempts to create a |
I see your point, but I think it's unlikely that anyone would rely on a
In fact, forget it; as mentioned by @ryanwischkaemper in #1345, |
That's what I feared. |
@thomaslevesque, if we're still interested in this, I'm happy to take the issue. So far it goes well. In my sandbox I have special cases for
Are you interested in others? I can easily expand to all the integral types and floating-point types, but after that my imagination peters out. |
To be honest, I don't remember exactly what problem we were trying to solve... |
Your analysis is generally correct. For most cases, this is an optimization, at best. For string, it'd keep us from running through the constructors until we found the one that worked (the first time, after which we know which one works, and we just make its arguments and invoke it). For the value types, there's not much benefit, except that we currently try to fake them before we call I'm not inclined to special case Truth be told, after I created this issue, I did have second thoughts and was keeping it around mostly because I thought you were a fan. I'd be content to close this, or severely limit the scope (to |
I've been thinking more about special-casing |
I think we should do it for string. Currently strings are created from an empty char array and the int values 0 and 0; this is just dumb... You're probably right about DateTime and Guid, though. And 👍 to move value type strategy ahead of fake strategy, since we know we can't fake value types. |
Thanks for the merge, @thomaslevesque! |
This change has been released as part of FakeItEasy 4.9.0. |
As discussed in #1348 (comment)
(@blairconrad is the first speaker, @thomaslevesque the second)
Ties to #1345.
The text was updated successfully, but these errors were encountered: