PowerSharp is a Resharper and Rider compatible plugin which provides nice features I miss out-of-the box. I started this project to make my own experience with Resharper and Rider even more better, but I'd be happy if the plugin becomes useful for a community.
You can find a ready-to-install plugins here: PowerSharp->Plugins
Sometimes you have a field or a property in your class and you just want to initialize it in the class' constructor. For this purpose, a context action 'Create instance' was introduced. Look at the pictures below:
Both instance and static fields and properties are supported.
I guess every developer has its own set of favorite dependencies they use often. My favorites are NUnit and Fluent.Assertions. An action 'Add favorite dependency' will help you to add the dependencies into your project lightning fast. Look at the picture below.
In this version however, the set of dependencies is fixed and contains only NUnit and Fluent.Assertions libraries. I'm going to make the dependency set customizable through a settings page in the future.
Let's imagine you decided to develop some tests for you class. You create a test-project and add it to your solution. Next, you need to add some unit-testing framework dependency to your test-project. Then you need to setup dependencies between your projects (the test-project must reference under-the-test project). And finally, you write some boiler-plate code which could look like this:
using NUnit.Framework;
namespace Project.Tests {
[TestFixture]
public class MyClassTests {
[SetUp]
public void SetUp() {
}
[TearDown]
public void TearDown() {
}
}
}
Very boring!
The 'Create tests' action allows to do this much faster. Look at the picture:
The action generates a boiler-plate code for you and sets up required between-projects dependencies if that hasn't been done already.
Notes:
- Only NUnit framework is supported at the moment;
- The action is available if the test-project already has NUnit-dependency. You can add the dependency with 'Add favorite dependency' action by the way.
Let's consider the following use case: you have some interface in your code you need to implement. You create a class which implements the interface and ask Resharper (or Rider) to generate a boilerplate code for you. After this, you usually see something like this:
using System;
namespace Project {
interface I {
void Method1();
void Method2();
void Method3();
int Property1 { get; set; }
}
abstract class MyClass : I {
public void Method1() {
throw new NotImplementedException();
}
public void Method2() {
throw new NotImplementedException();
}
public void Method3() {
throw new NotImplementedException();
}
public int Property1 {
get { throw new NotImplementedException(); }
set { throw new NotImplementedException(); }
}
}
}
Now you need to navigate through your code and implement the members. But there is a problem (at least for me)): most navigation features of IDE set your caret at the name of target member. That means that to start writing a code, you need to move cursor down, delete generated stub-code (e.g. throw new NotImplementedException()) and set your caret to correct position. So, 3 or 4 actions need to be done for that! And 'Edit' action group is here to start coding faster.
'Edit Method' action
If your caret is set at a method, the 'Edit Method' action is available. When it runs, you get the following result:
'Edit Property Getter' and 'Edit Property Setter' actions
If the caret is set at a property, the 'Edit Property Getter' and 'Edit Property Setter' actions are available. This time the result is the following:
Those actions select a code of a method or a property, so you can start typing immediately in the correct position and replace old code at the same time. Of course, you can bind those actions to your favorite shortcuts to get a maximum efficiency.
'Edit Parameters' action
When you are typing a code, sometimes you need to jump to a parameters list of a method or indexer to fix it somehow. It usually takes a few keyboard actions to make it done. New 'Edit Parameters' action makes it done immediatelly. Take a look:
'Edit Return Value' action
This actions is a sibling-brother of previous one and allows to jump to a method return value:
Take a note that the 'Edit Return Value' action has a little wider scope than the 'Edit Parameters' one. For example, along with methods, properties are supported too.
Let's imagine you are typing a code or navigating through your code base and you need to add new type-member to it. For this, you usually need to set a caret at some point inside your type (usually after currently-edited method or after the last member of type), then add new empty line and start typing new code. This usually takes a few keyboard gestures. Considering that this is a very common scenario, it would be cool to make it faster. The action 'New Member Line' helps us here.
If your caret is placed inside some type-member, then running the action adds new line below the type-member and sets your caret to it considering IDE code-formatting rules. Look at the picture:
If your caret is placed outside a type-member (e.g. in the fields-section of type), new line is created after last type-member of type.
As usual, assigning a shortcut for this action makes a maximum efficiency.
This action helps to solve one subtle issue related to the code completion feature of R#/Rider. When we are typing a code, a code-completion popup appears and suggests to use some type-members or actions available in a current context. It is greatly useful but sometimes you don't need to use those suggestion, e.g. if the method you want to call doesn't exist at the moment. You type the method name, but then you have to close the code-completion popup (by pressing Esc usually) before you can finish a method call statement because typing '(' symbol selects a node in the code-completion popup and that is not what you want. It would be better to cut this path.
Look at the picture below:
Running the 'Force Method Call' action cancels the code-completion popup, finishes method-call statement (by adding '(', ')', ';' symbols) and sets caret between '(' and ')' symbols which allows to pass arguments to the method if required.
Note: of course IDE allows to customize the code-completion popup's behavior, but my experiments show that if one, for example, turns off automatic item selection in the code-completion popup (which solves the described issue at the first glance) actually makes general code-completion experience worse. So, I prefer to leave a default code-completion behavior as is and use the 'Force Method Call' action to solve the issue instead.