public void Method_LineChange3() { var src1 = @" class C { static int X() => 1; static int Y() => 1; } "; var src2 = @" class C { static int X() => 1; static int Y() => 1; }"; var edits = GetTopEdits(src1, src2); edits.VerifyLineEdits( new[] { new SourceLineUpdate(3, 4), AbstractEditAndContinueAnalyzer.CreateZeroDeltaSourceLineUpdate(4) }); }
public void Constructor_Reorder() { var src1 = @" class C { public C(int a) { } public C(bool a) { } } "; var src2 = @" class C { public C(bool a) { } public C(int a) { } }"; var edits = GetTopEdits(src1, src2); edits.VerifyLineEdits( new[] { new SourceLineUpdate(4, 8), AbstractEditAndContinueAnalyzer.CreateZeroDeltaSourceLineUpdate(6), new SourceLineUpdate(8, 4) }); }
public void Method_Reorder2() { var src1 = @" class Program { static void Main() { Goo(); Bar(); } static int Goo() { return 1; } static int Bar() { return 2; } }"; var src2 = @" class Program { static int Goo() { return 1; } static void Main() { Goo(); Bar(); } static int Bar() { return 2; } }"; var edits = GetTopEdits(src1, src2); edits.VerifyLineEdits( new[] { new SourceLineUpdate(4, 9), AbstractEditAndContinueAnalyzer.CreateZeroDeltaSourceLineUpdate(8), new SourceLineUpdate(10, 4), AbstractEditAndContinueAnalyzer.CreateZeroDeltaSourceLineUpdate(13), }, Array.Empty <string>()); }
public void Method_Reorder1() { var src1 = @" class C { static void Goo() { Console.ReadLine(1); } static void Bar() { Console.ReadLine(2); } } "; var src2 = @" class C { static void Bar() { Console.ReadLine(2); } static void Goo() { Console.ReadLine(1); } }"; var edits = GetTopEdits(src1, src2); edits.VerifyLineEdits( new[] { new SourceLineUpdate(4, 9), AbstractEditAndContinueAnalyzer.CreateZeroDeltaSourceLineUpdate(7), new SourceLineUpdate(9, 4) }, Array.Empty <string>()); }
internal static IEnumerable <KeyValuePair <SyntaxNode, SyntaxNode> > GetMethodMatches(AbstractEditAndContinueAnalyzer analyzer, Match <SyntaxNode> bodyMatch) { Dictionary <SyntaxNode, AbstractEditAndContinueAnalyzer.LambdaInfo> lazyActiveOrMatchedLambdas = null; var map = analyzer.GetTestAccessor().ComputeMap(bodyMatch, Array.Empty <AbstractEditAndContinueAnalyzer.ActiveNode>(), ref lazyActiveOrMatchedLambdas, new List <RudeEditDiagnostic>()); var result = new Dictionary <SyntaxNode, SyntaxNode>(); foreach (var pair in map.Forward) { if (pair.Value == bodyMatch.NewRoot) { Assert.Same(pair.Key, bodyMatch.OldRoot); continue; } result.Add(pair.Key, pair.Value); } return(result); }