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

« back to all changes in this revision

Viewing changes to src/core/MonoDevelop.Core/MonoDevelop.Core.Assemblies/TargetRuntime.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:
61
61
                RuntimeAssemblyContext assemblyContext;
62
62
                ComposedAssemblyContext composedAssemblyContext;
63
63
                ITimeTracker timer;
64
 
                SynchronizationContext mainContext;
65
64
                TargetFramework[] customFrameworks = new TargetFramework[0];
66
65
                
67
66
                protected bool ShuttingDown { get; private set; }
88
87
                
89
88
                internal void StartInitialization ()
90
89
                {
91
 
                        // Store the main sync context, since we'll need later on for subscribing
92
 
                        // add-in extension points (Mono.Addins isn't currently thread safe)
93
 
                        mainContext = SynchronizationContext.Current;
94
 
                        
95
 
                        // If there is no custom threading context, we can't use background initialization since
96
 
                        // we have no main thread into which to dispatch
97
 
                        backgroundInitialize = mainContext != null && mainContext.GetType () != typeof (SynchronizationContext);
98
 
                        
99
 
                        if (backgroundInitialize) {
100
 
                                // Initialize the service in a background thread.
101
 
                                initializing = true;
102
 
                                Thread t = new Thread (new ThreadStart (BackgroundInitialize)) {
103
 
                                        Name = "Assembly service initialization",
104
 
                                        IsBackground = true,
105
 
                                };
106
 
                                t.Start ();
107
 
                        }
 
90
                        backgroundInitialize = true;
 
91
                        initializing = true;
 
92
                        ThreadPool.QueueUserWorkItem (BackgroundInitialize);
108
93
                }
109
94
                
110
95
                /// <summary>
250
235
                                if (!IsInstalled (fx)) {
251
236
                                        // Look for a compatible framework which is installed
252
237
                                        foreach (TargetFramework f in Runtime.SystemAssemblyService.GetTargetFrameworks ()) {
253
 
                                                if (IsInstalled (f) && f.IsCompatibleWithFramework (fx.Id)) {
 
238
                                                if (IsInstalled (f) && f.CanReferenceAssembliesTargetingFramework (fx)) {
254
239
                                                        fx = f;
255
240
                                                        break;
256
241
                                                }
368
353
                                if (!initialized && !initializing) {
369
354
                                        if (!backgroundInitialize) {
370
355
                                                initializing = true;
371
 
                                                BackgroundInitialize ();
 
356
                                                BackgroundInitialize (null);
372
357
                                        }
373
358
                                        else
374
359
                                                // If we are here, that's because 1) the runtime has been initialized, or 2) the runtime is being initialized by *this* thread
383
368
                        }
384
369
                }
385
370
                
386
 
                void BackgroundInitialize ()
 
371
                void BackgroundInitialize (object state)
387
372
                {
388
373
                        timer = Counters.TargetRuntimesLoading.BeginTiming ("Initializing Runtime " + Id);
389
374
                        lock (initLock) {
390
375
                                try {
391
376
                                        RunInitialization ();
392
 
                                } catch (Exception ex) {
 
377
                                } catch (Exception ex) {
 
378
                                        LogReporting.LogReportingService.ReportUnhandledException (ex, false);
393
379
                                        LoggingService.LogFatalError ("Unhandled exception in SystemAssemblyService background initialisation thread.", ex);
394
380
                                } finally {
395
381
                                        lock (initEventLock) {
509
495
                {
510
496
                        var frameworks = new HashSet<TargetFrameworkMoniker> ();
511
497
                        
512
 
                        foreach (TargetFramework fx in Runtime.SystemAssemblyService.GetCoreFrameworks ()) {
 
498
                        foreach (TargetFramework fx in Runtime.SystemAssemblyService.GetKnownFrameworks ()) {
513
499
                                // A framework is installed if the assemblies directory exists and the first
514
500
                                // assembly of the list exists.
515
501
                                if (frameworks.Add (fx.Id) && IsInstalled (fx)) {
544
530
                                        if (File.Exists (file)) {
545
531
                                                if (assembly.Version == null && IsRunning) {
546
532
                                                        try {
547
 
                                                                System.Reflection.AssemblyName aname = SystemAssemblyService.GetAssemblyNameObj (file);
 
533
                                                                AssemblyName aname = SystemAssemblyService.GetAssemblyNameObj (file);
548
534
                                                                assembly.Update (aname);
549
535
                                                        } catch {
550
536
                                                                // If something goes wrong when getting the name, just ignore the assembly
578
564
                {
579
565
                        return GetBackend (fx).GetFrameworkPackageInfo (packageName);
580
566
                }
581
 
                
 
567
 
582
568
                protected static IEnumerable<TargetFramework> FindTargetFrameworks (FilePath frameworksDirectory)
583
569
                {
 
570
                        return FindTargetFrameworks (frameworksDirectory, false);
 
571
                }
 
572
 
 
573
                protected static IEnumerable<TargetFramework> FindTargetFrameworks (FilePath frameworksDirectory, bool rescanKnownFrameworks)
 
574
                {
584
575
                        foreach (FilePath idDir in Directory.GetDirectories (frameworksDirectory)) {
585
576
                                var id = idDir.FileName;
586
577
                                foreach (FilePath versionDir in Directory.GetDirectories (idDir)) {
587
578
                                        var version = versionDir.FileName;
588
579
                                        var moniker = new TargetFrameworkMoniker (id, version);
589
 
                                        var fx = ReadTargetFramework (moniker, versionDir);
590
 
                                        if (fx != null)
591
 
                                                yield return (fx);
 
580
                                        if (rescanKnownFrameworks || !Runtime.SystemAssemblyService.IsKnownFramework (moniker)) {
 
581
                                                var fx = ReadTargetFramework (moniker, versionDir);
 
582
                                                if (fx != null)
 
583
                                                        yield return (fx);
 
584
                                        }
592
585
                                        var profileListDir = versionDir.Combine ("Profile");
593
586
                                        if (!Directory.Exists (profileListDir))
594
587
                                                continue;
595
588
                                        foreach (FilePath profileDir in Directory.GetDirectories (profileListDir)) {
596
589
                                                var profile = profileDir.FileName;
597
590
                                                moniker = new TargetFrameworkMoniker (id, version, profile);
598
 
                                                fx = ReadTargetFramework (moniker, profileDir);
599
 
                                                if (fx != null)
600
 
                                                        yield return (fx);
 
591
                                                if (rescanKnownFrameworks || !Runtime.SystemAssemblyService.IsKnownFramework (moniker)) {
 
592
                                                        var fx = ReadTargetFramework (moniker, profileDir);
 
593
                                                        if (fx != null)
 
594
                                                                yield return (fx);
 
595
                                                }
601
596
                                        }
602
597
                                }
603
598
                        }