From b91895bfae3cd14c1d3b0dac652bff9ea05a6481 Mon Sep 17 00:00:00 2001 From: Matt Ward Date: Thu, 12 Apr 2018 16:28:45 +0100 Subject: [Core] Support facade assemblies from a custom location Added a OnGetFacadeAssemblies method to the DotNetProjectExtension that allows a project extension to provide the facade assemblies for a project if the default behaviour does not work for the project. This can be used by the Xamarin.Mac project extension to provide the facade assemblies when the project uses Xamarin.Mac full. A Xamarin.Mac full project will use a custom facades directory at build time but the project has a target framework of .NET Framework so the default facades assembly resolution logic will return the wrong facade assemblies that are included with Mono. --- .../MonoDevelop.Projects/DotNetProject.cs | 35 +++++++++++++++++----- .../MonoDevelop.Projects/DotNetProjectExtension.cs | 5 ++++ 2 files changed, 32 insertions(+), 8 deletions(-) (limited to 'main/src/core') diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/DotNetProject.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/DotNetProject.cs index 07b2ca1735..8186af470c 100644 --- a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/DotNetProject.cs +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/DotNetProject.cs @@ -972,19 +972,33 @@ namespace MonoDevelop.Projects } if (addFacadeAssemblies) { - var runtime = TargetRuntime ?? MonoDevelop.Core.Runtime.SystemAssemblyService.DefaultRuntime; - var facades = runtime.FindFacadeAssembliesForPCL (TargetFramework); - foreach (var facade in facades) { - if (!File.Exists (facade)) - continue; - var ar = new AssemblyReference (facade); - if (!result.Contains (ar)) - result.Add (ar); + var facades = await ProjectExtension.OnGetFacadeAssemblies (); + if (facades != null) { + foreach (var facade in facades) { + if (!result.Contains (facade)) + result.Add (facade); + } } } return result; } + internal protected virtual Task> OnGetFacadeAssemblies () + { + List result = null; + var runtime = TargetRuntime ?? Runtime.SystemAssemblyService.DefaultRuntime; + var facades = runtime.FindFacadeAssembliesForPCL (TargetFramework); + foreach (var facade in facades) { + if (!File.Exists (facade)) + continue; + if (result == null) + result = new List (); + var ar = new AssemblyReference (facade); + result.Add (ar); + } + return Task.FromResult (result); + } + AsyncCriticalSection referenceCacheLock = new AsyncCriticalSection (); ImmutableDictionary> referenceCache = ImmutableDictionary>.Empty; bool referenceCacheNeedsRefresh; @@ -2030,6 +2044,11 @@ namespace MonoDevelop.Projects return Project.OnGetReferencedAssemblyProjects (configuration); } + internal protected override Task> OnGetFacadeAssemblies () + { + return Project.OnGetFacadeAssemblies (); + } + #pragma warning disable 672 // Member overrides obsolete member internal protected override ExecutionCommand OnCreateExecutionCommand (ConfigurationSelector configSel, DotNetProjectConfiguration configuration) { diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/DotNetProjectExtension.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/DotNetProjectExtension.cs index 3737d95c64..62106c0508 100644 --- a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/DotNetProjectExtension.cs +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/DotNetProjectExtension.cs @@ -88,6 +88,11 @@ namespace MonoDevelop.Projects return next.OnGetReferencedAssemblyProjects (configuration); } + internal protected virtual Task> OnGetFacadeAssemblies () + { + return next.OnGetFacadeAssemblies (); + } + [Obsolete("User overload that takes a RunConfiguration")] internal protected virtual ExecutionCommand OnCreateExecutionCommand (ConfigurationSelector configSel, DotNetProjectConfiguration configuration) { -- cgit v1.2.3