Skip to content

Issues with 7.0rc1 IAsyncBasicConsumer's method  #1601

@Tornhoof

Description

@Tornhoof

Describe the bug

The new IAsyncBasicConsumer interface has a method HandleBasicDeliver and a method parameter ReadOnlyBasicProperties , but with the modifier in. You can't have in, ref in async methods. So as soon as you implement the interface and actually have anything async to do, i.e. you add the async keyword, it won't compile anymore, with CS1988 (https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/compiler-messages/ref-modifiers-errors#reference-variable-restrictions).

Task HandleBasicDeliver(string consumerTag,
ulong deliveryTag,
bool redelivered,
string exchange,
string routingKey,
in ReadOnlyBasicProperties properties,
ReadOnlyMemory<byte> body);

in basically makes only sense together with ref struct and specifically ref readonly struct, atleast that's what I understand from all the discussions around https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/proposals/csharp-11.0/low-level-struct-improvements.

I highly recommend simply removing in this prior to the 7.0 release, as modifying it would be a breaking change and at the moment implementations would need to jump through loops to use it with async (async local method etc.).

In IBasicConsumer it's not there:

Task HandleBasicDeliverAsync(string consumerTag,
ulong deliveryTag,
bool redelivered,
string exchange,
string routingKey,
ReadOnlyBasicProperties properties,
ReadOnlyMemory<byte> body);

Reproduction steps

See for example:
https://sharplab.io/#v2:EYLgxg9gTgpgtADwGwBYA0AXEBDAzgWwB8ABAJgEYBYAKGIAYACY8gVgG4biBmJ0hgYQYBvGgzFMexABxMkDALIBPeTAwALCABMAFAEsAdgwAqMXBgDKGKAFcwGBvkUA1bABtrMAJSjxQ8eJ8xAF9AhlDuBlhsTQh9V0UGMxs7Y1MLK1sMUJFqfxDqIKA===

Expected behavior

Additional context

No response

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions