Azure / Azure/azure-functions-dotnet-worker
Input binding fails for EventHub trigger when the binding type is List
- Dominant language
- C#
- Stars
- 466
- Forks
- 215
- Avg merge
- 3d 10h
- Merged PRs (30d)
- 7
Description
Input binding fails💥 for EventHub trigger when the binding type is `List`! See the below 2 functions. Run1 works fine, Run2 fails because `inputs` is not populated and is `null`
```csharp
[Function("MyEventHubTriggerEnumerable")]
public void Run1([EventHubTrigger("samples-workitems", Connection = "Con")] IEnumerable inputs)
{
_logger.LogInformation($"IEnumerable count: {inputs?.Count()}");
foreach (var item in inputs)
{
_logger.LogInformation($"{item}");
}
}
[Function("MyEventHubTriggerList")]
public void Run2([EventHubTrigger("samples-workitems", Connection = "Con")] List inputs)
{
_logger.LogInformation($"List Length: {inputs.Count}");
foreach (var item in inputs)
{
_logger.LogInformation($"{item}");
}
}
```
Works fine for `IEnumerable`, `ICollection`, `IList` and `IReadOnlyList`. `List` is the one unhappy puppy.
When target type is `IEnumerable`, `ICollection`, `IList` or `IReadOnlyList`, The [TypeConverter ](https://github.com/Azure/azure-functions-dotnet-worker/blob/2b78e7b03503f499ae71507b2a842d1848b86fb2/src/DotNetWorker.Core/Converters/TypeConverter.cs#L9) does the conversion. But it does not work for array or List.

When target type is `string[`], the [TypeConverter ](https://github.com/Azure/azure-functions-dotnet-worker/blob/2b78e7b03503f499ae71507b2a842d1848b86fb2/src/DotNetWorker.Core/Converters/TypeConverter.cs#L9) still returns an unhandled response, but the [ArrayConverter ](https://github.com/Azure/azure-functions-dotnet-worker/blob/2b78e7b03503f499ae71507b2a842d1848b86fb2/src/DotNetWorker.Core/Converters/ArrayConverter.cs#L12)can successfully convert.

In short, we do not have a converter which is able to convert when target type is `List` in this example.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.