Repository navigation
[release/8.0.1xx] Avoid 'Collection was modified' InvalidOperationException - #6937
Conversation
Fixes #6929 Ensure that we do not perform any state updates to the dataflow CoreAnalysisData inside the loop for the method `ClearOverlappingAnalysisDataForIndexedEntity`. We instead collect the key-value pairs to be updated in the loop, and perform these updates after the loop. I haven't been able to come up with a minimal repro case that reproduces this exception, but the loop for which exception was generated can no longer perform any state updates, so we can be quite certain the underlying exception can no longer be thrown.
|
@jeffhandley @artl93 can you please take a look at this backport request? |
Codecov Report
@@ Coverage Diff @@
## release/8.0.1xx #6937 +/- ##
================================================
Coverage 96.39% 96.40%
================================================
Files 1402 1402
Lines 331854 331865 +11
Branches 11027 11028 +1
================================================
+ Hits 319901 319919 +18
+ Misses 9190 9184 -6
+ Partials 2763 2762 -1 |
jeffhandley
left a comment
There was a problem hiding this comment.
Looks good and logical to me. The risk for .NET 8 is low here and I support the backport as it should improve reliability.
Attached is a minimal repro @mavasani |
Backport of #6935 to release/8.0.1xx
/cc @mavasani
Customer Impact
Couple of months back, we fixed a bunch of functionality issues in our dataflow analysis framework. One of those commits:
716272a caused a regression where in customers are now hitting new AD0001 analyzer exception diagnostics in different flow analysis based analyzers on RC1 bits, see #6929. We have received external as well internal reports for the same, but these are not that widespread because all the dataflow analysis based rules are disabled by default. However, any one who individually or bulk enables these rules via editorconfig or
AnalysisLevel/AnalysisModeproperties in MSBuild can potentially hit these exceptions.Testing
I haven't been able to create a minimal repro that leads to this exception. However, the loop in question has been modified to no longer perform any state updates, so the underlying InvalidOperationException from collection modification should definitely no longer be thrown. I am planning to request the external and internal customers to try out the analyzer NuGet package from our public dotnet8 feed produced from the main branch to confirm the fix indeed resolves their AD0001.
I'll share an update here once I have done so and received responses.This was confirmed by the external customer here: #6929 (comment). I have sent out an email to the internal contact who hit the same issue to help validate.Risk
This should be a pretty low risk fix as we are just changing to code to push all state updates after the loop which was enumerating the keys.