Arnolyzer.Analyzers.EncapsulationAnalyzers.AA1101ClassPropertiesShouldBePubliclyRead_OnlyAnalyzer.AnalyzeSyntaxTree C# (CSharp) Метод

AnalyzeSyntaxTree() приватный Метод

private AnalyzeSyntaxTree ( SyntaxTreeAnalysisContext context ) : void
context SyntaxTreeAnalysisContext
Результат void
        private void AnalyzeSyntaxTree(SyntaxTreeAnalysisContext context)
        {
            var syntaxRoot = context.Tree.GetRoot(context.CancellationToken);
            var settings = _settingsHandler.GetArnolyzerSettingsForProject(context.Tree.FilePath);

            var classDeclarations =
                syntaxRoot.DescendantNodes(DoNotDescendIntoTypeDeclarations)
                          .Where(NodeIsPublicClassDeclaration)
                          .Cast<ClassDeclarationSyntax>().ToList();

            var propertyDeclarations = from node in classDeclarations
                                       from property in
                                           node.DescendantNodes()
                                               .Where(NodeIsPropertyDeclaration)
                                               .Cast<PropertyDeclarationSyntax>()
                                       where SyntaxNodeIsPublic(property.Modifiers) &&
                                             !AutoGenerated(property) &&
                                             !IgnoredFile(property, settings) &&
                                             !PropertyHasIgnoreRuleAttribute(property, SuppressionAttributes)
                                       select new
                                       {
                                           className = node.Identifier.Text,
                                           property
                                       };

            foreach (var propertyDeclaration in propertyDeclarations)
            {
                propertyDeclaration.property.DescendantNodes()
                                   .Where(p => p.IsKind(SyntaxKind.SetAccessorDeclaration))
                                   .Cast<AccessorDeclarationSyntax>()
                                   .Where(s => s.Modifiers.Count == 0)
                                   .TryFirst()
                                   .Match()
                                   .Some()
                                   .Do(setter => context.ReportDiagnostic(
                                       Diagnostic.Create(Rule,
                                                         setter.Keyword.GetLocation(),
                                                         propertyDeclaration.property.Identifier,
                                                         propertyDeclaration.className)))
                                   .IgnoreElse()
                                   .Exec();
            }
        }