RiktigRefactor.CSharp.Tool 0.0.0-ci.78

This is a prerelease version of RiktigRefactor.CSharp.Tool.
There is a newer prerelease version of this package available.
See the version list below for details.
dotnet tool install --global RiktigRefactor.CSharp.Tool --version 0.0.0-ci.78
                    
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 RiktigRefactor.CSharp.Tool --version 0.0.0-ci.78
                    
This package contains a .NET tool you can call from the shell/command line.
#tool dotnet:?package=RiktigRefactor.CSharp.Tool&version=0.0.0-ci.78&prerelease
                    
nuke :add-package RiktigRefactor.CSharp.Tool --version 0.0.0-ci.78
                    

RiktigRefactor.CSharp

Build and test Status: early development

Seriously safe behavior-preserving refactorings for C#. Riktig means "correct" in Swedish/Norwegian. When the tool cannot prove a transformation is safe, it refuses with a clear reason instead of guessing.

This is the C# implementation of the RiktigRefactor specification.

Contents

What it can do

The tool has these refactorings:

Rename

Rename renames a symbol and every reference to it across a whole solution or project.

Before
class Order
{
    int qty;
    int Total() => qty * 2;
}
After
class Order
{
    int quantity;
    int Total() => quantity * 2;
}

See more details in docs/rename.md.

Extract IIFE

Extract IIFE (also called extract static lambda) wraps a selected expression, or whole statements of one block, in an immediately-invoked static lambda.

Before
var total = price * qty;
After
var total = ((Func<decimal, int, decimal>)(static (price, qty) => price * qty))(price, qty);

See more details in docs/extract-iife.md.

Make method static

Make method static turns an instance method into a static method on the same type, with the receiver as a new first parameter, and rewrites every call.

Before
public decimal Total(int qty) => price * qty;
var t = order.Total(3);
After
public static decimal Total(Order order, int qty) => order.price * qty;
var t = Order.Total(order, 3);

See more details in docs/make-method-static.md.

Move static member

Move static member moves a static method (including an extension method), field, property, event or constant to another class, struct or record in the same project, and updates every reference. With --create-target, a target that doesn't exist yet is created as a static class in a new file.

Before
class Order { public static decimal Total(Order order, int qty) => order.Price * qty; }
var t = Order.Total(order, 3);
After
class Pricing { public static decimal Total(Order order, int qty) => order.Price * qty; }
var t = Pricing.Total(order, 3);

See more details in docs/move-static-member.md.

Convert static method to instance method

Convert static method to instance method is the inverse of Make method static: a parameter of a class type becomes the receiver, the method moves into that class, and every call passes the argument as the receiver.

Before
public static class Pricing { public static decimal Total(Order order, int qty) => order.Price * qty; }
var t = Pricing.Total(order, 3);
After
public class Order { public decimal Total(int qty) => this.Price * qty; }
var t = order.Total(3);

See more details in docs/convert-to-instance-method.md.

Using it

The package is not published yet; run it from a clone:

dotnet run --project RiktigRefactor.CSharp.Tool -- rename --workspace App.sln --file src/Foo.cs --at 12:5 --new-name count

See the command line for the options, exit codes and refusal codes.

Building and testing

./build-and-test

For more information, see CONTRIBUTING.md.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  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. 
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
0.0.0-ci.79 62 11/29/2026
0.0.0-ci.78 60 11/29/2026
0.0.0-ci.77 70 11/29/2026
0.0.0-ci.76 58 11/29/2026
0.0.0-ci.75 60 11/29/2026
0.0.0-ci.74 70 11/25/2026