public async Task <AzureValidatedFile> Validate(string path, string contents) { var valid = new AzureValidatedFile { FilePath = path, Message = "" }; try { //load all the subtemplates and process them through var parsed = JObject.Parse(contents); var builtTemplate = _templateBuilder.Build("FullTemplate.json", contents); var result = await _restChecker.CheckArm(builtTemplate, _secrets); if (result.error != null) { valid.Failed = true; var mString = ""; if (result?.error?.details != null && result?.error?.details.Count > 0) { mString = string.Join(" \r\n ", result.error.details.Select(_ => _.message + "\r\n").ToList()); } else { mString = result.error.message; } valid.Message += $"{mString}\r\n"; } } catch (Exception ex) { valid.Failed = true; valid.Message = $"JSON is not valid or process failed -> {ex.Message}"; Debug.WriteLine(ex.Message); } return(valid); }
#pragma warning disable CS1998 // Async method lacks 'await' operators and will run synchronously public async Task <AzureValidatedFile> Validate(string path, string contents) #pragma warning restore CS1998 // Async method lacks 'await' operators and will run synchronously { var valid = new AzureValidatedFile { FilePath = path, Message = $"JSON is valid" }; try { var parsed = JObject.Parse(contents); } catch (JsonReaderException ex) { valid.Failed = true; valid.Message = $"JSON is not valid -> {ex.Message}"; Debug.WriteLine(ex.Message); } return(valid); }