Hi Martin, On 7/28/09, msponholtz <[email protected]> wrote: > It seems that I've found an inconsistency concerning arrays versus > multidimensional arrays. The following code illustrates the issue: > > public string IndexerMethod() > { > string[] singleDimension = new[] { "x" }; > string[,] multipleDimension = new[,] { { "x" } }; > return singleDimension[0] + multipleDimension[0, 0]; > } > > Analyzing the IL code of the above method body only results in three > method references which when resolved are: > > {System.Void System.String[,]::Set > (System.Int32,System.Int32,System.String)} > {System.String System.String[,]::Get(System.Int32,System.Int32)} > {System.String System.String::Concat(System.String,System.String)} > > Which leads me to believe that single dimensional arrays are handled > differently then multidimensional arrays in Mono.Cecil. Is this true?
Cecil handles them differently because the runtime does so. While there are opcodes to get and set elements from a vector, the runtime use those methods to get and set them from a multi dimensional array. > The secondary problem is then how do i look up the type definition for > the type "String[,]"... isn't this type really just System.Array, > which has the following members: There's no definition for an array type. What you can get, is an ArrayType (with the dimensions you want), in which you specify the element type you want. If you need to emit those special calls, just create the appropriate MethodReference with the proper declaring type. -- Jb Evain <[email protected]> --~--~---------~--~----~------------~-------~--~----~ -- mono-cecil -~----------~----~----~----~------~----~------~--~---
