# Interface generic w/ generic methods

**URL:** <https://www.ruby-forum.com/t/interface-generic-w-generic-methods/168389>\
**Category:** IronRuby\
**Created:** [May 20, 2009, 10:17am UTC](https://www.ruby-forum.com/t/interface-generic-w-generic-methods/168389 "2009-05-20T10:17:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![barby](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/c57346/32.png) [@barby](https://www.ruby-forum.com/u/barby)\
**Post date:** [May 20, 2009, 10:17am UTC](https://www.ruby-forum.com/t/interface-generic-w-generic-methods/168389/1 "2009-05-20T10:17:00Z")

</div>

Hi  
I’m observing the following behavior when I try to implement a CLR  
interface  
with generic method definitions.

So let’s say an interface contains the following method definition

public interface IRubyEngine {  
T CreateInstance(RubyClass rubyClass);  
}

in ruby  
class MyEngine  
include IRubyEngine  
end

So far so good nothing has actually been created yet.

MyEngine.new =\> raises

(master) Â» ir  
IronRuby 0.4.0.0 on .NET 2.0.50727.4918  
Copyright (c) Microsoft Corporation. All rights reserved.

> > > require ‘bin/System.Web.Mvc.IronRuby.dll’  
> > > =\> true  
> > > class MyEngine  
> > > … include System::Web::Mvc::IronRuby::Core::IRubyEngine  
> > > … end  
> > > =\> MyEngine  
> > > MyEngine.new  
> > > mscorlib:0:in `_TermCreateClass': Method 'ExecuteFile' in type 'IronRuby.Classes.Object$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:\tools\ironruby\ndp\fx\src\core\microsoft\scripting\Actions\DynamicMetaObjectBinder.cs:96:in `Bind’  
> > > from  
> > > c:\tools\ironruby\ndp\fx\src\core\microsoft\scripting\Actions\CallSiteBinder.cs:79:in  
> > > `BindDelegate’  
> > > from :0

> > > exit

in the console output above it complains about a different method but  
the  
idea is the same. that method def was T ExecuteFile(string path, bool  
throwIfNotExist);

## Do I put this on codeplex or is that the expected behavior?

Met vriendelijke groeten - Best regards - Salutations  
Ivan Porto C.  
Blog: [http://flanders.co.nz](http://flanders.co.nz)  
Twitter: [http://twitter.com/casualjim](http://twitter.com/casualjim)  
Author of IronRuby in Action ([http://manning.com/carrero](http://manning.com/carrero))

---

<div class="post-metadata">

**Author:** ![barby](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/c57346/32.png) [@barby](https://www.ruby-forum.com/u/barby)\
**Post date:** [May 20, 2009, 5:43pm UTC](https://www.ruby-forum.com/t/interface-generic-w-generic-methods/168389/2 "2009-05-20T17:43:44Z")

</div>

Two points: 1) We should probably have a clearer error message in this  
case. 2) That seems to be a bug since the behavior is different if  
IRubyEngine declares non-generic methods.

Please file a bug on CP with both points.

JD

â€¦there is no try

From: removed\_email\_address@domain.invalid  
[[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)] On Behalf Of Ivan Porto  
Carrero  
Sent: Tuesday, May 19, 2009 11:54 PM  
To: ironruby-core  
Subject: [Ironruby-core] interface generic w/ generic methods

Hi

I’m observing the following behavior when I try to implement a CLR  
interface with generic method definitions.

So let’s say an interface contains the following method definition

public interface IRubyEngine {  
T CreateInstance(RubyClass rubyClass);  
}

in ruby  
class MyEngine  
include IRubyEngine  
end

So far so good nothing has actually been created yet.

MyEngine.new =\> raises

(master) Â» ir  
IronRuby 0.4.0.0 on .NET 2.0.50727.4918  
Copyright (c) Microsoft Corporation. All rights reserved.

> > > require ‘bin/System.Web.Mvc.IronRuby.dll’  
> > > =\> true  
> > > class MyEngine  
> > > … include System::Web::Mvc::IronRuby::Core::IRubyEngine  
> > > … end  
> > > =\> MyEngine  
> > > MyEngine.new  
> > > mscorlib:0:in `_TermCreateClass': Method 'ExecuteFile' in type 'IronRuby.Classes.Object$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:\tools\ironruby\ndp\fx\src\core\microsoft\scripting\Actions\DynamicMetaObjectBinder.cs:96:in `Bind’  
> > > from  
> > > c:\tools\ironruby\ndp\fx\src\core\microsoft\scripting\Actions\CallSiteBinder.cs:79:in  
> > > `BindDelegate’  
> > > from :0

> > > exit

in the console output above it complains about a different method but  
the idea is the same. that method def was T ExecuteFile(string path,  
bool throwIfNotExist);

## Do I put this on codeplex or is that the expected behavior?

Met vriendelijke groeten - Best regards - Salutations  
Ivan Porto C.  
Blog: [http://flanders.co.nz](http://flanders.co.nz)  
Twitter: [http://twitter.com/casualjim](http://twitter.com/casualjim)  
Author of IronRuby in Action ([http://manning.com/carrero](http://manning.com/carrero))
