public static TemplateContext GetArmTemplateContext()

in src/Analyzer.BicepProcessor/BicepSourceLocationResolver.cs [101:128]


            public static TemplateContext GetArmTemplateContext(string templatePath)
            {
                if (!Cache.ContainsKey(templatePath))
                {
                    // Create a new JsonSourceLocationResolver where the top-level template is the ARM module (not the parent Bicep)
                    var templateString = File.ReadAllText(templatePath);
                    var armTemplateProcessor = new ArmTemplateProcessor(templateString);
                    var templatejObject = armTemplateProcessor.ProcessTemplate(null);

                    var templateContext = new TemplateContext
                    {
                        OriginalTemplate = JObject.Parse(templateString),
                        ExpandedTemplate = templatejObject,
                        IsMainTemplate = true,
                        ResourceMappings = armTemplateProcessor.ResourceMappings,
                        TemplateIdentifier = templatePath,
                        IsBicep = false,
                        BicepMetadata = null,
                        PathPrefix = string.Empty,
                        ParentContext = null
                    };

                    // Assumption: template has already been parsed by Bicep library and is valid
                    Cache[templatePath] = templateContext;
                }

                return Cache[templatePath];
            }