Skip to content

Conversation

@askpt
Copy link
Owner

@askpt askpt commented Sep 21, 2025

Introduce a new method for testing and improve the C# metrics analyzer to support complexity analysis specifically for preprocessor directives. This enhancement allows for better evaluation of code complexity in conditional compilation scenarios.

closes #38

Signed-off-by: GitHub <noreply@github.com>
…reprocessor directives

Signed-off-by: GitHub <noreply@github.com>
Copilot AI review requested due to automatic review settings September 21, 2025 09:29
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR enhances the C# metrics analyzer to better handle preprocessor directives (#if/#else/#endif) when calculating cognitive complexity. The enhancement addresses cases where method bodies are split across preprocessor blocks, which previously caused the analyzer to miss complexity patterns.

Key changes:

  • Enhanced function body detection to handle preprocessor-split methods
  • Added specialized analysis for ERROR nodes and malformed declarations in preprocessor contexts
  • Comprehensive test coverage for various preprocessor directive scenarios

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.

File Description
src/metricsAnalyzer/languages/csharpAnalyzer.ts Enhanced the core analyzer with preprocessor support, including new methods for handling fragmented method bodies and complexity detection in ERROR nodes
src/test/metricsAnalyzer/languages/csharpAnalyzer.test.ts Added comprehensive test suite for preprocessor directive scenarios including nested directives, conditional operators, and complex multi-construct cases
samples/Test.cs Added sample code demonstrating preprocessor directive usage that matches the test cases

@askpt askpt enabled auto-merge (squash) September 21, 2025 09:38
@askpt askpt merged commit 7e42f01 into main Sep 21, 2025
7 checks passed
@askpt askpt deleted the askpt/issue38 branch September 21, 2025 09:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Extension hangs when parsing C# method with conditional compilation and generics

2 participants