public void LogDiagnosticMessage(string message, string category, params string[] details) { _baseHost.LogDiagnosticMessage(message, category, details); }
// TODO: localize the diagnostic strings // checks that all the template sources are under the template root, and they exist. internal bool AreAllTemplatePathsValid(IRunnableProjectConfig templateConfig, RunnableProjectTemplate runnableTemplate) { ITemplateEngineHost host = runnableTemplate.Source.EnvironmentSettings.Host; if (runnableTemplate.TemplateSourceRoot == null) { host.LogDiagnosticMessage(string.Empty, "Authoring"); host.LogDiagnosticMessage(string.Format(LocalizableStrings.Authoring_TemplateRootOutsideInstallSource, runnableTemplate.Name), "Authoring"); return(false); } // check if any sources get out of the mount point bool allSourcesValid = true; foreach (FileSourceMatchInfo source in templateConfig.Sources) { try { IFile file = runnableTemplate.TemplateSourceRoot.FileInfo(source.Source); if (file?.Exists ?? false) { allSourcesValid = false; host.LogDiagnosticMessage(string.Empty, "Authoring"); host.LogDiagnosticMessage(string.Format(LocalizableStrings.Authoring_TemplateNameDisplay, runnableTemplate.Name), "Authoring"); host.LogDiagnosticMessage(string.Format(LocalizableStrings.Authoring_TemplateSourceRoot, runnableTemplate.TemplateSourceRoot.FullPath), "Authoring"); host.LogDiagnosticMessage(string.Format(LocalizableStrings.Authoring_SourceMustBeDirectory, source.Source), "Authoring"); } else { IDirectory sourceRoot = runnableTemplate.TemplateSourceRoot.DirectoryInfo(source.Source); if (!(sourceRoot?.Exists ?? false)) { // non-existant directory allSourcesValid = false; host.LogDiagnosticMessage(string.Empty, "Authoring"); host.LogDiagnosticMessage(string.Format(LocalizableStrings.Authoring_TemplateNameDisplay, runnableTemplate.Name), "Authoring"); host.LogDiagnosticMessage(string.Format(LocalizableStrings.Authoring_TemplateSourceRoot, runnableTemplate.TemplateSourceRoot.FullPath), "Authoring"); host.LogDiagnosticMessage(string.Format(LocalizableStrings.Authoring_SourceDoesNotExist, source.Source), "Authoring"); host.LogDiagnosticMessage(string.Format(LocalizableStrings.Authoring_SourceIsOutsideInstallSource, sourceRoot.FullPath), "Authoring"); } } } catch { // outside the mount point root // TODO: after the null ref exception in DirectoryInfo is fixed, change how this check works. allSourcesValid = false; host.LogDiagnosticMessage(string.Empty, "Authoring"); host.LogDiagnosticMessage(string.Format(LocalizableStrings.Authoring_TemplateNameDisplay, runnableTemplate.Name), "Authoring"); host.LogDiagnosticMessage(string.Format(LocalizableStrings.Authoring_TemplateSourceRoot, runnableTemplate.TemplateSourceRoot.FullPath), "Authoring"); host.LogDiagnosticMessage(string.Format(LocalizableStrings.Authoring_TemplateRootOutsideInstallSource, source.Source), "Authoring"); } } return(allSourcesValid); }
private bool PerformTemplateValidation(SimpleConfigModel templateModel, IFile templateFile, ITemplateEngineHost host) { //Do some basic checks... List <string> errorMessages = new List <string>(); List <string> warningMessages = new List <string>(); if (string.IsNullOrEmpty(templateModel.Identity)) { errorMessages.Add(string.Format(LocalizableStrings.Authoring_MissingValue, "identity", templateFile.FullPath)); } if (string.IsNullOrEmpty(templateModel.Name)) { errorMessages.Add(string.Format(LocalizableStrings.Authoring_MissingValue, "name", templateFile.FullPath)); } if ((templateModel.ShortNameList?.Count ?? 0) == 0) { errorMessages.Add(string.Format(LocalizableStrings.Authoring_MissingValue, "shortName", templateFile.FullPath)); } if (string.IsNullOrEmpty(templateModel.SourceName)) { warningMessages.Add(string.Format(LocalizableStrings.Authoring_MissingValue, "sourceName", templateFile.FullPath)); } if (string.IsNullOrEmpty(templateModel.Author)) { warningMessages.Add(string.Format(LocalizableStrings.Authoring_MissingValue, "author", templateFile.FullPath)); } if (string.IsNullOrEmpty(templateModel.GroupIdentity)) { warningMessages.Add(string.Format(LocalizableStrings.Authoring_MissingValue, "groupIdentity", templateFile.FullPath)); } if (string.IsNullOrEmpty(templateModel.GeneratorVersions)) { warningMessages.Add(string.Format(LocalizableStrings.Authoring_MissingValue, "generatorVersions", templateFile.FullPath)); } if (templateModel.Precedence == 0) { warningMessages.Add(string.Format(LocalizableStrings.Authoring_MissingValue, "precedence", templateFile.FullPath)); } if ((templateModel.Classifications?.Count ?? 0) == 0) { warningMessages.Add(string.Format(LocalizableStrings.Authoring_MissingValue, "classifications", templateFile.FullPath)); } if (templateModel.PostActionModel != null && templateModel.PostActionModel.Any(x => x.ManualInstructionInfo == null || x.ManualInstructionInfo.Count == 0)) { warningMessages.Add(string.Format(LocalizableStrings.Authoring_MalformedPostActionManualInstructions, templateFile.FullPath)); } if (warningMessages.Count > 0) { host.LogDiagnosticMessage(string.Format(LocalizableStrings.Authoring_TemplateMissingCommonInformation, templateFile.FullPath), "Authoring"); foreach (string message in warningMessages) { host.LogDiagnosticMessage(" " + message, "Authoring"); } } if (errorMessages.Count > 0) { host.LogDiagnosticMessage(string.Format(LocalizableStrings.Authoring_TemplateNotInstalled, templateFile.FullPath), "Authoring"); foreach (string message in errorMessages) { host.LogDiagnosticMessage(" " + message, "Authoring"); } return(false); } return(true); }
public void LogDebug(string data) { _host.LogDiagnosticMessage(data, DebugLogCategory); }