~ubuntu-branches/ubuntu/oneiric/monodevelop/oneiric

« back to all changes in this revision

Viewing changes to src/core/MonoDevelop.Core/MonoDevelop.Projects/DotNetProject.cs

  • Committer: Bazaar Package Importer
  • Author(s): Jo Shields
  • Date: 2011-06-27 17:03:13 UTC
  • mto: (1.8.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 54.
  • Revision ID: james.westby@ubuntu.com-20110627170313-6cvz3s19x6e9hqe9
ImportĀ upstreamĀ versionĀ 2.5.92+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
49
49
namespace MonoDevelop.Projects
50
50
{
51
51
        [DataInclude(typeof(DotNetProjectConfiguration))]
 
52
        [ProjectModelDataItem ("AbstractDotNetProject")]
52
53
        public abstract class DotNetProject : Project, IAssemblyProject
53
54
        {
54
55
 
135
136
                        }
136
137
 
137
138
                        if ((projectOptions != null) && (projectOptions.Attributes["TargetFrameworkVersion"] != null))
138
 
                                targetFrameworkVersion = projectOptions.Attributes["TargetFrameworkVersion"].Value;
 
139
                                targetFrameworkId = TargetFrameworkMoniker.Parse (projectOptions.Attributes["TargetFrameworkVersion"].Value);
139
140
 
140
141
                        string binPath;
141
142
                        if (projectCreateInfo != null) {
275
276
                        }
276
277
                }
277
278
 
278
 
                string targetFrameworkVersion;
 
279
                TargetFrameworkMoniker targetFrameworkId;
279
280
                TargetFramework targetFramework;
280
281
 
281
282
                public TargetFramework TargetFramework {
291
292
                                if (targetFramework == validValue || validValue == null)
292
293
                                        return;
293
294
                                targetFramework = validValue;
294
 
                                targetFrameworkVersion = validValue.Id;
 
295
                                targetFrameworkId = validValue.Id;
295
296
                                if (replacingValue)
296
297
                                        UpdateSystemReferences ();
297
298
                                NotifyModified ("TargetFramework");
301
302
                public TargetRuntime TargetRuntime {
302
303
                        get { return Runtime.SystemAssemblyService.DefaultRuntime; }
303
304
                }
 
305
                
 
306
                public virtual TargetFrameworkMoniker GetDefaultTargetFrameworkId ()
 
307
                {
 
308
                        return ProjectService.DefaultTargetFrameworkId;
 
309
                }
304
310
 
305
311
                public IAssemblyContext AssemblyContext {
306
312
                        get {
325
331
                void SetDefaultFramework ()
326
332
                {
327
333
                        if (targetFramework == null) {
328
 
                                if (targetFrameworkVersion != null)
329
 
                                        targetFramework = Runtime.SystemAssemblyService.GetTargetFramework (targetFrameworkVersion);
 
334
                                if (targetFrameworkId != null)
 
335
                                        targetFramework = Runtime.SystemAssemblyService.GetTargetFramework (targetFrameworkId);
330
336
                                if (targetFramework == null)
331
337
                                        TargetFramework = Services.ProjectService.DefaultTargetFramework;
332
338
                        }
382
388
 
383
389
                public override void Dispose ()
384
390
                {
385
 
                        base.Dispose ();
386
 
                        if (composedAssemblyContext != null)
 
391
                        if (composedAssemblyContext != null) {
387
392
                                composedAssemblyContext.Dispose ();
 
393
                                // composedAssemblyContext = null;
 
394
                        }
 
395
                                
 
396
                        // languageParameters = null;
 
397
                        // privateAssemblyContext = null;
 
398
                        // currentRuntimeContext = null;
 
399
                        // languageBinding = null;
 
400
                        // projectReferences = null;
 
401
                        
388
402
                        Runtime.SystemAssemblyService.DefaultRuntimeChanged -= RuntimeSystemAssemblyServiceDefaultRuntimeChanged;
389
403
                        FileService.FileRemoved -= OnFileRemoved;
 
404
                        
 
405
                        base.Dispose ();
390
406
                }
391
407
 
392
408
                public virtual bool SupportsPartialTypes {
416
432
 
417
433
                internal override void OnFileChanged (object source, MonoDevelop.Core.FileEventArgs e)
418
434
                {
 
435
                        // The OnFileChanged handler is unsubscibed in the Dispose method, so in theory we shouldn't need
 
436
                        // to check for disposed here. However, it might happen that this project is disposed while the
 
437
                        // FileService.FileChanged event is being dispatched, in which case the event handler list is already
 
438
                        // cached and won't take into account unsubscriptions until the next dispatch
 
439
                        if (Disposed)
 
440
                                return;
 
441
                        
419
442
                        base.OnFileChanged (source, e);
420
 
                        CheckReferenceChange (e.FileName);
 
443
                        foreach (FileEventInfo ei in e)
 
444
                                CheckReferenceChange (ei.FileName);
421
445
                }
422
446
 
423
447
 
449
473
                        return base.OnRunTarget (monitor, target, configuration);
450
474
                }
451
475
                
452
 
                protected override void PopulateOutputFileList (List<FilePath> list, ConfigurationSelector configuration)
 
476
                internal protected override void PopulateOutputFileList (List<FilePath> list, ConfigurationSelector configuration)
453
477
                {
454
478
                        base.PopulateOutputFileList (list, configuration);
455
479
                        DotNetProjectConfiguration conf = GetConfiguration (configuration) as DotNetProjectConfiguration;
479
503
                                }
480
504
                        }
481
505
                }
 
506
                
 
507
                [ThreadStatic]
 
508
                static int supportReferDistance = -1;
482
509
 
483
 
                protected override void PopulateSupportFileList (FileCopySet list, ConfigurationSelector configuration)
 
510
                internal protected override void PopulateSupportFileList (FileCopySet list, ConfigurationSelector configuration)
484
511
                {
485
 
                        PopulateSupportFileList (list, configuration, 0);
 
512
                        try {
 
513
                                supportReferDistance++;
 
514
                                PopulateSupportFileListInternal (list, configuration);
 
515
                        } finally {
 
516
                                supportReferDistance--;
 
517
                        }
486
518
                }
487
519
 
488
 
                void PopulateSupportFileList (FileCopySet list, ConfigurationSelector configuration, int referenceDistance)
 
520
                void PopulateSupportFileListInternal (FileCopySet list, ConfigurationSelector configuration)
489
521
                {
490
 
                        if (referenceDistance < 2)
 
522
                        if (supportReferDistance < 2)
491
523
                                base.PopulateSupportFileList (list, configuration);
492
524
 
493
525
                        //rename the app.config file
494
 
                        FileCopySet.Item appConfig = list.Remove ("app.config");
495
 
                        if (appConfig == null)
496
 
                                appConfig = list.Remove ("App.config");
 
526
                        list.Remove ("app.config");
 
527
                        list.Remove ("App.config");
 
528
                        
 
529
                        ProjectFile appConfig = Files.FirstOrDefault (f => f.FilePath.FileName.Equals ("app.config", StringComparison.CurrentCultureIgnoreCase));
497
530
                        if (appConfig != null) {
498
 
                                string output = Path.GetFileName (GetOutputFileName (configuration));
499
 
                                list.Add (appConfig.Src, appConfig.CopyOnlyIfNewer, output + ".config");
 
531
                                string output = GetOutputFileName (configuration).FileName;
 
532
                                list.Add (appConfig.FilePath, true, output + ".config");
500
533
                        }
501
534
                        
502
535
                        //collect all the "local copy" references and their attendant files
522
555
 
523
556
                                        //VS COMPAT: recursively copy references's "local copy" files
524
557
                                        //but only copy the "copy to output" files from the immediate references
525
 
                                        p.PopulateSupportFileList (list, configuration, referenceDistance + 1);
 
558
                                        foreach (var f in p.GetSupportFileList (configuration))
 
559
                                                list.Add (f.Src, f.CopyOnlyIfNewer, f.Target);
526
560
 
527
561
                                        DotNetProjectConfiguration refConfig = p.GetConfiguration (configuration) as DotNetProjectConfiguration;
528
562
 
537
571
                                        // VS COMPAT: Copy the assembly, but also all other assemblies referenced by it
538
572
                                        // that are located in the same folder
539
573
                                        foreach (string file in GetAssemblyRefsRec (projectReference.Reference, new HashSet<string> ())) {
540
 
                                                list.Add (file);
 
574
                                                // Indirectly referenced assemblies are only copied if a newer copy doesn't exist. This avoids overwritting directly referenced assemblies
 
575
                                                // by indirectly referenced stale copies of the same assembly. See bug #655566.
 
576
                                                bool copyIfNewer = file != projectReference.Reference;
 
577
                                                list.Add (file, copyIfNewer);
541
578
                                                if (File.Exists (file + ".config"))
542
 
                                                        list.Add (file + ".config");
 
579
                                                        list.Add (file + ".config", copyIfNewer);
543
580
                                                string mdbFile = TargetRuntime.GetAssemblyDebugInfoFile (file);
544
581
                                                if (File.Exists (mdbFile))
545
 
                                                        list.Add (mdbFile);
 
582
                                                        list.Add (mdbFile, copyIfNewer);
546
583
                                        }
547
584
                                }
548
585
                                else if (projectReference.ReferenceType == ReferenceType.Custom) {
624
661
                        yield return fileName;
625
662
                        Mono.Cecil.AssemblyDefinition adef;
626
663
                        try {
627
 
                                adef = Mono.Cecil.AssemblyFactory.GetAssemblyManifest (fileName);
 
664
                                adef = Mono.Cecil.AssemblyDefinition.ReadAssembly (fileName);
628
665
                        } catch {
629
666
                                yield break;
630
667
                        }
1025
1062
                        }
1026
1063
                }
1027
1064
 
1028
 
                protected internal override void OnItemAdded (object obj)
 
1065
                protected internal override void OnItemsAdded (IEnumerable<ProjectItem> objs)
1029
1066
                {
1030
 
                        base.OnItemAdded (obj);
1031
 
                        if (obj is ProjectReference) {
1032
 
                                ProjectReference pref = (ProjectReference)obj;
 
1067
                        base.OnItemsAdded (objs);
 
1068
                        foreach (var pref in objs.OfType<ProjectReference> ()) {
1033
1069
                                pref.SetOwnerProject (this);
1034
1070
                                NotifyReferenceAddedToProject (pref);
1035
1071
                        }
1036
1072
                }
1037
1073
 
1038
 
                protected internal override void OnItemRemoved (object obj)
 
1074
                protected internal override void OnItemsRemoved (IEnumerable<ProjectItem> objs)
1039
1075
                {
1040
 
                        base.OnItemRemoved (obj);
1041
 
                        if (obj is ProjectReference) {
1042
 
                                ProjectReference pref = (ProjectReference)obj;
 
1076
                        base.OnItemsRemoved (objs);
 
1077
                        foreach (var pref in objs.OfType<ProjectReference> ()) {
1043
1078
                                pref.SetOwnerProject (null);
1044
1079
                                NotifyReferenceRemovedFromProject (pref);
1045
1080
                        }
1079
1114
 
1080
1115
                private void OnFileRemoved (Object o, FileEventArgs e)
1081
1116
                {
1082
 
                        CheckReferenceChange (e.FileName);
 
1117
                        foreach (FileEventInfo ei in e)
 
1118
                                CheckReferenceChange (ei.FileName);
1083
1119
                }
1084
1120
 
1085
1121
                protected override void DoExecute (IProgressMonitor monitor, ExecutionContext context, ConfigurationSelector configuration)