extract-method

Extract selected C# statements into a new private method with inferred parameters.

Updated Mar 13, 2026
One-click install
npx skills add https://github.com/darylmcd/Roslyn-Backed-MCP --skill extract-method
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: extract-method
Source: https://github.com/darylmcd/Roslyn-Backed-MCP/tree/main/skills/extract-method
Command: npx skills add https://github.com/darylmcd/Roslyn-Backed-MCP --skill extract-method

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Extract Method Refactoring helps you reduce method complexity by turning a selected block of statements into a new, properly parameterized private method.

Core Features & Use Cases

  • Identify cohesive code blocks within a method
  • Generate a new method with inferred parameters and return values
  • Replace the original block with a call to the new method and verify compilation

Quick Start

Provide a target code region and method name, and the skill will propose the extraction plan and perform a safe refactor with previews and post-change verification

Frequently Asked Questions about extract-method

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I extract a block of C# code into a new method to reduce complexity?

Extract method refactoring turns a selected block of C# statements into a new private method, automatically inferring parameters and return values, then replacing the original block with a call to the new method.

How does extract method refactoring determine parameters and return values?

Extract method analyzes the selected C# code block to determine which local variables are read or modified, inferring the new method's parameters and return values to ensure functional equivalence at the call site.

Can I extract C# methods using Roslyn with compile checks and previews?

Yes, this refactoring operates on C# code within loaded solutions using Roslyn, enforcing a preview before applying changes and running compile checks after extraction to verify code integrity.

What happens if I select an infeasible code block for extract method refactoring?

When an infeasible selection is encountered during extraction, the process provides error handling to prevent invalid refactoring, ensuring only cohesive, extractable C# code blocks are turned into new methods.

What is the best way to break down large C# methods into focused helpers?

The best way to reduce method complexity is identifying cohesive code blocks and extracting them into properly parameterized private methods, replacing the original statements with a method call and verifying compilation.

Do I need a loaded C# solution to perform extract method refactoring?

Yes, extract method operates on C# code within loaded solutions to analyze syntax, determine parameters and return values, update the call site, and perform post-extraction compile checks.