You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To be able to use Sourcery to generate code for such things like test doubles or dependency injection container it's vital to be able to access information about methods defined in class (or even on a protocol?).
To start method can be modeled like this:
classMethod:NSObject{classParameter:NSObject{varargumentLabel:StringvarparameterName:Stringvartype:String}varparameters:[Parameter]varshortName:String//does not include external parameters namesvarfullName:StringvarreturnType:StringvaraccessLevel:AccessLevelvarisStatic:BoolvarisClass:Bool}
Then in template it might be used something like this (taking Dobby as an example):
{% for type in types.classes %}
class {{ type.name }}Mock: {{ type.name }} {
{% for method in type.methods %}
override func {{ method.shortName }}({% for parameter in method.parameters %}{% if parameter.argumentLabel %}{{ parameter. argumentLabel }} {% endif %}{{ parameter.parameterName}}: {{ parameter.type }}{% endfor %}) -> {{ method.returnType }} {
/* record a method call */
}
}
{% endfor %}
The text was updated successfully, but these errors were encountered:
Another good idea, we should avoid using tuple as that might not be accessible via reflection. We'll just create an inner type for the MethodParameter.
I wonder if I should add something to readme/contributing doc about why the code here is more of an objective-c rather than how you'd write real swift code, due to the fact it's using it allows us to leverage the runtime in templates.
To be able to use Sourcery to generate code for such things like test doubles or dependency injection container it's vital to be able to access information about methods defined in class (or even on a protocol?).
To start method can be modeled like this:
Then in template it might be used something like this (taking Dobby as an example):
The text was updated successfully, but these errors were encountered: