Skip to content

Commit 9326d09

Browse files
committed
Merge branch 'dev'
2 parents 07d1384 + a3374f2 commit 9326d09

File tree

96 files changed

+2315
-1286
lines changed

Some content is hidden

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

96 files changed

+2315
-1286
lines changed

Flow.Launcher.Core/Flow.Launcher.Core.csproj

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,7 @@
5757
<PackageReference Include="JetBrains.Annotations" Version="2019.1.3" />
5858
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
5959
<PackageReference Include="squirrel.windows" Version="1.5.2" />
60-
<PackageReference Include="PropertyChanged.Fody" Version="3.2.8">
61-
<PrivateAssets>all</PrivateAssets>
62-
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
63-
</PackageReference>
60+
<PackageReference Include="PropertyChanged.Fody" Version="2.5.13" />
6461
<PackageReference Include="SharpZipLib" Version="1.2.0" />
6562
<PackageReference Include="System.Runtime" Version="4.3.1" />
6663
</ItemGroup>

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: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
1+
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
22

33
<PropertyGroup>
44
<TargetFramework>netcoreapp3.1</TargetFramework>
@@ -12,7 +12,26 @@
1212
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
1313
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
1414
</PropertyGroup>
15-
15+
16+
<PropertyGroup>
17+
<Version>1.0.0</Version>
18+
<PackageVersion>1.0.0-beta3</PackageVersion>
19+
<AssemblyVersion>1.0.0</AssemblyVersion>
20+
<FileVersion>1.0.0</FileVersion>
21+
<PackageId>Flow.Launcher.Plugin</PackageId>
22+
<Authors>Flow-Launcher</Authors>
23+
<PackageLicenseExpression>MIT</PackageLicenseExpression>
24+
<RepositoryUrl>https://github.com/Flow-Launcher/Flow.Launcher</RepositoryUrl>
25+
<PackageDescription>Reference this library if you want to develop a Flow Launcher plugin</PackageDescription>
26+
<PackageTags>flowlauncher</PackageTags>
27+
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
28+
<PublishRepositoryUrl>true</PublishRepositoryUrl>
29+
</PropertyGroup>
30+
31+
<PropertyGroup Condition="'$(APPVEYOR)' == 'True'">
32+
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
33+
</PropertyGroup>
34+
1635
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
1736
<DebugSymbols>true</DebugSymbols>
1837
<DebugType>full</DebugType>
@@ -26,7 +45,7 @@
2645
</PropertyGroup>
2746

2847
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
29-
<DebugType>pdbonly</DebugType>
48+
<DebugType>embedded</DebugType>
3049
<Optimize>true</Optimize>
3150
<OutputPath>..\Output\Release\</OutputPath>
3251
<DefineConstants>TRACE</DefineConstants>
@@ -37,28 +56,15 @@
3756

3857
<ItemGroup>
3958
<None Include="README.md" />
40-
</ItemGroup>
41-
42-
<ItemGroup>
43-
<None Remove="FodyWeavers.xml" />
44-
</ItemGroup>
45-
46-
<ItemGroup>
47-
<Compile Include="..\SolutionAssemblyInfo.cs" Link="Properties\SolutionAssemblyInfo.cs" />
48-
</ItemGroup>
49-
50-
<ItemGroup>
51-
<Content Include="FodyWeavers.xml" />
59+
<None Include="FodyWeavers.xml" />
5260
</ItemGroup>
5361

5462
<ItemGroup>
63+
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All"/>
5564
<PackageReference Include="JetBrains.Annotations" Version="2019.1.3" />
5665
<PackageReference Include="Mono.Cecil" Version="0.11.2" />
5766
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
58-
<PackageReference Include="PropertyChanged.Fody" Version="3.2.8">
59-
<PrivateAssets>all</PrivateAssets>
60-
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
61-
</PackageReference>
67+
<PackageReference Include="PropertyChanged.Fody" Version="2.5.13" />
6268
<PackageReference Include="System.Runtime" Version="4.3.1" />
6369
</ItemGroup>
6470

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 & 4 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" />
@@ -56,8 +57,4 @@
5657
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.6.1" />
5758
</ItemGroup>
5859

59-
<ItemGroup>
60-
<Folder Include="Properties\" />
61-
</ItemGroup>
62-
6360
</Project>

0 commit comments

Comments
 (0)