fix(plugins): resolve RPC API calls with omitted or null parameters

GU
25d ago
+144-3

Fixes #4716

TL;DR

  • ExecuteFlowLauncherAPI resolved the IPublicAPI method with an exact GetType() array, so two invocation patterns were impossible from RPC plugins: omitting an optional parameter (no overload with that arity) and passing null (NullReferenceException in GetType()).
  • The overload is now resolved by name and arity: supplied arguments must be assignable to their parameter, null arguments must sit on a nullable slot, and trailing parameters omitted by the caller must be optional — they are filled with their declared default values on invoke.
  • Behavior for fully-specified calls is unchanged.

Tests

  • New JsonRPCPluginBaseTest (NUnit + Moq, same stack as the project) with a minimal concrete plugin: omitted optional parameter, explicit null, fully-specified call, unknown method, and incompatible argument (still silently ignored as before). All 5 pass via dotnet test --filter FullyQualifiedName~JsonRPCPluginBaseTest.

Summary by cubic

Summary of changes

Fixes #4716. ExecuteFlowLauncherAPI in JsonRPCPluginBase previously resolved the IPublicAPI method using an exact GetType() array, which made two invocation patterns impossible from RPC plugins: omitting an optional parameter (no overload matched the arity) and passing null (which threw a NullReferenceException in GetType()). OpenDirectory(path) and OpenDirectory(path, null) were both unusable.

Changed behavior:

  • The overload is now resolved by name and arity. Supplied arguments must be assignable to their parameter, null arguments must sit on a nullable parameter slot, and trailing parameters omitted by the caller must be optional — they are filled with their declared default values on invoke.
  • The old exact-type resolution logic is removed. Behavior for fully-specified calls is unchanged.
  • No memory usage impact: the reflection-based method scan is transient.
  • No new security risks: resolution is limited to the IPublicAPI interface.
  • Added JsonRPCPluginBaseTest (NUnit + Moq) with a minimal concrete plugin covering omitted optional parameter, explicit null, fully-specified call, unknown method, and incompatible argument. All 5 tests pass via dotnet test --filter FullyQualifiedName~JsonRPCPluginBaseTest.

Release Note

RPC plugins can now call Flow Launcher API methods that have optional parameters, either by omitting them or passing null.