Version Used: VS 18.0.0 Insiders [11201.2]
Steps to Reproduce:
At the marked location, open the lightbulb menu and select "Introduce parameter for 'a'" > "into extracted method to invoke at callsites".
class C
{
object M() => new
{
$$a = new { },
};
}
Expected Behavior:
Valid, compilable code is produced.
Actual Behavior:
Uncompilable code is generated:
class C
{
private global::System.Object GetA() // <- Name is not simplified
{
return a; // CS0103: The name 'a' does not exist in the current context
}
object M(var a) => new
// ~~~ CS0825: The contextual keyword 'var' may only appear within a local variable declaration or in script code
{
a = new { },
};
}
