Skip to content

Commit c4224cf

Browse files
committed
test: cover stacked C# attributes for DeusData#1692 (repro_issue1692)
A C# method carrying three stacked attributes ([Foo][Bar("x")][Baz]) must end up with three DECORATES edges, one per bracket group. The fixture is indexed through the real production pipeline (rh_index) and asserts rh_count_edges(..., "DECORATES") == 3, so it exercises the MCP path rather than the extractor in isolation. Verified to actually reproduce: with find_jvm_modifiers() reverted to its first-child lookup the suite goes red (decorates=1, expected 3), and green again with the fix in place. C#-only by design. Parsing the equivalent fixtures with the vendored grammars shows `[A] [B] [C]` yields three sibling `attribute_list` nodes in C#, while PHP's `#[A] #[B] #[C]` yields ONE `attribute_list` holding three `attribute_group` children — the pre-fix lookup already found all of them, so PHP could not hit this bug and a stacked-PHP fixture would pass either way. Java/Kotlin/Swift use the `modifiers` wrapper, a single node that never repeats. PHP's DECORATES path stays covered by mkc_c3_php8_attribute (tests/test_matrix_known_classes.c). Registered in repro_main.c and Makefile.cbm's TEST_REPRO_SRCS. Signed-off-by: Jumaga2015 <jumaga2015@gmail.com>
1 parent 6b23078 commit c4224cf

3 files changed

Lines changed: 94 additions & 0 deletions

File tree

‎Makefile.cbm‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -677,6 +677,7 @@ TEST_REPRO_SRCS = \
677677
tests/repro/repro_issue787.c \
678678
tests/repro/repro_issue842.c \
679679
tests/repro/repro_issue964.c \
680+
tests/repro/repro_issue1692.c \
680681
tests/repro/repro_invariant_calls.c \
681682
tests/repro/repro_invariant_graph.c \
682683
tests/repro/repro_invariant_breadth.c \

‎tests/repro/repro_issue1692.c‎

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
/*
2+
* repro_issue1692.c — Reproduce-first case for OPEN bug #1692.
3+
*
4+
* Issue: #1692 — "C#: ... ASP.NET Core [Route]/[HttpGet] attribute routes
5+
* not extracted (cross-repo-intelligence returns 0 edges)". The reporter's
6+
* repro 2 shows a class carrying three stacked attributes
7+
* ([ServiceFilter]/[Route]/[ApiController]) where DECORATES exists 13,964
8+
* times elsewhere in the same graph but zero times for that declaration.
9+
*
10+
* Root cause (traced further than the issue body): C# does not attach one
11+
* `attribute_list` wrapper holding every bracket group above a declaration —
12+
* each `[A]` / `[B]` / `[C]` line compiles to its OWN `attribute_list` node,
13+
* so a stack of three produces three separate `attribute_list` siblings
14+
* among the declaration's children. `find_jvm_modifiers()`
15+
* (internal/cbm/extract_defs.c) located that wrapper with
16+
* `ts_node_child_by_field_name(node, "attribute_list", ...)`, which only
17+
* ever returns the FIRST child registered under a repeated field — so only
18+
* the first bracket group's attribute(s) ever produced a DECORATES edge;
19+
* every attribute after the first was silently dropped, with no warning and
20+
* no staleness signal (confirmed indexed, not stale, via grafo_coverage in
21+
* the downstream McpDevGrafo-bugs.md BUG-004 report that led here).
22+
*
23+
* Expected (correct) behaviour:
24+
* A method carrying N stacked attributes gets exactly N outbound
25+
* DECORATES edges — not just one for the first bracket group.
26+
*
27+
* Why RED on current code: only the first attribute's DECORATES edge
28+
* exists, so the project-wide DECORATES count is 1, not 3.
29+
*
30+
* Scope — why this file is C#-only:
31+
* find_jvm_modifiers() shares ONE switch across Java/Kotlin/Swift/C#/PHP,
32+
* but only C# can reach this bug. Verified against the vendored grammars:
33+
* `[A] [B] [C]` in C# parses as THREE sibling `attribute_list` nodes, while
34+
* PHP's `#[A] #[B] #[C]` parses as ONE `attribute_list` holding three
35+
* `attribute_group` children — so the first-child lookup already found them
36+
* all and PHP never dropped an attribute. Java/Kotlin/Swift use the
37+
* `modifiers` wrapper, a single node that never repeats. PHP's DECORATES
38+
* path stays covered by mkc_c3_php8_attribute (test_matrix_known_classes.c);
39+
* a stacked-PHP fixture here would pass with or without the fix and prove
40+
* nothing. No other language reaches this function (`default` returns 0).
41+
*/
42+
43+
#include <foundation/compat.h>
44+
#include "test_framework.h"
45+
#include "repro_harness.h"
46+
47+
#include <string.h>
48+
#include <stdlib.h>
49+
#include <stdio.h>
50+
51+
/* ── Fixture: C# ───────────────────────────────────────────────────────────
52+
*
53+
* One C# method, three stacked attributes, nothing else in the file that
54+
* could carry a DECORATES edge — so a project-wide edge count is as precise
55+
* as scoping to the method node, without the extra node lookup.
56+
* ──────────────────────────────────────────────────────────────────────── */
57+
static const char *kStackedAttrsCs = "using System;\n"
58+
"\n"
59+
"namespace ReproNS\n"
60+
"{\n"
61+
" public class AttrController\n"
62+
" {\n"
63+
" [Foo]\n"
64+
" [Bar(\"x\")]\n"
65+
" [Baz]\n"
66+
" public void StackedAttrsMethod() { }\n"
67+
" }\n"
68+
"}\n";
69+
70+
TEST(repro_issue1692_csharp_stacked_attributes_all_decorate) {
71+
RProj lp;
72+
cbm_store_t *store = rh_index(&lp, "StackedAttrs.cs", kStackedAttrsCs);
73+
ASSERT_NOT_NULL(store);
74+
75+
int decorates_count = rh_count_edges(store, lp.project, "DECORATES");
76+
if (decorates_count != 3) {
77+
fprintf(stderr,
78+
" [1692] FAIL decorates=%d (expected 3 — one per stacked [Foo][Bar][Baz]; "
79+
"only the first attribute_list's attribute(s) survive find_jvm_modifiers' "
80+
"single-field lookup)\n",
81+
decorates_count);
82+
}
83+
ASSERT_EQ(3, decorates_count); /* one DECORATES per stacked attribute, not just the first */
84+
85+
rh_cleanup(&lp, store);
86+
PASS();
87+
}
88+
89+
SUITE(repro_issue1692) {
90+
RUN_TEST(repro_issue1692_csharp_stacked_attributes_all_decorate);
91+
}

‎tests/repro/repro_main.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ extern void suite_repro_issue581(void);
9191
extern void suite_repro_issue787(void);
9292
extern void suite_repro_issue842(void);
9393
extern void suite_repro_issue964(void);
94+
extern void suite_repro_issue1692(void);
9495
/* NEW bugs found by the discovery sweep */
9596
extern void suite_repro_new_ts_class_field_arrow(void);
9697
extern void suite_repro_new_py_tuple_unpack(void);
@@ -192,6 +193,7 @@ int main(void) {
192193
RUN_SUITE(repro_issue787);
193194
RUN_SUITE(repro_issue842);
194195
RUN_SUITE(repro_issue964);
196+
RUN_SUITE(repro_issue1692);
195197
RUN_SUITE(repro_invariant_calls);
196198
RUN_SUITE(repro_invariant_graph);
197199
RUN_SUITE(repro_invariant_breadth);

0 commit comments

Comments
 (0)