Skip to content

A bunch of quality refactorings and code fixes that are going to improve your C# development experience in Visual Studio and remove some common pain.

License

Notifications You must be signed in to change notification settings

honhwa/experimental-tools

 
 

Repository files navigation

Experimental Tools 2017

Build status

Download this extension from the VS Marketplace or get the CI build.


A bunch of quality refactorings and code fixes that are going to improve your C# development experience in Visual Studio and remove some common pain.

See the change log for changes and road map.

Features

  • Add constructor and initialize field
  • Add/Remove braces
  • Change access modifier on type declarations
  • Field can be made readonly
  • Generate GUID (nguid)
  • Initialize field from constructor parameter
  • Initialize field in existing constructor
  • Locate in Solution Explorer (Shift+Alt+L)
  • Make it a constructor (when copied from another class)
  • Namespace vs file path analyzer and code fix
  • Scaffold xunit data driven tests
  • Settings page (ability to enable/disable individual features)
  • Analyze if type name matches file name

Add constructor and initialize field

Ctrl+. on a field and choose Add constructor and initialize field.

Add constructor and initialize field

Add/Remove braces

Allows you to quickly add missing braces to single statements:

Add braces

It works both ways and allows you to remove braces if you prefer so.

Change access modifier on type declarations

Ctrl+. on a type declaration (either top level or nested) and choose one of proposed options.

Change access modifier on type declarations

Field can be made readonly

Suggest to declare a field as readonly if it's possible:

Field can be made readonly

Generate GUID (nguid)

Just type nguid where you want the new GUID to be inserted:

Generate Guid - before

and press TAB:

Generate Guid - After

Initialize field from constructor parameter

Ctrl+. on a constructor parameter and choose Add initialized field.

Initialize field from constructor parameter

Initialize field in existing constructor

Ctrl+. on a field and choose Initialize field in existing constructor.

Initialize field in existing constructor

Locate in Solution Explorer (Shift+Alt+L)

There is a standard command in Solution Explorer called 'Sync with Active Document'. People coming from ReSharper will appreciate its Shift+Alt+L equivalent.

Locate in Solution Explorer

The command is available in the code editor either from the context menu or as a shortcut.

Make it a constructor (when copied from another class)

Sometimes you copy code from another class into a new one and this quick fix allows you to update the constructor name.

Make it a constructor

Namespace vs file path analyzer and code fix

Analyze if a top level namespace does not match the path of the file where it is declared or does not start with the project's default namespace.

Namespace and file path analyzer

Note that the code fix currently does not update references.

Scaffold xunit data driven tests

If you're a fan of Xunit data driven tests this one's going to be a little time saver for you. You can scaffold MemberData:

Scaffold Xunit MemberData

As well as InlineData:

Scaffold Xunit MemberData

If your InlineData contains acceptable parameters they will be respected unless the test method already defines parameters (in which case neither of the scaffolding refactoring will work).

Note that this feature works with Xunit 2.x only.

Settings page (ability to enable/disable individual features)

All features can be individually enabled or disabled.

Type and file name analyzer

Analyze if type name matches file name

Analyzes if a top level type name matches the name of the file where it is declared and displays a warning if not.

Type and file name analyzer

Visual Studio 2017 and above provide code refactorings to rename types and file names to match each other out of the box.

Contribute

Check out the contribution guidelines if you want to contribute to this project.

For cloning and building this project yourself, make sure to install the Extensibility Tools extension for Visual Studio which enables some features used by this project.

License

MIT

About

A bunch of quality refactorings and code fixes that are going to improve your C# development experience in Visual Studio and remove some common pain.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C# 100.0%