Skip to content

Commit

Permalink
Fix warnings that cause build to fail because they are treated as errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Jericho committed Jun 6, 2024
1 parent 9abe6f0 commit 6c23897
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions Source/ZoomNet/Utilities/Log/ValueStringBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ public int Length
get => _pos;
set
{
Debug.Assert(value >= 0);
Debug.Assert(value <= _chars.Length);
Debug.Assert(value >= 0, "Value must be greater than zero");
Debug.Assert(value <= _chars.Length, "Value cannot exceed the size of the buffer");
_pos = value;
}
}
Expand All @@ -43,7 +43,7 @@ public int Length
public void EnsureCapacity(int capacity)
{
// This is not expected to be called this with negative capacity
Debug.Assert(capacity >= 0);
Debug.Assert(capacity >= 0, "Capacity must be greater than zero");

// If the caller has a bug and calls this with negative capacity, make sure to call Grow to throw an exception.
if ((uint)capacity > (uint)_chars.Length)
Expand Down Expand Up @@ -80,7 +80,7 @@ public ref char this[int index]
{
get
{
Debug.Assert(index < _pos);
Debug.Assert(index < _pos, "Index must less than the number of items currently in the buffer");
return ref _chars[index];
}
}
Expand Down Expand Up @@ -194,8 +194,10 @@ public void Append(string s)
}

int pos = _pos;
if (s.Length == 1 && (uint)pos < (uint)_chars.Length) // very common case, e.g. appending strings from NumberFormatInfo like separators, percent symbols, etc.

if (s.Length == 1 && (uint)pos < (uint)_chars.Length)
{
// very common case, e.g. appending strings from NumberFormatInfo like separators, percent symbols, etc.
_chars[pos] = s[0];
_pos = pos + 1;
}
Expand Down Expand Up @@ -275,7 +277,7 @@ private void GrowAndAppend(char c)
[MethodImpl(MethodImplOptions.NoInlining)]
private void Grow(int additionalCapacityBeyondPos)
{
Debug.Assert(additionalCapacityBeyondPos > 0);
Debug.Assert(additionalCapacityBeyondPos > 0, "Value must be greater than zero");
Debug.Assert(_pos > _chars.Length - additionalCapacityBeyondPos, "Grow called incorrectly, no resize is needed.");

const uint ArrayMaxLength = 0x7FFFFFC7; // same as Array.MaxLength
Expand Down

0 comments on commit 6c23897

Please sign in to comment.