コード例 #1
0
ファイル: CodeFixVerifier.cs プロジェクト: ikvm/Roslynator
        public async Task VerifyDiagnosticAndFixAsync(
            string theory,
            string fromData,
            string toData,
            CodeVerificationOptions options     = null,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            (string source, string expected, TextSpan span) = TestSourceText.ReplaceSpan(theory, fromData, toData);

            TestSourceTextAnalysis analysis = TestSourceText.GetSpans(source);

            if (analysis.Spans.Any())
            {
                IEnumerable <Diagnostic> diagnostics = analysis.Spans.Select(f => CreateDiagnostic(f.Span, f.LineSpan));

                await VerifyDiagnosticAsync(analysis.Source, diagnostics, additionalSources : null, options : options, cancellationToken).ConfigureAwait(false);

                await VerifyFixAsync(analysis.Source, expected, options, cancellationToken).ConfigureAwait(false);
            }
            else
            {
                await VerifyDiagnosticAsync(source, span, options, cancellationToken).ConfigureAwait(false);

                await VerifyFixAsync(source, expected, options, cancellationToken).ConfigureAwait(false);
            }
        }
コード例 #2
0
        public async Task VerifyRefactoringAsync(
            string theory,
            string beforeData,
            string afterData,
            string equivalenceKey,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            (string source, string expected, TextSpan span) = TestSourceText.ReplaceSpan(theory, beforeData, afterData);

            TestSourceTextAnalysis analysis = TestSourceText.GetSpans(source, reverse: true);

            if (analysis.Spans.Any())
            {
                await VerifyRefactoringAsync(
                    source : analysis.Source,
                    expected : expected,
                    spans : analysis.Spans.Select(f => f.Span),
                    equivalenceKey : equivalenceKey,
                    cancellationToken : cancellationToken).ConfigureAwait(false);
            }
            else
            {
                await VerifyRefactoringAsync(
                    source : source,
                    expected : expected,
                    span : span,
                    equivalenceKey : equivalenceKey,
                    cancellationToken : cancellationToken).ConfigureAwait(false);
            }
        }
コード例 #3
0
        public async Task VerifyDiagnosticAsync(
            string source,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            TestSourceTextAnalysis analysis = TestSourceText.GetSpans(source);

            await VerifyDiagnosticAsync(
                analysis.Source,
                analysis.Spans.Select(f => CreateDiagnostic(f.Span, f.LineSpan)),
                additionalSources : null,
                cancellationToken).ConfigureAwait(false);
        }
コード例 #4
0
        public async Task VerifyNoDiagnosticAsync(
            string theory,
            string fromData,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            (string source, TextSpan span) = TestSourceText.ReplaceSpan(theory, fromData);

            await VerifyNoDiagnosticAsync(
                source : source,
                additionalSource : null,
                cancellationToken).ConfigureAwait(false);
        }
コード例 #5
0
        public async Task VerifyNoRefactoringAsync(
            string source,
            string equivalenceKey,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            TestSourceTextAnalysis analysis = TestSourceText.GetSpans(source, reverse: true);

            await VerifyNoRefactoringAsync(
                source : analysis.Source,
                spans : analysis.Spans.Select(f => f.Span),
                equivalenceKey : equivalenceKey,
                cancellationToken : cancellationToken).ConfigureAwait(false);
        }
コード例 #6
0
        public async Task VerifyFixAsync(
            string theory,
            string fromData,
            string toData,
            string equivalenceKey)
        {
            (string source, string expected, TextSpan span) = TestSourceText.ReplaceSpan(theory, fromData, toData);

            await VerifyFixAsync(
                source : source,
                expected : expected,
                equivalenceKey : equivalenceKey).ConfigureAwait(false);
        }
コード例 #7
0
        public async Task VerifyDiagnosticAndFixAsync(
            string source,
            string expected,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            TestSourceTextAnalysis analysis = TestSourceText.GetSpans(source);

            IEnumerable <Diagnostic> diagnostics = analysis.Spans.Select(f => CreateDiagnostic(f.Span, f.LineSpan));

            await VerifyDiagnosticAsync(analysis.Source, diagnostics, additionalSources : null, cancellationToken : cancellationToken).ConfigureAwait(false);

            await VerifyFixAsync(analysis.Source, expected, cancellationToken).ConfigureAwait(false);
        }
コード例 #8
0
ファイル: CodeFixVerifier.cs プロジェクト: ikvm/Roslynator
        public async Task VerifyFixAsync(
            string theory,
            string fromData,
            string toData,
            CodeVerificationOptions options     = null,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            (string source, string expected, TextSpan span) = TestSourceText.ReplaceSpan(theory, fromData, toData);

            await VerifyFixAsync(
                source : source,
                expected : expected,
                options : options,
                cancellationToken : cancellationToken).ConfigureAwait(false);
        }
コード例 #9
0
        public async Task VerifyDiagnosticAsync(
            string theory,
            string fromData,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            (string source, TextSpan span) = TestSourceText.ReplaceSpan(theory, fromData);

            TestSourceTextAnalysis analysis = TestSourceText.GetSpans(source);

            if (analysis.Spans.Any())
            {
                await VerifyDiagnosticAsync(analysis.Source, analysis.Spans.Select(f => f.Span), cancellationToken).ConfigureAwait(false);
            }
            else
            {
                await VerifyDiagnosticAsync(source, span, cancellationToken).ConfigureAwait(false);
            }
        }
コード例 #10
0
        public async Task VerifyRefactoringAsync(
            string source,
            string expected,
            string equivalenceKey               = null,
            string[] additionalSources          = null,
            CodeVerificationOptions options     = null,
            CancellationToken cancellationToken = default(CancellationToken))
        {
            TestSourceTextAnalysis analysis = TestSourceText.GetSpans(source, reverse: true);

            await VerifyRefactoringAsync(
                source : analysis.Source,
                expected : expected,
                spans : analysis.Spans.Select(f => f.Span),
                equivalenceKey : equivalenceKey,
                additionalSources : additionalSources,
                options : options,
                cancellationToken : cancellationToken).ConfigureAwait(false);
        }