Code inspection: Put local function after 'return' or 'continue'
This inspection reports a local function declared before the logical end of a scope. When local functions are mixed into the main execution flow instead of being placed after the regular statements in the block, the flow can be harder to follow.
Example
Moving local functions down makes the flow easier to follow.
void M()
{
Console.WriteLine("start");
Work();
Console.WriteLine("end");
void Work()
{
Console.WriteLine("work");
}
}
void M()
{
Console.WriteLine("start");
Work();
Console.WriteLine("end");
return;
void Work()
{
Console.WriteLine("work");
}
}
Quick-fix
Move the local function to the end of the scope. If needed, the fix also inserts an explicit jump statement such as return to clearly separate executable code from local function declarations.
29 March 2026