Refresh.Tool 1.2.2

There is a newer version of this package available.
See the version list below for details.
dotnet tool install --global Refresh.Tool --version 1.2.2
                    
This package contains a .NET tool you can call from the shell/command line.
dotnet new tool-manifest
                    
if you are setting up this repo
dotnet tool install --local Refresh.Tool --version 1.2.2
                    
This package contains a .NET tool you can call from the shell/command line.
#tool dotnet:?package=Refresh.Tool&version=1.2.2
                    
nuke :add-package Refresh.Tool --version 1.2.2
                    

Refresh.NET

A simple CLI tool to easily migrate .NET projects by writing custom migrations.

This tool is built with intention to create shareable migrations to be able to easily adapt to library, framework or even language updates.

Supported migrations:

  • Rename class, interface, method, member, namespace
  • Add, remove, change, reorder arguments
  • Replace class, method
  • Change method return type

⚠️Disclaimer! At this point, only references are refactored! Support for end-to-end refactoring (with declarations) is coming soon.

Usage

Install the tool by using:

dotnet tool install -g refresh.tool

Use the tool:

refresh [-p Path/To/Project.csproj | -s Path/To/Solution.sln] -m Path/To/Migration.cs

If both defined, solution takes precendence over project.

Migration file

Install Refresh.Components Nuget package in order to get Intelli-Sense support:

Install-Package Refresh.Components

Migration.cs can be any C# class, implementing IMigration and it can have any name (Migration, MyMigration, CustomMigration etc.).

IMigration interface

SyntaxTree Apply(SyntaxTree initialAST, MigrationContext context);

SyntaxTree is just Microsoft.CodeAnalysis.SyntaxTree without any alterations. This is an AST of a file being migrated.

MigrationContext - context that stores types of AST nodes. Needs to be updated after every refactoring.

MigrationBuilder

In order to simplify standard migrations, MigrationBuilder provides fluent API for buidling a CompositeMigration.

MigrationBuilder API:

RenameClass(string type, string newName);
RenameInterface(string type, string newName);
RenameMethod(Method method, string newName);
RenameMember(string type, string memberName, string newName);
RenameNamespace(string namespaceName, string newName);

ReplaceClass(string oldType, string newType);
ReplaceMethod(Method method, string newMethodName);

AddArguments(Method method, List<PositionalArgument> arguments);
ChangeArguments(Method method, string argumentName, List<PositionalArgument> newArgument);
RemoveArguments(Method method, List<int> positions);
ReorderArguments(Method method, List<int> newArgumentOrder);

ChangeMethodReturnType(Method method, string newReturnType);
ChangeMemberType(string type, string memberName, string newType);

SplitMethod(Method method, Method newMethod1, Method newMethod2);

Overloads are provided in order to build Method, Argument and List<PositionalArgument> types.

Usage:

new MigrationBuilder()
      .RenameClass("Namespace.TestClass", "NewClass")
      .RenameMethod(m => m
          .OfClass("Namespace.NewClass")
          .WithName("TestMethod"), 
          "NewMethod")
      .AddArguments(m => m
          .OfClass("Namespace.NewClass")
          .WithName("NewMethod"),
          a => a
              .OfType("string")
              .WithDefaultValueExpression("\"this is a new string value\"")
              .AtPosition(1))
      .Build()
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.2 is compatible.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

This package has no dependencies.

Version Downloads Last Updated
1.3.0 816 5/9/2020
1.2.2 617 5/6/2020
1.2.0 674 5/5/2020
1.1.1 593 5/4/2020
1.1.0 611 5/4/2020
1.0.8 603 5/1/2020
1.0.7 608 4/28/2020
1.0.6 660 4/27/2020
1.0.5 634 4/26/2020
1.0.4 616 4/26/2020
1.0.3 602 4/26/2020
1.0.2 639 4/26/2020