internal ElementDiagnosticContext(
     MSBuildAnalysisSession session,
     MSBuildElement element)
 {
     this.session = session;
     Element      = element;
 }
        static bool IsStatic(MSBuildElement propertyGroupOrItemGroup)
        {
            switch (propertyGroupOrItemGroup.Parent.SyntaxKind)
            {
            case MSBuildSyntaxKind.When:
            case MSBuildSyntaxKind.Otherwise:
            case MSBuildSyntaxKind.Project:
                return(true);

            default:
                return(false);
            }
        }
 public void ExecuteElementActions(MSBuildElement element)
 {
     if (Context.GetElementActions(element.SyntaxKind, out var actions))
     {
         var ctx = new ElementDiagnosticContext(this, element);
         foreach (var(analyzer, action) in actions)
         {
             try {
                 if (!analyzer.Disabled)
                 {
                     action(ctx);
                 }
             } catch (Exception ex) {
                 Context.ReportAnalyzerError(analyzer, ex);
             }
         }
     }
 }
        static void AnalyzeElement(MSBuildElement element, MSBuildAnalysisSession session, CancellationToken token)
        {
            token.ThrowIfCancellationRequested();

            session.ExecuteElementActions(element);

            foreach (var child in element.Elements)
            {
                AnalyzeElement(child, session, token);
            }

            foreach (var att in element.Attributes)
            {
                session.ExecuteAttributeActions(att);
            }

            if (element is MSBuildPropertyElement propertyElement)
            {
                session.ExecutePropertyWriteActions(propertyElement);
            }
        }
Example #5
0
 internal MSBuildWhenElement(MSBuildElement parent, XElement xelement, ExpressionNode value) : base(parent, xelement, value)
 {
 }
Example #6
0
 internal MSBuildPropertyGroupElement(MSBuildElement parent, XElement xelement, ExpressionNode value) : base(parent, xelement, value)
 {
 }
Example #7
0
 internal MSBuildProjectExtensionsElement(MSBuildElement parent, XElement xelement, ExpressionNode value) : base(parent, xelement, value)
 {
 }
Example #8
0
 internal MSBuildItemDefinitionGroupElement(MSBuildElement parent, XElement xelement, ExpressionNode value) : base(parent, xelement, value)
 {
 }
Example #9
0
 protected MSBuildConditionedElement(MSBuildElement parent, XElement xelement, ExpressionNode value) : base(parent, xelement, value)
 {
 }