It seems like the current version does not handle lower case namespaces when referencing a .NET DLL. It thinks it is a method call whenever a constant starts with lower case. It also doesn''t handle non-alphabet characters such as _ (underscore). I''m trying to call WCF service from IronRuby via the proxies file. svcutil converts all namespaces in the proxies file to lower case. Here''s some info on it: http://connect.microsoft.com/wcf/feedback/ViewFeedback.aspx?FeedbackID=298408 I also noticed that "puts" does not output the value of Int64. However, it does if I use Console.WriteLine in my ruby program. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20081205/fc7f8253/attachment.html>
Well, that''s very unfortunate. They seems to break .NET guidelines for
namespace naming. It''s not compatible with Ruby language to have
lowercased namespaces since they behave like modules. Module names must start
with an upper case. We can add some API to overcome this, but it won''t
be pretty. Something like
clr.class_get :foo, :bar, :baz would return class for type foo.bar.baz.
For now you can use reflection API to get the type (and Ruby class for that
type):
System::Type.get_type("foo.bar.baz").to_class
As for Int64... it prints #<System::Int64:0x000005e>, which is not
particularly useful. It should probably call ToString. I''ll file a bug.
Tomas
From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at
rubyforge.org] On Behalf Of Aaron Feng
Sent: Friday, December 05, 2008 1:07 PM
To: ironruby-core at rubyforge.org
Subject: [Ironruby-core] Handling C# lower case namespaces
It seems like the current version does not handle lower case namespaces when
referencing a .NET DLL. It thinks it is a method call whenever a constant
starts with lower case. It also doesn''t handle non-alphabet characters
such as _ (underscore).
I''m trying to call WCF service from IronRuby via the proxies file.
svcutil converts all namespaces in the proxies file to lower case.
Here''s some info on it:
http://connect.microsoft.com/wcf/feedback/ViewFeedback.aspx?FeedbackID=298408
I also noticed that "puts" does not output the value of Int64.
However, it does if I use Console.WriteLine in my ruby program.
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://rubyforge.org/pipermail/ironruby-core/attachments/20081205/c3114486/attachment-0001.html>
Just monkey-patch it:
class System::Int64
def inspect
self.to_string.to_s
end
end
;)
On Fri, Dec 5, 2008 at 4:50 PM, Tomas Matousek <Tomas.Matousek at
microsoft.com> wrote:
> Well, that''s very unfortunate. They seems to break .NET
guidelines for
> namespace naming. It''s not compatible with Ruby language to have
lowercased
> namespaces since they behave like modules. Module names must start with an
> upper case. We can add some API to overcome this, but it won''t be
pretty.
> Something like
>
>
>
> clr.class_get :foo, :bar, :baz would return class for type foo.bar.baz.
>
>
>
> For now you can use reflection API to get the type (and Ruby class for that
> type):
>
> System::Type.get_type("foo.bar.baz").to_class
>
>
>
> As for Int64? it prints #<System::Int64:0x000005e>, which is not
> particularly useful. It should probably call ToString. I''ll file a
bug.
>
>
>
> Tomas
>
>
>
> *From:* ironruby-core-bounces at rubyforge.org [mailto:
> ironruby-core-bounces at rubyforge.org] *On Behalf Of *Aaron Feng
> *Sent:* Friday, December 05, 2008 1:07 PM
> *To:* ironruby-core at rubyforge.org
> *Subject:* [Ironruby-core] Handling C# lower case namespaces
>
>
>
> It seems like the current version does not handle lower case namespaces
> when referencing a .NET DLL. It thinks it is a method call whenever a
> constant starts with lower case. It also doesn''t handle
non-alphabet
> characters such as _ (underscore).
>
> I''m trying to call WCF service from IronRuby via the proxies file.
svcutil
> converts all namespaces in the proxies file to lower case. Here''s
some info
> on it:
>
>
>
http://connect.microsoft.com/wcf/feedback/ViewFeedback.aspx?FeedbackID=298408
>
> I also noticed that "puts" does not output the value of Int64.
However, it
> does if I use Console.WriteLine in my ruby program.
>
> _______________________________________________
> Ironruby-core mailing list
> Ironruby-core at rubyforge.org
> http://rubyforge.org/mailman/listinfo/ironruby-core
>
>
--
Michael Letterle
[Polymath Prokrammer]
http://blog.prokrams.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://rubyforge.org/pipermail/ironruby-core/attachments/20081205/8a9516f6/attachment.html>
Tomas,> System::Type.get_type("foo.bar.baz").to_classAre you sure that works with lower case namespaces? I tried it real quick, and didn''t seem to work for me. But I''ll try it again later. Aaron -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20081205/ba20e549/attachment.html>
Thumbs up :) You might however expect this to work for all CLR types. In which case you can indeed monkey patch it as well (kind of):>>> class Object... def to_s ... self.class.name[0,8] == "System::" ? to_string.to_s : super ... end ... end => nil>>>=> nil>>> require ''mscorlib''=> true>>>=> nil>>> System::Convert.to_int64(1234)=> 1234 Tomas From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Michael Letterle Sent: Friday, December 05, 2008 1:58 PM To: ironruby-core at rubyforge.org Subject: Re: [Ironruby-core] Handling C# lower case namespaces Just monkey-patch it: class System::Int64 def inspect self.to_string.to_s end end ;) On Fri, Dec 5, 2008 at 4:50 PM, Tomas Matousek <Tomas.Matousek at microsoft.com<mailto:Tomas.Matousek at microsoft.com>> wrote: Well, that''s very unfortunate. They seems to break .NET guidelines for namespace naming. It''s not compatible with Ruby language to have lowercased namespaces since they behave like modules. Module names must start with an upper case. We can add some API to overcome this, but it won''t be pretty. Something like clr.class_get :foo, :bar, :baz would return class for type foo.bar.baz. For now you can use reflection API to get the type (and Ruby class for that type): System::Type.get_type("foo.bar.baz").to_class As for Int64... it prints #<System::Int64:0x000005e>, which is not particularly useful. It should probably call ToString. I''ll file a bug. Tomas From: ironruby-core-bounces at rubyforge.org<mailto:ironruby-core-bounces at rubyforge.org> [mailto:ironruby-core-bounces at rubyforge.org<mailto:ironruby-core-bounces at rubyforge.org>] On Behalf Of Aaron Feng Sent: Friday, December 05, 2008 1:07 PM To: ironruby-core at rubyforge.org<mailto:ironruby-core at rubyforge.org> Subject: [Ironruby-core] Handling C# lower case namespaces It seems like the current version does not handle lower case namespaces when referencing a .NET DLL. It thinks it is a method call whenever a constant starts with lower case. It also doesn''t handle non-alphabet characters such as _ (underscore). I''m trying to call WCF service from IronRuby via the proxies file. svcutil converts all namespaces in the proxies file to lower case. Here''s some info on it: http://connect.microsoft.com/wcf/feedback/ViewFeedback.aspx?FeedbackID=298408 I also noticed that "puts" does not output the value of Int64. However, it does if I use Console.WriteLine in my ruby program. _______________________________________________ Ironruby-core mailing list Ironruby-core at rubyforge.org<mailto:Ironruby-core at rubyforge.org> http://rubyforge.org/mailman/listinfo/ironruby-core -- Michael Letterle [Polymath Prokrammer] http://blog.prokrams.com -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20081205/201d6647/attachment.html>
Tomas, I tried it again. I couldn''t get the following to work with my own DLL even If I capitalize the namespace (It does work fine with build in types like System.String):> System::Type.get_type("Abc.Hi, Version=1.0.0.0, Culture=neutral,PublicKeyToken=null") Do I have any other options? Thanks, Aaron -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20081208/20a6bcb2/attachment.html>
Ivan Porto Carrero
2008-Dec-08 17:45 UTC
[Ironruby-core] Handling C# lower case namespaces
I get the same behavior. I can load types from the CLR but not from my own assembly. I copied my assembly into the folder that contains ir.exe>>> require ''mscorlib''=> true>>> require ''IronNails.Library, Version=1.0.0.0, Culture=neutral,PublicKeyToken=null'' => true>>> IronNails::View::XamlProxy=> IronNails::View::XamlProxy>>> System::Type.get_type ''IronNails.View.XamlProxy''=> nil>>> System::Type.get_type ''System.String''=> #<System::RuntimeType:0x000005c>>>> IronNails::View::XamlProxy.to_clr_type=> #<System::RuntimeType:0x000005e> On Mon, Dec 8, 2008 at 5:54 PM, Aaron Feng <aaron.feng at gmail.com> wrote:> Tomas, > > I tried it again. I couldn''t get the following to work with my own DLL > even If I capitalize the namespace (It does work fine with build in types > like System.String): > > > System::Type.get_type("Abc.Hi, Version=1.0.0.0, Culture=neutral, > PublicKeyToken=null") > > Do I have any other options? > > Thanks, > > Aaron > > _______________________________________________ > 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/20081208/63a60590/attachment.html>
Can you load the assembly and get the type explicitly?
require ?mscorlib?
System::Reflection::Assembly.Load(?IronNails.Library, Version=1.0.0.0,
Culture=neutral,
PublicKeyToken=null").GetType(''IronNails.View.XamlProxy?)
Tomas
From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at
rubyforge.org] On Behalf Of Ivan Porto Carrero
Sent: Monday, December 08, 2008 9:46 AM
To: ironruby-core at rubyforge.org
Subject: Re: [Ironruby-core] Handling C# lower case namespaces
I get the same behavior.
I can load types from the CLR but not from my own assembly.
I copied my assembly into the folder that contains ir.exe
>>> require ''mscorlib''
=> true>>> require ''IronNails.Library,
Version=1.0.0.0<http://1.0.0.0>, Culture=neutral,
PublicKeyToken=null''
=> true>>> IronNails::View::XamlProxy
=> IronNails::View::XamlProxy>>> System::Type.get_type ''IronNails.View.XamlProxy''
=> nil>>> System::Type.get_type ''System.String''
=> #<System::RuntimeType:0x000005c>>>> IronNails::View::XamlProxy.to_clr_type
=> #<System::RuntimeType:0x000005e>
On Mon, Dec 8, 2008 at 5:54 PM, Aaron Feng <aaron.feng at
gmail.com<mailto:aaron.feng at gmail.com>> wrote:
Tomas,
I tried it again. I couldn''t get the following to work with my own DLL
even If I capitalize the namespace (It does work fine with build in types like
System.String):
> System::Type.get_type("Abc.Hi, Version=1.0.0.0<http://1.0.0.0>,
Culture=neutral, PublicKeyToken=null")
Do I have any other options?
Thanks,
Aaron
_______________________________________________
Ironruby-core mailing list
Ironruby-core at rubyforge.org<mailto: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/20081208/1e7f00f6/attachment-0001.html>
Ivan Porto Carrero
2008-Dec-08 19:24 UTC
[Ironruby-core] Handling C# lower case namespaces
Yes that works On Mon, Dec 8, 2008 at 8:11 PM, Tomas Matousek <Tomas.Matousek at microsoft.com> wrote:> Can you load the assembly and get the type explicitly? > > > > require ''mscorlib'' > > System::Reflection::Assembly.Load("IronNails.Library, Version=1.0.0.0, > Culture=neutral, PublicKeyToken=null").GetType(''IronNails.View.XamlProxy'') > > > > Tomas > > > > *From:* ironruby-core-bounces at rubyforge.org [mailto: > ironruby-core-bounces at rubyforge.org] *On Behalf Of *Ivan Porto Carrero > *Sent:* Monday, December 08, 2008 9:46 AM > *To:* ironruby-core at rubyforge.org > *Subject:* Re: [Ironruby-core] Handling C# lower case namespaces > > > > I get the same behavior. > I can load types from the CLR but not from my own assembly. > > I copied my assembly into the folder that contains ir.exe > > >>> require ''mscorlib'' > => true > >>> require ''IronNails.Library, Version=1.0.0.0, Culture=neutral, > PublicKeyToken=null'' > => true > >>> IronNails::View::XamlProxy > => IronNails::View::XamlProxy > >>> System::Type.get_type ''IronNails.View.XamlProxy'' > => nil > >>> System::Type.get_type ''System.String'' > => #<System::RuntimeType:0x000005c> > >>> IronNails::View::XamlProxy.to_clr_type > => #<System::RuntimeType:0x000005e> > > > > On Mon, Dec 8, 2008 at 5:54 PM, Aaron Feng <aaron.feng at gmail.com> wrote: > > Tomas, > > I tried it again. I couldn''t get the following to work with my own DLL > even If I capitalize the namespace (It does work fine with build in types > like System.String): > > > System::Type.get_type("Abc.Hi, Version=1.0.0.0, Culture=neutral, > PublicKeyToken=null") > > Do I have any other options? > > Thanks, > > Aaron > > _______________________________________________ > 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 > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20081208/87bc060b/attachment.html>
Ok, I got Assembly.Load and Type.get_type both to work with my own DLL. The actual DLL have to live where ir.exe lives. Is there a way for it to look in the directory of the ruby file? Like the way require statement work. Aaron On Mon, Dec 8, 2008 at 2:11 PM, Tomas Matousek <Tomas.Matousek at microsoft.com> wrote:> Can you load the assembly and get the type explicitly? > > > > require ''mscorlib'' > > System::Reflection::Assembly.Load("IronNails.Library, Version=1.0.0.0, > Culture=neutral, PublicKeyToken=null").GetType(''IronNails.View.XamlProxy'') > > > > Tomas > > > > *From:* ironruby-core-bounces at rubyforge.org [mailto: > ironruby-core-bounces at rubyforge.org] *On Behalf Of *Ivan Porto Carrero > *Sent:* Monday, December 08, 2008 9:46 AM > *To:* ironruby-core at rubyforge.org > *Subject:* Re: [Ironruby-core] Handling C# lower case namespaces > > > > I get the same behavior. > I can load types from the CLR but not from my own assembly. > > I copied my assembly into the folder that contains ir.exe > > >>> require ''mscorlib'' > => true > >>> require ''IronNails.Library, Version=1.0.0.0, Culture=neutral, > PublicKeyToken=null'' > => true > >>> IronNails::View::XamlProxy > => IronNails::View::XamlProxy > >>> System::Type.get_type ''IronNails.View.XamlProxy'' > => nil > >>> System::Type.get_type ''System.String'' > => #<System::RuntimeType:0x000005c> > >>> IronNails::View::XamlProxy.to_clr_type > => #<System::RuntimeType:0x000005e> > > > > On Mon, Dec 8, 2008 at 5:54 PM, Aaron Feng <aaron.feng at gmail.com> wrote: > > Tomas, > > I tried it again. I couldn''t get the following to work with my own DLL > even If I capitalize the namespace (It does work fine with build in types > like System.String): > > > System::Type.get_type("Abc.Hi, Version=1.0.0.0, Culture=neutral, > PublicKeyToken=null") > > Do I have any other options? > > Thanks, > > Aaron > > _______________________________________________ > 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 > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20081208/63a13e02/attachment.html>
You can use Assembly.LoadFile and point it to an absolute path instead.
Tomas
From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at
rubyforge.org] On Behalf Of Aaron Feng
Sent: Monday, December 08, 2008 12:33 PM
To: ironruby-core at rubyforge.org
Subject: Re: [Ironruby-core] Handling C# lower case namespaces
Ok, I got Assembly.Load and Type.get_type both to work with my own DLL. The
actual DLL have to live where ir.exe lives. Is there a way for it to look in
the directory of the ruby file? Like the way require statement work.
Aaron
On Mon, Dec 8, 2008 at 2:11 PM, Tomas Matousek <Tomas.Matousek at
microsoft.com<mailto:Tomas.Matousek at microsoft.com>> wrote:
Can you load the assembly and get the type explicitly?
require ''mscorlib''
System::Reflection::Assembly.Load("IronNails.Library,
Version=1.0.0.0<http://1.0.0.0>, Culture=neutral,
PublicKeyToken=null").GetType(''IronNails.View.XamlProxy'')
Tomas
From: ironruby-core-bounces at rubyforge.org<mailto:ironruby-core-bounces at
rubyforge.org> [mailto:ironruby-core-bounces at
rubyforge.org<mailto:ironruby-core-bounces at rubyforge.org>] On Behalf Of
Ivan Porto Carrero
Sent: Monday, December 08, 2008 9:46 AM
To: ironruby-core at rubyforge.org<mailto:ironruby-core at rubyforge.org>
Subject: Re: [Ironruby-core] Handling C# lower case namespaces
I get the same behavior.
I can load types from the CLR but not from my own assembly.
I copied my assembly into the folder that contains ir.exe
>>> require ''mscorlib''
=> true>>> require ''IronNails.Library,
Version=1.0.0.0<http://1.0.0.0>, Culture=neutral,
PublicKeyToken=null''
=> true>>> IronNails::View::XamlProxy
=> IronNails::View::XamlProxy>>> System::Type.get_type ''IronNails.View.XamlProxy''
=> nil>>> System::Type.get_type ''System.String''
=> #<System::RuntimeType:0x000005c>>>> IronNails::View::XamlProxy.to_clr_type
=> #<System::RuntimeType:0x000005e>
On Mon, Dec 8, 2008 at 5:54 PM, Aaron Feng <aaron.feng at
gmail.com<mailto:aaron.feng at gmail.com>> wrote:
Tomas,
I tried it again. I couldn''t get the following to work with my own DLL
even If I capitalize the namespace (It does work fine with build in types like
System.String):
> System::Type.get_type("Abc.Hi, Version=1.0.0.0<http://1.0.0.0>,
Culture=neutral, PublicKeyToken=null")
Do I have any other options?
Thanks,
Aaron
_______________________________________________
Ironruby-core mailing list
Ironruby-core at rubyforge.org<mailto:Ironruby-core at rubyforge.org>
http://rubyforge.org/mailman/listinfo/ironruby-core
_______________________________________________
Ironruby-core mailing list
Ironruby-core at rubyforge.org<mailto: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/20081208/60458e31/attachment-0001.html>
Hi Aaron! I''m doing this way for now: require ''../../your_folder/your_assembly.dll'' ? 2008/12/8 Aaron Feng <aaron.feng at gmail.com>:> Ok, I got Assembly.Load and Type.get_type both to work with my own DLL. > The actual DLL have to live where ir.exe lives. Is there a way for it to > look in the directory of the ruby file? Like the way require statement > work. > > Aaron
I tried to load the struct the same way, but I don''t know how to set
the
value of it. For example:
C#
namespace x.y.z {
public struct Foo {
public long Bar;
public Foo(long bar) {
this.Bar = bar;
}
}
}
var foo = new x.y.z.Foo(1);
IronRuby
Foo = Type.get_type("x.y.z.Foo, MyAssembly, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=null", true).to_class
# how do I do the equivalent of
# var foo = new x.y.z.Foo(1); ?
Aaron
On Mon, Dec 8, 2008 at 3:45 PM, Tomas Matousek <Tomas.Matousek at
microsoft.com> wrote:
> You can use Assembly.LoadFile and point it to an absolute path instead.
>
>
>
> Tomas
>
>
>
> *From:* ironruby-core-bounces at rubyforge.org [mailto:
> ironruby-core-bounces at rubyforge.org] *On Behalf Of *Aaron Feng
> *Sent:* Monday, December 08, 2008 12:33 PM
>
> *To:* ironruby-core at rubyforge.org
> *Subject:* Re: [Ironruby-core] Handling C# lower case namespaces
>
>
>
> Ok, I got Assembly.Load and Type.get_type both to work with my own DLL.
> The actual DLL have to live where ir.exe lives. Is there a way for it to
> look in the directory of the ruby file? Like the way require statement
> work.
>
> Aaron
>
>
> On Mon, Dec 8, 2008 at 2:11 PM, Tomas Matousek <
> Tomas.Matousek at microsoft.com> wrote:
>
> Can you load the assembly and get the type explicitly?
>
>
>
> require ''mscorlib''
>
> System::Reflection::Assembly.Load("IronNails.Library, Version=1.0.0.0,
> Culture=neutral,
PublicKeyToken=null").GetType(''IronNails.View.XamlProxy'')
>
>
>
> Tomas
>
>
>
> *From:* ironruby-core-bounces at rubyforge.org [mailto:
> ironruby-core-bounces at rubyforge.org] *On Behalf Of *Ivan Porto Carrero
> *Sent:* Monday, December 08, 2008 9:46 AM
>
>
> *To:* ironruby-core at rubyforge.org
>
> *Subject:* Re: [Ironruby-core] Handling C# lower case namespaces
>
>
>
> I get the same behavior.
> I can load types from the CLR but not from my own assembly.
>
> I copied my assembly into the folder that contains ir.exe
>
> >>> require ''mscorlib''
> => true
> >>> require ''IronNails.Library, Version=1.0.0.0,
Culture=neutral,
> PublicKeyToken=null''
> => true
> >>> IronNails::View::XamlProxy
> => IronNails::View::XamlProxy
> >>> System::Type.get_type
''IronNails.View.XamlProxy''
> => nil
> >>> System::Type.get_type ''System.String''
> => #<System::RuntimeType:0x000005c>
> >>> IronNails::View::XamlProxy.to_clr_type
> => #<System::RuntimeType:0x000005e>
>
>
> On Mon, Dec 8, 2008 at 5:54 PM, Aaron Feng <aaron.feng at gmail.com>
wrote:
>
> Tomas,
>
> I tried it again. I couldn''t get the following to work with my
own DLL
> even If I capitalize the namespace (It does work fine with build in types
> like System.String):
>
> > System::Type.get_type("Abc.Hi, Version=1.0.0.0, Culture=neutral,
> PublicKeyToken=null")
>
> Do I have any other options?
>
> Thanks,
>
> Aaron
>
> _______________________________________________
> 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
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://rubyforge.org/pipermail/ironruby-core/attachments/20081208/d5c3f2e4/attachment.html>
Ivan Porto Carrero
2008-Dec-08 21:52 UTC
[Ironruby-core] Handling C# lower case namespaces
Normally foo = x::y::z::Foo.new(1) in the console you need to use global variables:$foo = x::y::z::Foo.new(1) On Mon, Dec 8, 2008 at 10:43 PM, Aaron Feng <aaron.feng at gmail.com> wrote:> I tried to load the struct the same way, but I don''t know how to set the > value of it. For example: > > C# > > namespace x.y.z { > public struct Foo { > public long Bar; > public Foo(long bar) { > this.Bar = bar; > } > } > } > > var foo = new x.y.z.Foo(1); > > IronRuby > > Foo = Type.get_type("x.y.z.Foo, MyAssembly, Version=1.0.0.0, > Culture=neutral, PublicKeyToken=null", true).to_class > > # how do I do the equivalent of > # var foo = new x.y.z.Foo(1); ? > > Aaron > > > On Mon, Dec 8, 2008 at 3:45 PM, Tomas Matousek < > Tomas.Matousek at microsoft.com> wrote: > >> You can use Assembly.LoadFile and point it to an absolute path instead. >> >> >> >> Tomas >> >> >> >> *From:* ironruby-core-bounces at rubyforge.org [mailto: >> ironruby-core-bounces at rubyforge.org] *On Behalf Of *Aaron Feng >> *Sent:* Monday, December 08, 2008 12:33 PM >> >> *To:* ironruby-core at rubyforge.org >> *Subject:* Re: [Ironruby-core] Handling C# lower case namespaces >> >> >> >> Ok, I got Assembly.Load and Type.get_type both to work with my own DLL. >> The actual DLL have to live where ir.exe lives. Is there a way for it to >> look in the directory of the ruby file? Like the way require statement >> work. >> >> Aaron >> >> >> On Mon, Dec 8, 2008 at 2:11 PM, Tomas Matousek < >> Tomas.Matousek at microsoft.com> wrote: >> >> Can you load the assembly and get the type explicitly? >> >> >> >> require ''mscorlib'' >> >> System::Reflection::Assembly.Load("IronNails.Library, Version=1.0.0.0, >> Culture=neutral, PublicKeyToken=null").GetType( >> ''IronNails.View.XamlProxy'') >> >> >> >> Tomas >> >> >> >> *From:* ironruby-core-bounces at rubyforge.org [mailto: >> ironruby-core-bounces at rubyforge.org] *On Behalf Of *Ivan Porto Carrero >> *Sent:* Monday, December 08, 2008 9:46 AM >> >> >> *To:* ironruby-core at rubyforge.org >> >> *Subject:* Re: [Ironruby-core] Handling C# lower case namespaces >> >> >> >> I get the same behavior. >> I can load types from the CLR but not from my own assembly. >> >> I copied my assembly into the folder that contains ir.exe >> >> >>> require ''mscorlib'' >> => true >> >>> require ''IronNails.Library, Version=1.0.0.0, Culture=neutral, >> PublicKeyToken=null'' >> => true >> >>> IronNails::View::XamlProxy >> => IronNails::View::XamlProxy >> >>> System::Type.get_type ''IronNails.View.XamlProxy'' >> => nil >> >>> System::Type.get_type ''System.String'' >> => #<System::RuntimeType:0x000005c> >> >>> IronNails::View::XamlProxy.to_clr_type >> => #<System::RuntimeType:0x000005e> >> >> >> On Mon, Dec 8, 2008 at 5:54 PM, Aaron Feng <aaron.feng at gmail.com> wrote: >> >> Tomas, >> >> I tried it again. I couldn''t get the following to work with my own DLL >> even If I capitalize the namespace (It does work fine with build in types >> like System.String): >> >> > System::Type.get_type("Abc.Hi, Version=1.0.0.0, Culture=neutral, >> PublicKeyToken=null") >> >> Do I have any other options? >> >> Thanks, >> >> >> Aaron >> >> _______________________________________________ >> 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 > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20081208/02008f25/attachment-0001.html>
Ivan,
In this case you actually can''t do foo = x::y::z::Foo.new(1) because
IronRuby doesn''t support lowercase namespace. It think it''s a
method call.
That''s why I started out
Foo = Type.get_type("x.y.z.Foo, MyAssembly, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=null", true).to_class
Aaron
On Mon, Dec 8, 2008 at 4:52 PM, Ivan Porto Carrero <ivan at
flanders.co.nz>wrote:
> Normally
> foo = x::y::z::Foo.new(1)
>
> in the console you need to use global variables:$foo = x::y::z::Foo.new(1)
>
>
>
> On Mon, Dec 8, 2008 at 10:43 PM, Aaron Feng <aaron.feng at gmail.com>
wrote:
>
>> I tried to load the struct the same way, but I don''t know how
to set the
>> value of it. For example:
>>
>> C#
>>
>> namespace x.y.z {
>> public struct Foo {
>> public long Bar;
>> public Foo(long bar) {
>> this.Bar = bar;
>> }
>> }
>> }
>>
>> var foo = new x.y.z.Foo(1);
>>
>> IronRuby
>>
>> Foo = Type.get_type("x.y.z.Foo, MyAssembly, Version=1.0.0.0,
>> Culture=neutral, PublicKeyToken=null", true).to_class
>>
>> # how do I do the equivalent of
>> # var foo = new x.y.z.Foo(1); ?
>>
>> Aaron
>>
>>
>> On Mon, Dec 8, 2008 at 3:45 PM, Tomas Matousek <
>> Tomas.Matousek at microsoft.com> wrote:
>>
>>> You can use Assembly.LoadFile and point it to an absolute path
instead.
>>>
>>>
>>>
>>> Tomas
>>>
>>>
>>>
>>> *From:* ironruby-core-bounces at rubyforge.org [mailto:
>>> ironruby-core-bounces at rubyforge.org] *On Behalf Of *Aaron Feng
>>> *Sent:* Monday, December 08, 2008 12:33 PM
>>>
>>> *To:* ironruby-core at rubyforge.org
>>> *Subject:* Re: [Ironruby-core] Handling C# lower case namespaces
>>>
>>>
>>>
>>> Ok, I got Assembly.Load and Type.get_type both to work with my own
>>> DLL. The actual DLL have to live where ir.exe lives. Is there a
way for it
>>> to look in the directory of the ruby file? Like the way require
statement
>>> work.
>>>
>>> Aaron
>>>
>>>
>>> On Mon, Dec 8, 2008 at 2:11 PM, Tomas Matousek <
>>> Tomas.Matousek at microsoft.com> wrote:
>>>
>>> Can you load the assembly and get the type explicitly?
>>>
>>>
>>>
>>> require ''mscorlib''
>>>
>>> System::Reflection::Assembly.Load("IronNails.Library,
Version=1.0.0.0,
>>> Culture=neutral, PublicKeyToken=null").GetType(
>>> ''IronNails.View.XamlProxy'')
>>>
>>>
>>>
>>> Tomas
>>>
>>>
>>>
>>> *From:* ironruby-core-bounces at rubyforge.org [mailto:
>>> ironruby-core-bounces at rubyforge.org] *On Behalf Of *Ivan Porto
Carrero
>>> *Sent:* Monday, December 08, 2008 9:46 AM
>>>
>>>
>>> *To:* ironruby-core at rubyforge.org
>>>
>>> *Subject:* Re: [Ironruby-core] Handling C# lower case namespaces
>>>
>>>
>>>
>>> I get the same behavior.
>>> I can load types from the CLR but not from my own assembly.
>>>
>>> I copied my assembly into the folder that contains ir.exe
>>>
>>> >>> require ''mscorlib''
>>> => true
>>> >>> require ''IronNails.Library, Version=1.0.0.0,
Culture=neutral,
>>> PublicKeyToken=null''
>>> => true
>>> >>> IronNails::View::XamlProxy
>>> => IronNails::View::XamlProxy
>>> >>> System::Type.get_type
''IronNails.View.XamlProxy''
>>> => nil
>>> >>> System::Type.get_type
''System.String''
>>> => #<System::RuntimeType:0x000005c>
>>> >>> IronNails::View::XamlProxy.to_clr_type
>>> => #<System::RuntimeType:0x000005e>
>>>
>>>
>>> On Mon, Dec 8, 2008 at 5:54 PM, Aaron Feng <aaron.feng at
gmail.com>
>>> wrote:
>>>
>>> Tomas,
>>>
>>> I tried it again. I couldn''t get the following to work
with my own DLL
>>> even If I capitalize the namespace (It does work fine with build in
types
>>> like System.String):
>>>
>>> > System::Type.get_type("Abc.Hi, Version=1.0.0.0,
Culture=neutral,
>>> PublicKeyToken=null")
>>>
>>> Do I have any other options?
>>>
>>> Thanks,
>>>
>>>
>>> Aaron
>>>
>>> _______________________________________________
>>> 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
>>
>>
>
> _______________________________________________
> 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/20081208/1b2bccc1/attachment.html>
Welcome to the "wonderful" world of Fusion. If you use Assembly.LoadFrom, then you can only use the assembly reference itself to get the types. The canonical names don''t match assemblies loaded using LoadFrom. To use Assembly.Load, it has to be in one of the approved search paths (which, by default, is the path of the launching executable only, plus the GAC of course). We went through an almost excruciating amount of pain with assembly load paths and such to make all this work correctly in xUnit.net. -- Brad http://bradwilson.typepad.com/ On Mon, Dec 8, 2008 at 12:33 PM, Aaron Feng <aaron.feng at gmail.com> wrote:> Ok, I got Assembly.Load and Type.get_type both to work with my own DLL. > The actual DLL have to live where ir.exe lives. Is there a way for it to > look in the directory of the ruby file? Like the way require statement > work. > > Aaron > > > > On Mon, Dec 8, 2008 at 2:11 PM, Tomas Matousek < > Tomas.Matousek at microsoft.com> wrote: > >> Can you load the assembly and get the type explicitly? >> >> >> >> require ''mscorlib'' >> >> System::Reflection::Assembly.Load("IronNails.Library, Version=1.0.0.0, >> Culture=neutral, PublicKeyToken=null").GetType( >> ''IronNails.View.XamlProxy'') >> >> >> >> Tomas >> >> >> >> *From:* ironruby-core-bounces at rubyforge.org [mailto: >> ironruby-core-bounces at rubyforge.org] *On Behalf Of *Ivan Porto Carrero >> *Sent:* Monday, December 08, 2008 9:46 AM >> *To:* ironruby-core at rubyforge.org >> *Subject:* Re: [Ironruby-core] Handling C# lower case namespaces >> >> >> >> I get the same behavior. >> I can load types from the CLR but not from my own assembly. >> >> I copied my assembly into the folder that contains ir.exe >> >> >>> require ''mscorlib'' >> => true >> >>> require ''IronNails.Library, Version=1.0.0.0, Culture=neutral, >> PublicKeyToken=null'' >> => true >> >>> IronNails::View::XamlProxy >> => IronNails::View::XamlProxy >> >>> System::Type.get_type ''IronNails.View.XamlProxy'' >> => nil >> >>> System::Type.get_type ''System.String'' >> => #<System::RuntimeType:0x000005c> >> >>> IronNails::View::XamlProxy.to_clr_type >> => #<System::RuntimeType:0x000005e> >> >> >> >> On Mon, Dec 8, 2008 at 5:54 PM, Aaron Feng <aaron.feng at gmail.com> wrote: >> >> Tomas, >> >> I tried it again. I couldn''t get the following to work with my own DLL >> even If I capitalize the namespace (It does work fine with build in types >> like System.String): >> >> > System::Type.get_type("Abc.Hi, Version=1.0.0.0, Culture=neutral, >> PublicKeyToken=null") >> >> Do I have any other options? >> >> Thanks, >> >> Aaron >> >> _______________________________________________ >> 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 > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20081208/a85ab581/attachment-0001.html>