When I extract method from this code, final result have global::System.Int32[] list as parameter in NewMethod:
using System;
public class Program
{
public static void Main(string[] args)
{
var list = new int[] {3, 2, 1 };
foreach(var i in list) Console.WriteLine(i);
}
}
Final result:
using System;
public class Program
{
public static void Main(string[] args)
{
var list = new int[] { 3, 2, 1 };
NewMethod(list);
}
private static void NewMethod(**global::System.Int32[] list**)
{
foreach (var i in list) Console.WriteLine(i);
}
}
I use this this Roslyn class to extract method:
var options = new ExtractMethodGenerationOptions()
{CodeGenerationOptions = CodeGenerationOptions.GetDefault(document.Project.Services),
ExtractOptions = new() { DontPutOutOrRefOnStruct = true}}
var service = new CSharpExtractMethodService() as IExtractMethodService;
var extract = await service.ExtractMethodAsync(document, span, false,options, CancellationToken.None);
var result = extract.DocumentWithoutFinalFormatting;
Why I have global::, when I extract method with Visual Studio, the NewMethod have simple int[] list as method parameter?