mono/mono — pull request #440 by gary-b (2012-08-21 20:56:46+00:00)
Title: Bring resources implementation close to .NET 2 standard.

Implementation of StronglyTypedResourceBuilder
------------------------------------------------------------------------
This is an implementation of the class along with quite thorough test coverage.

Bring System.Resources closer to .NET 2 standard
-------------------------------------------------------------------------
A limited implementation of .NET 2 ResX handling was present in mono's System.Resources. .NET 2 ResX handling is based around the ResXDataNode class, these can be returned from a ResXResourceReader with UseResXDataNodes set to true encapsulating the resources in the file. Where as before ResXResourceReader simply returned the instantiated resource objects, this class provides details about the resource entry, including comments against it in the ResX file, the details of its location in the file system (through a ResXFileRef object) if it is not embedded and so on. Overloads of GetValueTypeName return the type of the resource object and GetValue returns the actual resource object, both of which accept parameters to customise the type resolution.

With the mono implementation, the ResXDataNode simply held a copy of the instantiated resource object, you couldn't tell if the resource was from a file at all. The GetValue (...) and GetValueTypeName (...) overloads simply returned this object or its type respectively and any parameters passed in were ignored.

Unit tests against .NET revealed it was very inconsistent itself. The ITypeResolutionService parameter passed in to GetValue and GetValueTypeName are sometimes ignored and sometimes used to resolve types. This depends on the way the resource are stored in the ResX file and under numerous conditions the output of one does not reflect the other. To be as compatible as possible this has been replicated.

Unit tests also show that a ResXDataNode created from a resource in a ResX file keeps the "serialised" string value pulled from the XML and this is used by the ResXResourceWriter when being written back again.

Support for soap formatted serialisation has also been added.

ResXResourceWriter has been updated to write out comments as well as support added for the BasePath property which now changes an absolute path to one relative to that specified.

Code for type resolution has been moved from ResXResourceReader to ResXDataNode.

Exception types have been updated to match .NET.

Unit tests have been included for everything.