ActiveMesa R2P is a productivity plug-in for JetBrains ReSharper. Here is an overview of some of its features:
One of the key features of R2P is the ability to transform string literals. For example, thestring splicing feature brings PHP-style string splicing to C#. Simply use the curly braces to delimit variables and R2P will offer a suitable context action:
Applying the action replaces the string with a
string.Format() call, with the variables moved to the argument list:
R2P supports several transformations from strings to .NET types. For example, you can define time as a string andconvert it to DateTime:
After invocation, the declaration is replaced with the following:
R2P supports transformations from string literals into the following types:
R2P also comes with a menu item called Paste Verbatim String that pastes strings from the clipboard with correct escapement. This facilitates transformations from strings into something else: for example, you can copy a block of XML from some app, paste it, then use the Convert to XElement context action to turn it into a fully object-oriented declaration.
In addition to the above, the plugin also supports a few string manipulations, such as:
The plugin comes with several generators, which all embed themselves into the Generate menu:
Binary read/write members — for a given class, generates
WriteTo() methods that use
BinaryWriter respectively and serialize chosen fields. Special care is taken when serializing known .NET types: for example, for a
DateTime, only its
Ticks property is serialized:
Copy constructor — for a given class creates a constructor that takes this class as a parameter and performs a copy of its properties/fields to the owner class.
Disposing members — in addition to being able to correctly identify all disposable fields and generate the appropriate
Dispose() declaration, R2P’s implementation also offers to implement the fullDispose pattern.
Read-only interface — for a given class
Foo, generates an interface
IFoo where all properties are exposed as
get-only, effectively creating a read-only interface contract for this class.
R2P comes with several computation-related inspections, such as:
Inspections that detect inefficient Math.Pow() calls and refactor them to unline multiplication:
An inspection and corresponding context action that allows factoring out of common subexpressions:
Inspections and fixes relating to possible use of MAD (multiply-add) instruction when usingGPU.NET:
In addition, R2P can help correct misspelt identifiers based on information about the available types:
Odds and Ends
R2P comes with a lot more functionality than we can list here. Some of its features include:
Refactorings such as Make Singleton (implements the Singleton pattern) and Enum to Class (turns an enumeration into a class with enum cases transformed to member variables).
Unit testing helpers such as being able to Assert on all public properties of an object instance, an ability toadd a value as a Row in data-driven testing, and a Visual row editor.
General-purpose context actions such as code contract generators (generate code contract specifications for parameters), an action tomake a method fluent (i.e.,
return this), and even a context action to treat the
^ operator as a power function.
A String format helper window that lets the user build a format string and preview the end result.
… and a lot more