Parsing/Processing DWF Section content

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Parsing/Processing DWF Section content

Jackie Ng
Hi All,

I've almost finished porting the PHP web tier test runner over to .net, allowing the SQLite-driven test suite to be executable from .net, exercising against the .net wrappers to the MapGuide API, giving us greater test coverage of the MapGuide wrapper APIs as a result.

Currently the .net test runner has 3 test failures and they all stem from what I'm certain is an incorrect .net implementation of the RemoveDwfSectionName function from ValidateUtils.php (ref: http://trac.osgeo.org/mapguide/browser/trunk/MgDev/UnitTest/WebTier/Php/ValidateUtils.php#L114)

Just looking at the function itself seems really simple. Return the bits between ".w2d" and "EndOfDWF" if both tokens exists and compare that snippet against the expected result from the SQLite test database, or the original content of neither token is found.

But the problem in .net is that we're working with byte arrays (because that's what Read() in MgByteReader is expecting in .net), and there's obviously some voodoo black magic in PHP that allows strings and byte arrays to be interchangeable. Well that doesn't really fly in .net as strings and byte arrays are two distinctly different things and we need to know the correct encoding in order to be able to transfer from one to the other or vice versa.

Here's what I currently have for .net (http://trac.osgeo.org/mapguide/browser/trunk/MgDev/UnitTest/WebTier/DotNet/TestCommon/CommonUtility.cs#L441). Not sure what I'm doing wrong here. Should we be trying to process this as a string or a raw byte array? Either way, the System.Text.Encoding will have to be involved (either to convert the whole byte array to a string, or to convert the tokens we're looking for into byte arrays for raw direct comparison), and I have no real clue what encoding I should be using. I'm currently just assuming System.Text.Encoding.UTF8. Not sure if this is right or not.

Any ideas?

- Jackie