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

Update ReadAny to skip over lists and maps #372

Merged
merged 2 commits into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
58 changes: 58 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
###############################################################################
# Set default behavior to automatically normalize line endings.
###############################################################################
* text=auto

*.sln text eol=crlf
*.csproj text eol=crlf
*.vbproj text eol=crlf
*.vcxproj text eol=crlf
*.vcproj text eol=crlf
*.dbproj text eol=crlf
*.fsproj text eol=crlf
*.lsproj text eol=crlf
*.wixproj text eol=crlf
*.modelproj text eol=crlf
*.sqlproj text eol=crlf
*.wmaproj text eol=crlf

*.xproj text eol=crlf
*.props text eol=crlf
*.filters text eol=crlf
*.vcxitems text eol=crlf
*.dgml text eol=crlf

*.bat text eol=crlf
*.cmd text eol=crlf
*.sh text eol=lf

*.DotSettings text eol=lf
*.svg text eol=lf
*.kts text eol=lf

*.cs diff=csharp
*.doc diff=astextplain
*.DOC diff=astextplain
*.docx diff=astextplain
*.DOCX diff=astextplain
*.dot diff=astextplain
*.DOT diff=astextplain
*.pdf diff=astextplain
*.PDF diff=astextplain
*.rtf diff=astextplain
*.RTF diff=astextplain

*.exe binary
*.pdf binary
*.bmp binary
*.cur binary
*.dll binary
*.doc binary
*.docx binary
*.ico binary
*.jpg binary
*.ocx binary
*.xls binary
*.xlsx binary
*.png binary
*.gif binary
29 changes: 29 additions & 0 deletions RabbitMQ.Stream.Client/AMQP/AmqpWireFormattingRead.cs
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,35 @@ internal static int ReadAny(ref SequenceReader<byte> reader, out object value)
value = null;
reader.Advance(1);
return 1;

case FormatCode.List0:
case FormatCode.List8:
case FormatCode.List32:
{
offset = ReadListHeader(ref reader, out var fields);
for (long i = 0; i < fields; i++)
{
offset += ReadAny(ref reader, out _);
}

value = null;
return offset;
}

case FormatCode.Map8:
case FormatCode.Map32:
{
offset = ReadMapHeader(ref reader, out var count);
var values = count / 2;
for (uint i = 0; i < values; i++)
{
offset += ReadAny(ref reader, out _);
offset += ReadAny(ref reader, out _);
}

value = null;
return offset;
}
}

throw new AmqpParseException($"Read Any: Invalid type: {type}");
Expand Down