-
Notifications
You must be signed in to change notification settings - Fork 325
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
Print start of testhost standard error message #1708
Conversation
@@ -17,5 +19,28 @@ public static string AddDoubleQuote(this string value) | |||
{ | |||
return "\"" + value + "\""; | |||
} | |||
|
|||
public static void AppendToStringBuilderBasedOnMaxLength(this string data, StringBuilder result) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't look like string extension. May be a string builder extension.
public static void AppendSafe(this StringBuilder stringBuilder, string data)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Create StringBuilderExtensions
class with AppendSafeWithNewLine()
.
@@ -17,5 +19,28 @@ public static string AddDoubleQuote(this string value) | |||
{ | |||
return "\"" + value + "\""; | |||
} | |||
|
|||
public static void AppendToStringBuilderBasedOnMaxLength(this string data, StringBuilder result) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we write comment as well for this method?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
@@ -36,17 +36,12 @@ public DataCollectionLauncher(IProcessHelper processHelper, IMessageLogger messa | |||
{ | |||
this.processHelper = processHelper; | |||
this.messageLogger = messageLogger; | |||
this.processStdError = new StringBuilder(this.ErrorLength, this.ErrorLength); | |||
this.processStdError = new StringBuilder(0, CoreUtilities.Constants.StandardErrorMaxLength); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When setting capacity to zero, will stringBuilder not be perf inefficient? As it needs to keep on copying and pasting the content to new instance whenever grow is required.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't expect any stderr most of time. StringBuilder increase size exponentially.
} | ||
|
||
[TestMethod] | ||
public void ErrorReceivedCallbackShouldAppendEntireStringEvenItReachesToMaxLength() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
EvenItReachesToMaxLength
? In code, max length is not reached.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In Windows NewLine
is two characters.
} | ||
|
||
// Add newline for readbility. | ||
data += Environment.NewLine; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we are writing stringBuilder extension, then it should not be job of stringBuilder to add a new line. It should be the user's responsibility to add a new line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Create StringBuilderExtensions
class with AppendSafeWithNewLine()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
approved with suggestions.
|
||
/// <summary> | ||
/// Number of character should be logged on child process exited with | ||
/// error message on stadard error. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit:standard
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
/// Number of character should be logged on child process exited with | ||
/// error message on stadard error. | ||
/// </summary> | ||
public const int StandardErrorMaxLength = 20480; // 20 KB |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see a reason for increasing it by 5 times. 4096 was a reasonable buffer, we can probably make ti 8192 (2x), if user wants more info, they can always go ahead check the logs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Made it 8192
/// <param name="result">string builder</param> | ||
/// /// <param name="data">data to be appended.</param> | ||
/// <returns></returns> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit:Extra line
Nit:readability* inside the method below
public static class StringBuilderExtensions | ||
{ | ||
/// <summary> | ||
/// Add double quote around string. Useful in case of path which has white space in between. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Summary needs to be corrected.
@@ -17,5 +17,28 @@ public static string AddDoubleQuote(this string value) | |||
{ | |||
return "\"" + value + "\""; | |||
} | |||
|
|||
public static void AppendToStringBuilderBasedOnMaxLength(this string data, StringBuilder result) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still see this code, please remove this.
// 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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the idea here, are we saying the original Sting content will remain, & only add small part of new data?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes.
@@ -17,5 +17,28 @@ public static string AddDoubleQuote(this string value) | |||
{ | |||
return "\"" + value + "\""; | |||
} | |||
|
|||
public static void AppendToStringBuilderBasedOnMaxLength(this string data, StringBuilder result) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this method needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is removed in latest commits.
@@ -6,7 +6,7 @@ namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.DataCollection | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Text; | |||
|
|||
using CoreUtilities.Extensions; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Please use full namespace
@@ -36,17 +36,12 @@ public DataCollectionLauncher(IProcessHelper processHelper, IMessageLogger messa | |||
{ | |||
this.processHelper = processHelper; | |||
this.messageLogger = messageLogger; | |||
this.processStdError = new StringBuilder(this.ErrorLength, this.ErrorLength); | |||
this.processStdError = new StringBuilder(0, CoreUtilities.Constants.StandardErrorMaxLength); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we initialize it with something other than that of 0 length?
Description
Related issue
Fixes #1688