Structural Duplication Tool is a Roslyn-powered C# command-line utility that automates structural duplication of method signatures and parameters.
It provides flag-based control for suffixes, comments, and file filtering — simplifying large-scale refactoring tasks.
- Duplicate method parameters or entire method signatures
- Add custom suffixes to duplicated parameters
- Insert inline comments after modified signatures
- Filter processed files with patterns (e.g.
*Service.cs) - Analyze and rewrite C# code using the Roslyn API
- Output updated code to a custom directory
Clone the repository and build:
git clone https://github.com/yourname/structural-duplication-tool.git
cd structural-duplication-tool
dotnet buildYou can also run it directly with:
dotnet run --project structural-duplication-toolBasic example:
dotnet run -- \\
--input ./src \\
--output ./out \\
--duplicate-all \\
--suffix "_dup" \\
--filter *Service.cs| Flag | Description | Default | Example |
|---|---|---|---|
--input |
Path to source directory | ${projectRoot}/testing/Samples/ |
--input ./src |
--output |
Output directory for modified files | ${projectRoot}/testing/Results/ |
--output ./out |
--duplicate-all |
Duplicate all parameters (if omitted — duplicates only methods with one parameter) | false |
--duplicate-all |
--suffix |
Suffix appended to duplicated parameters | _duplicate |
--suffix "_copy" |
--comment |
Inline comment added after modified methods | // duplicated parameter added |
--comment "// dup" |
--filter |
File name pattern to include | *.cs |
--filter *Service.cs |
public class UserService
{
public void CreateUser(string name)
{
// logic
}
public int GetUser(int id)
{
return id;
}
}dotnet run -- \\
--input ./src \\
--output ./out \\
--duplicate-all \\
--suffix "_dup" \\public class UserService
{
// duplicated parameter added
public void CreateUser(string name, string name_dup)
{
// logic
}
// duplicated parameter added
public int GetUser(int id, int id_dup)
{
return id;
}
}Console output:
[ParamsDuplicator] Processing 1 file
[ParamsDuplicator] Methods modified: 2
[ParamsDuplicator] Parameters duplicated: 2
[ParamsDuplicator] Saved to: ./out