// This method should not be visited by PropertyAccessSyntax of Resource/Modules (But Variables should visit). This is meant to catch variable // properties which are assigned entire resource/modules, or to recurse through a chain of variable references. public override void VisitVariableAccessSyntax(VariableAccessSyntax syntax) { if (DeployTimeConstantVisitor.ExtractResourceOrModuleSymbolAndBodyObj(this.model, syntax) is ({} declaredSymbol, {} referencedBodyObj)) { this.invalidReferencedBodyObj = referencedBodyObj; visitedStack.Push(declaredSymbol.Name); }
// This method should not be visited by PropertyAccessSyntax of Resource/Modules (But Variables should visit). This is meant to catch variable // properties which are assigned entire resource/modules, or to recurse through a chain of variable references. public override void VisitVariableAccessSyntax(VariableAccessSyntax syntax) { if (DeployTimeConstantVisitor.ExtractResourceOrModuleSymbolAndBodyType(this.model, syntax) is ({} referencedSymbol, {} referencedBodyType)) { this.InvalidReferencedBodyType = referencedBodyType; VisitedStack.Push(referencedSymbol); }
// entry point for this visitor. We only iterate through modules and resources public static void ValidateDeployTimeConstants(SemanticModel model, IDiagnosticWriter diagnosticWriter) { var deploymentTimeConstantVisitor = new DeployTimeConstantVisitor(model, diagnosticWriter); foreach (var declaredSymbol in model.Root.ResourceDeclarations) { deploymentTimeConstantVisitor.Visit(declaredSymbol.DeclaringSyntax); } foreach (var declaredSymbol in model.Root.ModuleDeclarations) { deploymentTimeConstantVisitor.Visit(declaredSymbol.DeclaringSyntax); } }