causoryn 0.0.0-stage → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/plugin.json +36 -0
- package/.codex-plugin/mcp.json +19 -0
- package/.codex-plugin/plugin.json +38 -0
- package/.zcode-plugin/plugin.json +42 -0
- package/LICENSE +21 -0
- package/README.md +171 -2
- package/THIRD-PARTY-NOTICES.md +443 -0
- package/dist/bundle-manifest.json +39 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.js +253 -0
- package/dist/doctor.d.ts +13 -0
- package/dist/doctor.js +507 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +10 -0
- package/dist/mcp-server.mjs +288477 -0
- package/dist/mcp-server.mjs.LEGAL.txt +17 -0
- package/dist/node_modules/better-sqlite3/LICENSE +21 -0
- package/dist/node_modules/better-sqlite3/lib/binding.js +62 -0
- package/dist/node_modules/better-sqlite3/lib/darwin-arm64.js +3 -0
- package/dist/node_modules/better-sqlite3/lib/darwin-x64.js +3 -0
- package/dist/node_modules/better-sqlite3/lib/database.js +109 -0
- package/dist/node_modules/better-sqlite3/lib/index.js +3 -0
- package/dist/node_modules/better-sqlite3/lib/linux-arm64.js +3 -0
- package/dist/node_modules/better-sqlite3/lib/linux-x64.js +3 -0
- package/dist/node_modules/better-sqlite3/lib/linuxmusl-arm64.js +4 -0
- package/dist/node_modules/better-sqlite3/lib/linuxmusl-x64.js +4 -0
- package/dist/node_modules/better-sqlite3/lib/methods/aggregate.js +43 -0
- package/dist/node_modules/better-sqlite3/lib/methods/backup.js +67 -0
- package/dist/node_modules/better-sqlite3/lib/methods/explain.js +9 -0
- package/dist/node_modules/better-sqlite3/lib/methods/function.js +31 -0
- package/dist/node_modules/better-sqlite3/lib/methods/inspect.js +7 -0
- package/dist/node_modules/better-sqlite3/lib/methods/pragma.js +12 -0
- package/dist/node_modules/better-sqlite3/lib/methods/serialize.js +16 -0
- package/dist/node_modules/better-sqlite3/lib/methods/table.js +195 -0
- package/dist/node_modules/better-sqlite3/lib/methods/transaction.js +78 -0
- package/dist/node_modules/better-sqlite3/lib/methods/wrappers.js +54 -0
- package/dist/node_modules/better-sqlite3/lib/sqlite-error.js +25 -0
- package/dist/node_modules/better-sqlite3/lib/util.js +12 -0
- package/dist/node_modules/better-sqlite3/lib/win32-arm64.js +3 -0
- package/dist/node_modules/better-sqlite3/lib/win32-x64.js +3 -0
- package/dist/node_modules/better-sqlite3/package.json +67 -0
- package/dist/node_modules/better-sqlite3/prebuilds/darwin-arm64.node +0 -0
- package/dist/node_modules/better-sqlite3/prebuilds/darwin-x64.node +0 -0
- package/dist/node_modules/better-sqlite3/prebuilds/linux-arm64.node +0 -0
- package/dist/node_modules/better-sqlite3/prebuilds/linux-x64.node +0 -0
- package/dist/node_modules/better-sqlite3/prebuilds/linuxmusl-arm64.node +0 -0
- package/dist/node_modules/better-sqlite3/prebuilds/linuxmusl-x64.node +0 -0
- package/dist/node_modules/better-sqlite3/prebuilds/win32-arm64.node +0 -0
- package/dist/node_modules/better-sqlite3/prebuilds/win32-x64.node +0 -0
- package/dist/runtime-stage.d.ts +8 -0
- package/dist/runtime-stage.js +159 -0
- package/dist/setup.d.ts +15 -0
- package/dist/setup.js +735 -0
- package/dist/toml-patch.d.ts +10 -0
- package/dist/toml-patch.js +587 -0
- package/dist/types.d.ts +144 -0
- package/dist/types.js +35 -0
- package/dist/typescript-lib/lib.d.ts +22 -0
- package/dist/typescript-lib/lib.decorators.d.ts +384 -0
- package/dist/typescript-lib/lib.decorators.legacy.d.ts +22 -0
- package/dist/typescript-lib/lib.dom.asynciterable.d.ts +41 -0
- package/dist/typescript-lib/lib.dom.d.ts +39429 -0
- package/dist/typescript-lib/lib.dom.iterable.d.ts +571 -0
- package/dist/typescript-lib/lib.es2015.collection.d.ts +147 -0
- package/dist/typescript-lib/lib.es2015.core.d.ts +597 -0
- package/dist/typescript-lib/lib.es2015.d.ts +28 -0
- package/dist/typescript-lib/lib.es2015.generator.d.ts +77 -0
- package/dist/typescript-lib/lib.es2015.iterable.d.ts +605 -0
- package/dist/typescript-lib/lib.es2015.promise.d.ts +81 -0
- package/dist/typescript-lib/lib.es2015.proxy.d.ts +128 -0
- package/dist/typescript-lib/lib.es2015.reflect.d.ts +144 -0
- package/dist/typescript-lib/lib.es2015.symbol.d.ts +46 -0
- package/dist/typescript-lib/lib.es2015.symbol.wellknown.d.ts +326 -0
- package/dist/typescript-lib/lib.es2016.array.include.d.ts +116 -0
- package/dist/typescript-lib/lib.es2016.d.ts +21 -0
- package/dist/typescript-lib/lib.es2016.full.d.ts +23 -0
- package/dist/typescript-lib/lib.es2016.intl.d.ts +31 -0
- package/dist/typescript-lib/lib.es2017.arraybuffer.d.ts +21 -0
- package/dist/typescript-lib/lib.es2017.d.ts +26 -0
- package/dist/typescript-lib/lib.es2017.date.d.ts +31 -0
- package/dist/typescript-lib/lib.es2017.full.d.ts +23 -0
- package/dist/typescript-lib/lib.es2017.intl.d.ts +44 -0
- package/dist/typescript-lib/lib.es2017.object.d.ts +49 -0
- package/dist/typescript-lib/lib.es2017.sharedmemory.d.ts +135 -0
- package/dist/typescript-lib/lib.es2017.string.d.ts +45 -0
- package/dist/typescript-lib/lib.es2017.typedarrays.d.ts +53 -0
- package/dist/typescript-lib/lib.es2018.asyncgenerator.d.ts +77 -0
- package/dist/typescript-lib/lib.es2018.asynciterable.d.ts +53 -0
- package/dist/typescript-lib/lib.es2018.d.ts +24 -0
- package/dist/typescript-lib/lib.es2018.full.d.ts +24 -0
- package/dist/typescript-lib/lib.es2018.intl.d.ts +83 -0
- package/dist/typescript-lib/lib.es2018.promise.d.ts +30 -0
- package/dist/typescript-lib/lib.es2018.regexp.d.ts +37 -0
- package/dist/typescript-lib/lib.es2019.array.d.ts +79 -0
- package/dist/typescript-lib/lib.es2019.d.ts +24 -0
- package/dist/typescript-lib/lib.es2019.full.d.ts +24 -0
- package/dist/typescript-lib/lib.es2019.intl.d.ts +23 -0
- package/dist/typescript-lib/lib.es2019.object.d.ts +33 -0
- package/dist/typescript-lib/lib.es2019.string.d.ts +37 -0
- package/dist/typescript-lib/lib.es2019.symbol.d.ts +24 -0
- package/dist/typescript-lib/lib.es2020.bigint.d.ts +765 -0
- package/dist/typescript-lib/lib.es2020.d.ts +27 -0
- package/dist/typescript-lib/lib.es2020.date.d.ts +42 -0
- package/dist/typescript-lib/lib.es2020.full.d.ts +24 -0
- package/dist/typescript-lib/lib.es2020.intl.d.ts +474 -0
- package/dist/typescript-lib/lib.es2020.number.d.ts +28 -0
- package/dist/typescript-lib/lib.es2020.promise.d.ts +47 -0
- package/dist/typescript-lib/lib.es2020.sharedmemory.d.ts +99 -0
- package/dist/typescript-lib/lib.es2020.string.d.ts +44 -0
- package/dist/typescript-lib/lib.es2020.symbol.wellknown.d.ts +41 -0
- package/dist/typescript-lib/lib.es2021.d.ts +23 -0
- package/dist/typescript-lib/lib.es2021.full.d.ts +24 -0
- package/dist/typescript-lib/lib.es2021.intl.d.ts +166 -0
- package/dist/typescript-lib/lib.es2021.promise.d.ts +48 -0
- package/dist/typescript-lib/lib.es2021.string.d.ts +33 -0
- package/dist/typescript-lib/lib.es2021.weakref.d.ts +78 -0
- package/dist/typescript-lib/lib.es2022.array.d.ts +121 -0
- package/dist/typescript-lib/lib.es2022.d.ts +25 -0
- package/dist/typescript-lib/lib.es2022.error.d.ts +75 -0
- package/dist/typescript-lib/lib.es2022.full.d.ts +24 -0
- package/dist/typescript-lib/lib.es2022.intl.d.ts +145 -0
- package/dist/typescript-lib/lib.es2022.object.d.ts +26 -0
- package/dist/typescript-lib/lib.es2022.regexp.d.ts +39 -0
- package/dist/typescript-lib/lib.es2022.string.d.ts +25 -0
- package/dist/typescript-lib/lib.es2023.array.d.ts +924 -0
- package/dist/typescript-lib/lib.es2023.collection.d.ts +21 -0
- package/dist/typescript-lib/lib.es2023.d.ts +22 -0
- package/dist/typescript-lib/lib.es2023.full.d.ts +24 -0
- package/dist/typescript-lib/lib.es2023.intl.d.ts +56 -0
- package/dist/typescript-lib/lib.es2024.arraybuffer.d.ts +65 -0
- package/dist/typescript-lib/lib.es2024.collection.d.ts +29 -0
- package/dist/typescript-lib/lib.es2024.d.ts +26 -0
- package/dist/typescript-lib/lib.es2024.full.d.ts +24 -0
- package/dist/typescript-lib/lib.es2024.object.d.ts +29 -0
- package/dist/typescript-lib/lib.es2024.promise.d.ts +35 -0
- package/dist/typescript-lib/lib.es2024.regexp.d.ts +25 -0
- package/dist/typescript-lib/lib.es2024.sharedmemory.d.ts +68 -0
- package/dist/typescript-lib/lib.es2024.string.d.ts +29 -0
- package/dist/typescript-lib/lib.es5.d.ts +4601 -0
- package/dist/typescript-lib/lib.es6.d.ts +23 -0
- package/dist/typescript-lib/lib.esnext.array.d.ts +35 -0
- package/dist/typescript-lib/lib.esnext.collection.d.ts +96 -0
- package/dist/typescript-lib/lib.esnext.d.ts +29 -0
- package/dist/typescript-lib/lib.esnext.decorators.d.ts +28 -0
- package/dist/typescript-lib/lib.esnext.disposable.d.ts +193 -0
- package/dist/typescript-lib/lib.esnext.error.d.ts +24 -0
- package/dist/typescript-lib/lib.esnext.float16.d.ts +445 -0
- package/dist/typescript-lib/lib.esnext.full.d.ts +24 -0
- package/dist/typescript-lib/lib.esnext.intl.d.ts +21 -0
- package/dist/typescript-lib/lib.esnext.iterator.d.ts +148 -0
- package/dist/typescript-lib/lib.esnext.promise.d.ts +34 -0
- package/dist/typescript-lib/lib.esnext.sharedmemory.d.ts +25 -0
- package/dist/typescript-lib/lib.scripthost.d.ts +322 -0
- package/dist/typescript-lib/lib.webworker.asynciterable.d.ts +41 -0
- package/dist/typescript-lib/lib.webworker.d.ts +13150 -0
- package/dist/typescript-lib/lib.webworker.importscripts.d.ts +23 -0
- package/dist/typescript-lib/lib.webworker.iterable.d.ts +340 -0
- package/licenses/Apache-2.0.txt +55 -0
- package/licenses/TypeScript-ThirdPartyNoticeText.txt +193 -0
- package/licenses/better-sqlite3-LICENSE.txt +21 -0
- package/mcp_config.json +16 -0
- package/native/go-worker/PROTOCOL.md +316 -0
- package/native/go-worker/cmd/worker/main.go +440 -0
- package/native/go-worker/go.mod +3 -0
- package/native/go-worker/internal/analyze/analyze.go +820 -0
- package/native/go-worker/internal/analyze/model.go +182 -0
- package/native/go-worker/internal/analyze/routes.go +181 -0
- package/native/python-worker/PROTOCOL.md +342 -0
- package/native/python-worker/worker.py +1190 -0
- package/native/roslyn-worker/Causoryn.RoslynWorker.csproj +40 -0
- package/native/roslyn-worker/Causoryn.RoslynWorker.deps.json +59 -0
- package/native/roslyn-worker/Causoryn.RoslynWorker.dll +0 -0
- package/native/roslyn-worker/Causoryn.RoslynWorker.runtimeconfig.json +13 -0
- package/native/roslyn-worker/Microsoft.CodeAnalysis.CSharp.dll +0 -0
- package/native/roslyn-worker/Microsoft.CodeAnalysis.dll +0 -0
- package/native/roslyn-worker/PROTOCOL.md +285 -0
- package/native/roslyn-worker/Program.cs +249 -0
- package/native/roslyn-worker/Protocol.cs +397 -0
- package/native/roslyn-worker/ReferenceResolver.cs +235 -0
- package/native/roslyn-worker/WorkerAnalyzer.cs +1669 -0
- package/native/roslyn-worker/packages.lock.json +30 -0
- package/native/rust-worker/Cargo.lock +107 -0
- package/native/rust-worker/Cargo.toml +23 -0
- package/native/rust-worker/PROTOCOL.md +294 -0
- package/native/rust-worker/src/analyzer.rs +1209 -0
- package/native/rust-worker/src/main.rs +127 -0
- package/native/rust-worker/src/protocol.rs +284 -0
- package/native/rust-worker/src/sha256.rs +136 -0
- package/package.json +71 -4
- package/plugin.json +17 -0
- package/scripts/causoryn.mjs +40 -0
- package/scripts/lib/node-version-guard.mjs +24 -0
- package/scripts/plugin-mcp-launcher.mjs +111 -0
- package/skills/causoryn/SKILL.md +53 -0
- package/skills/map-system/SKILL.md +69 -0
- package/skills/preflight-change/SKILL.md +38 -0
- package/skills/verify-change/SKILL.md +31 -0
|
@@ -0,0 +1,397 @@
|
|
|
1
|
+
using System.Text.Json;
|
|
2
|
+
using System.Text.Json.Serialization;
|
|
3
|
+
|
|
4
|
+
namespace Causoryn.RoslynWorker;
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* stdin/stdout JSON protokolü — TŞ v2.1 §7 (Roslyn sidecar) ve
|
|
8
|
+
* native/roslyn-worker/PROTOCOL.md sözleşmesi (sprint-2 / B1).
|
|
9
|
+
*
|
|
10
|
+
* Alan adları, packages/domain/src/snapshot.ts'teki createSnapshot GİRDİ
|
|
11
|
+
* sözleşmesiyle (SnapshotNodeInput / SnapshotEdgeInput / SnapshotEvidenceInput
|
|
12
|
+
* — NodeRef uçlu, ID'siz) birebir hizalıdır:
|
|
13
|
+
* Node {kind, qualifiedName, language?, relativePath?, attributes},
|
|
14
|
+
* Edge {kind, from: NodeRef, to: NodeRef, resolution, evidence?, ambiguity?},
|
|
15
|
+
* Evidence {kind, span?, analyzerId, analyzerVersion, rationale},
|
|
16
|
+
* SourceSpan {relativePath, startLine, endLine, sourceHash}.
|
|
17
|
+
* (graph-schema.ts'teki GraphNode'tan fark: NodeRef'te location yerine
|
|
18
|
+
* relativePath kimlik alanıdır — worker çıktısı doğrudan createSnapshot'a
|
|
19
|
+
* beslenir.)
|
|
20
|
+
*
|
|
21
|
+
* Bilinçli sapma (PROTOCOL.md §"ID'ler"): worker KİMLİK ÜRETMEZ. TŞ §7.1
|
|
22
|
+
* gereği canonical ID, de-duplication ve güven seviyesi merkezi normalizer'da
|
|
23
|
+
* (packages/domain createSnapshot) yönetilir; worker çıktısı ID'siz
|
|
24
|
+
* NodeRef/Edge/Evidence girdisidir ve B2'deki TS adapter bunu workspaceId ile
|
|
25
|
+
* createSnapshot'a besler (invariant iii tek noktadan korunur).
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
public static class ProtocolConstants
|
|
29
|
+
{
|
|
30
|
+
/** Bu worker'ın uyguladığı protokol sürümü ( kırılabilir değişiklikte artar). */
|
|
31
|
+
public const string ProtocolVersion = "1";
|
|
32
|
+
|
|
33
|
+
/** TŞ §8 Evidence.analyzerId karşılığı — sabit analyzer kimliği. */
|
|
34
|
+
public const string AnalyzerId = "roslyn-worker";
|
|
35
|
+
|
|
36
|
+
/** csproj Version ile senkron tutulur; Evidence.analyzerVersion'a yazılır. */
|
|
37
|
+
public const string AnalyzerVersion = "0.1.0";
|
|
38
|
+
|
|
39
|
+
/** Node dil etiketi — TS adapter'ın "typescript" karşılığı. */
|
|
40
|
+
public const string Language = "csharp";
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Kaynak sınırları — TŞ §9 resource budget, K-010 (yalnızca boyut
|
|
44
|
+
* limitleri). Aşım → LIMIT_EXCEEDED hata yanıtı; süreç ölmez.
|
|
45
|
+
*
|
|
46
|
+
* MaxRequestLineChars: tek istek satırı için üst sınır (char sayımı).
|
|
47
|
+
* UTF-8'de her char ≥1 bayt olduğundan char limiti bayt limitinin
|
|
48
|
+
* KÖTÜMSER üst sınırıdır — 64M char, 64 MB bayt bütçesini aşamaz.
|
|
49
|
+
* Aşılırsa satır tüketilir (bir sonraki newline'a kadar), id:null +
|
|
50
|
+
* LIMIT_EXCEEDED yanıtı döner ve döngü devam eder.
|
|
51
|
+
*/
|
|
52
|
+
public const int MaxRequestLineChars = 64 * 1024 * 1024;
|
|
53
|
+
|
|
54
|
+
/** Tek analyze isteğindeki maksimum dosya sayısı. */
|
|
55
|
+
public const int MaxFileCount = 5000;
|
|
56
|
+
|
|
57
|
+
/** files[] tek girdisinin UTF-8 bayt üst sınırı (TŞ §20 maxFileBytes ile uyumlu). */
|
|
58
|
+
public const int MaxFileContentBytes = 2_000_000;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Güvenlik bulgusu 4: tek yanıtta yayınlanan node sayısının sert üst
|
|
62
|
+
* sınırı (savunma derinliği — istek bacakındaki MaxRequestLineChars/
|
|
63
|
+
* MaxFileCount sınırlarının yanıt bacağı karşılığı). Sınır aşılırsa
|
|
64
|
+
* aşan node/kenarlar YAYINLANMAZ, yanıta RESPONSE_TRUNCATED tanısı
|
|
65
|
+
* düşer ve status "partial" olur (sessiz kesim yoktur). İstekteki
|
|
66
|
+
* opsiyonel "maxNodes" alanı bu tavanın ALTINDA bir bütçe seçebilir;
|
|
67
|
+
* üstünü istemek INVALID_ARGUMENT reddidir.
|
|
68
|
+
*/
|
|
69
|
+
public const int MaxResponseNodes = 250_000;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Hata kodları: TŞ §10.1 listesinden (INTERNAL_ERROR, LIMIT_EXCEEDED) ve
|
|
74
|
+
* repoya ait K-008 uzantısından (INVALID_ARGUMENT) alınır; worker kendi kodu
|
|
75
|
+
* icat etmez. LIMIT_EXCEEDED'in TŞ §10.1'deki yeri birincil kaynaktan
|
|
76
|
+
* doğrulanmıştır (TŞ çıkarım satır 620; packages/mcp-server/src/errors.ts:21).
|
|
77
|
+
*/
|
|
78
|
+
public static class ProtocolErrorCodes
|
|
79
|
+
{
|
|
80
|
+
public const string InvalidArgument = "INVALID_ARGUMENT";
|
|
81
|
+
public const string InternalError = "INTERNAL_ERROR";
|
|
82
|
+
public const string LimitExceeded = "LIMIT_EXCEEDED";
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* TŞ §8 katalog aynası (packages/domain/src/graph-kinds.ts). Worker çıktısı
|
|
87
|
+
* bu kümelere göre çıktı anında doğrulanır — liste dışı kind üretilemez.
|
|
88
|
+
*/
|
|
89
|
+
public static class GraphKinds
|
|
90
|
+
{
|
|
91
|
+
public static readonly IReadOnlySet<string> NodeKinds = new HashSet<string>
|
|
92
|
+
{
|
|
93
|
+
"Workspace", "Repository", "Project", "Module", "Package", "File",
|
|
94
|
+
"Namespace", "Class", "Interface", "Type", "Function", "Method",
|
|
95
|
+
"Endpoint", "Handler", "Event", "Topic", "Queue", "Database", "Table",
|
|
96
|
+
"Column", "ApiContract", "EventContract", "SchemaContract",
|
|
97
|
+
"ContractVersion", "Test", "Config", "UnknownExternal",
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
public static readonly IReadOnlySet<string> EdgeKinds = new HashSet<string>
|
|
101
|
+
{
|
|
102
|
+
"CONTAINS", "IMPORTS", "DECLARES", "CALLS", "REFERENCES", "IMPLEMENTS",
|
|
103
|
+
"INHERITS", "INJECTS", "ROUTES_TO", "READS", "WRITES", "PUBLISHES",
|
|
104
|
+
"SUBSCRIBES", "HANDLES", "PRODUCES_CONTRACT", "CONSUMES_CONTRACT",
|
|
105
|
+
"VALIDATES", "TESTS", "DEPENDS_ON", "CONFIGURES",
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/* ------------------------------------------------------------------ */
|
|
110
|
+
/* İstek */
|
|
111
|
+
/* ------------------------------------------------------------------ */
|
|
112
|
+
|
|
113
|
+
public sealed class WorkerRequest
|
|
114
|
+
{
|
|
115
|
+
[JsonPropertyName("id")]
|
|
116
|
+
public JsonElement Id { get; set; }
|
|
117
|
+
|
|
118
|
+
[JsonPropertyName("type")]
|
|
119
|
+
public string Type { get; set; } = string.Empty;
|
|
120
|
+
|
|
121
|
+
[JsonPropertyName("protocolVersion")]
|
|
122
|
+
public string? ProtocolVersion { get; set; }
|
|
123
|
+
|
|
124
|
+
[JsonPropertyName("files")]
|
|
125
|
+
public List<SourceFileIn>? Files { get; set; }
|
|
126
|
+
|
|
127
|
+
[JsonPropertyName("referenceDirs")]
|
|
128
|
+
public List<string>? ReferenceDirs { get; set; }
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Güvenlik bulgusu 4: opsiyonel yanıt node bütçesi. null →
|
|
132
|
+
* ProtocolConstants.MaxResponseNodes (sert tavan); tavan üstü veya
|
|
133
|
+
* <1 → INVALID_ARGUMENT. Testler küçük değerle kesimi kanıtlar.
|
|
134
|
+
*/
|
|
135
|
+
[JsonPropertyName("maxNodes")]
|
|
136
|
+
public int? MaxNodes { get; set; }
|
|
137
|
+
|
|
138
|
+
[JsonExtensionData]
|
|
139
|
+
public Dictionary<string, JsonElement>? ExtensionData { get; set; }
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
public sealed class SourceFileIn
|
|
143
|
+
{
|
|
144
|
+
[JsonPropertyName("path")]
|
|
145
|
+
public string Path { get; set; } = string.Empty;
|
|
146
|
+
|
|
147
|
+
[JsonPropertyName("content")]
|
|
148
|
+
public string Content { get; set; } = string.Empty;
|
|
149
|
+
|
|
150
|
+
[JsonExtensionData]
|
|
151
|
+
public Dictionary<string, JsonElement>? ExtensionData { get; set; }
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/* ------------------------------------------------------------------ */
|
|
155
|
+
/* Yanıt */
|
|
156
|
+
/* ------------------------------------------------------------------ */
|
|
157
|
+
|
|
158
|
+
public sealed class WorkerResponse
|
|
159
|
+
{
|
|
160
|
+
/**
|
|
161
|
+
* id her yanıtta MEVCUTTUR; bozuk satırlarda null olarak yazılır.
|
|
162
|
+
* Never koşulu, genel WhenWritingNull varsayılanını bu alan için ezer.
|
|
163
|
+
*/
|
|
164
|
+
[JsonPropertyName("id")]
|
|
165
|
+
[JsonIgnore(Condition = JsonIgnoreCondition.Never)]
|
|
166
|
+
public JsonElement? Id { get; set; }
|
|
167
|
+
|
|
168
|
+
[JsonPropertyName("protocolVersion")]
|
|
169
|
+
public string ProtocolVersion { get; set; } = ProtocolConstants.ProtocolVersion;
|
|
170
|
+
|
|
171
|
+
[JsonPropertyName("status")]
|
|
172
|
+
public string Status { get; set; } = "ready";
|
|
173
|
+
|
|
174
|
+
[JsonPropertyName("worker")]
|
|
175
|
+
public WorkerInfo? Worker { get; set; }
|
|
176
|
+
|
|
177
|
+
[JsonPropertyName("capabilities")]
|
|
178
|
+
public CapabilitiesOut? Capabilities { get; set; }
|
|
179
|
+
|
|
180
|
+
[JsonPropertyName("coverageRatio")]
|
|
181
|
+
public double? CoverageRatio { get; set; }
|
|
182
|
+
|
|
183
|
+
[JsonPropertyName("unsupportedConstructs")]
|
|
184
|
+
public List<string>? UnsupportedConstructs { get; set; }
|
|
185
|
+
|
|
186
|
+
[JsonPropertyName("warnings")]
|
|
187
|
+
public List<string>? Warnings { get; set; }
|
|
188
|
+
|
|
189
|
+
[JsonPropertyName("diagnostics")]
|
|
190
|
+
public List<DiagnosticOut>? Diagnostics { get; set; }
|
|
191
|
+
|
|
192
|
+
[JsonPropertyName("nodes")]
|
|
193
|
+
public List<NodeOut>? Nodes { get; set; }
|
|
194
|
+
|
|
195
|
+
[JsonPropertyName("edges")]
|
|
196
|
+
public List<EdgeOut>? Edges { get; set; }
|
|
197
|
+
|
|
198
|
+
[JsonPropertyName("evidence")]
|
|
199
|
+
public List<EvidenceOut>? Evidence { get; set; }
|
|
200
|
+
|
|
201
|
+
[JsonPropertyName("error")]
|
|
202
|
+
public ErrorOut? Error { get; set; }
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
public sealed class WorkerInfo
|
|
206
|
+
{
|
|
207
|
+
[JsonPropertyName("analyzerId")]
|
|
208
|
+
public string AnalyzerId { get; set; } = ProtocolConstants.AnalyzerId;
|
|
209
|
+
|
|
210
|
+
[JsonPropertyName("analyzerVersion")]
|
|
211
|
+
public string AnalyzerVersion { get; set; } = ProtocolConstants.AnalyzerVersion;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/** Adapter yetenek beyanı (TŞ §7: her adapter çıktısında capabilities bulunur). */
|
|
215
|
+
public sealed class CapabilitiesOut
|
|
216
|
+
{
|
|
217
|
+
[JsonPropertyName("astParse")]
|
|
218
|
+
public bool AstParse { get; set; }
|
|
219
|
+
|
|
220
|
+
[JsonPropertyName("symbolResolution")]
|
|
221
|
+
public bool SymbolResolution { get; set; }
|
|
222
|
+
|
|
223
|
+
[JsonPropertyName("containsEdges")]
|
|
224
|
+
public bool ContainsEdges { get; set; }
|
|
225
|
+
|
|
226
|
+
[JsonPropertyName("callEdges")]
|
|
227
|
+
public bool CallEdges { get; set; }
|
|
228
|
+
|
|
229
|
+
/** B1 diliminde C# using → IMPORTS kenarı üretilmez (açık beyan). */
|
|
230
|
+
[JsonPropertyName("importEdges")]
|
|
231
|
+
public bool ImportEdges { get; set; }
|
|
232
|
+
|
|
233
|
+
[JsonPropertyName("routeDetection")]
|
|
234
|
+
public string RouteDetection { get; set; } = "aspnetcore-controller-attribute-and-minimal-api-call-pattern";
|
|
235
|
+
|
|
236
|
+
[JsonPropertyName("frameworkLinkers")]
|
|
237
|
+
public bool FrameworkLinkers { get; set; }
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
public sealed class ErrorOut
|
|
241
|
+
{
|
|
242
|
+
[JsonPropertyName("code")]
|
|
243
|
+
public string Code { get; set; } = string.Empty;
|
|
244
|
+
|
|
245
|
+
[JsonPropertyName("message")]
|
|
246
|
+
public string Message { get; set; } = string.Empty;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
public sealed class DiagnosticOut
|
|
250
|
+
{
|
|
251
|
+
[JsonPropertyName("relativePath")]
|
|
252
|
+
public string RelativePath { get; set; } = string.Empty;
|
|
253
|
+
|
|
254
|
+
[JsonPropertyName("code")]
|
|
255
|
+
public string Code { get; set; } = string.Empty;
|
|
256
|
+
|
|
257
|
+
[JsonPropertyName("message")]
|
|
258
|
+
public string Message { get; set; } = string.Empty;
|
|
259
|
+
|
|
260
|
+
/** Bilinmiyorsa 0 (TS adapter DiagnosticOut kuralı). */
|
|
261
|
+
[JsonPropertyName("line")]
|
|
262
|
+
public int Line { get; set; }
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
/* ------------------------------------------------------------------ */
|
|
266
|
+
/* Graph kayıtları — domain alan adlarıyla hizalı (ID'siz) */
|
|
267
|
+
/* ------------------------------------------------------------------ */
|
|
268
|
+
|
|
269
|
+
/** TŞ §8 SourceSpan karşılığı. */
|
|
270
|
+
public sealed class SpanOut
|
|
271
|
+
{
|
|
272
|
+
[JsonPropertyName("relativePath")]
|
|
273
|
+
public string RelativePath { get; set; } = string.Empty;
|
|
274
|
+
|
|
275
|
+
[JsonPropertyName("startLine")]
|
|
276
|
+
public int StartLine { get; set; }
|
|
277
|
+
|
|
278
|
+
[JsonPropertyName("endLine")]
|
|
279
|
+
public int EndLine { get; set; }
|
|
280
|
+
|
|
281
|
+
[JsonPropertyName("sourceHash")]
|
|
282
|
+
public string SourceHash { get; set; } = string.Empty;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
/** TŞ §8 Evidence karşılığı (ID'siz; domain içerikten ID türetir). */
|
|
286
|
+
public sealed class EvidenceOut
|
|
287
|
+
{
|
|
288
|
+
[JsonPropertyName("kind")]
|
|
289
|
+
public string Kind { get; set; } = string.Empty;
|
|
290
|
+
|
|
291
|
+
[JsonPropertyName("span")]
|
|
292
|
+
public SpanOut? Span { get; set; }
|
|
293
|
+
|
|
294
|
+
[JsonPropertyName("analyzerId")]
|
|
295
|
+
public string AnalyzerId { get; set; } = ProtocolConstants.AnalyzerId;
|
|
296
|
+
|
|
297
|
+
[JsonPropertyName("analyzerVersion")]
|
|
298
|
+
public string AnalyzerVersion { get; set; } = ProtocolConstants.AnalyzerVersion;
|
|
299
|
+
|
|
300
|
+
[JsonPropertyName("rationale")]
|
|
301
|
+
public string Rationale { get; set; } = string.Empty;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
/** Kenar ucu referansı — domain NodeRef (node kimlik anahtarı) karşılığı. */
|
|
305
|
+
public sealed class NodeRefOut
|
|
306
|
+
{
|
|
307
|
+
[JsonPropertyName("kind")]
|
|
308
|
+
public string Kind { get; set; } = string.Empty;
|
|
309
|
+
|
|
310
|
+
[JsonPropertyName("qualifiedName")]
|
|
311
|
+
public string QualifiedName { get; set; } = string.Empty;
|
|
312
|
+
|
|
313
|
+
[JsonPropertyName("relativePath")]
|
|
314
|
+
public string? RelativePath { get; set; }
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
/** TŞ §8 GraphNode karşılığı (ID'siz). */
|
|
318
|
+
public sealed class NodeOut
|
|
319
|
+
{
|
|
320
|
+
[JsonPropertyName("kind")]
|
|
321
|
+
public string Kind { get; set; } = string.Empty;
|
|
322
|
+
|
|
323
|
+
[JsonPropertyName("qualifiedName")]
|
|
324
|
+
public string QualifiedName { get; set; } = string.Empty;
|
|
325
|
+
|
|
326
|
+
[JsonPropertyName("language")]
|
|
327
|
+
public string? Language { get; set; }
|
|
328
|
+
|
|
329
|
+
[JsonPropertyName("relativePath")]
|
|
330
|
+
public string? RelativePath { get; set; }
|
|
331
|
+
|
|
332
|
+
[JsonPropertyName("attributes")]
|
|
333
|
+
public Dictionary<string, object> Attributes { get; set; } = new();
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
/** TŞ §8 GraphEdge karşılığı (ID'siz; uçlar NodeRef). */
|
|
337
|
+
public sealed class EdgeOut
|
|
338
|
+
{
|
|
339
|
+
[JsonPropertyName("kind")]
|
|
340
|
+
public string Kind { get; set; } = string.Empty;
|
|
341
|
+
|
|
342
|
+
[JsonPropertyName("from")]
|
|
343
|
+
public NodeRefOut From { get; set; } = new();
|
|
344
|
+
|
|
345
|
+
[JsonPropertyName("to")]
|
|
346
|
+
public NodeRefOut To { get; set; } = new();
|
|
347
|
+
|
|
348
|
+
[JsonPropertyName("resolution")]
|
|
349
|
+
public string Resolution { get; set; } = string.Empty;
|
|
350
|
+
|
|
351
|
+
[JsonPropertyName("evidence")]
|
|
352
|
+
public List<EvidenceOut> Evidence { get; set; } = new();
|
|
353
|
+
|
|
354
|
+
[JsonPropertyName("ambiguity")]
|
|
355
|
+
public AmbiguityOut? Ambiguity { get; set; }
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
public sealed class AmbiguityOut
|
|
359
|
+
{
|
|
360
|
+
[JsonPropertyName("candidates")]
|
|
361
|
+
public List<string> Candidates { get; set; } = new();
|
|
362
|
+
|
|
363
|
+
[JsonPropertyName("reason")]
|
|
364
|
+
public string Reason { get; set; } = string.Empty;
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
/* ------------------------------------------------------------------ */
|
|
368
|
+
/* İstisna + serileştirme */
|
|
369
|
+
/* ------------------------------------------------------------------ */
|
|
370
|
+
|
|
371
|
+
/** İstek düzeyinde reddedilen girdi → status:"error" yanıtı üretir. */
|
|
372
|
+
public sealed class ProtocolException : Exception
|
|
373
|
+
{
|
|
374
|
+
public string Code { get; }
|
|
375
|
+
|
|
376
|
+
public ProtocolException(string code, string message) : base(message)
|
|
377
|
+
{
|
|
378
|
+
Code = code;
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
public static class ProtocolJson
|
|
383
|
+
{
|
|
384
|
+
/**
|
|
385
|
+
* Satır-bazlı framing için kompakt serileştirme; PropertyNamePolicy
|
|
386
|
+
* devre dışıdır çünkü tüm alanlar açık [JsonPropertyName] taşır.
|
|
387
|
+
* WhenWritingNull, domain strictObject'in null reddiyle uyumlu olarak
|
|
388
|
+
* opsiyonel alanları null yerine YOK olarak yazar.
|
|
389
|
+
*/
|
|
390
|
+
public static readonly JsonSerializerOptions Options = new()
|
|
391
|
+
{
|
|
392
|
+
PropertyNamingPolicy = null,
|
|
393
|
+
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull,
|
|
394
|
+
Encoder = System.Text.Encodings.Web.JavaScriptEncoder.UnsafeRelaxedJsonEscaping,
|
|
395
|
+
WriteIndented = false,
|
|
396
|
+
};
|
|
397
|
+
}
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
using System.Text.RegularExpressions;
|
|
2
|
+
|
|
3
|
+
namespace Causoryn.RoslynWorker;
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Derleme referans çözücü — worker'ın bellek-içi derlemesine BCL ve
|
|
7
|
+
* ASP.NET Core "ref assembly" kümelerini bağlar (TŞ §7: Roslyn sidecar,
|
|
8
|
+
* ASP.NET Core L3).
|
|
9
|
+
*
|
|
10
|
+
* Strateji (sırayla denenir; bulunanlar toplanır):
|
|
11
|
+
* 1. İstekteki opsiyonel `referenceDirs` (B2 adapter'ının açık verdiği
|
|
12
|
+
* dizinler — her .dll bir MetadataReference olarak eklenir).
|
|
13
|
+
* 2. DOTNET_ROOT / dotnet host konumundan erişilen kurulum kökü altında:
|
|
14
|
+
* - packs/Microsoft.NETCore.App.Ref/<sürüm>/ref/netX.Y (BCL)
|
|
15
|
+
* - packs/Microsoft.AspNetCore.App.Ref/<sürüm>/ref/netX.Y (ASP.NET Core)
|
|
16
|
+
* 3. Ref pack'ler yoksa çalışma zamanı düşüşü: System.Private.CoreLib
|
|
17
|
+
* (typeof(object).Assembly) referansı — kaynak-içi semantik çözümleme
|
|
18
|
+
* çalışmaya devam eder, BCL türetilen tipler çözümsüz kalır ve tanı/
|
|
19
|
+
* uyarı açıkça raporlanır (graceful degradation).
|
|
20
|
+
*
|
|
21
|
+
* Dosyalar daima sıralı döndürülür (deterministik derleme — aynı girdi
|
|
22
|
+
* aynı semantik sonuç).
|
|
23
|
+
*/
|
|
24
|
+
public static class ReferenceResolver
|
|
25
|
+
{
|
|
26
|
+
private static readonly Regex VersionDirRegex = new("^\\d+\\.\\d+\\.\\d+$", RegexOptions.Compiled);
|
|
27
|
+
private static readonly Regex TfmDirRegex = new("^net(\\d+)\\.(\\d+)$", RegexOptions.Compiled);
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Referans DLL yollarını döndürür. `workerTfm` örn. "net10.0".
|
|
31
|
+
* Bulunamayan kaynaklar için `warnings` içine açık not yazılır.
|
|
32
|
+
*/
|
|
33
|
+
public static IReadOnlyList<string> Resolve(
|
|
34
|
+
IReadOnlyList<string>? extraDirs,
|
|
35
|
+
string workerTfm,
|
|
36
|
+
ICollection<string> warnings)
|
|
37
|
+
{
|
|
38
|
+
var paths = new SortedSet<string>(StringComparer.Ordinal);
|
|
39
|
+
|
|
40
|
+
foreach (var dir in extraDirs ?? Array.Empty<string>())
|
|
41
|
+
{
|
|
42
|
+
if (Directory.Exists(dir))
|
|
43
|
+
{
|
|
44
|
+
AddDlls(dir, paths);
|
|
45
|
+
}
|
|
46
|
+
else
|
|
47
|
+
{
|
|
48
|
+
warnings.Add($"referenceDirs girdisi yok: {dir} (atlandı)");
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
var dotnetRoots = CandidateDotNetRoots();
|
|
53
|
+
var bclAdded = TryAddRefPack(dotnetRoots, "Microsoft.NETCore.App.Ref", workerTfm, paths, warnings);
|
|
54
|
+
var aspNetCoreAdded = TryAddRefPack(dotnetRoots, "Microsoft.AspNetCore.App.Ref", workerTfm, paths, warnings);
|
|
55
|
+
|
|
56
|
+
if (!bclAdded)
|
|
57
|
+
{
|
|
58
|
+
var coreLib = typeof(object).Assembly.Location;
|
|
59
|
+
if (!string.IsNullOrEmpty(coreLib) && File.Exists(coreLib))
|
|
60
|
+
{
|
|
61
|
+
paths.Add(coreLib);
|
|
62
|
+
warnings.Add(
|
|
63
|
+
"Microsoft.NETCore.App.Ref pack bulunamadı; çalışma zamanı düşüşü: " +
|
|
64
|
+
$"yalnızca {Path.GetFileName(coreLib)} referansı eklendi. BCL tiplerinden " +
|
|
65
|
+
"türeyen semboller çözümsüz kalabilir (kaynak-içi CALLS/CONTAINS etkilenmez).");
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (!aspNetCoreAdded)
|
|
70
|
+
{
|
|
71
|
+
warnings.Add(
|
|
72
|
+
"Microsoft.AspNetCore.App.Ref pack bulunamadı; controller/minimal API " +
|
|
73
|
+
"öz nitelikleri semantik olarak çözümlenemez — bilinen-ad kuralı ile " +
|
|
74
|
+
"heuristic ROUTES_TO üretilir (TŞ §8 resolution kuralı).");
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return paths.ToList();
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
private static IEnumerable<string> CandidateDotNetRoots()
|
|
81
|
+
{
|
|
82
|
+
// 1) Açık ortam değişkeni.
|
|
83
|
+
var dotnetRoot = Environment.GetEnvironmentVariable("DOTNET_ROOT");
|
|
84
|
+
if (!string.IsNullOrEmpty(dotnetRoot) && Directory.Exists(dotnetRoot))
|
|
85
|
+
{
|
|
86
|
+
yield return dotnetRoot;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// 2) Host binary'si dotnet.exe/dotnet ise kurulum kökü onun ata dizinidir.
|
|
90
|
+
var processPath = Environment.ProcessPath;
|
|
91
|
+
if (!string.IsNullOrEmpty(processPath))
|
|
92
|
+
{
|
|
93
|
+
var dir = Path.GetDirectoryName(processPath);
|
|
94
|
+
var fileName = Path.GetFileName(processPath);
|
|
95
|
+
if (dir is not null &&
|
|
96
|
+
(fileName.Equals("dotnet", StringComparison.OrdinalIgnoreCase) ||
|
|
97
|
+
fileName.Equals("dotnet.exe", StringComparison.OrdinalIgnoreCase)))
|
|
98
|
+
{
|
|
99
|
+
yield return dir;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// 3) Bilinen standart kurulum konumları (platform matrisi: TŞ §7).
|
|
104
|
+
var standardRoots = OperatingSystem.IsWindows()
|
|
105
|
+
? new[] { Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), "dotnet") }
|
|
106
|
+
: new[] { "/usr/share/dotnet", "/usr/lib/dotnet" };
|
|
107
|
+
foreach (var root in standardRoots)
|
|
108
|
+
{
|
|
109
|
+
if (Directory.Exists(root))
|
|
110
|
+
{
|
|
111
|
+
yield return root;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
private static bool TryAddRefPack(
|
|
117
|
+
IEnumerable<string> roots,
|
|
118
|
+
string packName,
|
|
119
|
+
string workerTfm,
|
|
120
|
+
SortedSet<string> paths,
|
|
121
|
+
ICollection<string> warnings)
|
|
122
|
+
{
|
|
123
|
+
foreach (var root in roots)
|
|
124
|
+
{
|
|
125
|
+
var packRoot = Path.Combine(root, "packs", packName);
|
|
126
|
+
if (!Directory.Exists(packRoot))
|
|
127
|
+
{
|
|
128
|
+
continue;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
var versionDir = HighestVersionDir(packRoot);
|
|
132
|
+
if (versionDir is null)
|
|
133
|
+
{
|
|
134
|
+
continue;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
var tfmDir = SelectTfmDir(Path.Combine(packRoot, versionDir, "ref"), workerTfm);
|
|
138
|
+
if (tfmDir is null)
|
|
139
|
+
{
|
|
140
|
+
continue;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
AddDlls(tfmDir, paths);
|
|
144
|
+
warnings.Add($"referans paketi yüklendi: {packName} {versionDir} ({tfmDir})");
|
|
145
|
+
return true;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
return false;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/** Sürüm dizinleri içinden semantik sürüm sıralamasıyla en yenisini seçer. */
|
|
152
|
+
private static string? HighestVersionDir(string parent)
|
|
153
|
+
{
|
|
154
|
+
if (!Directory.Exists(parent))
|
|
155
|
+
{
|
|
156
|
+
return null;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
string? best = null;
|
|
160
|
+
Version? bestVersion = null;
|
|
161
|
+
foreach (var entry in Directory.EnumerateDirectories(parent))
|
|
162
|
+
{
|
|
163
|
+
var name = Path.GetFileName(entry);
|
|
164
|
+
if (!VersionDirRegex.IsMatch(name) || !Version.TryParse(name, out var version))
|
|
165
|
+
{
|
|
166
|
+
continue;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
if (bestVersion is null || version > bestVersion)
|
|
170
|
+
{
|
|
171
|
+
best = name;
|
|
172
|
+
bestVersion = version;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
return best;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* ref/ altından TFM seçimi: önce worker TFM'iyle birebir eşleşme,
|
|
181
|
+
* sonra worker TFM'inden küçük/eşit en yüksek, en sonda en yüksek.
|
|
182
|
+
*/
|
|
183
|
+
private static string? SelectTfmDir(string refParent, string workerTfm)
|
|
184
|
+
{
|
|
185
|
+
if (!Directory.Exists(refParent))
|
|
186
|
+
{
|
|
187
|
+
return null;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
var candidates = new List<(string Dir, int Major, int Minor)>();
|
|
191
|
+
foreach (var dir in Directory.EnumerateDirectories(refParent))
|
|
192
|
+
{
|
|
193
|
+
var name = Path.GetFileName(dir);
|
|
194
|
+
var match = TfmDirRegex.Match(name);
|
|
195
|
+
if (!match.Success)
|
|
196
|
+
{
|
|
197
|
+
continue;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
candidates.Add((dir, int.Parse(match.Groups[1].Value), int.Parse(match.Groups[2].Value)));
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
if (candidates.Count == 0)
|
|
204
|
+
{
|
|
205
|
+
return null;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
var exact = Path.Combine(refParent, workerTfm);
|
|
209
|
+
if (Directory.Exists(exact))
|
|
210
|
+
{
|
|
211
|
+
return exact;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
var workerMatch = TfmDirRegex.Match(workerTfm);
|
|
215
|
+
int workerMajor = workerMatch.Success ? int.Parse(workerMatch.Groups[1].Value) : 0;
|
|
216
|
+
int workerMinor = workerMatch.Success ? int.Parse(workerMatch.Groups[2].Value) : 0;
|
|
217
|
+
|
|
218
|
+
var candidatesSorted = candidates
|
|
219
|
+
.OrderByDescending(c => c.Major)
|
|
220
|
+
.ThenByDescending(c => c.Minor)
|
|
221
|
+
.ToList();
|
|
222
|
+
|
|
223
|
+
var compatible = candidatesSorted.FirstOrDefault(c => c.Major < workerMajor ||
|
|
224
|
+
(c.Major == workerMajor && c.Minor <= workerMinor));
|
|
225
|
+
return (compatible.Dir ?? candidatesSorted[0].Dir);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
private static void AddDlls(string dir, SortedSet<string> paths)
|
|
229
|
+
{
|
|
230
|
+
foreach (var dll in Directory.EnumerateFiles(dir, "*.dll", SearchOption.TopDirectoryOnly))
|
|
231
|
+
{
|
|
232
|
+
paths.Add(dll);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|