// 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);
     }
Пример #2
0
 public override void VisitVariableDeclarationSyntax(VariableDeclarationSyntax syntax)
 {
     VisitedStack.Push(syntax.Name.IdentifierName);
     base.VisitVariableDeclarationSyntax(syntax);
     if (this.InvalidReferencedBodyType != null)
     {
         return;
     }
     // This variable declaration was deployment time constant
     if (VisitedStack.Pop() is var popped &&
         popped != syntax.Name.IdentifierName)
     {
         throw new InvalidOperationException($"{this.GetType().Name} performed an invalid Stack push/pop: expected popped element to be {syntax.Name.IdentifierName} but got {popped}");
     }
 }
        public override void VisitVariableDeclarationSyntax(VariableDeclarationSyntax syntax)
        {
            var variableSymbol = this.model.GetSymbolInfo(syntax) as VariableSymbol ?? throw new InvalidOperationException($"{nameof(syntax)} must be bound to a VariableSymbol.");

            VisitedStack.Push(variableSymbol);

            base.VisitVariableDeclarationSyntax(syntax);
            if (this.InvalidReferencedBodyType != null)
            {
                return;
            }
            // This variable declaration was deployment time constant
            if (VisitedStack.Pop() is var popped && popped != variableSymbol)
            {
                throw new InvalidOperationException($"{this.GetType().Name} performed an invalid Stack push/pop: expected popped element to be {variableSymbol.Name} but got {popped?.Name}");
            }
        }