ContextMenu Plugin API

Is there any documentation / example available on how to write a LinqPad plugin which is able to insert items into the Query Context Menu? Idealy a registered listener would either get the name of the Query relative to the Query Root Folder or a FileInfo pointing to the query.

I've written a LinqPad Query to netcore project generator / build controller which can generate standalone programs whenever needed. I currently use this by way of a central LinqPad query where I register the name of the queries that should be processed, their intended targets (msbuild project / binary / nuget package + location), some additional information (version number etc.), and the transformation that should be applied along the way (i.e. I'm abusing region precompiler directives to mark namespaces in LinqPad, also to insert company specific metadata/assets into the assembly and so on).

However I'd rather prefer to be able to just right click a query and select Generate Project, Compile, or Update Nuget at Repository for that instead of constantly having to change the query name in my compiler query. All the metainfo that is currently in that query as well could also be added to the App.config and applied and afterwards removed during the processing phase - the only thing I need is the name of the query and the intended action.

I'd appreciate any help on that.

Comments

  • I've added an experimental feature to the latest build that might help.

    Download 5.22.11 and create/save a query called 'Automator". Save it in "My Queries". Your query should contain the following:
    void Main (System.Windows.Forms.Keys key, string queryPath)
    {
       ...
    }
    This query will fire when you press Shift+Alt+Control plus a function key. You can check which key was pressed and the query that was active via the parameters.

    Let me know how you get along.
  • Thanks for implementing the Automator Query. I've used this for some time now and found some nice use for it additionally to the one I initially described (i.e. being able to first test some simple algorithm, then send it for execution to some remote computer with a different shortkey without leaving LinqPad).

    However: is it still possible to additionally implement plugins for the Query context menu? I love the simplicity of short-keys, but whenever I haven't used one for some days I always tend to forget it's combination...

    And: Is there a way to optionally redirect output to the Results (or a separate) Window tab, the same way it is done for "normal" queries? At the moment I put messages into a separate window, but having them in LinqPad would make this a more integrated experience.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!