private void ProcessTemplateResourceLanguageExpressions()

in src/Analyzer.TemplateProcessor/ArmTemplateProcessor.cs [383:414]


        private void ProcessTemplateResourceLanguageExpressions(TemplateResource templateResource, TemplateExpressionEvaluationHelper evaluationHelper)
        {
            try
            {
                if (templateResource.Properties != null)
                {
                    evaluationHelper.OnGetCopyContext = () => templateResource.CopyContext;
                    InsensitiveHashSet evaluationsToSkip = new InsensitiveHashSet();
                    if (templateResource.Type.Value.Equals("Microsoft.Resources/deployments", StringComparison.OrdinalIgnoreCase))
                    {
                        evaluationsToSkip.Add("template");  // The tool should skip properties in nested templates to avoid false positive warnings
                    }

                    templateResource.Properties.Value = ExpressionsEngine.EvaluateLanguageExpressionsRecursive(
                        root: templateResource.Properties.Value,
                        evaluationContext: evaluationHelper.EvaluationContext, 
                        skipEvaluationPaths: evaluationsToSkip);
                }
            }
            catch (Exception ex)
            {
                // Do not throw if there was an issue with evaluating language expressions

                // We are using the resource name instead of the resource path because nested templates have a relative path that could be ambiguous:
                logger?.LogWarning(ex, "An exception occurred while evaluating the properties of the resource named {resourceName}", templateResource.OriginalName);
                logger?.LogDebug("Properties: {properties}", templateResource.Properties.Value);

                return;
            }

            return;
        }