Dealing with StringReference types

Dec 9, 2010 at 11:20 AM
Edited Dec 9, 2010 at 11:21 AM

Recently we've come across a problem with the StringReference type, where in Charles we can see multiple strings of the same value in an array - the first element is of type String, and the rest are all of type StringReference, but on the server side we only get one string in the array.

Presumably this is an optimization technique to cut down on the size of the AMF objects, but the flash remoting decoder doesn't seem to handle this at the moment. Do you have any plans to incorporate support for it soon? Or perhaps you know of a way to turn this optimization off?

Thanks,

Yan

Coordinator
Dec 9, 2010 at 7:42 PM

That's unfortunate to hear - I thought that I had built that functionality into the codebase.  Unfortunately, I don't know how much time I have to work on it, however, I might be able to help you debug.  

In the Amf3Reader, there is a _stringReferences field - it should contain the initial reference when it reaches the ReadStringReference method.  Does that look like it's happening?

Dec 20, 2010 at 4:36 PM
Edited Dec 20, 2010 at 4:37 PM

Hi,

Please close this issue, had another look at this and confirmed that the _stringReferences field did contain all the initial references by the time it reaches ReadStringReference method and it's actually some of our code that's the problem. Turns out it became a problem when we made an Enumerable.Except call which surprising returns the distinct items:

var ilist = new[] { 1, 1, 1, 1 };

var ilist2 = Enumerable.Empty<int>();

ilist.Except(ilist2); // returns { 1 } as opposed to { 1, 1, 1, 1 }

and it works the same way with reference types too..

Thanks again for the fast reply and pointing me in the right direction!