Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

StudioViews.Services.ProjectFileService: Update GetProjectFiles to avoid silent fail #1681

Open
murxh opened this issue Dec 8, 2024 · 0 comments

Comments

@murxh
Copy link
Contributor

murxh commented Dec 8, 2024

public List<ProjectFileInfo> GetProjectFiles(string filePath)

ProjectFileService.GetProjectFiles fails silently if it encounters invalid xml chars (like 0x1C, 0x1E, ...), resulting in an empty export file without any warning to the user
An easy fix would be to use XmlReaderSettings { CheckCharacters = false };

Instead of var xml = XDocument.Load(filePath, LoadOptions.PreserveWhitespace);

  XDocument xml = null;
  // avoid System.Xml.XmlException Message: '?', hexadecimal value 0x1C, 0x1E, ... is an invalid character.
  XmlReaderSettings xmlReaderSettings = new XmlReaderSettings { CheckCharacters = false };
  using (XmlReader xmlReader = XmlReader.Create(filePath, xmlReaderSettings))
  {
    xmlReader.MoveToContent();
    xml = XDocument.Load(xmlReader, LoadOptions.PreserveWhitespace);
  }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant