Skip to content

Commit 1b78a68

Browse files
The1nkclaude
andcommitted
feat(discover): map .razor to C# so Blazor components are discovered
A .razor file had no entry in EXT_TABLE, so discovery skipped it entirely and a Blazor application produced no graph nodes for any of its components. The only way in was an undocumented extra_extensions entry in a per-project .codebase-memory.json. Map .razor to CBM_LANG_CSHARP. This is best-effort by design: the C# grammar recovers the @code block, while the surrounding markup lands in ERROR regions and is reported through parse_partial. That is strictly more than the Module-and-imports the other markup-hosted languages (Vue, Svelte, Astro) extract today, and it needs no new grammar. Covered by tests/test_language.c:lang_ext_razor. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Signed-off-by: The1nk <23087600+The1nk@users.noreply.github.com>
1 parent 010569f commit 1b78a68

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

‎src/discover/language.c‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ static const ext_entry_t EXT_TABLE[] = {
4949

5050
/* C# */
5151
{".cs", CBM_LANG_CSHARP},
52+
/* Blazor components. The C# grammar recovers the @code block; the
53+
* surrounding markup parses as ERROR regions and is reported via
54+
* parse_partial, which is why this is a best-effort mapping rather
55+
* than a dedicated grammar. */
56+
{".razor", CBM_LANG_CSHARP},
5257

5358
/* Clojure */
5459
{".clj", CBM_LANG_CLOJURE},

‎tests/test_language.c‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,14 @@ TEST(lang_ext_csharp) {
8989
ASSERT_EQ(cbm_language_for_extension(".cs"), CBM_LANG_CSHARP);
9090
PASS();
9191
}
92+
/* Blazor components were unmapped, so a .razor file was never discovered at
93+
* all: indexing a Blazor app produced no nodes for any component, and reaching
94+
* them required an undocumented extra_extensions entry in a per-project
95+
* .codebase-memory.json. */
96+
TEST(lang_ext_razor) {
97+
ASSERT_EQ(cbm_language_for_extension(".razor"), CBM_LANG_CSHARP);
98+
PASS();
99+
}
92100
TEST(lang_ext_php) {
93101
ASSERT_EQ(cbm_language_for_extension(".php"), CBM_LANG_PHP);
94102
PASS();
@@ -1079,6 +1087,7 @@ SUITE(language) {
10791087
RUN_TEST(lang_ext_h);
10801088
RUN_TEST(lang_ext_ixx);
10811089
RUN_TEST(lang_ext_csharp);
1090+
RUN_TEST(lang_ext_razor);
10821091
RUN_TEST(lang_ext_php);
10831092
RUN_TEST(lang_ext_lua);
10841093
RUN_TEST(lang_ext_scala);

0 commit comments

Comments
 (0)