Skip to content

Commit

Permalink
Added more detailed schema validation tracing
Browse files Browse the repository at this point in the history
  • Loading branch information
TomProkop committed Mar 15, 2024
1 parent 711de41 commit 149c103
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/Dataverse/MSBuildTasks/Tasks/ValidateXmlFiles.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public override bool Execute()
XmlReaderSettings settings = new XmlReaderSettings
{
ValidationType = ValidationType.Schema,
ValidationFlags = XmlSchemaValidationFlags.ReportValidationWarnings | XmlSchemaValidationFlags.ProcessIdentityConstraints | XmlSchemaValidationFlags.ProcessInlineSchema | XmlSchemaValidationFlags.ProcessSchemaLocation,
Schemas = schemas,
DtdProcessing = DtdProcessing.Ignore
};
Expand All @@ -39,7 +40,9 @@ public override bool Execute()
switch (e.Severity)
{
case XmlSeverityType.Error:
throw e.Exception;
string text = $"Line: {e.Exception?.LineNumber}, Column: {e.Exception?.LinePosition}> {e.Message}";
// fail the build if there is an error
throw new Exception(text);
case XmlSeverityType.Warning:
Log.LogWarning($"Schema validation warning: {e.Message}");
break;
Expand Down

0 comments on commit 149c103

Please sign in to comment.