Detection of collection modifications during its enumeration in the C# source code using static analysis
News
Detection of collection modifications during its enumeration in the C# source code using static analysis
Abstract
The article is dedicated to the development of the method for detecting collection modification error during their enumeration in C# programs. Such errors lead to an InvalidOperationException and program crash at runtime. The proposed solution is implemented within the industrial static analyzer SharpChecker and uses interprocedural symbolic analysis, sensitive to control flow and execution paths. The detector tracks both direct modifications of collections within a foreach loop and modifications occurring through chains of method calls. Testing on open-source projects showed an accuracy of about 69%. The results demonstrate the effectiveness of the approach for detecting complex cases of collection modification.
Keywords
Edition
Proceedings of the Institute for System Programming, vol. 38, issue 3, part 1, 2026, pp. 129-142
ISSN 2220-6426 (Online), ISSN 2079-8156 (Print).
DOI: 10.15514/ISPRAS-2026-38(3)-7
For citation
Full text of the paper in pdf (in Russian)
Back to the contents of the volume