@@ -11190,6 +11190,102 @@ TEST(pipeline_go_parallel_field_hint_requires_owner_segment) {
1119011190 PASS();
1119111191}
1119211192
11193+ static int count_calls_with(cbm_store_t *s, const char *project, const char *caller_suffix,
11194+ const char *callee_suffix, const char *fragment);
11195+
11196+ TEST(pipeline_csharp_parallel_field_hint_requires_owner_segment) {
11197+ /* #1927, non-Go twin. Go no longer runs try_field_type_hint (e554a2ab),
11198+ * but every other language on the parallel path still does, and C# is the
11199+ * hint's intended consumer (it strips the _ / m_ field prefixes). C#
11200+ * method names are PascalCase, so a one-letter receiver hints a letter
11201+ * that every candidate QN already contains in the METHOD name: `w.Write()`
11202+ * hints "W", and a raw substring test accepts "...FileStore.Write" and
11203+ * "...Conn.Write" alike, whichever the registry lists first. The hint must
11204+ * bind only a candidate whose OWNING segment equals the hinted type.
11205+ * >= 50 files forces pass_parallel.c, the only path with the hint. */
11206+ char tmp[256];
11207+ snprintf(tmp, sizeof(tmp), "/tmp/cbm_cs_fth_XXXXXX");
11208+ if (!cbm_mkdtemp(tmp)) {
11209+ FAIL("tmpdir");
11210+ }
11211+
11212+ /* Two project methods named Write: an untyped receiver resolves as an
11213+ * ambiguous short-name match (candidate_count 2), the shape the hint
11214+ * upgrades. */
11215+ write_temp_file(tmp, "Storage/FileStore.cs",
11216+ "namespace Storage {\n"
11217+ " public class FileStore {\n"
11218+ " private int written;\n"
11219+ " public void Write(int v) { written += v; }\n"
11220+ " public void Put(int v) { written = v; }\n"
11221+ " }\n"
11222+ "}\n");
11223+ write_temp_file(tmp, "Net/Conn.cs",
11224+ "namespace Net {\n"
11225+ " public class Conn {\n"
11226+ " private int sent;\n"
11227+ " public void Write(int v) { sent += v; }\n"
11228+ " }\n"
11229+ "}\n");
11230+ /* Two project methods named Put, one owned by Store: the receiver `store`
11231+ * names its type, the case the hint exists for. FileStore's QN also
11232+ * contains "Store", so only segment equality picks Store.Put whatever
11233+ * the candidate order. */
11234+ write_temp_file(tmp, "Repo/Store.cs",
11235+ "namespace Repo {\n"
11236+ " public class Store {\n"
11237+ " private int held;\n"
11238+ " public void Put(int v) { held = v; }\n"
11239+ " }\n"
11240+ "}\n");
11241+ write_temp_file(tmp, "App/Worker.cs",
11242+ "namespace App {\n"
11243+ " public class Worker {\n"
11244+ " public void Log(System.IO.StreamWriter w) {\n"
11245+ " w.Write(1);\n"
11246+ " }\n"
11247+ " public void Keep() {\n"
11248+ " var store = Services.Resolve();\n"
11249+ " store.Put(2);\n"
11250+ " }\n"
11251+ " }\n"
11252+ "}\n");
11253+ for (int i = 0; i < 52; i++) {
11254+ char name[64];
11255+ char body[192];
11256+ snprintf(name, sizeof(name), "Pad/Filler%d.cs", i);
11257+ snprintf(body, sizeof(body),
11258+ "namespace Pad {\n public class Filler%d {\n"
11259+ " public int Get%d() { return %d; }\n }\n}\n",
11260+ i, i, i);
11261+ write_temp_file(tmp, name, body);
11262+ }
11263+
11264+ char db_path[512];
11265+ snprintf(db_path, sizeof(db_path), "%s/cs_fth.db", tmp);
11266+ cbm_pipeline_t *p = cbm_pipeline_new(tmp, db_path, CBM_MODE_FULL);
11267+ ASSERT_NOT_NULL(p);
11268+ ASSERT_EQ(cbm_pipeline_run(p), 0);
11269+ const char *project = cbm_pipeline_project_name(p);
11270+
11271+ cbm_store_t *s = cbm_store_open_path(db_path);
11272+ ASSERT_NOT_NULL(s);
11273+
11274+ /* (1) Reproduce-first: RED before the fix. "W" is a substring of every
11275+ * Write candidate, so the old hint upgraded the StreamWriter call to an
11276+ * arbitrary project Write at PP_FIELD_HINT_CONF. No owner segment is "W",
11277+ * so the fixed hint must not fire at all. */
11278+ ASSERT_FALSE(cross_file_call_has_strategy(s, project, "Log", "Write", "field_type_hint"));
11279+ /* (2) The intended hint case binds the owner it names, never FileStore. */
11280+ ASSERT_EQ(count_calls_with(s, project, ".Keep", ".Store.Put", "field_type_hint"), 1);
11281+ ASSERT_EQ(count_calls_with(s, project, ".Keep", ".FileStore.Put", NULL), 0);
11282+
11283+ cbm_store_close(s);
11284+ cbm_pipeline_free(p);
11285+ th_rmtree(tmp);
11286+ PASS();
11287+ }
11288+
1119311289/* Fixture for the #1928 cross-language reference-guard probes (sequential and
1119411290 * parallel twins). pad_files > 0 adds filler files to push the index over the
1119511291 * parallel-pipeline threshold, since USAGE/WRITES/READS have one resolver per
@@ -29738,6 +29834,7 @@ SUITE(pipeline) {
2973829834 RUN_TEST(pipeline_go_multi_return_receiver_is_typed);
2973929835 RUN_TEST(pipeline_go_multi_return_receiver_is_typed_parallel);
2974029836 RUN_TEST(pipeline_go_parallel_field_hint_requires_owner_segment);
29837+ RUN_TEST(pipeline_csharp_parallel_field_hint_requires_owner_segment);
2974129838 RUN_TEST(pipeline_go_multi_init_nodes_survive);
2974229839 RUN_TEST(pipeline_go_init_lsp_edges_per_file);
2974329840 RUN_TEST(pipeline_go_init_lsp_edges_per_file_parallel);
0 commit comments