Open idg10 opened 4 years ago
Thanks for the elaborate issue! I think it makes sense to me.
@fabiocav and @brettsam, would either of you have thoughts on this one? Wondering if we can update our reference of System.Interactive.Async
to v4. Though, I am not sure if there are breaking changes that could break existing users' apps.
I encountered a same problem. Currently, using IAsyncEnumerable<T>
and System.Interactive.Async
is unavoidable if we try to write more effective code using modern C#. Of course, we can workaround this issue like following.
<PropertyGroup>
<_FunctionsSkipCleanOutput>true</_FunctionsSkipCleanOutput>
</PropertyGroup>
However, RemoveRuntimeDependencies
build task that speed up the execution of Azure Functions is very attractive. If there're no major problems, I'd like you to remove System.Interactive.Async.dll
from the removals list.
I really apologize for the super long delay here. I missed providing any updates on this. I don't think we could remove or update the major version of that package without being potentially breaking. As this is a Host runtime dependency, the way to keep the v4 of that dependency in the build artifacts would be one of two approaches --
<ItemGroup>
<FunctionsPreservedDependencies Include="System.Interactive.Async.dll" />
</ItemGroup>
Note that this is only supported in Microsoft.Azure.WebJobs.Script.ExtensionsMetadataGenerator
version 1.2.1+
. So you may also need to add an explicit reference to the higher version of "ExtensionsMetadataGenerator" like --
<PackageReference Include="Microsoft.Azure.WebJobs.Script.ExtensionsMetadataGenerator" Version="1.2.1" />
I will leave this issue open in case people have further questions. Once again, I apologize that I missed providing any updates here.
@ankitkumarr
Thanks you for your very useful reply. I'll try recommendation option you suggested. I'm happy I can remove _FunctionsSkipCleanOutput
.
If you add a reference to v4.1.1 of the
System.Interactive.Async
NuGet package to an Azure Functions project, you cannot use it because theRemoveRuntimeDependencies
build task defined in this repo deletes it from your build output.The code that performs the deletion lives in this repo at https://github.com/Azure/azure-functions-host/blob/1ed2a54159eb3c9aaff11a9289be2bf1ce91dcb5/tools/ExtensionsMetadataGenerator/src/ExtensionsMetadataGenerator/BuildTasks/RemoveRuntimeDependencies.cs, specifically: https://github.com/Azure/azure-functions-host/blob/1ed2a54159eb3c9aaff11a9289be2bf1ce91dcb5/tools/ExtensionsMetadataGenerator/src/ExtensionsMetadataGenerator/BuildTasks/RemoveRuntimeDependencies.cs#L26-L42
The list of files this uses is also in this repo, and the offending entry is at https://github.com/Azure/azure-functions-host/blob/1ed2a54159eb3c9aaff11a9289be2bf1ce91dcb5/tools/ExtensionsMetadataGenerator/src/ExtensionsMetadataGenerator/runtimeassemblies.txt#L228
The rationale for this appears to be that Functions already brings its own copy - see https://github.com/Azure/azure-functions-host/pull/6208
But the problem is that this appears to be a v3.x era
System.Interactive.Async
which uses a definition ofIAsyncEnumerable<T>
that is incompatible with C# 8.0'sawait foreach
. The PR at https://github.com/dotnet/reactive/pull/423 modifiedSystem.Interactive.Async
to work with the new definition of this interface. This first became available in v4.0.The main reason I was trying to use the features in
System.Interactive.Async
at all was to be able to useawait foreach
, so being prevented from using v4.x defeats the purpose for me.(In the project I encountered this problem I was attempting to use the
Buffer
extension method thatSystem.Interactive.Async
defines. ThisBuffer
method is not available onIAsyncEnumerable
unless you add a reference toSystem.Interactive.Async
, and although the v3.x version supported in Functions does defineBuffer
, it does it for the wrong, old version ofIAsyncEnumerable<T>
.)Investigative information
Version information:
NuGet packages:
Microsoft.NET.Sdk.Functions
v3.0.8System.Interactive.Async
v4.1.1The local functions emulator displays this:
I'm not providing any cloud information because this problem occurs at build time. (It causes runtime problems, but you can see those in the local emulator)
Repro steps
3.0.8
and click UpdateSystem.Interactive.Async
4.1.1
)Function1.cs
Run
method, addlog.LogInformation(typeof(AsyncEnumerableEx).AssemblyQualifiedName);
An error occurs.
Expected behavior
The expected behaviour is that when the timer fires, it displays the assembly-qualified name of the
AsyncEnumerableEx
type in the log output. In fact, that's exactly what happens if you use Microsoft.NET.Sdk.Functions v3.0.3:Actual behavior
Although it works in the emulator with the 3.0.3
Microsoft.NET.Sdk.Functions
package, it doesn't with3.0.8
. You get this output instead: