public async Task VerifyRefactoringAsync( string theory, string fromData, string toData, string equivalenceKey = null, CodeVerificationOptions options = null, CancellationToken cancellationToken = default(CancellationToken)) { (TextSpan span, string source, string expected) = SpanParser.ReplaceSpan(theory, fromData, toData); SpanParserResult result = SpanParser.GetSpans(source, reverse: true); if (result.Spans.Any()) { await VerifyRefactoringAsync( source : result.Text, expected : expected, spans : result.Spans.Select(f => f.Span), equivalenceKey : equivalenceKey, options : options, cancellationToken : cancellationToken).ConfigureAwait(false); } else { await VerifyRefactoringAsync( source : source, expected : expected, span : span, equivalenceKey : equivalenceKey, options : options, cancellationToken : cancellationToken).ConfigureAwait(false); } }
public async Task VerifyDiagnosticAsync( string source, CodeVerificationOptions options = null, CancellationToken cancellationToken = default(CancellationToken)) { SpanParserResult result = SpanParser.GetSpans(source); await VerifyDiagnosticAsync( result.Text, result.Spans.Select(f => CreateDiagnostic(f.Span, f.LineSpan)), additionalSources : null, options : options, cancellationToken).ConfigureAwait(false); }
public async Task VerifyNoRefactoringAsync( string source, string equivalenceKey = null, CodeVerificationOptions options = null, CancellationToken cancellationToken = default(CancellationToken)) { SpanParserResult result = SpanParser.GetSpans(source, reverse: true); await VerifyNoRefactoringAsync( source : result.Text, spans : result.Spans.Select(f => f.Span), equivalenceKey : equivalenceKey, options : options, cancellationToken : cancellationToken).ConfigureAwait(false); }
public async Task VerifyDiagnosticAsync( string theory, string fromData, CodeVerificationOptions options = null, CancellationToken cancellationToken = default(CancellationToken)) { (TextSpan span, string text) = SpanParser.ReplaceSpan(theory, fromData); SpanParserResult result = SpanParser.GetSpans(text); if (result.Spans.Any()) { await VerifyDiagnosticAsync(result.Text, result.Spans.Select(f => f.Span), options, cancellationToken).ConfigureAwait(false); } else { await VerifyDiagnosticAsync(text, span, options, cancellationToken).ConfigureAwait(false); } }
public static void TestExpressionChainEnumerator_WithSpan4() { const string s = @" class C { void M(string a, string b) { string s = a + [|b|]; } }"; SpanParserResult result = SpanParser.Default.GetSpans(s); BinaryExpressionSyntax be = CSharpSyntaxTree.ParseText(result.Text).GetRoot().FirstDescendant <BinaryExpressionSyntax>(); ExpressionChain.Enumerator en = new ExpressionChain(be, result.Spans[0].Span).GetEnumerator(); Assert.True(en.MoveNext() && en.Current == be.Right); Assert.True(!en.MoveNext()); }
public static void TestExpressionChainReversedEnumerator_WithSpan() { const string s = @" class C { void M(string a, string b, string c) { string s = [|a + b + c|]; } }"; SpanParserResult result = SpanParser.Default.GetSpans(s); BinaryExpressionSyntax be = CSharpSyntaxTree.ParseText(result.Text).GetRoot().FirstDescendant <BinaryExpressionSyntax>(); var be2 = (BinaryExpressionSyntax)be.Left; ExpressionChain.Reversed.Enumerator en = new ExpressionChain(be, result.Spans[0].Span).Reverse().GetEnumerator(); Assert.True(en.MoveNext() && en.Current == be.Right); Assert.True(en.MoveNext() && en.Current == be2.Right); Assert.True(en.MoveNext() && en.Current == be2.Left); Assert.True(!en.MoveNext()); }