Page 1 of 2
[return:AttributeName]
Posted:
Mon Jun 01, 2009 4:41 pm
by gauthier
Is there a way to do like c#:
- Code: Select all
[return:AttributeName]
public object MethodName(){
return null;
}
Re: [return:AttributeName]
Posted:
Mon Jun 01, 2009 4:53 pm
by Charles
No, I guess there isn't. What do you think the syntax should be? Here are the current test cases:
<workspace>/Tests/320-misc-two/800-attributesAlthough the source will look better in your local editor with syntax highlighting.
Re: [return:AttributeName]
Posted:
Mon Jun 01, 2009 5:21 pm
by gauthier
it could be
def methodName as dynamic
has return(AttributeName(someValue="value")), Another(withAnotherValue="another one")
return 1
or anyother idea that looks better?
also, I'm in need for attribute on method parameters:
- Code: Select all
void MethodName([AttributeName]object argument){}
could be
def methodName(argument has AttributeName as Object)
pass
Re: [return:AttributeName]
Posted:
Mon Jun 01, 2009 7:13 pm
by Charles
Can you provide some actual attribute names you will be using for return and parameter attributes? I just want to see some concrete examples from your own use.
Re: [return:AttributeName]
Posted:
Tue Jun 02, 2009 1:25 pm
by gauthier
Re: [return:AttributeName]
Posted:
Tue Jun 02, 2009 9:00 pm
by Charles
Thanks. For parameters, I'm thinking:
use Castle.MonoRail.Framework
class ProductController inherits SmartDispatcherController
def create(prod as Product has DataBind('product'))
pass
which follows the same format as methods where "has Attribute" follows "as Type".
For return attributes I was thinking of just using the "return" keyword as a prefix:
class Foo
def getStates(countryCode as String) as State[]
has return JSONReturnBinder
return stateRepository.fetchAllByCountry(Country(countryCode))
Thoughts? Feelings?
Re: [return:AttributeName]
Posted:
Wed Jun 03, 2009 1:01 pm
by gauthier
Chuck,
the only inconsistence with the parameter attribute is that the "has AttributeName" occurs somewhat after the parameter name to which it is attached,
but you are right that this is consistent with class and method declarations (however mostly occuring on another line) so it may be the right solution.
as for the second sample, that feel quite good to me
what others think about that?
Re: [return:AttributeName]
Posted:
Fri Jun 05, 2009 12:41 am
by Charles
I have added the attributes for parameters in the Cobra repository. changeset:2102
Try it out and let me know if you have any problems.
I'll try to do the "return" attribute soon.
Re: [return:AttributeName]
Posted:
Fri Jun 05, 2009 5:08 pm
by gauthier
Chuck, that's working all along for my purpose, thank you!
Re: [return:AttributeName]
Posted:
Fri Jun 05, 2009 8:28 pm
by Charles
No problem. Now I've added support for the "return" target in changeset:2103. Try it out and let me know how it goes.