Open-NET-Libraries / Open.ChannelExtensions

A set of extensions for optimizing/simplifying System.Threading.Channels usage.
https://open-net-libraries.github.io/Open.ChannelExtensions/api/Open.ChannelExtensions.Extensions.html#methods
MIT License
401 stars 25 forks source link

IAsyncEnumerable ToChannel Extension not visible in .NET 8 projects #33

Closed kamisoft-fr closed 7 months ago

kamisoft-fr commented 7 months ago

Hi guys,

I have a problem upgrading from 6.x to 8.x, it appears that ToChannel extension is not visible anymore for IAsyncEnumerable<>

I downloaded the project and added a test method as I remarked that the test project is targeting .NET 8 to see whether the code would build or not

Result : I observe the same behavior, the following code does not build

image

Here is the code I added to BasicTests.cs

        [Theory]
    [InlineData(testSize1)]
    [InlineData(testSize2)]
    [SuppressMessage("Reliability", "CA2012:Use ValueTasks correctly", Justification = "Testing only.")]
    [SuppressMessage("CodeQuality", "IDE0079:Remove unnecessary suppression", Justification = "<Pending>")]
    public static async Task ToChannelTest(int testSize)
    {
        var range = CreateAsyncEnumerableRange(testSize);
        var result = new List<int>(testSize);

        var startedAt = TimeProvider.System.GetTimestamp();
        ChannelReader<int> reader = range
            .ToChannel(singleReader: true, deferredExecution: true);

        _ = reader.ReadAll(i => result.Add(i), true);

        await reader.Completion;
        var elapsed = TimeProvider.System.GetElapsedTime(startedAt);
    }

    static async IAsyncEnumerable<int> CreateAsyncEnumerableRange(int testSize)
    {
        foreach (var i in Enumerable.Range(0, testSize))
            yield return i;
        await Task.CompletedTask;
    }
electricessence commented 7 months ago

On it.

electricessence commented 7 months ago

v6, v7, and v8 all updated. (nuget) Please check and see if that fixes it. (it should).

kamisoft-fr commented 7 months ago

I confirm it's compiling now, thanks mate 👌