[MonoDevelop] Resource IDs

Andras Biczo abiczo@easymail.hu
Thu, 21 Apr 2005 02:29:58 +0200

This is a multi-part message in MIME format.
Content-Type: text/plain; charset=ISO-8859-2; format=flowed
Content-Transfer-Encoding: 7bit


currently the resource ID of an embedded resource will be it's filename 
in MD (at least for c# projects, I haven't checked the others).
This is different from what Visual Studio does. What VS does is 
explained here:
I think this is a better way of assigning the IDs because currently in 
MD it can cause problems if you have two resources with the same 
filename (e.g. res/small/logo.png, res/big/logo.png). Besides this, it 
makes life easier for people that use MD and VS to work on the same project.

The patch I attached modifies the way MD assigns embedded resources' IDs 
(only for c# projects). It works as follows:
1. If the resource file is "inside" the project base directory then its 
ID will be its relative path with the directory separator character 
replaced with '.'.
2. Otherwise it gets the same ID as before.

Would anyone please review the patch?


Content-Type: text/x-patch;
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;

Index: Core/src/AddIns/BackendBindings/CSharpBinding/CSharpBindingCompilerManager.cs
--- Core/src/AddIns/BackendBindings/CSharpBinding/CSharpBindingCompilerManager.cs	(revision 2468)
+++ Core/src/AddIns/BackendBindings/CSharpBinding/CSharpBindingCompilerManager.cs	(working copy)
@@ -128,7 +128,13 @@
 							case BuildAction.EmbedAsResource:
 								// FIXME: workaround 60990
-								writer.WriteLine(@"""/res:{0},{1}""", finfo.Name, Path.GetFileName (finfo.Name));
+								string resourceId;
+								if(finfo.RelativePath.StartsWith ("." + Path.DirectorySeparatorChar)) {
+									resourceId = finfo.RelativePath.Substring(2).Replace (Path.DirectorySeparatorChar, '.');
+								} else {
+									resourceId = Path.GetFileName (finfo.Name);
+								}
+								writer.WriteLine(@"""/res:{0},{1}""", finfo.Name, resourceId);