-
-
Notifications
You must be signed in to change notification settings - Fork 339
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #191 from Flow-Launcher/dev
Release 1.4.0 | Plugin 1.2.2
- Loading branch information
Showing
54 changed files
with
493 additions
and
513 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<Project> | ||
<Target Name="ExcludePluginProjectReferenceOutput" | ||
AfterTargets="AssignProjectConfiguration" | ||
BeforeTargets="ResolveProjectReferences" | ||
Condition="'$(OutputType)' == 'Library' and '$(CopyLocalLockFileAssemblies)' == 'true' and $(AssemblyName.EndsWith('Tests')) == 'false' "> | ||
<ItemGroup> | ||
<ProjectReferenceWithConfiguration Update="@(ProjectReferenceWithConfiguration)" > | ||
<Private>false</Private> | ||
</ProjectReferenceWithConfiguration> | ||
<ProjectReference Update="@(ProjectReference)" > | ||
<Private>false</Private> | ||
</ProjectReference> | ||
</ItemGroup> | ||
</Target> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
using Flow.Launcher.Infrastructure; | ||
using System; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Reflection; | ||
using System.Runtime.Loader; | ||
|
||
namespace Flow.Launcher.Core.Plugin | ||
{ | ||
internal class PluginAssemblyLoader : AssemblyLoadContext | ||
{ | ||
private readonly AssemblyDependencyResolver dependencyResolver; | ||
|
||
private readonly AssemblyDependencyResolver referencedPluginPackageDependencyResolver; | ||
|
||
private readonly AssemblyName assemblyName; | ||
|
||
internal PluginAssemblyLoader(string assemblyFilePath) | ||
{ | ||
dependencyResolver = new AssemblyDependencyResolver(assemblyFilePath); | ||
assemblyName = new AssemblyName(Path.GetFileNameWithoutExtension(assemblyFilePath)); | ||
|
||
referencedPluginPackageDependencyResolver = | ||
new AssemblyDependencyResolver(Path.Combine(Constant.ProgramDirectory, "Flow.Launcher.Plugin.dll")); | ||
} | ||
|
||
internal Assembly LoadAssemblyAndDependencies() | ||
{ | ||
return LoadFromAssemblyName(assemblyName); | ||
} | ||
|
||
protected override Assembly Load(AssemblyName assemblyName) | ||
{ | ||
string assemblyPath = dependencyResolver.ResolveAssemblyToPath(assemblyName); | ||
|
||
// When resolving dependencies, ignore assembly depenedencies that already exits with Flow.Launcher.Plugin | ||
// Otherwise will get unexpected behaviour with plugins, e.g. JsonIgnore attribute not honored in WebSearch or other plugins | ||
// that use Newtonsoft.Json | ||
if (assemblyPath == null || ExistsInReferencedPluginPackage(assemblyName)) | ||
return null; | ||
|
||
return LoadFromAssemblyPath(assemblyPath); | ||
} | ||
|
||
internal Type FromAssemblyGetTypeOfInterface(Assembly assembly, Type type) | ||
{ | ||
var allTypes = assembly.ExportedTypes; | ||
|
||
return allTypes.First(o => o.IsClass && !o.IsAbstract && o.GetInterfaces().Contains(type)); | ||
} | ||
|
||
internal bool ExistsInReferencedPluginPackage(AssemblyName assemblyName) | ||
{ | ||
return referencedPluginPackageDependencyResolver.ResolveAssemblyToPath(assemblyName) != null; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.