-
Notifications
You must be signed in to change notification settings - Fork 15
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
Illegal xml characters in data to be logged block log creation #59
Comments
i was able to repro this on windows. After some reading, it doesn't look like the standard library provides an option to escape characters that aren't legal. I'm not sure how we would want to do that. @codito thoughts? [Test]
public void XmlTest()
{
XmlSerializer ser = new XmlSerializer(typeof(XmlNode));
XmlNode myNode = new XmlDocument().
CreateNode(XmlNodeType.Element, "MyNode", "ns");
byte[] data = new byte[] { 0x1F };
string ascii = Encoding.ASCII.GetString(data);
myNode.InnerText = $"Hello Node {ascii}";
TextWriter writer = new StreamWriter("c:\\temp\\invalid.xml");
ser.Serialize(writer, myNode);
writer.Close();
}
|
@Alikont I'm still not sure how we would approach fixing this. Do you think its going to be a persistent issue? |
The XML writer just checks the character code as invalid https://source.dot.net/#System.Private.Xml/System/Xml/Core/XmlEncodedRawTextWriter.cs,1107 So there is not a lot that can be done on XML side of things. The more interesting question is how this character even appears in the data, maybe it's better to escape/filter them on the emitter side of things? Maybe some stdout input generates some broken characters so it should be filtered there on capture? |
I have the same issue on a Windows system without Docker. I use Nlog for logging. |
@Alikont @jairbubbles @merlinschumacher It seems clear this isn't a one-off issue. While @mbaturin-bars has shown this can sometimes have to do with how your console output is produced, I realize the illegal characters may sometimes be intended. I see a few problems:
So, I would appreciate input from any of you. @codito I see no reason why this wouldn't happen in the other users so I'm thinking the solution would have to be in the core logger. Whatever it is. |
In my case I didn't really care about the log, it was related to a very specific git command output ( So if the characters were just dismissed it would have been totally fine, not having a result file created at all was very disturbing, it took me time to figure out what was going on. A warning message could be returned to indicate some illegal characters were thrown out. |
@Siphonophora we've to replace the invalid xml characters. Let's provide an utility in TestLogger core and use it in the loggers. What do you think? E.g. the TrxLogger inbuilt in |
@codito Having the pattern from TRX to follow is great. Thanks for pointing that out. The unicode escaping seems like a solid plan I will try to dig into it soon and will ping when I have something in the core library. |
I think I'm also experiencing this when running the JSON Schema Test Suite, which definitely tests for odd characters. I particularly care about the log file as I have test counts as a badge in my readme. I have to collate a bunch of test result files and sum the counts. Because this one file is not generating, it's indicating about 20,000 tests short of the real number. Honestly, I care less about the actual test results as long as I can get a total tests run. GH Actions is pretty good at capturing output. |
Fix is work in progress here: spekt/testlogger#37 |
Hello, I wanted to kindly bring attention that the pull request is merged but not released yet. |
@msrouchou thanks for the nudge. Just pushed https://www.nuget.org/packages/JunitXml.TestLogger/3.0.125 |
Latest release is https://github.com/spekt/junit.testlogger/releases/tag/v3.0.134 and https://www.nuget.org/packages/JunitXml.TestLogger/3.0.134. Please try the fix. |
Hello, I'm trying to use junit test logger for building and uploading results from inside
dotnet/sdk:6.0
container.When I run test command
Tests are run but no
test-result.xml
file is created.It works fine if run from Windows
When I run it with
-d diag.log
and inspect log file I've noticed strange exception related to junit loggerMy csproj packages
The text was updated successfully, but these errors were encountered: