Commit 85ec995
committed
fix(parity): infer var-declared local types from new-expression initializers in C#
Both the WASM and native C# extractors were skipping variable declarations
with `var`/`implicit_type` type nodes entirely, so `var service = new
UserService(repo)` never added `service → UserService` to the typeMap. The
call-edge resolver therefore could not resolve `service.AddUser()` or
`service.GetUser()` to the qualified methods on `UserService`.
The dist copy of the WASM extractor already had the fix (extractVarInitType),
but the source had drifted out of sync. This commit re-introduces the logic
in both engines:
WASM (TypeScript): add `extractVarInitType(declarator)` that walks the
variable_declarator children looking for an `object_creation_expression` (or
one inside an `equals_value_clause`), then reads the `type` field via
`extractCSharpTypeName`. `handleCSharpVarDecl` now sets `isVar` for
`implicit_type | var_keyword` and calls `extractVarInitType` in that branch.
Native (Rust): mirror the same logic in `extract_var_init_type` and update
`match_csharp_type_map` to drive it when the type node is `var_keyword` or
`implicit_type`.
Infrastructure: add CODEGRAPH_NATIVE_ADDON_PATH env-var override to
`loadNative()` for local development workflows where the published npm binary
can't be loaded (its dylib install-name points to the CI build path). Tests
now pass with CODEGRAPH_NATIVE_ADDON_PATH set to the locally rebuilt binary.
Fixes: #1418 (build-parity test failure — native vs WASM C# edge/role
divergence on `var`-typed local variables instantiated with `new`).1 parent 1b98e7f commit 85ec995
3 files changed
Lines changed: 89 additions & 22 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
450 | 450 | | |
451 | 451 | | |
452 | 452 | | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
453 | 476 | | |
454 | 477 | | |
455 | 478 | | |
456 | 479 | | |
457 | 480 | | |
458 | | - | |
459 | | - | |
460 | | - | |
461 | | - | |
462 | | - | |
463 | | - | |
464 | | - | |
465 | | - | |
466 | | - | |
467 | | - | |
468 | | - | |
469 | | - | |
470 | | - | |
471 | | - | |
472 | | - | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
473 | 502 | | |
474 | 503 | | |
475 | 504 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
329 | 329 | | |
330 | 330 | | |
331 | 331 | | |
332 | | - | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
333 | 354 | | |
334 | 355 | | |
335 | | - | |
336 | | - | |
337 | | - | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
338 | 360 | | |
339 | 361 | | |
340 | 362 | | |
341 | 363 | | |
342 | | - | |
343 | | - | |
344 | | - | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
345 | 367 | | |
346 | 368 | | |
347 | 369 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
61 | 65 | | |
62 | 66 | | |
63 | 67 | | |
64 | 68 | | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
65 | 81 | | |
66 | 82 | | |
67 | 83 | | |
| |||
0 commit comments