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

Enable the self diagnostics and fix a NullReferenceException bug #2302

Merged
merged 3 commits into from
Jun 14, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,15 @@ public void SelfDiagnosticsEventListener_DateTimeGetBytes()
CollectionAssert.AreEqual(expected, results);
}

[TestMethod]
public void SelfDiagnosticsEventListener_EncodeInBuffer_Null()
{
byte[] buffer = new byte[20];
int startPos = 0;
int endPos = SelfDiagnosticsEventListener.EncodeInBuffer(null, false, buffer, startPos);
Assert.AreEqual(startPos, endPos);
}

[TestMethod]
public void SelfDiagnosticsEventListener_EncodeInBuffer_Empty()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ public override void Dispose()
/// <returns>The position of the buffer after the last byte of the resulting sequence.</returns>
internal static int EncodeInBuffer(string str, bool isParameter, byte[] buffer, int position)
{
if (str == null)
xiang17 marked this conversation as resolved.
Show resolved Hide resolved
{
return position;
}

int charCount = str.Length;
int ellipses = isParameter ? "{...}\n".Length : "...\n".Length;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ internal class SelfDiagnosticsInitializer : IDisposable

// Long-living object that holds a refresher which checks whether the configuration file was updated
// every 10 seconds.
// private readonly SelfDiagnosticsConfigRefresher configRefresher;
private readonly SelfDiagnosticsConfigRefresher configRefresher;

static SelfDiagnosticsInitializer()
{
Expand All @@ -27,7 +27,7 @@ static SelfDiagnosticsInitializer()

private SelfDiagnosticsInitializer()
{
// this.configRefresher = new SelfDiagnosticsConfigRefresher();
this.configRefresher = new SelfDiagnosticsConfigRefresher();
}

/// <summary>
Expand All @@ -54,7 +54,7 @@ protected virtual void Dispose(bool disposing)
{
if (disposing)
{
// this.configRefresher.Dispose();
this.configRefresher.Dispose();
}
}
}
Expand Down