Validating XML files in CSPROJ
I have multiple XML files as project items. These files are filled by developers and are consumed on build by a source generator.
A dev can make a typo in the XML and the generator will fail. Yes, it is possible to introduce XML validation into the generator and outout diagnostics that specify the location of the error.
But, is it possible to do static XML validation via some XSD while it being edited from Visual Studio/Rider without relying on the generator diagnostics? So that the dev has instant feedback on what they are doing wrong, before they even compile.
6 Replies
XML schema?
Elaborate?
XSD is my XML schema
Right right, I missed that. I'd think any competent IDE would provide instant feedback based on XSD
Yes... But how do I specify the XSD for each XML file? Especially when the XSD is in one project and the XML s are in others. I cannot create references to the project with the xsd
xsi:schemaLocation
https://stackoverflow.com/a/3966381/6042255
You could try using a relative path, I guess
But putting that schema file somewhere online — if possible — would probably be the easiestI didn't think of that... Great idea, thanks!