Detection of Multiple Enumeration in the C# Source Code Using Static Analysis


Detection of Multiple Enumeration in the C# Source Code Using Static Analysis

Khanevskaya K.A. (ISP RAS, Moscow, Russia; MIPT, Dolgoprudny, Moscow Region, Russia)
Tsiazhkorob U.V. (ISP RAS, Moscow, Russia; MIPT, Dolgoprudny, Moscow Region, Russia)
Ignatiev V.N. (ISP RAS, Moscow, Russia; MSU, Moscow, Russia)

Abstract

This article is dedicated to the problem of multiple enumeration of lazy collections in C#, an antipattern that can lead to significant performance degradation and unpredictable program behavior. A static detector is proposed, implemented within the industrial static analyzer SharpChecker. The algorithm is based on symbolic execution sensitive to control flow and execution paths and supports interprocedural analysis. The detector identifies both repeated enumerations within a single method and those occurring through chains of called methods. Experimental evaluation on 20 open-source projects demonstrated a high true positive rate (approximately 95%). The results demonstrate the effectiveness and practical value of the proposed approach, allowing its integration as a core detector and providing the functionality to users.

Keywords

static analysis; symbolic execution; bug detection; multiple enumeration; LINQ methods; deferred execution; working with collections.

Edition

Proceedings of the Institute for System Programming, vol. 38, issue 6, part 1, 2026, pp. 9-22

ISSN 2220-6426 (Online), ISSN 2079-8156 (Print).

DOI: 10.15514/ISPRAS-2026-38(6)-1

For citation

Khanevskaya K.A., Tsiazhkorob U.V., Ignatiev V.N. Detection of Multiple Enumeration in the C# Source Code Using Static Analysis. Proceedings of the Institute for System Programming, vol. 38, issue 6, part 1, 2026, pp. 9-22 DOI: 10.15514/ISPRAS-2026-38(6)-1.

Full text of the paper in pdf (in Russian) Back to the contents of the volume