Skip to content

C# parser: local-function calls are attributed to the outer method #1790

Open

Description

@Shashankss1205

Found during an installed-checkout audit of CodeGraphContext/CodeGraphContext at 1b595a61663d60862ac20aca2422ea187671c01c (package 0.6.13).

Environment: Python 3.12, tree-sitter 0.25.2, tree-sitter-language-pack 1.20.0. The existing 384 parser/language/call-resolution tests pass. These are additional independently specified semantic checks.

This is the consolidated c_sharp issue; all confirmed findings for this parser from this audit are kept here.

Reproduce

The reproducible audit harness is on the audit branch.

python -m pip install -e '.[dev,parsing]'
python scripts/audit_language_parsers.py --language c_sharp --output parser-audit.json

The JSON retains every input, expected assertion, actual output and grammar recovery status. LF, CRLF, Unicode comment padding, dependency/source mode, repeat parsing and pre-scan are checked.

Triage correction: C# records are already emitted in the dedicated records bucket, as intended. That initial oracle mismatch has been removed; the local-function ownership defect below is confirmed.

Confirmed failures

1. local function

class S { void Outer() { void Inner() { Helper(); } Inner(); } }
  • Expected: function_calls["Helper"].context.0 must equal "Inner".
    Actual: [{"name":"Helper","line_number":1,"args":[],"context":["Outer","method_declaration",1],"class_context":["S",1]}].

Acceptance criteria

  • Preserve the missing declarations/dependencies and correct ownership shown above without adding false symbols or edges.
  • Add regression tests for these examples, including negative controls and source locations where relevant.
  • Keep existing parser and resolution tests passing; verify pre-scan agrees with parsing for affected declarations.

Audit scope: 27 registry entries, 205 semantic fixtures in five input/state variants, resilience inputs, pre-scan checks, and 29 build/mapper fixtures. Syntax recovery alone is not used as evidence for the valid-source findings here.

Fix and focused regressions: #1812. The audit report indexes all consolidated language issues and validation results.

Activity

  1. github-actions commented on Oct 17, 2026

    @github-actions
    Contributor

    Hi! 👋 Join our CodeGraphContext Discord channel to collaborate: https://discord.gg/dR4QY32uYQ

  2. changed the title [-]C# parser: record types are omitted and local-function calls use the outer owner[/-] [+]C# parser: local-function calls are attributed to the outer method[/+] on Oct 17, 2026
  3. moved this from Backlog tasks to In progress in CGC Progress Boardon Oct 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions