Archived

This forum has been archived. Please start a new discussion on GitHub.

problem in mapping string->string[] in C#

Hi guys,

I tried to generate a C# dictionaryBase impl which names stringArrayMap that maps string->string[], however, the generated code couldn't be compiled:

public override bool Equals(object other)
{
if(object.ReferenceEquals(this, other))
{
return true;
}
if(!(other is StringArrayMap))
{
return false;
}
if(Count != ((StringArrayMap)other).Count)
{
return false;
}
string[] __klhs = new string[Count];
Keys.CopyTo(__klhs, 0);
_System.Array.Sort(__klhs);
string[] __krhs = new string[((StringArrayMap)other).Count];
((StringArrayMap)other).Keys.CopyTo(__krhs, 0);
_System.Array.Sort(__krhs);
for(int i = 0; i < Count; ++i)
{
if(!__klhs.Equals(__krhs))
{
return false;
}
}
string[][] __vlhs = new string[][Count];
Values.CopyTo(__vlhs, 0);
_System.Array.Sort(__vlhs);
string[][] __vrhs = new string[][((StringArrayMap)other).Count];
((StringArrayMap)other).Values.CopyTo(__vrhs, 0);
_System.Array.Sort(__vrhs);
for(int i = 0; i < Count; ++i)
{
if(__vlhs == null && __vrhs != null)
{
return false;
}
if(!__vlhs.Equals(__vrhs))
{
return false;
}
}
return true;
}

the problem lies in:
string[][] __vlhs = new string[][Count];

do I have to turn to string->collection to get around that? Thanks!

Tea

Comments

  • Re: problem in mapping string->string[] in C#
    Originally posted by teayu
    Hi guys,

    I tried to generate a C# dictionaryBase impl which names stringArrayMap that maps string->string[], however, the generated code couldn't be compiled:


    string[][] __vlhs = new string[][Count];
    Values.CopyTo(__vlhs, 0);
    _System.Array.Sort(__vlhs);
    string[][] __vrhs = new string[][((StringArrayMap)other).Count];
    the problem lies in:
    string[][] __vlhs = new string[][Count];

    You are right, that's a bug. This should read:
    	    string[][] __vlhs = new string[Count][];
    	    Values.CopyTo(__vlhs, 0);
    	    _System.Array.Sort(__vlhs);
    	    string[][] __vrhs = new string[((StringArrayMap)other).Count][];
    
    do I have to turn to string->collection to get around that?

    For the moment, that will get you off the hook. I'll post a patch to fix this later today. Thanks for the bug report!

    Cheers,

    Michi.
  • I've posted a patch for this problem at http://www.zeroc.com/vbulletin/showthread.php?s=&threadid=914.

    Cheers,

    Michi.