I have the solution. I'll send you the fix as soon a I get approval
for that (company policies rule ;) )

On Jun 10, 1:44 pm, emvy <[EMAIL PROTECTED]> wrote:
> I am closer to the problem now :)
>
> The problem is with the unbounded arrays. Cecil implicitly assumes
> that the array indices have the lower bound of 0, that's why the array
> types of [,,] are changed to [0...,0...,0...]. The CIL, however, may
> contain arrays with non-bounded indices (see ECMA-335 standard,
> Partition II, 14.2).
>
> I'll check the Mono source for that problem.
>
> On Jun 9, 7:55 pm, emvy <[EMAIL PROTECTED]> wrote:
>
> > Sorry for the many posts:
>
> > actually, the code produced by the F# compiler contains the following
> > TypeRef:
>
> > TypeRef #43 (0100002b)
> > -------------------------------------------------------
> > Token:             0x0100002b
> > ResolutionScope:   0x23000002
> > TypeRefName:       Microsoft.FSharp.Collections.Array3
> >         MemberRef #1 (0a00007e)
> >         -------------------------------------------------------
> >                 Member: (0a00007e) init:
> >                 CallCnvntn: [DEFAULT]
> >                 generic
> >                 Type Arity:1
> >                 ReturnType: MDArray MVar!!0 3 0 0
> >                 4 Arguments
> >                         Argument #1:  I4
> >                         Argument #2:  I4
> >                         Argument #3:  I4
> >                         Argument #4:  GenericInst Class 
> > Microsoft.FSharp.Core.FastFunc`2<
> > I4, GenericInst Class Microsoft.FSharp.Core.FastFunc`2< I4,
> > GenericInst Class Microsoft.FSharp.Core.FastFunc`2< I4, MVar!!0>>>
>
> > If i load/save it with mono, it changes to
>
> > TypeRef #2 (01000002)
> > -------------------------------------------------------
> > Token:             0x01000002
> > ResolutionScope:   0x23000002
> > TypeRefName:       Microsoft.FSharp.Collections.Array3
> >         MemberRef #1 (0a00000e)
> >         -------------------------------------------------------
> >                 Member: (0a00000e) init:
> >                 CallCnvntn: [DEFAULT]
> >                 generic
> >                 Type Arity:1
> >                 ReturnType: MDArray MVar!!0 3 0 3 0 0 0
> >                 4 Arguments
> >                         Argument #1:  I4
> >                         Argument #2:  I4
> >                         Argument #3:  I4
> >                         Argument #4:  GenericInst Class 
> > Microsoft.FSharp.Core.FastFunc`2<
> > I4, GenericInst Class Microsoft.FSharp.Core.FastFunc`2< I4,
> > GenericInst Class Microsoft.FSharp.Core.FastFunc`2< I4, MVar!!0>>>
>
> > You can see that the return type is changed somehow. The format Cecil
> > emits (ReturnType: MDArray MVar!!0 3 0 3 0 0 0) is exactly the same
> > what the C# compiler emits. But for some reason, the F# compiler emits
> > the different form (ReturnType: MDArray MVar!!0 3 0 0), which is
> > correct (it runs, verifies, etc.), and Cecil knows that it's an array,
> > but because of the changes what saving causes, the token resolution
> > does not work.
>
> > On Jun 9, 7:45 pm, emvy <[EMAIL PROTECTED]> wrote:
>
> > > Sorry, it is not a good example. The only good example I found is when
> > > I use Array3.init<T1,T2,T3,classT> which is in the fslib.dll, which is
> > > the free F# library from Microsoft. The class definitions of fslib.dll
> > > differ from the usual ones. I'll try to examine it further...
>
> > > On Jun 9, 7:01 pm, emvy <[EMAIL PROTECTED]> wrote:
>
> > > > The problem is the following, it seems:
> > > > Assume that you have an assembly (A1) referencing an other
> > > > assembly(A2). A2 has a method in it which returns a multidimensional
> > > > array. A1 calls this method somewhere. If A1 is opened / saved by
> > > > Cecil, then the signatures of methods which return a MD array will
> > > > change from [,,] like to [0...,0...,0...]. This is not a problem in
> > > > the general case, when the method is specified in A1, because the type
> > > > reference is also changed. But because Cecil changes A1 but not A2, on
> > > > assembly loading, Fusion will be unable to associate the method
> > > > reference called from A1 and the method definition in A2, because in
> > > > A1, the signatures changed.
>
> > > > Sample code:
> > > > A1: (first assembly:)
>
> > > > namespace ArrayReturnType
> > > > {
> > > >   class Program
> > > >   {
> > > >     static void Main(string[] args)
> > > >     {
> > > >       ArrayReturn.GetArray();
> > > >     }
> > > >   }
>
> > > > }
>
> > > > A2:
> > > > namespace ArrayReturnTypeDLL
> > > > {
> > > >   public class ArrayReturn
> > > >   {
> > > >     public static int[,] GetArray()
> > > >     {
> > > >       return new int[1, 1];
> > > >     }
> > > >   }
>
> > > > }
>
> > > > If you load / save A1, peverify will be unable to resolve the tokens
> > > > of the method.
>
> > > > On Jun 9, 6:07 pm, "Jb Evain" <[EMAIL PROTECTED]> wrote:
>
> > > > > On 6/9/08, emvy <[EMAIL PROTECTED]> wrote:
>
> > > > > >  And I have to tell that the problem occurs in a situation when a
> > > > > >  generic method returns an array of its generic parameters.
>
> > > > > Could you please provide a test case?
>
> > > > > --
> > > > > Jb Evain  <[EMAIL PROTECTED]>
--~--~---------~--~----~------------~-------~--~----~
--
mono-cecil
-~----------~----~----~----~------~----~------~--~---

Reply via email to