Skip to content

Roslyn based, set of code refactorings for Visual Studio

License

Notifications You must be signed in to change notification settings

NeVeSpl/CodeRefactoringsForVisualStudio

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Code refactorings for VisualStudio

Invert assignment direction

download

Visual Studio code refactoring that allows swapping arguments around the equal sign in an assignment statement. It works on single or many selected assignment statements at once.

Generate mapping

download

Visual Studio code refactoring that generates mapping code, between method input parameters and method return type. If any of them is void, "this" is used instead. Design time AutoMapper alternative.

What can be generated:

  • mapping method
  • copy constructor
  • memento method get state
  • memento method set state
  • deconstruct method

General rules:

  • mapping is available only for methods/constructors with an empty body
  • mapping can be done for more than one input parameter
  • for the left side of the assignment considered are all writable fields and properties
  • for the right side of the assignment considered are all readable fields and properties
  • for the assignment of mutable reference type, a "new" instance is always created
  • recursive mapping is not, and will not be supported
  • mapping to tuples is supported
  • mapping to positional records is supported

Rename variable after type/expression

download

Visual Studio code refactoring that changes a variable name, to an auto-generated name from the variable type or expression used in the assignment, e.g. "Foo x =" => "Foo foo ="

  • works on:
    • single or many variables at once
    • single method parameter
    • single invocation argument
    • foreach loop variable

Introduce parameter object

download

Visual Studio implementation of code refactoring Introduce Parameter Object from Martin Fowler's book "Refactoring, Improving the Design of Existing Code".

Limitations
  • it does not support generic type parameters
  • updating a method body is done syntactically, not semantically, which means, conflicts may appear if a method parameter shares the same name with something else

MediatR add RequestHandler and Request

download

Visual Studio code refactoring that adds Command class which implements MediatR IRequest<> interface and handler class which implements MediatR IRequestHandler<> interface. It only creates empty boilerplate code required by MediatR based on the selected method name and return type.

Limitations
  • does not support generic type parameters
Changelog

version 1.5

  • RequestHandler can also be generated from an existing Request class

Convert to full WPF Property

download

Visual Studio code refactoring that replaces an auto-property with full property implementation that consists of invocation of OnPropertyChanged in a setter. It can convert many auto-properties at once.

Encapsulate field (WPF)

download

Visual Studio code refactoring that creates full property implementation with an invocation of OnPropertyChanged in a setter for a selected set of backing fields.

Copy/Paste with case conversion

download

Visual Studio extension that adds two commands to the text editor context menu that do case conversion before copy/paste.

Two kinds of conversion are available:

  • Copy as sentence case (also splits selected text to separate words)
  • PasteAsPascalCase

About

Roslyn based, set of code refactorings for Visual Studio

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages