-
Notifications
You must be signed in to change notification settings - Fork 50
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
Generated mocks do not handle generic functions #8
Comments
Thanks for raising this issue. Generic methods aren't supported yet. But I'll look at implementing this ASAP. |
That would be great. I was trying to think of how to handle this myself, just modifying the generated mock but I was coming up short. What are you thinking as a possible solution? |
It seems like we can use Same goes for capturing types. Returning generic types gets a little tricky but we can cast our stubbed value to the generic type in the return statement. What do you think?
|
I think this looks great! Thank you for being so attentive and quick to come up with a solution. Would you be able to merge the changes in? Right now I am working on switching some older mocks over to use your generator and I have one I can not yet switch without this change. |
No problem. I’m still working on the fix but I’ll upload it as soon as it’s done. |
I've added this feature now and uploaded the app here. One note, I couldn't support methods with |
Fantastic! Thanks for being so attentive. Your library has saved us a lot of time and made it easier to teach those that are learning about tests. |
Okay so what I am seeing here is a little bit different than what you had posted above in the edge case that an array of generic type is one of the parameters or the return type also
|
Thanks for raising this case and I’m glad this plugin is saving you some time. The information I get from SourceKit is really basic (just a string for a parameter type) which is why my plugin won’t recognise the type within an array (and many other cases). I’m working on ditching it in favour of a custom syntax parser which I’m writing myself. But I’ll make generics my priority when it’s done. Let’s leave this issue open and I’ll write any updates here. |
Sounds good! Let me know if you need anything. For the time being I just swapped out "T" for "Any" and left a note that it needed to be done if the mock was regenerated. Works great :) |
The release to fix your generic array is finally ready 🎉 I've replaced SourceKit with a custom parser which will hopefully speed things up going forward. There are still some types that aren't supported yet (see the README) but I'll add support for them soon. |
fantastic thank you! |
Any news on this issue? |
Protocols which contain generic functions can not be generated because the generic type can not be determined.
ex, this function:
Will generate as:
Where type 'T' is undeclared.
The text was updated successfully, but these errors were encountered: