On Wed, Jan 26, 2011 at 10:37 AM, impworks <[email protected]> wrote:
> I strongly believe something should be done on the Cecil side to deal
> with this inconsistency. C# itself does some sort of transformations:
Sorry, but have you been reading what I wrote?
> class A
> {
> void Test(double[,] a) { ... }
> }
>
> If I do the following:
>
> var method = typeof(A).GetMethod("Test", new Type[]
> { typeof(double[,]) } );
>
> The method will be found.
Sorry, but this is irrelevant.
> It can be later imported into Cecil Assembly without any problems, but
> it will cause a definite exception when you try to call it!
> My best guess is because at import time the actual type of the
> parameter generated by C# compiler (double[0...,0...]) falls back to
> double[,].
Allow me to repeat.
System.Type has no way to differentiate between a [,] and a
[0...,0...] array, so they're always represented as [,]. Which means
that if you try to Import a method with a parameter type of
[0...,0...], the ParameterType will be of type [,].
The only thing Cecil could do would be to resolve the MethodInfo to a
MethodDefinition (meaning reading the assembly in Cecil) which is
completely overkill to support this scenario only. Especially as there
is a very simple way to fix this: you need to use the overloads of
Import for Cecil types, as Cecil is able to differentiate [,] and
[0...,0...].
Consider taking some time to read
http://support.microsoft.com/kb/960240 It all boils down to the
incapacity of System.Type to differentiate [,] and [0...,0...].
Jb
--
--
mono-cecil