stronginject
stronginject copied to clipboard
Innermost hasAwaitStarted catch block is a no-op and could be omitted
How can !hasAwaitStarted_a_1_1
in the catch block ever not evaluate to false
? It's not assigned anywhere else.
https://github.com/YairHalberstadt/stronginject/blob/2143d9f27dfdf7269b4de3e60dd198c4374cd586/StrongInject.Tests.Unit/GeneratorTests.cs#L7112-L7125
In that particular case you are right. If you want an example where this is relevant check out the testInstancePerDependencyDependenciesWithFactories
. In that example async calls are parallelized - so we trigger 2 async calls then await one, then await the other. In that case you can have a situation where you need to keep track of whether an await has started.
We definitely could improve codegen to detect this scenario and remove the unnecessary bookkeeping.
Makes sense. I'm not too concerned. Do you want to leave this issue open to track skipping this try block for the innermost await?
Yep, thanks