You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
await writer.YieldAsync(default).ForLinqExtension(); is used heavily internally to prevent wrapped enumerators from being disposed before the current enumerator is disposed in order to support TempCollections. This method could be useful for users to write their own AsyncEnumerable extensions. The current API is not suitable to make public. I'm thinking a better API would be:
It is on a helper type in the Proto.Promises.CompilerServices namespace instead of on the AsyncStreamWriter<T> type so that it won't be available to users directly. It's technically not unsafe because we can verify its usage, but it is an unintuitive API that should only be used by advanced users who know what they are doing (similar to many APIs in System.Runtime.CompilerServices namespace).
This API should be the very last instruction used in the async iterator function before the finally block that disposes any wrapped async enumerators. It should be the last instruction inside the try block or (await) using block. This should theoretically be verifiable by an analyzer, but I'm not familiar enough with the flow analysis to be able to write that analyzer. Unless someone more skilled with analyzers wants to take a crack at it, we can just use the existing async iterator analyzers, and rely on runtime validation to ensure no further yields or waits are used after it.
The text was updated successfully, but these errors were encountered:
await writer.YieldAsync(default).ForLinqExtension();
is used heavily internally to prevent wrapped enumerators from being disposed before the current enumerator is disposed in order to supportTempCollection
s. This method could be useful for users to write their ownAsyncEnumerable
extensions. The current API is not suitable to make public. I'm thinking a better API would be:It is on a helper type in the
Proto.Promises.CompilerServices
namespace instead of on theAsyncStreamWriter<T>
type so that it won't be available to users directly. It's technically not unsafe because we can verify its usage, but it is an unintuitive API that should only be used by advanced users who know what they are doing (similar to many APIs inSystem.Runtime.CompilerServices
namespace).This API should be the very last instruction used in the async iterator function before the
finally
block that disposes any wrapped async enumerators. It should be the last instruction inside thetry
block or(await) using
block. This should theoretically be verifiable by an analyzer, but I'm not familiar enough with the flow analysis to be able to write that analyzer. Unless someone more skilled with analyzers wants to take a crack at it, we can just use the existing async iterator analyzers, and rely on runtime validation to ensure no further yields or waits are used after it.The text was updated successfully, but these errors were encountered: