Skip to content

Commit e74d7ce

Browse files
committed
Fix AmbiguousMatchException when plugins call Flow API (JsonRPC)
Why: `GetMethod(String)` raise AmbiguousMatchException when method have overloads (e.g. `ShowMsg`) Solution: `Use GetMethod(String, Type[])` https://stackoverflow.com/questions/1969411/avoiding-an-ambiguous-match-exception
1 parent e6db8b8 commit e74d7ce

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

Flow.Launcher.Core/Plugin/JsonRPCPlugin.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.Collections.Generic;
44
using System.Diagnostics;
55
using System.IO;
6+
using System.Linq;
67
using System.Reflection;
78
using System.Text.Json;
89
using System.Threading;
@@ -128,7 +129,8 @@ private List<Result> ParseResults(JsonRPCQueryResponseModel queryResponseModel)
128129

129130
private void ExecuteFlowLauncherAPI(string method, object[] parameters)
130131
{
131-
MethodInfo methodInfo = PluginManager.API.GetType().GetMethod(method);
132+
var parametersTypeArray = parameters.Select(param => param.GetType()).ToArray();
133+
MethodInfo methodInfo = PluginManager.API.GetType().GetMethod(method, parametersTypeArray);
132134
if (methodInfo != null)
133135
{
134136
try

0 commit comments

Comments
 (0)