Example #1
0
        private static void ReportOnInvalidIdentifier(SyntaxToken identifier, SemanticModel semanticModel, Action <Diagnostic> reportAction, CancellationToken cancellationToken)
        {
            if (!identifier.Text.EndsWith(OptSuffix, StringComparison.Ordinal) ||
                !semanticModel.GetNullableContext(identifier.SpanStart).AnnotationsEnabled())
            {
                return;
            }

            var symbol = semanticModel.GetDeclaredSymbol(identifier.Parent, cancellationToken);

            if (ShouldReport(symbol))
            {
                reportAction(identifier.CreateDiagnostic(Rule));
            }
        }
Example #2
0
        private static void ReportOnInvalidIdentifier(SyntaxToken identifier, SemanticModel semanticModel, Action <Diagnostic> reportAction)
        {
            if (!identifier.Text.EndsWith(OptSuffix, StringComparison.Ordinal) ||
                !semanticModel.GetNullableContext(identifier.SpanStart).AnnotationsEnabled())
            {
                return;
            }

            var symbol = semanticModel.GetDeclaredSymbol(identifier.Parent);

            if (symbol?.GetMemberOrLocalOrParameterType()?.NullableAnnotation() == Analyzer.Utilities.Lightup.NullableAnnotation.Annotated)
            {
                reportAction(identifier.CreateDiagnostic(Rule));
            }
        }
 protected override Diagnostic CreateDiagnostic(IMethodSymbol containingMethod, SyntaxToken catchKeyword)
 {
     return(catchKeyword.CreateDiagnostic(Rule, containingMethod.Name));
 }