~ubuntu-branches/ubuntu/trusty/monodevelop/trusty-proposed

« back to all changes in this revision

Viewing changes to src/core/MonoDevelop.Core/MonoDevelop.Projects.Formats.MD1/MD1DotNetProjectHandler.cs

  • Committer: Package Import Robot
  • Author(s): Jo Shields
  • Date: 2013-05-12 09:46:03 UTC
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20130512094603-mad323bzcxvmcam0
Tags: upstream-4.0.5+dfsg
ImportĀ upstreamĀ versionĀ 4.0.5+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
180
180
 
181
181
                                string fname = finfo.Name;
182
182
                                string resourceId;
183
 
                                CompilerError ce = GetResourceId (env, finfo, ref fname, resgen, out resourceId, monitor);
 
183
                                CompilerError ce = GetResourceId (configuration.IntermediateOutputDirectory.Combine (finfo.ResourceId), env, finfo, ref fname, resgen, out resourceId, monitor);
184
184
                                if (ce != null) {
185
185
                                        CompilerResults cr = new CompilerResults (new TempFileCollection ());
186
186
                                        cr.Errors.Add (ce);
207
207
                                projectItems.Remove (finfo);
208
208
                        }
209
209
 
210
 
                        string al = configuration.TargetFramework.ClrVersion == ClrVersion.Net_2_0 ? "al2" : "al";
 
210
                        string al = configuration.TargetRuntime.GetToolPath (configuration.TargetFramework, "al");
211
211
                        CompilerError err = GenerateSatelliteAssemblies (resourcesByCulture, configuration.OutputDirectory, al, Path.GetFileName (configuration.OutputAssembly), monitor);
212
212
                        if (err != null) {
213
213
                                CompilerResults cr = new CompilerResults (new TempFileCollection ());
219
219
                        return null;
220
220
                }
221
221
                
222
 
                CompilerError GetResourceId (ExecutionEnvironment env, ProjectFile finfo, ref string fname, string resgen, out string resourceId, IProgressMonitor monitor)
 
222
                CompilerError GetResourceId (FilePath outputFile, ExecutionEnvironment env, ProjectFile finfo, ref string fname, string resgen, out string resourceId, IProgressMonitor monitor)
223
223
                {
224
224
                        resourceId = finfo.ResourceId;
225
225
                        if (resourceId == null) {
233
233
                        if (String.Compare (Path.GetExtension (fname), ".resx", true) != 0)
234
234
                                return null;
235
235
 
236
 
                        if (!IsResgenRequired (fname)) {
237
 
                                fname = Path.ChangeExtension (fname, ".resources");
 
236
                        if (!IsResgenRequired (fname, outputFile)) {
 
237
                                fname = File.Exists (outputFile) ? (string)outputFile : Path.ChangeExtension (fname, ".resources");
238
238
                                return null;
239
239
                        }
240
240
                        
307
307
 
308
308
                // true if the resx file or any file referenced
309
309
                // by the resx is newer than the .resources file
310
 
                public static bool IsResgenRequired (string resx_filename)
 
310
                public static bool IsResgenRequired (string resx_filename, string output_filename)
311
311
                {
312
312
                        if (String.Compare (Path.GetExtension (resx_filename), ".resx", true) != 0)
313
313
                                throw new ArgumentException (".resx file expected", "resx_filename");
314
314
 
315
 
                        string resources_filename = Path.ChangeExtension (resx_filename, ".resources");
316
 
 
317
 
                        if (IsFileNewerThan (resx_filename, resources_filename))
318
 
                                return true;
319
 
 
320
 
                        XmlTextReader xr = null;
321
 
                        try {
322
 
                                // look for
323
 
                                // <data type="System.Resources.ResXFileRef, System.Windows.Forms" ..>
324
 
                                //   <value>... filename;.. </value>
325
 
                                // </data>
326
 
                                xr = new XmlTextReader (resx_filename);
327
 
                                string basepath = Path.GetDirectoryName (resx_filename);
328
 
                                while (xr.Read ()) {
329
 
                                        if (xr.NodeType != XmlNodeType.Element ||
330
 
                                                String.Compare (xr.LocalName, "data") != 0)
331
 
                                                continue;
332
 
 
333
 
                                        string type = xr.GetAttribute ("type");
334
 
                                        if (String.IsNullOrEmpty (type))
335
 
                                                continue;
336
 
 
337
 
                                        if (String.Compare (type, "System.Resources.ResXFileRef, System.Windows.Forms") != 0)
338
 
                                                continue;
339
 
 
340
 
                                        xr.ReadToDescendant ("value");
341
 
                                        if (xr.NodeType != XmlNodeType.Element)
342
 
                                                continue;
343
 
 
344
 
                                        string value = xr.ReadElementContentAsString ();
345
 
 
346
 
                                        string [] parts = value.Split (';');
347
 
                                        if (parts.Length > 0) {
348
 
                                                string referenced_filename = MSBuildProjectService.FromMSBuildPath (
349
 
                                                                String.Empty, Path.Combine (basepath, parts [0]).Trim ());
350
 
                                                if (File.Exists (referenced_filename) &&
351
 
                                                        IsFileNewerThan (referenced_filename, resources_filename))
352
 
                                                        return true;
353
 
                                        }
354
 
                                }
355
 
                        } catch (XmlException) {
356
 
                                // Ignore xml errors, let resgen handle it
357
 
                                return true;
358
 
                        } finally {
359
 
                                if (xr != null)
360
 
                                        xr.Close ();
361
 
                        }
362
 
 
363
 
                        return false;
 
315
                        if (File.Exists (output_filename))
 
316
                                return IsFileNewerThan (resx_filename, output_filename);
 
317
                        return IsFileNewerThan (resx_filename, Path.ChangeExtension (resx_filename, ".resources"));
364
318
                }
365
319
 
366
320
                // true if first is newer than second