Exemplo n.º 1
0
        /// <summary>
        /// Determines whether a node can be handled by either Y0001 or Y0002.
        /// </summary>
        private static bool ShouldAnalyze(VariableDeclarationSyntax node, out EqualsValueClauseSyntax?initializer)
        {
            initializer = default;

            // Don't bother with checking nodes with compile-errors.
            if (node.DescendantNodesAndTokensAndSelf().Any(n => n.GetDiagnostics().Any(d => d.Severity == DiagnosticSeverity.Error)))
            {
                return(false);
            }

            // CS0822: Implicitly-typed variables cannot be constant
            // TODO: Can it be a constant but parent is not LocalDeclarationStatementSyntax??
            if (node.Parent is LocalDeclarationStatementSyntax {
                IsConst: true
            })