[Ironruby-core] Ruby and ObservableCollection

Jimmy Schementi Jimmy.Schementi at microsoft.com
Thu Oct 22 13:41:04 EDT 2009


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?


From: Hans Hugli
Sent: Thursday, October 22, 2009 9:29 AM
To: DLR Discussion
Subject: Ruby and ObservableCollection


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/24987ff9/attachment-0001.html>

More information about the Ironruby-core mailing list