Passing null to a function/accessing enums

Jan 19, 2010 at 8:22 PM

I have a method whose signature looks like this

public static MethodInfo GetMethodInfo(System.Type t, Type[] argTypes, string strMethod)

 

I would like to pass null for the Type[] arg. I thought i could do this by passing '() to it, but this doesn't work. It throws an error:

Unhandled exception during evaluation:
&assertion
&who: initialize
&message: "expected type: Type"
&irritants: (())

 

when doing

(set! t (clr-static-call IronScheme.Compiler.ClrGenerator GetTypeFast "IronScheme.Compiler.ClrGenerator"))

(clr-static-call Utils.Reflection GetMethodInfo t '() "ScanForTypes")

 

Also, I was wondering if it was possible to access the values of an  enum class like System.Reflection.BindingFlags

or would i somehow have to use reflectio? I tried (clr-static-prop-get System.Reflection.BindingFlags Default) but got the error

Unhandled exception during evaluation:
&who: "clr-call"
&message: "member could not be resolved on type: BindingFlags"
&syntax:
  form: ('System.Reflection.BindingFlags 'get_Default '())
  subform: "get_Default"

 

 

 

 

 

 

Jan 19, 2010 at 11:58 PM

Oh, and just btw, anyone reading this dont make the same mistake i  did. Dynamic method calling already exists --> in (import (ironscheme clr dynamic)) . Woops.

 

--creating procedure

(set! func (clr-call-site System.String Substring))

(func "WOOPS" 0 2)

--dynamically calling procedure (should probably memoize)

and other functions available, like

(clr-dynamic "AAAAA" Substring 0 2)

Coordinator
Jan 20, 2010 at 4:24 AM
Suroy wrote:

I have a method whose signature looks like this

public static MethodInfo GetMethodInfo(System.Type t, Type[] argTypes, string strMethod)

 

I would like to pass null for the Type[] arg. I thought i could do this by passing '() to it, but this doesn't work. It throws an error:

Unhandled exception during evaluation:
&assertion
&who: initialize
&message: "expected type: Type"
&irritants: (())

 

when doing

(set! t (clr-static-call IronScheme.Compiler.ClrGenerator GetTypeFast "IronScheme.Compiler.ClrGenerator"))

(clr-static-call Utils.Reflection GetMethodInfo t '() "ScanForTypes")

 

Also, I was wondering if it was possible to access the values of an  enum class like System.Reflection.BindingFlags

or would i somehow have to use reflectio? I tried (clr-static-prop-get System.Reflection.BindingFlags Default) but got the error

Unhandled exception during evaluation:
&who: "clr-call"
&message: "member could not be resolved on type: BindingFlags"
&syntax:
  form: ('System.Reflection.BindingFlags 'get_Default '())
  subform: "get_Default"

Hi

I think passing null could be a bug, will look.

For enums, just pass the symbol or a list of symbols. Eg (for BindingFlags)

'default

'(instance public)

Cheers

leppie

PS: Might need to use proper case, cant recall if I changed that too (yet).

 

'

Jan 20, 2010 at 5:14 AM

Thanks. Also, I found that theres a bug in generate-clr-call-site for methods which take no arguments.

(import (ironscheme clr dynamic))

(generate-clr-call-site (clr-call #f GetType "") 'ToString #f)

Unhandled exception during evaluation:
&assertion
&who: "car"
&message: "not a pair"
&irritants: (())

 

 

 

Coordinator
Jan 21, 2010 at 6:35 AM
Suroy wrote:

Thanks. Also, I found that theres a bug in generate-clr-call-site for methods which take no arguments.

(import (ironscheme clr dynamic))

(generate-clr-call-site (clr-call #f GetType "") 'ToString #f)

Unhandled exception during evaluation:
&assertion
&who: "car"
&message: "not a pair"
&irritants: (())

Thanks

Definitely a bug :)

To confirm, this only happen with methods taking 0 arguments?

Cheers

leppie

Coordinator
Jan 21, 2010 at 6:36 AM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.