Skip to content

Commit

Permalink
ref[C#]: C# protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
jaysunxiao committed Jul 15, 2024
1 parent d444cd5 commit 2794348
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 16 deletions.
14 changes: 6 additions & 8 deletions protocol/src/main/resources/csharp/Buffer/ByteBuffer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,11 @@ public void SetWriteOffset(int writeIndex)
{
if (writeIndex > buffer.Length)
{
throw new Exception("writeIndex[" + writeIndex + "] out of bounds exception: readerIndex: " +
throw new Exception("writeIndex[" + writeIndex + "] out of bounds exception: readOffset: " +
readOffset +
", writerIndex: " + writeOffset +
"(expected: 0 <= readerIndex <= writerIndex <= capacity:" + buffer.Length);
", writeOffset: " + writeOffset +
"(expected: 0 <= readOffset <= writeOffset <= capacity:" + buffer.Length);
}

writeOffset = writeIndex;
}

Expand All @@ -107,11 +106,10 @@ public void SetReadOffset(int readIndex)
{
if (readIndex > writeOffset)
{
throw new Exception("readIndex[" + readIndex + "] out of bounds exception: readerIndex: " + readOffset +
", writerIndex: " + writeOffset +
"(expected: 0 <= readerIndex <= writerIndex <= capacity:" + buffer.Length);
throw new Exception("readIndex[" + readIndex + "] out of bounds exception: readIndex: " + readOffset +
", writeOffset: " + writeOffset +
"(expected: 0 <= readOffset <= writeOffset <= capacity:" + buffer.Length);
}

readOffset = readIndex;
}

Expand Down
14 changes: 6 additions & 8 deletions protocol/src/test/csharp/zfoocs/Buffer/ByteBuffer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,11 @@ public void SetWriteOffset(int writeIndex)
{
if (writeIndex > buffer.Length)
{
throw new Exception("writeIndex[" + writeIndex + "] out of bounds exception: readerIndex: " +
throw new Exception("writeIndex[" + writeIndex + "] out of bounds exception: readOffset: " +
readOffset +
", writerIndex: " + writeOffset +
"(expected: 0 <= readerIndex <= writerIndex <= capacity:" + buffer.Length);
", writeOffset: " + writeOffset +
"(expected: 0 <= readOffset <= writeOffset <= capacity:" + buffer.Length);
}

writeOffset = writeIndex;
}

Expand All @@ -107,11 +106,10 @@ public void SetReadOffset(int readIndex)
{
if (readIndex > writeOffset)
{
throw new Exception("readIndex[" + readIndex + "] out of bounds exception: readerIndex: " + readOffset +
", writerIndex: " + writeOffset +
"(expected: 0 <= readerIndex <= writerIndex <= capacity:" + buffer.Length);
throw new Exception("readIndex[" + readIndex + "] out of bounds exception: readIndex: " + readOffset +
", writeOffset: " + writeOffset +
"(expected: 0 <= readOffset <= writeOffset <= capacity:" + buffer.Length);
}

readOffset = readIndex;
}

Expand Down

0 comments on commit 2794348

Please sign in to comment.