Skip to content

Commit 032a203

Browse files
committed
add F# as an allowed plugin language
* rename PluginsLoader.CSharpPlugins to the more generic DotNetPlugins * add AllowedLanguage.IsDotNet which checks for either C# or F#
1 parent eb26329 commit 032a203

File tree

2 files changed

+21
-10
lines changed

2 files changed

+21
-10
lines changed

Flow.Launcher.Core/Plugin/PluginsLoader.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,21 @@ public static class PluginsLoader
2020

2121
public static List<PluginPair> Plugins(List<PluginMetadata> metadatas, PluginsSettings settings)
2222
{
23-
var csharpPlugins = CSharpPlugins(metadatas).ToList();
23+
var dotnetPlugins = DotNetPlugins(metadatas).ToList();
2424
var pythonPlugins = PythonPlugins(metadatas, settings.PythonDirectory);
2525
var executablePlugins = ExecutablePlugins(metadatas);
26-
var plugins = csharpPlugins.Concat(pythonPlugins).Concat(executablePlugins).ToList();
26+
var plugins = dotnetPlugins.Concat(pythonPlugins).Concat(executablePlugins).ToList();
2727
return plugins;
2828
}
2929

30-
public static IEnumerable<PluginPair> CSharpPlugins(List<PluginMetadata> source)
30+
public static IEnumerable<PluginPair> DotNetPlugins(List<PluginMetadata> source)
3131
{
3232
var plugins = new List<PluginPair>();
33-
var metadatas = source.Where(o => o.Language.ToUpper() == AllowedLanguage.CSharp);
33+
var metadatas = source.Where(o => AllowedLanguage.IsDotNet(o.Language));
3434

3535
foreach (var metadata in metadatas)
3636
{
37-
var milliseconds = Stopwatch.Debug($"|PluginsLoader.CSharpPlugins|Constructor init cost for {metadata.Name}", () =>
37+
var milliseconds = Stopwatch.Debug($"|PluginsLoader.DotNetPlugins|Constructor init cost for {metadata.Name}", () =>
3838
{
3939

4040
#if DEBUG
@@ -50,7 +50,7 @@ public static IEnumerable<PluginPair> CSharpPlugins(List<PluginMetadata> source)
5050
}
5151
catch (Exception e)
5252
{
53-
Log.Exception($"|PluginsLoader.CSharpPlugins|Couldn't load assembly for {metadata.Name}", e);
53+
Log.Exception($"|PluginsLoader.DotNetPlugins|Couldn't load assembly for {metadata.Name}", e);
5454
return;
5555
}
5656
var types = assembly.GetTypes();
@@ -61,7 +61,7 @@ public static IEnumerable<PluginPair> CSharpPlugins(List<PluginMetadata> source)
6161
}
6262
catch (InvalidOperationException e)
6363
{
64-
Log.Exception($"|PluginsLoader.CSharpPlugins|Can't find class implement IPlugin for <{metadata.Name}>", e);
64+
Log.Exception($"|PluginsLoader.DotNetPlugins|Can't find class implement IPlugin for <{metadata.Name}>", e);
6565
return;
6666
}
6767
IPlugin plugin;
@@ -71,7 +71,7 @@ public static IEnumerable<PluginPair> CSharpPlugins(List<PluginMetadata> source)
7171
}
7272
catch (Exception e)
7373
{
74-
Log.Exception($"|PluginsLoader.CSharpPlugins|Can't create instance for <{metadata.Name}>", e);
74+
Log.Exception($"|PluginsLoader.DotNetPlugins|Can't create instance for <{metadata.Name}>", e);
7575
return;
7676
}
7777
#endif

Flow.Launcher.Plugin/AllowedLanguage.cs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,26 @@ public static string CSharp
1212
get { return "CSHARP"; }
1313
}
1414

15+
public static string FSharp
16+
{
17+
get { return "FSHARP"; }
18+
}
19+
1520
public static string Executable
1621
{
1722
get { return "EXECUTABLE"; }
1823
}
1924

25+
public static bool IsDotNet(string language)
26+
{
27+
return language.ToUpper() == CSharp
28+
|| language.ToUpper() == FSharp;
29+
}
30+
2031
public static bool IsAllowed(string language)
2132
{
22-
return language.ToUpper() == Python.ToUpper()
23-
|| language.ToUpper() == CSharp.ToUpper()
33+
return IsDotNet(language)
34+
|| language.ToUpper() == Python.ToUpper()
2435
|| language.ToUpper() == Executable.ToUpper();
2536
}
2637
}

0 commit comments

Comments
 (0)