Xerxes Battiwalla
2009-Jun-23 04:03 UTC
[Ironruby-core] Dynamic Binding fails if abstract event not implemented
Hi - I''ve just downloaded the latest IR source from GitHub and have a problem with what looks like a regression from v0.4. We have an interface defining an event which is implemented by an abstract class in C#. In Ruby, we create an implementation of the abstract class and call only a subset of methods as we require them. The 0.4 version played nicely and would only do the dynamic binding of methods we required at the time we called them, however the latest version of IR seems to try and bind the event (even though we don''t hook up to it) and can''t find an implementation in ruby so it throws a TypeLoadException citing the adder for the event does not have an implementation. A reproducible case is pasted below. Hoping someone would be able to shed light on whether this is intentional, and if so what we can do to implement the event in ruby. *************************** using System; namespace HelloWorldApp { public interface IHelloWorld { event EventHandler SomeEvent; } public abstract class AbstractHelloWorld : IHelloWorld { public abstract event EventHandler SomeEvent; } } *************************** require "HelloWorldApp.dll" class HelloWorlder < HelloWorldApp::AbstractHelloWorld end @hello_app = HelloWorlder.new #barf *************************** D:\source\dotnet\IronRubyInteropBug>ir ruby_test.rb mscorlib:0:in `_TermCreateClass'': Method ''add_SomeEvent'' in type ''IronRuby.Classes.AbstractHelloWorld$1'' from assembly ''Snippets.scripting, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'' does not have an implementation. (System::TypeLoadException) from mscorlib:0:in `CreateTypeNoLock'' from mscorlib:0:in `CreateType'' from c:\IronRuby\ndp\fx\src\Core\Microsoft\Scripting\Actions\DynamicMetaObjectBinder.cs:107:in `Bind'' from c:\IronRuby\ndp\fx\src\Core\Microsoft\Scripting\Actions\CallSiteBinder.cs:85:in `BindCore'' from ruby_test.rb:6 Any assistance appreciated - cheers! -xerx
Tomas Matousek
2009-Jun-23 04:49 UTC
[Ironruby-core] Dynamic Binding fails if abstract event not implemented
Definitely a bug. I''ve filed it under http://ironruby.codeplex.com/WorkItem/View.aspx?WorkItemId=1628. Tomas -----Original Message----- From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Xerxes Battiwalla Sent: Monday, June 22, 2009 9:04 PM To: ironruby-core at rubyforge.org Subject: [Ironruby-core] Dynamic Binding fails if abstract event not implemented Hi - I''ve just downloaded the latest IR source from GitHub and have a problem with what looks like a regression from v0.4. We have an interface defining an event which is implemented by an abstract class in C#. In Ruby, we create an implementation of the abstract class and call only a subset of methods as we require them. The 0.4 version played nicely and would only do the dynamic binding of methods we required at the time we called them, however the latest version of IR seems to try and bind the event (even though we don''t hook up to it) and can''t find an implementation in ruby so it throws a TypeLoadException citing the adder for the event does not have an implementation. A reproducible case is pasted below. Hoping someone would be able to shed light on whether this is intentional, and if so what we can do to implement the event in ruby. *************************** using System; namespace HelloWorldApp { public interface IHelloWorld { event EventHandler SomeEvent; } public abstract class AbstractHelloWorld : IHelloWorld { public abstract event EventHandler SomeEvent; } } *************************** require "HelloWorldApp.dll" class HelloWorlder < HelloWorldApp::AbstractHelloWorld end @hello_app = HelloWorlder.new #barf *************************** D:\source\dotnet\IronRubyInteropBug>ir ruby_test.rb mscorlib:0:in `_TermCreateClass'': Method ''add_SomeEvent'' in type ''IronRuby.Classes.AbstractHelloWorld$1'' from assembly ''Snippets.scripting, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'' does not have an implementation. (System::TypeLoadException) from mscorlib:0:in `CreateTypeNoLock'' from mscorlib:0:in `CreateType'' from c:\IronRuby\ndp\fx\src\Core\Microsoft\Scripting\Actions\DynamicMetaObjectBinder.cs:107:in `Bind'' from c:\IronRuby\ndp\fx\src\Core\Microsoft\Scripting\Actions\CallSiteBinder.cs:85:in `BindCore'' from ruby_test.rb:6 Any assistance appreciated - cheers! -xerx _______________________________________________ Ironruby-core mailing list Ironruby-core at rubyforge.org http://rubyforge.org/mailman/listinfo/ironruby-core
Xerxes Battiwalla
2009-Jun-23 05:42 UTC
[Ironruby-core] Dynamic Binding fails if abstract event not implemented
great - thanks for the follow up, Tomas. Is there a workaround we could use in the meantime? Really keen to get Cucumber going ;) -Xerx On Tue, Jun 23, 2009 at 2:49 PM, Tomas Matousek<Tomas.Matousek at microsoft.com> wrote:> Definitely a bug. I''ve filed it under http://ironruby.codeplex.com/WorkItem/View.aspx?WorkItemId=1628. > > Tomas > > -----Original Message----- > From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Xerxes Battiwalla > Sent: Monday, June 22, 2009 9:04 PM > To: ironruby-core at rubyforge.org > Subject: [Ironruby-core] Dynamic Binding fails if abstract event not implemented > > Hi - I''ve just downloaded the latest IR source from GitHub and have a > problem with what looks like a regression from v0.4. > > We have an interface defining an event which is implemented by an > abstract class in C#. In Ruby, we create an implementation of the > abstract class and call only a subset of methods as we require them. > The 0.4 version played nicely and would only do the dynamic binding of > methods we required at the time we called them, however the latest > version of IR seems to try and bind the event (even though we don''t > hook up to it) and can''t find an implementation in ruby so it throws a > TypeLoadException citing the adder for the event does not have an > implementation. > > A reproducible case is pasted below. Hoping someone would be able to > shed light on whether this is intentional, and if so what we can do to > implement the event in ruby. > > *************************** > using System; > > namespace HelloWorldApp > { > ? ?public interface IHelloWorld > ? ?{ > ? ? ? ?event EventHandler SomeEvent; > ? ?} > > ? ?public abstract class AbstractHelloWorld : IHelloWorld > ? ?{ > ? ? ? ?public abstract event EventHandler SomeEvent; > ? ?} > } > > *************************** > require "HelloWorldApp.dll" > > class HelloWorlder < HelloWorldApp::AbstractHelloWorld > end > > @hello_app = HelloWorlder.new #barf > > *************************** > D:\source\dotnet\IronRubyInteropBug>ir ruby_test.rb > mscorlib:0:in `_TermCreateClass'': Method ''add_SomeEvent'' in type > ''IronRuby.Classes.AbstractHelloWorld$1'' from assembly > ''Snippets.scripting, Version=0.0.0.0, Culture=neutral, > PublicKeyToken=null'' does not have an implementation. > (System::TypeLoadException) > ? ? ? ?from mscorlib:0:in `CreateTypeNoLock'' > ? ? ? ?from mscorlib:0:in `CreateType'' > ? ? ? ?from c:\IronRuby\ndp\fx\src\Core\Microsoft\Scripting\Actions\DynamicMetaObjectBinder.cs:107:in > `Bind'' > ? ? ? ?from c:\IronRuby\ndp\fx\src\Core\Microsoft\Scripting\Actions\CallSiteBinder.cs:85:in > `BindCore'' > ? ? ? ?from ruby_test.rb:6 > > > Any assistance appreciated - cheers! > > -xerx > _______________________________________________ > Ironruby-core mailing list > Ironruby-core at rubyforge.org > http://rubyforge.org/mailman/listinfo/ironruby-core > > _______________________________________________ > Ironruby-core mailing list > Ironruby-core at rubyforge.org > http://rubyforge.org/mailman/listinfo/ironruby-core >
Tomas Matousek
2009-Jun-23 06:51 UTC
[Ironruby-core] Dynamic Binding fails if abstract event not implemented
Could you derive from AbstractHelloWorld in C# and implement the abstract event and then derive from this derived class in Ruby? Tomas -----Original Message----- From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Xerxes Battiwalla Sent: Monday, June 22, 2009 10:43 PM To: ironruby-core at rubyforge.org Subject: Re: [Ironruby-core] Dynamic Binding fails if abstract event not implemented great - thanks for the follow up, Tomas. Is there a workaround we could use in the meantime? Really keen to get Cucumber going ;) -Xerx On Tue, Jun 23, 2009 at 2:49 PM, Tomas Matousek<Tomas.Matousek at microsoft.com> wrote:> Definitely a bug. I''ve filed it under http://ironruby.codeplex.com/WorkItem/View.aspx?WorkItemId=1628. > > Tomas > > -----Original Message----- > From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Xerxes Battiwalla > Sent: Monday, June 22, 2009 9:04 PM > To: ironruby-core at rubyforge.org > Subject: [Ironruby-core] Dynamic Binding fails if abstract event not implemented > > Hi - I''ve just downloaded the latest IR source from GitHub and have a > problem with what looks like a regression from v0.4. > > We have an interface defining an event which is implemented by an > abstract class in C#. In Ruby, we create an implementation of the > abstract class and call only a subset of methods as we require them. > The 0.4 version played nicely and would only do the dynamic binding of > methods we required at the time we called them, however the latest > version of IR seems to try and bind the event (even though we don''t > hook up to it) and can''t find an implementation in ruby so it throws a > TypeLoadException citing the adder for the event does not have an > implementation. > > A reproducible case is pasted below. Hoping someone would be able to > shed light on whether this is intentional, and if so what we can do to > implement the event in ruby. > > *************************** > using System; > > namespace HelloWorldApp > { > ? ?public interface IHelloWorld > ? ?{ > ? ? ? ?event EventHandler SomeEvent; > ? ?} > > ? ?public abstract class AbstractHelloWorld : IHelloWorld > ? ?{ > ? ? ? ?public abstract event EventHandler SomeEvent; > ? ?} > } > > *************************** > require "HelloWorldApp.dll" > > class HelloWorlder < HelloWorldApp::AbstractHelloWorld > end > > @hello_app = HelloWorlder.new #barf > > *************************** > D:\source\dotnet\IronRubyInteropBug>ir ruby_test.rb > mscorlib:0:in `_TermCreateClass'': Method ''add_SomeEvent'' in type > ''IronRuby.Classes.AbstractHelloWorld$1'' from assembly > ''Snippets.scripting, Version=0.0.0.0, Culture=neutral, > PublicKeyToken=null'' does not have an implementation. > (System::TypeLoadException) > ? ? ? ?from mscorlib:0:in `CreateTypeNoLock'' > ? ? ? ?from mscorlib:0:in `CreateType'' > ? ? ? ?from c:\IronRuby\ndp\fx\src\Core\Microsoft\Scripting\Actions\DynamicMetaObjectBinder.cs:107:in > `Bind'' > ? ? ? ?from c:\IronRuby\ndp\fx\src\Core\Microsoft\Scripting\Actions\CallSiteBinder.cs:85:in > `BindCore'' > ? ? ? ?from ruby_test.rb:6 > > > Any assistance appreciated - cheers! > > -xerx > _______________________________________________ > Ironruby-core mailing list > Ironruby-core at rubyforge.org > http://rubyforge.org/mailman/listinfo/ironruby-core > > _______________________________________________ > Ironruby-core mailing list > Ironruby-core at rubyforge.org > http://rubyforge.org/mailman/listinfo/ironruby-core >_______________________________________________ Ironruby-core mailing list Ironruby-core at rubyforge.org http://rubyforge.org/mailman/listinfo/ironruby-core
Xerxes Battiwalla
2009-Jun-23 07:34 UTC
[Ironruby-core] Dynamic Binding fails if abstract event not implemented
Actually the AbstractHelloWorld is used as a work-around for implementing the interface directly in ruby (see http://ironruby.codeplex.com/WorkItem/View.aspx?WorkItemId=772), so implementing it in C# gives us no benefit. I did try (in our codebase, i havent tested this particular example) removing the abstract modifier on SomeEvent in AbstractHelloWorld and leaving everything else as abstract on the interface, and I get the same failure for add_OnProgress on IronRuby::System::Object. -Xerx On Tue, Jun 23, 2009 at 4:51 PM, Tomas Matousek<Tomas.Matousek at microsoft.com> wrote:> Could you derive from AbstractHelloWorld in C# and implement the abstract event and then derive from this derived class in Ruby? > > Tomas > > -----Original Message----- > From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Xerxes Battiwalla > Sent: Monday, June 22, 2009 10:43 PM > To: ironruby-core at rubyforge.org > Subject: Re: [Ironruby-core] Dynamic Binding fails if abstract event not implemented > > great - thanks for the follow up, Tomas. > > Is there a workaround we could use in the meantime? Really keen to get > Cucumber going ;) > > -Xerx > > On Tue, Jun 23, 2009 at 2:49 PM, Tomas > Matousek<Tomas.Matousek at microsoft.com> wrote: >> Definitely a bug. I''ve filed it under http://ironruby.codeplex.com/WorkItem/View.aspx?WorkItemId=1628. >> >> Tomas >> >> -----Original Message----- >> From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Xerxes Battiwalla >> Sent: Monday, June 22, 2009 9:04 PM >> To: ironruby-core at rubyforge.org >> Subject: [Ironruby-core] Dynamic Binding fails if abstract event not implemented >> >> Hi - I''ve just downloaded the latest IR source from GitHub and have a >> problem with what looks like a regression from v0.4. >> >> We have an interface defining an event which is implemented by an >> abstract class in C#. In Ruby, we create an implementation of the >> abstract class and call only a subset of methods as we require them. >> The 0.4 version played nicely and would only do the dynamic binding of >> methods we required at the time we called them, however the latest >> version of IR seems to try and bind the event (even though we don''t >> hook up to it) and can''t find an implementation in ruby so it throws a >> TypeLoadException citing the adder for the event does not have an >> implementation. >> >> A reproducible case is pasted below. Hoping someone would be able to >> shed light on whether this is intentional, and if so what we can do to >> implement the event in ruby. >> >> *************************** >> using System; >> >> namespace HelloWorldApp >> { >> ? ?public interface IHelloWorld >> ? ?{ >> ? ? ? ?event EventHandler SomeEvent; >> ? ?} >> >> ? ?public abstract class AbstractHelloWorld : IHelloWorld >> ? ?{ >> ? ? ? ?public abstract event EventHandler SomeEvent; >> ? ?} >> } >> >> *************************** >> require "HelloWorldApp.dll" >> >> class HelloWorlder < HelloWorldApp::AbstractHelloWorld >> end >> >> @hello_app = HelloWorlder.new #barf >> >> *************************** >> D:\source\dotnet\IronRubyInteropBug>ir ruby_test.rb >> mscorlib:0:in `_TermCreateClass'': Method ''add_SomeEvent'' in type >> ''IronRuby.Classes.AbstractHelloWorld$1'' from assembly >> ''Snippets.scripting, Version=0.0.0.0, Culture=neutral, >> PublicKeyToken=null'' does not have an implementation. >> (System::TypeLoadException) >> ? ? ? ?from mscorlib:0:in `CreateTypeNoLock'' >> ? ? ? ?from mscorlib:0:in `CreateType'' >> ? ? ? ?from c:\IronRuby\ndp\fx\src\Core\Microsoft\Scripting\Actions\DynamicMetaObjectBinder.cs:107:in >> `Bind'' >> ? ? ? ?from c:\IronRuby\ndp\fx\src\Core\Microsoft\Scripting\Actions\CallSiteBinder.cs:85:in >> `BindCore'' >> ? ? ? ?from ruby_test.rb:6 >> >> >> Any assistance appreciated - cheers! >> >> -xerx >> _______________________________________________ >> Ironruby-core mailing list >> Ironruby-core at rubyforge.org >> http://rubyforge.org/mailman/listinfo/ironruby-core >> >> _______________________________________________ >> Ironruby-core mailing list >> Ironruby-core at rubyforge.org >> http://rubyforge.org/mailman/listinfo/ironruby-core >> > _______________________________________________ > Ironruby-core mailing list > Ironruby-core at rubyforge.org > http://rubyforge.org/mailman/listinfo/ironruby-core > > _______________________________________________ > Ironruby-core mailing list > Ironruby-core at rubyforge.org > http://rubyforge.org/mailman/listinfo/ironruby-core >
Ivan Porto Carrero
2009-Jun-23 07:51 UTC
[Ironruby-core] Dynamic Binding fails if abstract event not implemented
I''ve been meaning to ask this for a while now. Can I implement an event that is defined on an interface because whichever way I try it just won''t work. public interface IHaveAnEvent { event EventHandler SomeEvent; } class EventImplementor include IHaveAnEvent # what now? I can''t find any test cases for interface to see how it can be done. end --- Met vriendelijke groeten - Best regards - Salutations Ivan Porto Carrero Blog: http://flanders.co.nz Twitter: http://twitter.com/casualjim Author of IronRuby in Action (http://manning.com/carrero) On Tue, Jun 23, 2009 at 6:03 AM, Xerxes Battiwalla <xerxesb at gmail.com>wrote:> Hi - I''ve just downloaded the latest IR source from GitHub and have a > problem with what looks like a regression from v0.4. > > We have an interface defining an event which is implemented by an > abstract class in C#. In Ruby, we create an implementation of the > abstract class and call only a subset of methods as we require them. > The 0.4 version played nicely and would only do the dynamic binding of > methods we required at the time we called them, however the latest > version of IR seems to try and bind the event (even though we don''t > hook up to it) and can''t find an implementation in ruby so it throws a > TypeLoadException citing the adder for the event does not have an > implementation. > > A reproducible case is pasted below. Hoping someone would be able to > shed light on whether this is intentional, and if so what we can do to > implement the event in ruby. > > *************************** > using System; > > namespace HelloWorldApp > { > public interface IHelloWorld > { > event EventHandler SomeEvent; > } > > public abstract class AbstractHelloWorld : IHelloWorld > { > public abstract event EventHandler SomeEvent; > } > } > > *************************** > require "HelloWorldApp.dll" > > class HelloWorlder < HelloWorldApp::AbstractHelloWorld > end > > @hello_app = HelloWorlder.new #barf > > *************************** > D:\source\dotnet\IronRubyInteropBug>ir ruby_test.rb > mscorlib:0:in `_TermCreateClass'': Method ''add_SomeEvent'' in type > ''IronRuby.Classes.AbstractHelloWorld$1'' from assembly > ''Snippets.scripting, Version=0.0.0.0, Culture=neutral, > PublicKeyToken=null'' does not have an implementation. > (System::TypeLoadException) > from mscorlib:0:in `CreateTypeNoLock'' > from mscorlib:0:in `CreateType'' > from > c:\IronRuby\ndp\fx\src\Core\Microsoft\Scripting\Actions\DynamicMetaObjectBinder.cs:107:in > `Bind'' > from > c:\IronRuby\ndp\fx\src\Core\Microsoft\Scripting\Actions\CallSiteBinder.cs:85:in > `BindCore'' > from ruby_test.rb:6 > > > Any assistance appreciated - cheers! > > -xerx > _______________________________________________ > Ironruby-core mailing list > Ironruby-core at rubyforge.org > http://rubyforge.org/mailman/listinfo/ironruby-core >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20090623/01c3be9b/attachment.html>
Kevin Radcliffe
2009-Jun-23 15:19 UTC
[Ironruby-core] Dynamic Binding fails if abstract event not implemented
Ivan Porto carrero wrote:> I''ve been meaning to ask this for a while now. > Can I implement an event that is defined on an interface because > whichever > way I try it just won''t work. > > public interface IHaveAnEvent { event EventHandler SomeEvent; } > > class EventImplementor > include IHaveAnEvent > > # what now? I can''t find any test cases for interface to see how it > can be > done. > end > --- > Met vriendelijke groeten - Best regards - Salutations > Ivan Porto Carrero > Blog: http://flanders.co.nz > Twitter: http://twitter.com/casualjim > Author of IronRuby in Action (http://manning.com/carrero)I was trying to implement an interface to use OpenRasta from IronRuby and ran into the same thing. Received the same error as Xerx did above, and assumed it was just a limitation of the language at the moment. Would be great if we can implement the add_SomeEvent handlers at some point though. For now I voted for the CodePlex issue Tomas pointed out above. -- Posted via http://www.ruby-forum.com/.