Forum: IronRuby Attributes

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
3a9ff49a9e689dcbfc8242f05180cc31?d=identicon&s=25 Orion Edwards (Guest)
on 2009-02-19 01:40
(Received via mailing list)
I'd like to mock up a WCF service using IronRuby.

This presents some stumbling blocks however, in that WCF
ServiceContracts
are defined by creating an Interface and then applying attributes to it.

Interface ~= Module in IronRuby, so that would probably be fine, but how
can
I apply attributes to the module and the methods it declares?
68f1bd9e9a7d9d10f0278c6535f700fe?d=identicon&s=25 Michael Letterle (mletterle)
on 2009-02-19 02:02
(Received via mailing list)
AFAIK you can't yet.  It's one of those interop things that are on the
back
burner while language compatibility is worked on.  There's still alot of
discussion needed about how to do this...
Cb51033949ffccd982ae32c9f890f25a?d=identicon&s=25 Tomas Matousek (Guest)
on 2009-02-19 02:19
(Received via mailing list)
We currently don't support attributes. As a workaround you can define a
class in C# that will have all the attributes. The class can then
forward all functionality to Ruby (e.g. via abstract methods implemented
in a class derived in Ruby).

Tomas

From: ironruby-core-bounces@rubyforge.org
[mailto:ironruby-core-bounces@rubyforge.org] On Behalf Of Orion Edwards
Sent: Wednesday, February 18, 2009 4:20 PM
To: ironruby-core@rubyforge.org
Subject: [Ironruby-core] Attributes

I'd like to mock up a WCF service using IronRuby.

This presents some stumbling blocks however, in that WCF
ServiceContracts are defined by creating an Interface and then applying
attributes to it.

Interface ~= Module in IronRuby, so that would probably be fine, but how
can I apply attributes to the module and the methods it declares?
3a9ff49a9e689dcbfc8242f05180cc31?d=identicon&s=25 Orion Edwards (Guest)
on 2009-02-19 02:32
(Received via mailing list)
Fair enough:
Here's my thoughts on what such a thing might look like:

module IMyService
    clr_attribute ServiceContractAttribute.new("blah")

    clr_attribute OperationContractAttribute.new, :on => "SomeMethod"
    def SomeMethod; end
end

Could also have similar methods which map from string to ClassName at
runtime

clr_attr "ServiceContract"
clr_attr "OperationContract", :on => "SomeMethod"

Could also implement named parameters eg

clr_attr "ServiceContract", :name => "MyFancyContract"
clr_attr "OperationContract", :name => "CoolOperation", :on =>
"SomeMethod"


Hope this helps inspire :-)


On Thu, Feb 19, 2009 at 2:01 PM, Michael Letterle <
3a9ff49a9e689dcbfc8242f05180cc31?d=identicon&s=25 Orion Edwards (Guest)
on 2009-02-19 02:57
(Received via mailing list)
Thanks for answering that. I wrote a small C# interface and then
implemented
that from IronRuby

On Thu, Feb 19, 2009 at 1:54 PM, Tomas Matousek <
Cb51033949ffccd982ae32c9f890f25a?d=identicon&s=25 Tomas Matousek (Guest)
on 2009-02-19 03:32
(Received via mailing list)
We think in similar directions.

Tomas

From: ironruby-core-bounces@rubyforge.org
[mailto:ironruby-core-bounces@rubyforge.org] On Behalf Of Orion Edwards
Sent: Wednesday, February 18, 2009 5:18 PM
To: ironruby-core@rubyforge.org
Subject: Re: [Ironruby-core] Attributes

Fair enough:
Here's my thoughts on what such a thing might look like:

module IMyService
    clr_attribute ServiceContractAttribute.new("blah")

    clr_attribute OperationContractAttribute.new, :on => "SomeMethod"
    def SomeMethod; end
end

Could also have similar methods which map from string to ClassName at
runtime

clr_attr "ServiceContract"
clr_attr "OperationContract", :on => "SomeMethod"

Could also implement named parameters eg

clr_attr "ServiceContract", :name => "MyFancyContract"
clr_attr "OperationContract", :name => "CoolOperation", :on =>
"SomeMethod"


Hope this helps inspire :-)

On Thu, Feb 19, 2009 at 2:01 PM, Michael Letterle
<michael.letterle@gmail.com<mailto:michael.letterle@gmail.com>> wrote:
AFAIK you can't yet.  It's one of those interop things that are on the
back burner while language compatibility is worked on.  There's still
alot of discussion needed about how to do this...
On Wed, Feb 18, 2009 at 7:20 PM, Orion Edwards
<orion.edwards@gmail.com<mailto:orion.edwards@gmail.com>> wrote:
I'd like to mock up a WCF service using IronRuby.

This presents some stumbling blocks however, in that WCF
ServiceContracts are defined by creating an Interface and then applying
attributes to it.

Interface ~= Module in IronRuby, so that would probably be fine, but how
can I apply attributes to the module and the methods it declares?
_______________________________________________
Ironruby-core mailing list
Ironruby-core@rubyforge.org<mailto:Ironruby-core@rubyforge.org>
http://rubyforge.org/mailman/listinfo/ironruby-core



--
Michael Letterle
IronRuby MVP
http://blog.prokrams.com
This topic is locked and can not be replied to.