Skip to content

Commit fc695b9

Browse files
committed
Merge branch 'dev' into update_uI_hotkey_actionkeyword
2 parents acdca57 + 1eafbd1 commit fc695b9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+2092
-1024
lines changed

Flow.Launcher.Core/Plugin/PluginsLoader.cs

Lines changed: 45 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
using System;
1+
using System;
22
using System.Collections.Generic;
33
using System.IO;
44
using System.Linq;
55
using System.Reflection;
66
using System.Runtime.Loader;
7+
using System.Threading.Tasks;
8+
using System.Windows.Forms;
79
using Flow.Launcher.Infrastructure;
8-
using Flow.Launcher.Infrastructure.Exception;
910
using Flow.Launcher.Infrastructure.Logger;
1011
using Flow.Launcher.Infrastructure.UserSettings;
1112
using Flow.Launcher.Plugin;
@@ -29,6 +30,8 @@ public static List<PluginPair> Plugins(List<PluginMetadata> metadatas, PluginsSe
2930

3031
public static IEnumerable<PluginPair> DotNetPlugins(List<PluginMetadata> source)
3132
{
33+
var erroredPlugins = new List<string>();
34+
3235
var plugins = new List<PluginPair>();
3336
var metadatas = source.Where(o => AllowedLanguage.IsDotNet(o.Language));
3437

@@ -50,28 +53,44 @@ public static IEnumerable<PluginPair> DotNetPlugins(List<PluginMetadata> source)
5053
}
5154
catch (Exception e)
5255
{
53-
Log.Exception($"|PluginsLoader.DotNetPlugins|Couldn't load assembly for {metadata.Name}", e);
56+
erroredPlugins.Add(metadata.Name);
57+
58+
Log.Exception($"|PluginsLoader.DotNetPlugins|Couldn't load assembly for the plugin: {metadata.Name}", e);
5459
return;
5560
}
56-
var types = assembly.GetTypes();
61+
5762
Type type;
5863
try
5964
{
65+
var types = assembly.GetTypes();
66+
6067
type = types.First(o => o.IsClass && !o.IsAbstract && o.GetInterfaces().Contains(typeof(IPlugin)));
6168
}
6269
catch (InvalidOperationException e)
6370
{
64-
Log.Exception($"|PluginsLoader.DotNetPlugins|Can't find class implement IPlugin for <{metadata.Name}>", e);
71+
erroredPlugins.Add(metadata.Name);
72+
73+
Log.Exception($"|PluginsLoader.DotNetPlugins|Can't find the required IPlugin interface for the plugin: <{metadata.Name}>", e);
74+
return;
75+
}
76+
catch (ReflectionTypeLoadException e)
77+
{
78+
erroredPlugins.Add(metadata.Name);
79+
80+
Log.Exception($"|PluginsLoader.DotNetPlugins|The GetTypes method was unable to load assembly types for the plugin: <{metadata.Name}>", e);
6581
return;
6682
}
83+
6784
IPlugin plugin;
6885
try
6986
{
7087
plugin = (IPlugin)Activator.CreateInstance(type);
7188
}
7289
catch (Exception e)
7390
{
74-
Log.Exception($"|PluginsLoader.DotNetPlugins|Can't create instance for <{metadata.Name}>", e);
91+
erroredPlugins.Add(metadata.Name);
92+
93+
Log.Exception($"|PluginsLoader.DotNetPlugins|The following plugin has errored and can not be loaded: <{metadata.Name}>", e);
7594
return;
7695
}
7796
#endif
@@ -85,6 +104,26 @@ public static IEnumerable<PluginPair> DotNetPlugins(List<PluginMetadata> source)
85104
metadata.InitTime += milliseconds;
86105

87106
}
107+
108+
if (erroredPlugins.Count > 0)
109+
{
110+
var errorPluginString = "";
111+
112+
var errorMessage = "The following "
113+
+ (erroredPlugins.Count > 1 ? "plugins have " : "plugin has ")
114+
+ "errored and cannot be loaded:";
115+
116+
erroredPlugins.ForEach(x => errorPluginString += x + Environment.NewLine);
117+
118+
Task.Run(() =>
119+
{
120+
MessageBox.Show($"{errorMessage}{Environment.NewLine}{Environment.NewLine}" +
121+
$"{errorPluginString}{Environment.NewLine}{Environment.NewLine}" +
122+
$"Please refer to the logs for more information","",
123+
MessageBoxButtons.OK, MessageBoxIcon.Warning);
124+
});
125+
}
126+
88127
return plugins;
89128
}
90129

Flow.Launcher.Plugin/Flow.Launcher.Plugin.csproj

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,10 @@
1515

1616
<PropertyGroup>
1717
<Version>1.0.0</Version>
18-
<PackageVersion>1.0.0-beta2</PackageVersion>
18+
<PackageVersion>1.0.0-beta3</PackageVersion>
1919
<AssemblyVersion>1.0.0</AssemblyVersion>
2020
<FileVersion>1.0.0</FileVersion>
2121
<PackageId>Flow.Launcher.Plugin</PackageId>
22-
<IncludeSymbols>true</IncludeSymbols>
23-
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
2422
<Authors>Flow-Launcher</Authors>
2523
<PackageLicenseExpression>MIT</PackageLicenseExpression>
2624
<RepositoryUrl>https://github.com/Flow-Launcher/Flow.Launcher</RepositoryUrl>
@@ -30,6 +28,10 @@
3028
<PublishRepositoryUrl>true</PublishRepositoryUrl>
3129
</PropertyGroup>
3230

