[Ironruby-core] Ruby and ObservableCollection
Jimmy Schementi
Jimmy.Schementi at microsoft.com
Thu Oct 22 14:30:04 EDT 2009
Curt, it does pick up Enumerable support, but using the Ruby methods to insert elements still causes the assert.
Thanks Tomas.
~Jimmy
From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Tomas Matousek
Sent: Thursday, October 22, 2009 11:16 AM
To: ironruby-core at rubyforge.org; Hans Hugli
Subject: Re: [Ironruby-core] Ruby and ObservableCollection
Well, that assert means there is a bug :). Working on fixing it.
Tomas
From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Curt Hagenlocher
Sent: Thursday, October 22, 2009 10:53 AM
To: ironruby-core at rubyforge.org; Hans Hugli
Subject: Re: [Ironruby-core] Ruby and ObservableCollection
ObservableCollection<T> is an IList, so it should pick up Enumerable support through IListOps, no?
From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Jimmy Schementi
Sent: Thursday, October 22, 2009 10:41 AM
To: Hans Hugli; ironruby-core at rubyforge.org
Subject: Re: [Ironruby-core] Ruby and ObservableCollection
Hans,
For Ruby and Python specific questions, the public mailing lists are preferred.
Ruby: ironruby-core at rubyforge.org<mailto:ironruby-core at rubyforge.org>
Python: users at lists.ironpython.com<mailto:users at lists.ironpython.com>
So I'm moving this to the IronRuby mailing list ...
To address your question, System.Collections.ObjectModel.ObservableCollection<T> has all protected members, so if you just create an instance and try to call a method you should see this error:
rb> $oc = System::Collections::ObjectModel::ObservableCollection[String].new
=> []
rb> $oc.insert_item "hi"
System.MissingMethodException: CLR protected method `insert_item' called for []:System::Collections::ObjectModel::ObservableCollection[String]; CLR protected methods can only be called with a receiver whose class is a Ruby subclass of the class declaring the method
However, if I subclass ObservableCollection and try to call methods I get an assert from RubyMethodGroupInfo.GetVisibleOverloads(CallArguments args, IList`1 overloads) and an exception:
rb> class OCSubclass < System::Collections::ObjectModel::ObservableCollection[String]
... def initialize
... super
... self.insert_item "hi"
... end
... end
=> nil
rb> $ocsub = OCSubclass.new
System.ArgumentNullException: Value cannot be null.
Parameter name: methods[0]
Tomas, have any idea?
~js
From: Hans Hugli
Sent: Thursday, October 22, 2009 9:29 AM
To: DLR Discussion
Subject: Ruby and ObservableCollection
Hi,
Is ObservableCollection implemented in IronRuby?
I am working with a student that can instantiate one [[ ObservableCollection[String].new ]], but calling the add method with a string results in a NullReferenceException.
Please respond to me directly. I just added myself to the alias, but pending owner approval.
If this is not the appropriate alias for this question, please let me know.
Thank you,
Hans Hugli Innovative Web team
www.visitmix.com<http://www.visitmix.com> twitter.com/hanshu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20091022/15415b2c/attachment-0001.html>
More information about the Ironruby-core
mailing list