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}"); } }