Is Use of the Microsoftl.Bcl.AsyncInterfaces Library Actually Supported? #81352
-
We are interested in using But according to official MS docs, the default language version for Framework 4.8 is
This library is not required from .NET Core 3.0 onwards, so apart from .NET Core 2.1 specifically, it would seem the only use case for this library is in a configuration that is warned against. So is using e.g. .NET Framework 4.8 with a Is the use of this library in this configuration guaranteed to work properly? And is there any guarantee it will continue to work with e.g. new point-releases of .NET Framework 4.8.x? |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments
-
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label. |
Beta Was this translation helpful? Give feedback.
-
As you pointed out, .NET Framework's supported lang ver is 7.3 (https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/configure-language-version). This means that moving the lang version ahead may lead to undefined behavior. |
Beta Was this translation helpful? Give feedback.
-
Tagging subscribers to this area: @dotnet/area-meta Issue DetailsWe are interested in using But according to official MS docs, the default language version for Framework 4.8 is
This library is not required from .NET Core 3.0 onwards, so apart from .NET Core 2.1 specifically, it would seem the only use case for this library is in a configuration that is warned against. So is using e.g. .NET Framework 4.8 with a Is the use of this library in this configuration guaranteed to work properly? And is there any guarantee it will continue to work with e.g. new point-releases of .NET Framework 4.8.x?
|
Beta Was this translation helpful? Give feedback.
-
It's a bit complicated situation. First, given that As for C# 8, it is not officially supported in earlier frameworks, but you can enable it at your own risk. I would do it if I were you and if the codebase is sufficiently tested, but if you don't want to do it, you can use IAsyncEnumerable<int> xs = // …
// C# >= 8
await foreach (int x in xs)
{
Console.WriteLine(x);
}
// C# < 8
IAsyncEnumerator<int> enumerator = xs.GetAsyncEnumerator();
try
{
while (await enumerator.MoveNextAsync())
{
Console.WriteLine(enumerator.Current);
}
}
finally
{
await enumerator.DisposeAsync();
} |
Beta Was this translation helpful? Give feedback.
It's a bit complicated situation. First, given that
Microsoft.Bcl.AsyncInterfaces
still receives updates and targets .NET Framework, it should be supported fine. In fact,IAsyncEnumerable
andIAsyncDisposable
are just interfaces; there is nothing actual to support in them. They useValueTask
from theSystem.Tasks.Extensions
package, which is supported on .NET Framework.As for C# 8, it is not officially supported in earlier frameworks, but you can enable it at your own risk. I would do it if I were you and if the codebase is sufficiently tested, but if you don't want to do it, you can use
IAsyncEnumerable
from earlier language versions the manual way: