public static async Task VerifyTemplatePathAsync()

in code/tools/TemplateValidator/TemplateJsonVerifier.cs [27:82]


        public static async Task<VerifierResult> VerifyTemplatePathAsync(string configFilePath)
        {
            var results = new List<string>();

            if (configFilePath == null)
            {
                results.Add("Path to template.json file not provided.");
            }

            if (Path.GetFileName(configFilePath) != "template.json")
            {
                results.Add("Path does not point to a template.json file.");
            }

            // handle relative and absolute paths
            var rootedFilePath = configFilePath;

            if (configFilePath != null && !Path.IsPathRooted(configFilePath))
            {
                rootedFilePath = new FileInfo(configFilePath).FullName;
            }

            if (!File.Exists(rootedFilePath))
            {
                results.Add("Path to template.json file does not exist.");
            }

            if (!results.Any())
            {
                var fileContents = File.ReadAllText(configFilePath);

                // The analyzer compares the JSON with the POCO type. It identifies discrepancies in types, missing or extra properties, etc.
                var analyzerResults = await Analyzer.AnalyzeJsonAsync(fileContents, typeof(ValidationTemplateInfo));

                // The "other" checks are specific to what the wizard does with the config file and expectations of the content
                var otherResults = await PerformOtherTemplateContentChecks(configFilePath, fileContents);

                results = new List<string>(analyzerResults);

                if (otherResults.Any())
                {
                    if (analyzerResults.First() == AllGood)
                    {
                        results = otherResults;
                    }
                    else
                    {
                        results.AddRange(otherResults);
                    }
                }
            }

            var success = results.Count == 1 && results.First() == AllGood;

            return new VerifierResult(success, results);
        }