Beispiel #1
0
        protected override void VerifyNullabilityFix(ParsedSourceCode source, params string[] messages)
        {
            Guard.NotNull(source, nameof(source));

            AnalyzerTestContext analyzerContext = CreateTestContext(source);

            var fixTestContext = new FixProviderTestContext(analyzerContext, new[] { string.Empty }, source.ReIndentExpected);

            AssertDiagnosticsWithCodeFixes(fixTestContext, messages);
        }
Beispiel #2
0
        protected virtual void VerifyNullabilityFix([NotNull] ParsedSourceCode source,
                                                    [NotNull][ItemNotNull] params string[] messages)
        {
            Guard.NotNull(source, nameof(source));

            AnalyzerTestContext analyzerContext = CreateTestContext(source);

            string fixNotNull   = source.GetExpectedTextForAttribute(NotNullAttributeName);
            string fixCanBeNull = source.GetExpectedTextForAttribute(CanBeNullAttributeName);

            var fixContext = new FixProviderTestContext(analyzerContext, new[] { fixNotNull, fixCanBeNull },
                                                        source.ReIndentExpected);

            AssertDiagnosticsWithCodeFixes(fixContext, messages);
        }
Beispiel #3
0
        protected void VerifyNullabilityFix([NotNull] ParsedSourceCode source)
        {
            Guard.NotNull(source, nameof(source));

            string fixNotNull   = source.GetExpectedTextForAttribute(NotNullAttributeName);
            string fixCanBeNull = source.GetExpectedTextForAttribute(CanBeNullAttributeName);

            AnalyzerTestContext analyzeTextContext = new AnalyzerTestContext(source.GetText(), LanguageNames.CSharp)
                                                     .WithReferences(source.References)
                                                     .WithFileName(source.Filename);
            var fixTestContext = new FixProviderTestContext(analyzeTextContext, new[] { fixNotNull, fixCanBeNull },
                                                            source.ReIndentExpected);

            AssertDiagnosticsWithCodeFixes(fixTestContext);
        }