Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoRossignoli committed Mar 7, 2022
1 parent 4400855 commit 92715a5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.TestRunAttachments
/// </summary>
internal class DataCollectorAttachmentProcessorAppDomain : IDataCollectorAttachmentProcessor, IDisposable
{
private static readonly char[] MessageTerminator = new char[] { '\0' };
private readonly string _pipeShutdownMessagePrefix = Guid.NewGuid().ToString();
private readonly DataCollectorAttachmentProcessorRemoteWrapper _wrapper;
private readonly InvokedDataCollector _invokedDataCollector;
Expand Down Expand Up @@ -97,10 +96,7 @@ private void PipeReaderTask()
{
try
{
var messagePayloads = sr.ReadLine().Split(MessageTerminator, StringSplitOptions.RemoveEmptyEntries);

// Reassemble the message if needed.
string messagePayload = messagePayloads.Aggregate((a, b) => $"{a}\n{b}");
string messagePayload = sr.ReadLine().Replace("\0", Environment.NewLine);

if (messagePayload.StartsWith(_pipeShutdownMessagePrefix))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ public async Task DataCollectorAttachmentProcessorAppDomain_ShouldLogCorrectly()
Assert.AreEqual(TestMessageLevel.Warning, messages[1].Item1);
Assert.AreEqual("Warning", messages[1].Item2);
Assert.AreEqual(TestMessageLevel.Error, messages[2].Item1);
Assert.AreEqual("line1\nline2\nline3", messages[2].Item2);
Assert.AreEqual($"line1{Environment.NewLine}line2{Environment.NewLine}line3", messages[2].Item2);
}

[TestMethod]
Expand Down Expand Up @@ -245,7 +245,7 @@ public async Task<ICollection<AttachmentSet>> ProcessAttachmentSetsAsync(XmlElem

logger.SendMessage(TestMessageLevel.Informational, "Info");
logger.SendMessage(TestMessageLevel.Warning, "Warning");
logger.SendMessage(TestMessageLevel.Error, $"line1\nline2{Environment.NewLine}\nline3");
logger.SendMessage(TestMessageLevel.Error, $"line1{Environment.NewLine}line2\nline3");

return attachments;
}
Expand Down

0 comments on commit 92715a5

Please sign in to comment.