31+
<PropertyGroup Condition="'$(APPVEYOR)' == 'True'">
32+
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
33+
</PropertyGroup>
34+
3335
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
3436
<DebugSymbols>true</DebugSymbols>
3537
<DebugType>full</DebugType>
@@ -43,7 +45,7 @@
4345
</PropertyGroup>
4446

4547
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
46-
<DebugType>portable</DebugType>
48+
<DebugType>embedded</DebugType>
4749
<Optimize>true</Optimize>
4850
<OutputPath>..\Output\Release\</OutputPath>
4951
<DefineConstants>TRACE</DefineConstants>
@@ -54,18 +56,7 @@
5456

5557
<ItemGroup>
5658
<None Include="README.md" />
57-
</ItemGroup>
58-
59-
<ItemGroup>
60-
<None Remove="FodyWeavers.xml" />
61-
</ItemGroup>
62-
63-
<ItemGroup>
64-
<Compile Include="..\SolutionAssemblyInfo.cs" Link="Properties\SolutionAssemblyInfo.cs" />
65-
</ItemGroup>
66-
67-
<ItemGroup>
68-
<Content Include="FodyWeavers.xml" />
59+
<None Include="FodyWeavers.xml" />
6960
</ItemGroup>
7061

7162
<ItemGroup>

Flow.Launcher.Plugin/SharedCommands/FilesFolders.cs

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,5 +127,81 @@ public static void OpenPath(string fileOrFolderPath)
127127
#endif
128128
}
129129
}
130+
131+
///<summary>
132+
/// This checks whether a given string is a directory path or network location string.
133+
/// It does not check if location actually exists.
134+
///</summary>
135+
public static bool IsLocationPathString(string querySearchString)
136+
{
137+
if (string.IsNullOrEmpty(querySearchString))
138+
return false;
139+
140+
// // shared folder location, and not \\\location\
141+
if (querySearchString.Length >= 3
142+
&& querySearchString.StartsWith(@"\\")
143+
&& char.IsLetter(querySearchString[2]))
144+
return true;
145+
146+
// c:\
147+
if (querySearchString.Length == 3
148+
&& char.IsLetter(querySearchString[0])
149+
&& querySearchString[1] == ':'
150+
&& querySearchString[2] == '\\')
151+
return true;
152+
153+
// c:\\
154+
if (querySearchString.Length >= 4
155+
&& char.IsLetter(querySearchString[0])
156+
&& querySearchString[1] == ':'
157+
&& querySearchString[2] == '\\'
158+
&& char.IsLetter(querySearchString[3]))
159+
return true;
160+
161+
return false;
162+
}
163+
164+
///<summary>
165+
/// Gets the previous level directory from a path string.
166+
/// Checks that previous level directory exists and returns it
167+
/// as a path string, or empty string if doesn't exit
168+
///</summary>
169+
public static string GetPreviousExistingDirectory(Func<string, bool> locationExists, string path)
170+
{
171+
var previousDirectoryPath = "";
172+
var index = path.LastIndexOf('\\');
173+
if (index > 0 && index < (path.Length - 1))
174+
{
175+
previousDirectoryPath = path.Substring(0, index + 1);
176+
if (!locationExists(previousDirectoryPath))
177+
{
178+
return "";
179+
}
180+
}
181+
else
182+
{
183+
return "";
184+
}
185+
186+
return previousDirectoryPath;
187+
}
188+
189+
///<summary>
190+
/// Returns the previous level directory if path incomplete (does not end with '\').
191+
/// Does not check if previous level directory exists.
192+
/// Returns passed in string if is complete path
193+
///</summary>
194+
public static string ReturnPreviousDirectoryIfIncompleteString(string path)
195+
{
196+
if (!path.EndsWith("\\"))
197+
{
198+
// not full path, get previous level directory string
199+
var indexOfSeparator = path.LastIndexOf('\\');
200+
201+
return path.Substring(0, indexOfSeparator + 1);
202+
}
203+
204+
return path;
205+
}
130206
}
131207
}

Flow.Launcher.Test/Flow.Launcher.Test.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
</ItemGroup>
4040

4141
<ItemGroup>
42+
<ProjectReference Include="..\Plugins\Flow.Launcher.Plugin.Explorer\Flow.Launcher.Plugin.Explorer.csproj" />
4243
<ProjectReference Include="..\Plugins\Flow.Launcher.Plugin.Program\Flow.Launcher.Plugin.Program.csproj" />
4344
<ProjectReference Include="..\Plugins\Flow.Launcher.Plugin.Url\Flow.Launcher.Plugin.Url.csproj" />
4445
<ProjectReference Include="..\Flow.Launcher.Core\Flow.Launcher.Core.csproj" />

0 commit comments

Comments
 (0)