From 484c824bd768f2e7206c1a47cd62deedc52eda09 Mon Sep 17 00:00:00 2001 From: rstefko Date: Mon, 9 Sep 2024 11:28:15 +0200 Subject: [PATCH] Added failonwarn property to xmlvalidate task --- .gitignore | 1 + src/Tasks/ValidateXmlTask.cs | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/.gitignore b/.gitignore index 44f8545..2597431 100644 --- a/.gitignore +++ b/.gitignore @@ -64,3 +64,4 @@ NUnit-Frame-Report NUnit-NoFrame-Report Mock-Frame-Report Mock-NoFrame-Report +/src/.vs diff --git a/src/Tasks/ValidateXmlTask.cs b/src/Tasks/ValidateXmlTask.cs index a193f3a..7ff471d 100644 --- a/src/Tasks/ValidateXmlTask.cs +++ b/src/Tasks/ValidateXmlTask.cs @@ -58,6 +58,17 @@ public class ValidateXmlTask : Task { #region Public Instance Properties + /// + /// Report warnings as errors. + /// + [TaskAttribute("failonwarn")] + [BooleanValidator] + public bool FailOnWarn + { + get; + set; + } + /// /// The XML files that must be validated. /// @@ -157,6 +168,10 @@ private void OnValidationError(object sender, ValidationEventArgs args) { case XmlSeverityType.Warning: // output error message Log(Level.Info, "Validation warning: {0}", args.Message); + if (this.FailOnWarn) + { + _numErrors++; + } break; } }