[System.Data.Services.Client] Compile in string resources.
authorJonathan Pryor <jonpryor@vt.edu>
Wed, 29 Feb 2012 00:31:02 +0000 (19:31 -0500)
committerJonathan Pryor <jonpryor@vt.edu>
Wed, 29 Feb 2012 00:36:49 +0000 (19:36 -0500)
System.Data.Services.Client uses System.Resources for localization
purposes (even though only one language is provided...). Consequently,
to get _useful_ strings (read: error messages) out of
System.Data.Services.Client, System.Resources needs to be able to find
them, such that the following works:

$ csharp -r:System.Data.Services.Client;
Mono C# Shell, type "help;" for help

Enter statements below.
csharp> using System.Resources;
csharp> using System.Data.Services.Client;
csharp> var a = typeof(SendingRequestEventArgs).Assembly;
csharp> var r = new ResourceManager("System.Data.Services.Client", a);
csharp> r.GetString("AtomMaterializer_PropertyNotExpectedEntry");

If `r.GetString()` fails, it'll throw an exception instead of
returning a useful string, which is bad. Unfortunately, it failed.

To fix this, we use `resgen` to compile
Client/System.Data.Services.Client.txt into a .resources file and
compile the .resources file into the assembly with `gmcs -resource:`,
which allows the above `csharp` fragment to work w/o throwing (and
thus allows OData users to get useful, meaningful error messages).

mcs/class/System.Data.Services.Client/Makefile

index 1610a466d7026d5df3556b7e6d9ef09086953a00..9f4e3b8b4d728420ece24048b42dd2632d205638 100644 (file)
@@ -4,6 +4,9 @@ include ../../build/rules.make
 
 LIBRARY = System.Data.Services.Client.dll
 
+Client/System.Data.Services.Client.resources: Client/System.Data.Services.Client.txt
+       $(RESGEN) "$<" "$@"
+
 LIB_MCS_FLAGS = \
        -d:NET_3_5      \
        -r:System.dll \
@@ -11,6 +14,7 @@ LIB_MCS_FLAGS = \
        -r:System.Xml.Linq.dll \
        -r:System.Data.dll \
        -r:System.Xml.dll \
+       -resource:Client/System.Data.Services.Client.resources \
        -warn:2
 
 ifneq (2.1, $(FRAMEWORK_VERSION))
@@ -18,3 +22,8 @@ LIB_MCS_FLAGS += -r:WindowsBase
 endif
 
 include ../../build/library.make
+
+$(the_lib): Client/System.Data.Services.Client.resources
+
+EXTRA_DISTFILES = Client/System.Data.Services.Client.txt
+CLEAN_FILES += Client/System.Data.Services.Client.resources