What the C# resolver looks at for DM_COST_REFS simple names that are not in * scope, documented `types` types deep in a namespace of `depth` segments, in * a file with `usings` using directives. `declared`: the names are types of * a namespace the file does not import (else no file declares them). 0 when * the repository cannot be indexed. */
| 8407 | * a namespace the file does not import (else no file declares them). 0 when |
| 8408 | * the repository cannot be indexed. */ |
| 8409 | static uint64_t dm_lookup_work(int depth, int usings, int types, bool declared) { |
| 8410 | char *src = malloc(DM_COST_TEXT); |
| 8411 | char tmp[256]; |
| 8412 | snprintf(tmp, sizeof(tmp), "/tmp/cbm_dm_cost_XXXXXX"); |
| 8413 | if (!src || !cbm_mkdtemp(tmp)) { |
| 8414 | free(src); |
| 8415 | return 0; |
| 8416 | } |
| 8417 | /* the namespaces the usings name, and (when declared) the names asked |
| 8418 | * for, in a namespace nothing imports */ |
| 8419 | size_t w = 0; |
| 8420 | w += (size_t)snprintf(src + w, DM_COST_TEXT - w, "namespace Far\n{\n"); |
| 8421 | for (int i = 0; declared && i < DM_COST_REFS; i++) { |
| 8422 | w += (size_t)snprintf(src + w, DM_COST_TEXT - w, "public class Nowhere%d { }\n", i); |
| 8423 | } |
| 8424 | w += (size_t)snprintf(src + w, DM_COST_TEXT - w, "}\n"); |
| 8425 | for (int i = 0; i < usings; i++) { |
| 8426 | w += (size_t)snprintf(src + w, DM_COST_TEXT - w, |
| 8427 | "namespace In.U%d { public class Other%d { } }\n", i, i); |
| 8428 | } |
| 8429 | th_write_file(TH_PATH(tmp, "src/Far.cs"), src); |
| 8430 | w = 0; |
| 8431 | for (int i = 0; i < usings; i++) { |
| 8432 | w += (size_t)snprintf(src + w, DM_COST_TEXT - w, "using In.U%d;\n", i); |
| 8433 | } |
| 8434 | w += (size_t)snprintf(src + w, DM_COST_TEXT - w, "namespace "); |
| 8435 | for (int i = 0; i < depth; i++) { |
| 8436 | w += (size_t)snprintf(src + w, DM_COST_TEXT - w, "%sN%d", i ? "." : "", i); |
| 8437 | } |
| 8438 | w += (size_t)snprintf(src + w, DM_COST_TEXT - w, "\n{\n"); |
| 8439 | for (int i = 0; i + 1 < types; i++) { |
| 8440 | w += (size_t)snprintf(src + w, DM_COST_TEXT - w, "public class T%d {\n", i); |
| 8441 | } |
| 8442 | w += (size_t)snprintf(src + w, DM_COST_TEXT - w, "/// <summary>"); |
| 8443 | for (int i = 0; i < DM_COST_REFS; i++) { |
| 8444 | w += (size_t)snprintf(src + w, DM_COST_TEXT - w, "<see cref=\"Nowhere%d\"/> ", i); |
| 8445 | } |
| 8446 | w += (size_t)snprintf(src + w, DM_COST_TEXT - w, "</summary>\npublic class Leaf { }\n"); |
| 8447 | for (int i = 0; i < types; i++) { |
| 8448 | w += (size_t)snprintf(src + w, DM_COST_TEXT - w, "}\n"); |
| 8449 | } |
| 8450 | th_write_file(TH_PATH(tmp, "src/Deep.cs"), src); |
| 8451 | free(src); |
| 8452 | char db[512]; |
| 8453 | snprintf(db, sizeof(db), "%s/cost.db", tmp); |
| 8454 | cbm_doclink_cs_test_work_reset(); |
| 8455 | uint64_t work = dm_index(tmp, db, NULL) == 0 ? cbm_doclink_cs_test_work() : 0; |
| 8456 | int rows = dm_count(db, "SELECT COUNT(*) FROM doc_link_unresolved"); |
| 8457 | dm_unlink_db(db); |
| 8458 | th_rmtree(tmp); |
| 8459 | return rows == DM_COST_REFS ? work : 0; /* every name was looked up, and found nowhere */ |
| 8460 | } |
| 8461 | |
| 8462 | /* The same for DM_COST_REFS references, written in product code, to an |
| 8463 | * operator that only test code declares -- `overloads` times over. */ |
no test coverage detected