About documentation, the bottom of
IronPython.net / Documentation / .NET Integration has this placeholder
Appendix - Rules for Type parameter inference while invoking generic
methods
TODO
Jim, Dino had added tests for IronPython, and you should be able to
leverage those for IronRuby
http://ironruby.codeplex.com/WorkItem/View.aspx?WorkItemId=3395 also
tracks the issues with generic inference.
From: [email protected]
[[email protected]] on behalf of Jim D.
[[email protected]]
Sent: Friday, February 12, 2010 9:06 AM
To: [email protected]
Subject: Re: [Ironruby-core] Calling a C# method with a byref parameter
Generic type inference should work like it does in C#. I’ll get some
more tests in there and get Jimmy to update the docs.
JD
From: [email protected]
[mailto:[email protected]] On Behalf Of Ryan R.
Sent: Thursday, February 11, 2010 9:56 AM
To: [email protected]
Subject: Re: [Ironruby-core] Calling a C# method with a byref parameter
On what types will IR be able to infer the types? Is that documented on
the site and I just didn’t see it?
Ryan R.
On Thu, Feb 11, 2010 at 9:55 AM, Jim D.
<[email protected]mailto:[email protected]> wrote:
That call actually should (usually) be able to infer the type. Please
file a bug on codeplex that Generic Type inference isn’t working with
ByRef types.
JD
From:
[email protected]mailto:[email protected]
[mailto:[email protected]mailto:[email protected]]
On Behalf Of Shay F.
Sent: Thursday, February 11, 2010 6:53 AM
To: [email protected]mailto:[email protected]
Subject: Re: [Ironruby-core] Calling a C# method with a byref parameter
You should call generic methods a bit differently.
The next code works:
ret_val = c.method(:do_something_else).of(String).call(str)
Shay.
Shay F. | .NET Technologies Expert | Author of IronRuby Unleashed
| Sela Technology Center
Blog: http://IronShay.com | Twitter: http://twitter.com/ironshay
On Thu, Feb 11, 2010 at 4:44 PM, Michael E.
<[email protected]mailto:[email protected]> wrote:
Thanks Shay.
OK your code works. But my trouble seems to come in with the Generic
method.
When I do:
public class Class1
{
public string DoSomething(ref string test)
{
test = test + “tamtamtam”;
return "return value";
}
public string DoSomethingElse<T>(ref T test)
{
return test.ToString();
}
}
and then call it from IR:
c = TestClass::Class1.new
=> TestClass.Class1
c.do_something(“Bla”)
=> [‘return value’, ‘Blatamtamtam’]
c.do_something_else(“Bla”)
Microsoft.Scripting.Core:0:in Bind': Expression of type 'IronRuby.Builtins.Muta bleString&' cannot be used for parameter of type 'IronRuby.Builtins.MutableStrin g' of method 'System.String DoSomethingElse[MutableString](IronRuby.Builtins.Mut ableString ByRef)' (ArgumentError) from Microsoft.Scripting.Core:0:in
BindCore’
from :0
On Thu, Feb 11, 2010 at 4:12 PM, Shay F.
<[email protected]mailto:[email protected]> wrote:
It returns another return value with the new ref value.
For example, if you have the next c# class:
public class Class1
{
public string DoSomething(ref string test)
{
test = test + “tamtamtam”;
return "return value";
}
}
This is the IronRuby code you can write to use it:
require ‘c:\dev\TestApps\TestClass\TestClass\bin\Debug\TestClass.dll’
=> true
c = Class1.new
=> TestClass.Class1
str = “hello”
=> “hello”
result = c.do_something(str)
=> [‘return value’, ‘hellotamtamtam’]
Pay attention that the result variable is an array that contains the
method return value as the first item and the ref value as the second
parameter.
Shay.
Shay F. | .NET Technologies Expert | Author of IronRuby Unleashed
| Sela Technology Center
Blog: http://IronShay.com | Twitter: http://twitter.com/ironshay
On Thu, Feb 11, 2010 at 3:44 PM, Michael E.
<[email protected]mailto:[email protected]> wrote:
Hi Everyone,
I’m trying to write a IronRuby script that interops with a a .NET
assembly written in C#.
It has a class that derives from a base class in the .NET assembly. One
of the base class protected methods looks like this:
protected void OnNotifyPropertyChanged(string name, ref T
localmember, T value)
{
…
}
I can’t for the life of me figure out how to call this method from IR in
my derived class.
The documentation mentions that you can call out parameters without
using them as arguments, but I can’t seem to find anything about ref
params.
If I just try calling the method like this:
OnNotifyPropertyChanged(property_name, value, value)
I get this error:
Microsoft.Scripting.Core:0:in Bind': Expression of type 'IronRuby.Builtins.Muta bleString&' cannot be used for parameter of type 'IronRuby.Builtins.MutableStrin g' of method 'Void #base#OnNotifyPropertyChanged[MutableString](System.String, I ronRuby.Builtins.MutableString ByRef, IronRuby.Builtins.MutableString)' (Argumen tError) from Microsoft.Scripting.Core:0:in
BindCore’
from ./dynamic_event_item.rb:22:in `method_missing’
from :0
Am I missing something?
Thanks
Michael E.
Ironruby-core mailing list
[email protected]mailto:[email protected]
http://rubyforge.org/mailman/listinfo/ironruby-core
Ironruby-core mailing list
[email protected]mailto:[email protected]
http://rubyforge.org/mailman/listinfo/ironruby-core
Ironruby-core mailing list
[email protected]mailto:[email protected]
http://rubyforge.org/mailman/listinfo/ironruby-core