void DomFromResource (string resfile, CodeCompileUnit unit, Dictionary <string,bool> assemblies,
CodeDomProvider provider)
{
+ if (String.IsNullOrEmpty (resfile))
+ return;
+
string fname, nsname, classname;
fname = Path.GetFileNameWithoutExtension (resfile);
if (!provider.IsValidIdentifier (nsname) || !provider.IsValidIdentifier (classname))
throw new ApplicationException ("Invalid resource file name.");
+
+ ResourceReader res;
+ try {
+ res = new ResourceReader (resfile);
+ } catch (ArgumentException) {
+ // invalid stream, probably empty - ignore silently and abort
+ return;
+ }
CodeNamespace ns = new CodeNamespace (nsname);
CodeTypeDeclaration cls = new CodeTypeDeclaration (classname);
// Add the resource properties
Dictionary<string,bool> imports = new Dictionary<string,bool> ();
try {
- ResourceReader res = new ResourceReader (resfile);
foreach (DictionaryEntry de in res) {
Type type = de.Value.GetType ();
cls.Members.Add (cmp);
}
} catch (Exception ex) {
- throw new ApplicationException ("Failed to comipile global resources.", ex);
+ throw new ApplicationException ("Failed to compile global resources.", ex);
}
foreach (KeyValuePair<string,bool> de in imports)
ns.Imports.Add (new CodeNamespaceImport(de.Key));
2007-03-09 Marek Habersack <mhabersack@novell.com>
+ * AppResourcesCompiler.cs: attempt to load the resource file
+ earlier in the process, to gracefully handle empty files.
+
* ThemeDirectoryCompiler.cs: make compiled themes depend on the
.skin and .css files composing the theme.