Skip to main content
Glama

roslyn:extract_variable

Extract a selected expression or cursor-positioned expression into a new local variable, simplifying refactoring in C# code.

Instructions

Extract an expression to a local variable.

USAGE: Position cursor on or select an expression. OUTPUT: Expression extracted to a new local variable. IMPORTANT: Uses ZERO-BASED coordinates (editor line - 1).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filePathYesAbsolute path to source file
lineYesZero-based line number
columnYesZero-based column number
endLineNoOptional: end line for selection
endColumnNoOptional: end column for selection
previewNoPreview mode (default: true)
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description bears full responsibility. It discloses a critical behavioral trait: 'Uses ZERO-BASED coordinates (editor line - 1).' This prevents coordinate errors. No mention of side effects, but for extraction, safety is implied.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is concise (three sentences) and front-loaded with the action. It includes an 'OUTPUT' line and a crucial note. Each sentence serves a purpose, but the 'OUTPUT' line could be more specific about return value.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Despite no output schema, the description only says 'Expression extracted to a new local variable,' lacking details on what the tool returns (e.g., success message, diff, or code action). With 6 parameters and no return info, completeness is adequate but not thorough.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so baseline is 3. The description adds minimal parameter meaning beyond the schema. It implies the 'line' and 'column' relate to cursor position, but no extra detail on optional parameters like 'preview'.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states 'Extract an expression to a local variable', which is a specific verb and resource. Among siblings, it distinguishes itself from 'extract_method' and 'inline_variable', making the purpose unambiguous.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides explicit usage guidance: 'Position cursor on or select an expression.' This tells the agent when and how to invoke the tool, though it lacks explicit when-not-to-use or alternative suggestions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/pzalutski-pixel/sharplens-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server