-
Notifications
You must be signed in to change notification settings - Fork 319
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Print start of testhost standard error message (#1708)
* Print start of testhost standard error message * update unit tests * Print datacollector stderr from the begining * Create StringBuilderExtensions * Fix nits * USe full namespace
- Loading branch information
Showing
11 changed files
with
165 additions
and
115 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
src/Microsoft.TestPlatform.CoreUtilities/Utilities/StringBuilderExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
namespace Microsoft.VisualStudio.TestPlatform.CoreUtilities.Extensions | ||
{ | ||
using System; | ||
using System.Text; | ||
|
||
public static class StringBuilderExtensions | ||
{ | ||
/// <summary> | ||
/// Append given data from to string builder with new line. | ||
/// </summary> | ||
/// <param name="result">string builder</param> | ||
/// <param name="data">data to be appended.</param> | ||
/// <returns></returns> | ||
public static void AppendSafeWithNewLine(this StringBuilder result, string data) | ||
{ | ||
if (!string.IsNullOrEmpty(data)) | ||
{ | ||
// Don't append more data if already reached max length. | ||
if (result.Length >= result.MaxCapacity) | ||
{ | ||
return; | ||
} | ||
|
||
// Add newline for readability. | ||
data += Environment.NewLine; | ||
|
||
// Append sub string of data if appending all the data exceeds max capacity. | ||
if (result.Length + data.Length >= result.MaxCapacity) | ||
{ | ||
data = data.Substring(0, result.MaxCapacity - result.Length); | ||
} | ||
|
||
result.Append(data); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.