diff options
Diffstat (limited to 'main/src/core/MonoDevelop.Core/MonoDevelop.Core.Assemblies/TargetRuntime.cs')
-rw-r--r-- | main/src/core/MonoDevelop.Core/MonoDevelop.Core.Assemblies/TargetRuntime.cs | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Core.Assemblies/TargetRuntime.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Core.Assemblies/TargetRuntime.cs index 6ec1e3b665..d4f6439cf8 100644 --- a/main/src/core/MonoDevelop.Core/MonoDevelop.Core.Assemblies/TargetRuntime.cs +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Core.Assemblies/TargetRuntime.cs @@ -37,6 +37,7 @@ using MonoDevelop.Core.AddIns; using MonoDevelop.Core.Execution; using MonoDevelop.Core.Instrumentation; using System.Runtime.CompilerServices; +using System.Collections.Immutable; namespace MonoDevelop.Core.Assemblies { @@ -268,14 +269,19 @@ namespace MonoDevelop.Core.Assemblies return GetBackend (fx).GetFrameworkFolders (); } + // You can't really delete Facade assemblies while running the app. + static ImmutableDictionary<TargetFramework, string []> cachedFacadeAssemblies = ImmutableDictionary<TargetFramework, string []>.Empty; public IEnumerable<string> FindFacadeAssembliesForPCL (TargetFramework tx) { + if (cachedFacadeAssemblies.TryGetValue (tx, out var value)) + return value; + foreach (var folder in GetFrameworkFolders (tx)) { var facades = Path.Combine (folder, "Facades"); if (!Directory.Exists (facades)) continue; - return Directory.EnumerateFiles (facades, "*.dll"); + return ImmutableInterlocked.GetOrAdd (ref cachedFacadeAssemblies, tx, (_, dir) => Directory.GetFiles (dir, "*.dll"), facades); } //MonoDroid is special case because it's keeping Fascades in v1.0 folder @@ -283,12 +289,13 @@ namespace MonoDevelop.Core.Assemblies var frameworkFolder = GetFrameworkFolders (tx).FirstOrDefault (); if (frameworkFolder != null) { var facades = Path.Combine (Path.Combine (Path.GetDirectoryName (frameworkFolder), "v1.0"), "Facades"); - if (Directory.Exists (facades)) - return Directory.EnumerateFiles (facades, "*.dll"); + if (Directory.Exists (facades)) { + return ImmutableInterlocked.GetOrAdd (ref cachedFacadeAssemblies, tx, (_, dir) => Directory.GetFiles (dir, "*.dll"), facades); + } } } - return new string[0]; + return ImmutableInterlocked.GetOrAdd (ref cachedFacadeAssemblies, tx, Array.Empty<string> ()); } /// <summary> |