RiktigRefactor.CSharp.Tool
0.0.0-ci.78
See the version list below for details.
dotnet tool install --global RiktigRefactor.CSharp.Tool --version 0.0.0-ci.78
dotnet new tool-manifest
dotnet tool install --local RiktigRefactor.CSharp.Tool --version 0.0.0-ci.78
#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
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 | Versions 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. |
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 |