Search code examples
c#resharperdataflow

Resharper Dataflow analysis


I'm using the TPL Dataflow library extensively, and really like the Used-By feature of R#. What would be nice is to look at the used by of a method which is the target of an ITargetBlock (Action block most likely) and return a list of the ITargetBlock.Post calls in addition to any direct method calls. Like-wise when you control click (go to declaration) on ITargetBlock.Post, it should take you directly to the destination method of the action block, not to the definition of the ITargetBlock.

ActionBlock<T> ab = new ActionBlock<T>(FuncCall, new ExecutionDataflowBlockOptions {TaskScheduler = taskScheduler});

Setup the action block

ab.Post(NewVal);

Post a new value to the action block, which will then be passed to the FuncCall method - Control clicking on ab / ab.Post should take you to the method below.

private void FuncCall(T parameter)
{
    //Do work
}

Calling find usages on the above method should take you to ab.Post(NewVal), not to the ab definition.

I'm wondering if there is any way to configure this with resharper. I imagine it is doable by writing a custom plugin, but I thought others may be running into this problem, and wanted to see if there was a simple way to achieve this first.


Solution

  • You would need to write a custom plug-in as the information to use would be different for each type of wrapper; Action, Func, ActionBlock, etc...

    It might be a convenience (which is what much of R# is about) but it'd only save you one keystroke.

    In your example, F12 on ab to GoToImplementation then Ctrl+Click on FuncCall