ReSharper Postfix

Ciekawym pomysłem na wydajniejszą (tak, jeszcze większą! :)) pracę z kodem jest dodatek do ReSharpera o nazwie Postfix.

Idea polega na uzupełnianiu kodu w oparciu o różne wzorce, tzw. postfix, które pojawiają się po napisaniu naszego kodu. Innymi słowy, jest to połączenie “surround templates” i resharperowego Quick Fix (Alt+Enter). Postfix uzupełniamy jednak klawiszem Tab. Cały pomysł najlepiej obrazuje poniższa animacja:

Aktualnie dostępne szablony:

.if – checks boolean expression to be true if (expr)
.else – checks boolean expression to be false if (!expr)
.null – checks nullable expression to be null if (expr == null)
.notnull – checks expression to be non-null if (expr != null)
.not – negates value of inner boolean expression !expr
.foreach – iterates over collection foreach (var x in expr)
.for – surrounds with loop for (var i = 0; i < expr.Length; i++)
.forr – reverse loop for (var i = expr.Length – 1; i >= 0; i–)
.var – initialize new variable with expression var x = expr;
.arg – helps surround argument with invocation Method(expr)
.to – assigns expression to some variable lvalue = expr;
.await – awaits expression with C# await keyword await expr
.cast – surrounds expression with cast ((SomeType) expr)
.field – intoduces field for expression _field = expr;
.prop – introduces property for expression Prop = expr;
.new – produces instantiation expression for type new T()
.par – surrounds outer expression with parentheses (expr)
.parse – parses string as value of some type int.Parse(expr)
.return – returns value from method/property return expr;
.typeof – wraps type usage with typeof-expression typeof(TExpr)
.switch – produces switch over integral/string type switch (expr)
.yield – yields value from iterator method yield return expr;
.throw – throws value of Exception type throw expr;
.using – surrounds disposable expression using (var x = expr)
.while – uses expression as loop condition while (expr)
.lock – surrounds expression with statement lock (expr)
.sel – selects expression in editor

Całość można zainstalować z menu ReSharper > Extension Gallery.

Link do dodatku: Postfix.

One thought on “ReSharper Postfix

  1. Pingback: dotnetomaniak.pl

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s