Skip to content

Feature request: option\setting to prevent\disallow duplicate methods in targets #547

Open

Description

@osexpert

When adding multiple rpc target classes, if multiple targets contain the same\similar method, the method in first target added is used (as documented). But I miss an option to disallow duplicates, as this is (in my case) always an error. Alternatives:
-Preferably a setting on JsonRpc itself that produce error when AddLocalRpcTarget is called
-A setting on JsonRpc itself that produce error during runtime, when duplicate method is attempted called
-A setting in JsonRpcTargetOptions, that produce error when AddLocalRpcTarget is called
-A setting in JsonRpcTargetOptions, that produce error during runtime, when duplicate method is attempted called

Thanks.

Activity

  1. AArnott commented on Sep 10, 2020

    @AArnott
    Member

    Thanks for the feedback.

    A setting in JsonRpcTargetOptions, that produce error when AddLocalRpcTarget is called

    I think this is a reasonable design.

  2. osexpert commented on Sep 12, 2020

    @osexpert
    Author

    Another thing that could solve the problem for me was if I could create multiple proxies and specify proxy option to alter method name (via delegate), eg. proxy for Service1 would postfix methods with Service1_ etc. Target already has option for method name modification so AddLocalRpcTarget(new Service1(), options) would already expose methods prefixed Service1_

  3. AArnott commented on Sep 13, 2020

    @AArnott
    Member

    Interesting. @gdalsnes are you aware that JsonRpcProxyOptions also offers you a method name transform delegate? So you can add the service prefix both on the target and proxy sides already.

    public Func<string, string> MethodNameTransform

  4. osexpert commented on Sep 13, 2020

    @osexpert
    Author

    Interesting. @gdalsnes are you aware that JsonRpcProxyOptions also offers you a method name transform delegate? So you can add the service prefix both on the target and proxy sides already.

    Ok great, I will try that!

  5. osexpert commented on Sep 14, 2020

    @osexpert
    Author

    It works but it actually got a lot more complicated with dozens of proxies instead of one super-proxy IServer (IServer : IService1, IService2, etc.) that I use via generic wrapper, the wrapper has a reference to the super-proxy, when recreating super-proxy after recreating JsonRpc (when the stream dies etc.) this just works.
    So for me I think the duplicate check is still helpful.
    Sorry.

  6. rruizGit commented on Oct 12, 2020

    @rruizGit
    Contributor

    Interesting conversation. We used the method and event name transforms to solve this problem. But, in our case, every target has a unique identifier, so it was easy to transform the name to :.. Also works because information on every target is published as part of our discovery system, so we are able to hide this complexity from someone using the system.

  7. added a commit that references this issue on Aug 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions