tazuna 0.16.0 → 0.17.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.
@@ -1,5 +1,5 @@
1
1
  /**
2
- * WinForms Designer.vb の要約(UI サマリー)。
2
+ * WinForms Designer.vb / Designer.cs の要約(UI サマリー)。
3
3
  *
4
4
  * デザイナー自動生成コード(InitializeComponent)を軽量解析し、
5
5
  * 「どんなコントロールが何という名前で存在し、表示テキストは何か、
@@ -10,6 +10,11 @@
10
10
  * VB の完全な構文解析は行わない(行単位の正規表現マッチ)。
11
11
  * 解析できない行は無視する。要約である以上、取りこぼしは許容し、
12
12
  * 原文が必要な場合は Designer 原文を含めるオプション側で対応する。
13
+ *
14
+ * C# の Designer.cs(tazuna 0.17.0〜。parseDesignerCs)も同じ形で要約する。`this.` の有無(.NET 6 以降の
15
+ * デザイナーは付けない)と、型名を前に書く宣言の違いだけを吸収する。C# はイベントの結び付け
16
+ * (`this.btnSave.Click += new System.EventHandler(this.btnSave_Click);`)が Designer.cs にあり、
17
+ * VB の Handles 句のように本体のコードからは見えないため、イベントとハンドラー名も要約に入れる。
13
18
  */
14
19
  /** メンバー宣言: Friend WithEvents btnSave As System.Windows.Forms.Button */
15
20
  const DECLARATION = /^\s*(?:Friend|Public|Private|Protected)(?:\s+Friend)?\s+(?:Shadows\s+)?(?:WithEvents\s+)?([A-Za-z_]\w*)\s+As\s+([A-Za-z_][\w.]*)\s*(?:'.*)?$/;
@@ -154,8 +159,271 @@ function recordParent(parentOf, declared, parentChain, children) {
154
159
  export function renderDesignerControlLines(controls, depth = 0, lines = []) {
155
160
  for (const control of controls) {
156
161
  const textPart = control.text === undefined ? "" : ` — Text "${control.text}"`;
157
- lines.push(`${" ".repeat(depth)}- ${control.name}: ${control.typeName}${textPart}`);
162
+ const eventsPart = control.events === undefined || control.events.length === 0 ? "" : ` — イベント ${formatDesignerEvents(control.events)}`;
163
+ lines.push(`${" ".repeat(depth)}- ${control.name}: ${control.typeName}${textPart}${eventsPart}`);
158
164
  renderDesignerControlLines(control.children, depth + 1, lines);
159
165
  }
160
166
  return lines;
161
167
  }
168
+ /** イベントの一覧を「Click → btnSave_Click, Enter → txt_Enter」の形にする */
169
+ export function formatDesignerEvents(events) {
170
+ return events.map((e) => `${e.event} → ${e.handler}`).join(", ");
171
+ }
172
+ // ---------------------------------------------------------------------------
173
+ // C# の Designer.cs(tazuna 0.17.0〜)
174
+ // ---------------------------------------------------------------------------
175
+ /** フィールド宣言: private System.Windows.Forms.Button btnSave; / private Button btnSave; */
176
+ const CS_DECLARATION = /^\s*(?:(?:private|internal|public|protected)\s+)+(?:readonly\s+)?([A-Za-z_][\w.]*(?:<[\w.,\s<>]*>)?)\s+([A-Za-z_]\w*)\s*(?:=\s*null\s*)?;/;
177
+ /** C# の文字列リテラル("..." のエスケープ付き、または @"..." の逐語的文字列) */
178
+ const CS_STRING = String.raw `(?:"((?:[^"\\]|\\.)*)"|@"((?:[^"]|"")*)")`;
179
+ /** コントロールの Text 代入: this.btnSave.Text = "保存"; / btnSave.Text = "保存"; */
180
+ const CS_CONTROL_TEXT = new RegExp(String.raw `^\s*(?:this\.)?([A-Za-z_]\w*)\.Text\s*=\s*${CS_STRING}\s*;`);
181
+ /** フォーム自身の Text 代入: this.Text = "受注入力"; / Text = "受注入力"; */
182
+ const CS_FORM_TEXT = new RegExp(String.raw `^\s*(?:this\.)?Text\s*=\s*${CS_STRING}\s*;`);
183
+ /** 入れ子: this.pnlHeader.Controls.Add(this.lblCustomer); / Controls.Add(btnSave); */
184
+ const CS_CONTROLS_ADD = /^\s*(?:this\.)?(?:([A-Za-z_]\w*(?:\.[A-Za-z_]\w*)*?)\.)?Controls\.Add\(\s*(?:this\.)?([A-Za-z_]\w*)\s*\)\s*;/;
185
+ /** 一括追加: this.mnuMain.Items.AddRange(new ToolStripItem[] { this.mnuFile, this.mnuEdit }); */
186
+ const CS_ADD_RANGE = /^\s*(?:this\.)?(?:([A-Za-z_]\w*(?:\.[A-Za-z_]\w*)*?)\.)?(?:Controls|Items|DropDownItems)\.AddRange\([^{]*\{([^}]*)\}/;
187
+ /**
188
+ * イベントの結び付け: this.btnSave.Click += new System.EventHandler(this.btnSave_Click);
189
+ * / btnSave.Click += btnSave_Click; / this.Load += new System.EventHandler(this.OrderForm_Load);
190
+ */
191
+ const CS_EVENT = /^\s*(?:this\.)?(?:([A-Za-z_]\w*)\.)?([A-Za-z_]\w*)\s*\+=\s*(?:new\s+[A-Za-z_][\w.<>]*\s*\(\s*)?(?:this\.)?([A-Za-z_]\w*)\s*\)?\s*;/;
192
+ /** partial class OrderForm */
193
+ const CS_CLASS_NAME = /\bclass\s+([A-Za-z_]\w*)/;
194
+ function unescapeCsString(regular, verbatim) {
195
+ if (verbatim !== undefined) {
196
+ return verbatim.replace(/""/g, '"');
197
+ }
198
+ return (regular ?? "").replace(/\\(u[0-9a-fA-F]{4}|.)/g, (_, c) => {
199
+ if (c.length === 5) {
200
+ return String.fromCharCode(Number.parseInt(c.slice(1), 16));
201
+ }
202
+ switch (c) {
203
+ case "n":
204
+ return "\n";
205
+ case "r":
206
+ return "\r";
207
+ case "t":
208
+ return "\t";
209
+ case "0":
210
+ return "\0";
211
+ default:
212
+ return c;
213
+ }
214
+ });
215
+ }
216
+ /**
217
+ * 文字列・文字リテラルの外の ( と ) の数の差(複数行にまたがる AddRange をつなぐため)。
218
+ * // のコメントは数えない
219
+ */
220
+ function parenDepthDelta(line) {
221
+ let depth = 0;
222
+ for (let i = 0; i < line.length; i += 1) {
223
+ const c = line[i];
224
+ if (c === "/" && line[i + 1] === "/") {
225
+ break;
226
+ }
227
+ if (c === "@" && line[i + 1] === '"') {
228
+ i += 2;
229
+ while (i < line.length && !(line[i] === '"' && line[i + 1] !== '"')) {
230
+ i += line[i] === '"' ? 2 : 1;
231
+ }
232
+ continue;
233
+ }
234
+ if (c === '"' || c === "'") {
235
+ i += 1;
236
+ while (i < line.length && line[i] !== c) {
237
+ i += line[i] === "\\" ? 2 : 1;
238
+ }
239
+ continue;
240
+ }
241
+ if (c === "(") {
242
+ depth += 1;
243
+ }
244
+ else if (c === ")") {
245
+ depth -= 1;
246
+ }
247
+ }
248
+ return depth;
249
+ }
250
+ /** 括弧が閉じるまでの行を 1 行につなぐ(VS は AddRange の要素を 1 つずつ改行して書く) */
251
+ function joinCsStatements(source) {
252
+ const out = [];
253
+ let pending;
254
+ let depth = 0;
255
+ for (const raw of source.split(/\r?\n/)) {
256
+ const trimmed = raw.trim();
257
+ if (pending === undefined) {
258
+ if (trimmed.startsWith("//")) {
259
+ continue;
260
+ }
261
+ depth = parenDepthDelta(raw);
262
+ if (depth > 0) {
263
+ pending = raw;
264
+ }
265
+ else {
266
+ out.push(raw);
267
+ }
268
+ continue;
269
+ }
270
+ if (trimmed.startsWith("//")) {
271
+ continue;
272
+ }
273
+ pending += ` ${trimmed}`;
274
+ depth += parenDepthDelta(raw);
275
+ if (depth <= 0) {
276
+ out.push(pending);
277
+ pending = undefined;
278
+ }
279
+ }
280
+ if (pending !== undefined) {
281
+ out.push(pending);
282
+ }
283
+ return out;
284
+ }
285
+ /**
286
+ * Designer.cs のソースを要約する(parseDesignerVb と同じ形)。
287
+ * コントロールのフィールド宣言が 1 件も見つからなければ controlCount = 0 を返す
288
+ */
289
+ export function parseDesignerCs(source) {
290
+ let className;
291
+ let formText;
292
+ const declared = new Map();
293
+ const parentOf = new Map();
294
+ const formEvents = [];
295
+ /** 宣言より前に出てくる Text・イベント(C# はフィールド宣言がファイルの末尾にある) */
296
+ const texts = new Map();
297
+ const events = [];
298
+ for (const line of joinCsStatements(source)) {
299
+ const trimmed = line.trimStart();
300
+ if (trimmed.startsWith("[") || trimmed.startsWith("#")) {
301
+ continue;
302
+ }
303
+ if (className === undefined) {
304
+ const classMatch = CS_CLASS_NAME.exec(line);
305
+ if (classMatch !== null && !/^\s*\/\//.test(line)) {
306
+ className = classMatch[1] ?? "";
307
+ }
308
+ }
309
+ const declaration = CS_DECLARATION.exec(line);
310
+ if (declaration !== null) {
311
+ const typeName = declaration[1] ?? "";
312
+ const name = declaration[2] ?? "";
313
+ if (name !== "components" && !isInfrastructureType(typeName)) {
314
+ declared.set(name, { typeName: shortenTypeName(typeName), events: [] });
315
+ }
316
+ continue;
317
+ }
318
+ // this.Text(フォーム自身)を先に見る(CS_CONTROL_TEXT は this をコントロール名として読めてしまう)
319
+ const formTextMatch = CS_FORM_TEXT.exec(line);
320
+ if (formTextMatch !== null) {
321
+ if (formText === undefined) {
322
+ formText = unescapeCsString(formTextMatch[1], formTextMatch[2]);
323
+ }
324
+ continue;
325
+ }
326
+ const controlText = CS_CONTROL_TEXT.exec(line);
327
+ if (controlText !== null) {
328
+ const name = controlText[1] ?? "";
329
+ if (name !== "this" && !texts.has(name)) {
330
+ texts.set(name, unescapeCsString(controlText[2], controlText[3]));
331
+ }
332
+ continue;
333
+ }
334
+ const add = CS_CONTROLS_ADD.exec(line);
335
+ if (add !== null) {
336
+ const parent = add[1] === "this" ? undefined : add[1];
337
+ recordParentLater(parentOf, parent, [add[2] ?? ""]);
338
+ continue;
339
+ }
340
+ const addRange = CS_ADD_RANGE.exec(line);
341
+ if (addRange !== null) {
342
+ const parent = addRange[1] === "this" ? undefined : addRange[1];
343
+ const children = (addRange[2] ?? "")
344
+ .split(",")
345
+ .map((part) => part.trim().replace(/^this\./, ""))
346
+ .filter((part) => /^[A-Za-z_]\w*$/.test(part));
347
+ recordParentLater(parentOf, parent, children);
348
+ continue;
349
+ }
350
+ const event = CS_EVENT.exec(line);
351
+ if (event !== null) {
352
+ events.push({
353
+ control: event[1] === "this" ? undefined : event[1],
354
+ event: { event: event[2] ?? "", handler: event[3] ?? "" },
355
+ });
356
+ }
357
+ }
358
+ for (const [name, text] of texts) {
359
+ const entry = declared.get(name);
360
+ if (entry !== undefined && entry.text === undefined) {
361
+ entry.text = text;
362
+ }
363
+ }
364
+ for (const { control, event } of events) {
365
+ if (control === undefined) {
366
+ formEvents.push(event);
367
+ continue;
368
+ }
369
+ declared.get(control)?.events.push(event);
370
+ }
371
+ // 親の名前を宣言済みのコントロールへ解決する(SplitContainer1.Panel1 は先頭の要素へ寄せる)
372
+ const resolvedParentOf = new Map();
373
+ for (const [child, chain] of parentOf) {
374
+ let parentName;
375
+ if (chain !== undefined) {
376
+ if (declared.has(chain)) {
377
+ parentName = chain;
378
+ }
379
+ else {
380
+ const firstSegment = chain.split(".")[0] ?? "";
381
+ parentName = declared.has(firstSegment) ? firstSegment : undefined;
382
+ }
383
+ }
384
+ if (child !== parentName) {
385
+ resolvedParentOf.set(child, parentName);
386
+ }
387
+ }
388
+ const nodes = new Map();
389
+ for (const [name, entry] of declared) {
390
+ const node = { name, typeName: entry.typeName, children: [] };
391
+ if (entry.text !== undefined) {
392
+ node.text = entry.text;
393
+ }
394
+ if (entry.events.length > 0) {
395
+ node.events = entry.events;
396
+ }
397
+ nodes.set(name, node);
398
+ }
399
+ const rootControls = [];
400
+ for (const [name, node] of nodes) {
401
+ const parentName = resolvedParentOf.get(name);
402
+ const parent = parentName === undefined ? undefined : nodes.get(parentName);
403
+ if (parent !== undefined && parent !== node) {
404
+ parent.children.push(node);
405
+ }
406
+ else {
407
+ rootControls.push(node);
408
+ }
409
+ }
410
+ const summary = { rootControls, controlCount: declared.size };
411
+ if (className !== undefined) {
412
+ summary.className = className;
413
+ }
414
+ if (formText !== undefined) {
415
+ summary.formText = formText;
416
+ }
417
+ if (formEvents.length > 0) {
418
+ summary.formEvents = formEvents;
419
+ }
420
+ return summary;
421
+ }
422
+ /** 親の候補を記録する(C# は宣言が後ろにあるため、名前の解決は最後に行う)。既に親が付いた子は上書きしない */
423
+ function recordParentLater(parentOf, parentChain, children) {
424
+ for (const child of children) {
425
+ if (!parentOf.has(child)) {
426
+ parentOf.set(child, parentChain);
427
+ }
428
+ }
429
+ }
@@ -11,8 +11,14 @@
11
11
  * 「みなす」と明記して上限を書く(推測したことを宣言する。原則 3)。新しい Visual Studio で
12
12
  * ビルドしていても古い構文は通るため、低い方に倒して困ることはない。
13
13
  *
14
+ * C# の .csproj(tazuna 0.17.0〜)も同じ形で載せる。言語の版は、LangVersion が無ければ旧スタイルは
15
+ * ToolsVersion の Visual Studio の既定、SDK スタイルはターゲット フレームワークの既定の版と「みなす」と明記する
16
+ * (SDK はターゲット フレームワークで既定の C# の版を決める)。VB には無い Nullable・ImplicitUsings と、
17
+ * プロジェクト全体の using(<Using Include>)を載せる。VB だけのときの出力は C# 対応の前と同じ。
18
+ *
14
19
  * 純粋関数。I/O なし。
15
20
  */
21
+ import { projectFilesLabel } from "../projectLanguage.js";
16
22
  /** ToolsVersion → その形式を作る Visual Studio と、その既定の Visual Basic の版 */
17
23
  const TOOLS_VERSIONS = {
18
24
  "2.0": { studio: "Visual Studio 2005", vb: 8 },
@@ -40,20 +46,80 @@ const VB_FEATURES = [
40
46
  },
41
47
  { vb: 15, features: ["タプル", "2 進数リテラル &B"] },
42
48
  ];
49
+ /** ToolsVersion → その形式を作る Visual Studio と、その既定の C# の版(VS2019 以降は .NET Framework の既定の 7.3) */
50
+ const CS_TOOLS_VERSIONS = {
51
+ "2.0": { studio: "Visual Studio 2005", cs: 2 },
52
+ "3.5": { studio: "Visual Studio 2008", cs: 3 },
53
+ "4.0": { studio: "Visual Studio 2010 / 2012", cs: 4, note: "古い方の Visual Studio 2010" },
54
+ "12.0": { studio: "Visual Studio 2013", cs: 5 },
55
+ "14.0": { studio: "Visual Studio 2015", cs: 6 },
56
+ "15.0": { studio: "Visual Studio 2017", cs: 7 },
57
+ current: { studio: "Visual Studio 2019 以降", cs: 7.3, note: "Visual Studio 2019 以降(.NET Framework)" },
58
+ };
59
+ /**
60
+ * 版ごとに増えた主な構文(上限より新しいものを「使えない」として挙げる。AI が書きがちなものに絞る。
61
+ * 12 より後は細かいので載せない)
62
+ */
63
+ const CS_FEATURES = [
64
+ { cs: 3, features: ["LINQ", "ラムダ式", "var", "拡張メソッド", "自動実装プロパティ", "オブジェクト初期化子"] },
65
+ { cs: 4, features: ["dynamic", "名前付き引数", "省略可能な引数"] },
66
+ { cs: 5, features: ["async / await"] },
67
+ {
68
+ cs: 6,
69
+ features: ['文字列補間 $"..."', "nameof", "Null 条件演算子 ?.", "式形式のメンバー =>", "get だけの自動実装プロパティ"],
70
+ },
71
+ { cs: 7, features: ["タプル", "out var", "is による型パターン", "ローカル関数", "2 進数リテラル 0b"] },
72
+ { cs: 7.1, features: ["default リテラル"] },
73
+ { cs: 8, features: ["switch 式", "null 許容参照型", "using 宣言", "??=", "インデックスと範囲 ^ .."] },
74
+ { cs: 9, features: ["record", "init アクセサー", "ターゲット型の new()", "トップレベル ステートメント"] },
75
+ { cs: 10, features: ["ファイル スコープの名前空間 namespace X;", "global using"] },
76
+ { cs: 11, features: ['生文字列リテラル """..."""', "required メンバー"] },
77
+ { cs: 12, features: ["プライマリ コンストラクター", "コレクション式 [...]"] },
78
+ ];
79
+ /**
80
+ * SDK スタイルで LangVersion が無いときの既定の C# の版(ターゲット フレームワークで決まる)。
81
+ * 分からないもの(MSBuild 式など)は undefined
82
+ */
83
+ function defaultCsVersionOf(framework) {
84
+ const tfm = framework.trim().toLowerCase();
85
+ const modern = /^net(\d+)\.(\d+)(?:-[a-z0-9.]+)?$/.exec(tfm);
86
+ if (modern !== null) {
87
+ const major = Number(modern[1]);
88
+ // net5.0 → C# 9、以降 1 つずつ(net10.0 → C# 14)
89
+ return major >= 5 ? major + 4 : undefined;
90
+ }
91
+ if (/^net(?:coreapp3\.\d|standard2\.1)$/.test(tfm)) {
92
+ return 8;
93
+ }
94
+ if (/^(?:net[1-4]\d*|netstandard[12]\.\d|netcoreapp[12]\.\d)$/.test(tfm) || /^v\d/.test(tfm)) {
95
+ return 7.3;
96
+ }
97
+ return undefined;
98
+ }
43
99
  /** 参照・Imports を並べる上限(超えた分は件数だけ) */
44
100
  const LIST_LIMIT = 40;
45
101
  function formatVersion(vb) {
46
102
  return Number.isInteger(vb) ? `${vb}.0` : String(vb);
47
103
  }
104
+ /** C# の版の表記(7.3 / 10。整数は .0 を付けない。C# の呼び方に合わせる) */
105
+ function formatCsVersion(cs) {
106
+ return String(cs);
107
+ }
48
108
  /** 上限より新しい版の構文を「14.0 以降の …、15.0 以降の …」の形で */
49
109
  function unavailableFeatures(limit) {
50
- const parts = VB_FEATURES.filter((entry) => entry.vb > limit).map((entry) => {
110
+ return listUnavailable(VB_FEATURES.map((entry) => ({ version: entry.vb, features: entry.features })), limit, formatVersion);
111
+ }
112
+ function listUnavailable(table, limit, format) {
113
+ const parts = table.filter((entry) => entry.version > limit).map((entry) => {
51
114
  const features = entry.features.join("・");
52
115
  // 英数字で始まるときは和文との間を空ける(「11.0 以降の Async」)
53
- return `${formatVersion(entry.vb)} 以降の${/^[\x21-\x7e]/.test(features) ? " " : ""}${features}`;
116
+ return `${format(entry.version)} 以降の${/^[\x21-\x7e]/.test(features) ? " " : ""}${features}`;
54
117
  });
55
118
  return parts.length === 0 ? undefined : `${parts.join("、")} は使えない`;
56
119
  }
120
+ function unavailableCsFeatures(limit) {
121
+ return listUnavailable(CS_FEATURES.map((entry) => ({ version: entry.cs, features: entry.features })), limit, formatCsVersion);
122
+ }
57
123
  function joinLimited(values) {
58
124
  if (values.length <= LIST_LIMIT) {
59
125
  return values.join(", ");
@@ -91,6 +157,54 @@ function describeLanguage(source, environment) {
91
157
  const unavailable = unavailableFeatures(known.vb);
92
158
  return `${formatVersion(known.vb)} まで(LangVersion の指定なし。ToolsVersion ${toolsVersion} は ${known.studio} の形式のため、${known.note ?? known.studio} の既定の Visual Basic ${formatVersion(known.vb)} とみなす)${unavailable === undefined ? "" : `。${unavailable}`}`;
93
159
  }
160
+ /** C# の言語の版の行 */
161
+ function describeCsLanguage(source, environment) {
162
+ const numeric = environment.langVersions
163
+ .map((value) => Number.parseFloat(value))
164
+ .filter((value) => Number.isFinite(value));
165
+ if (environment.langVersions.length > 0) {
166
+ if (numeric.length === 0) {
167
+ return `${joinValues(environment.langVersions)}(LangVersion の指定)`;
168
+ }
169
+ const limit = Math.min(...numeric);
170
+ const unavailable = unavailableCsFeatures(limit);
171
+ const lower = environment.langVersions.length > 1 ? "。低い方に合わせる" : "";
172
+ return `${formatCsVersion(limit)} まで(LangVersion の指定: ${environment.langVersions.join(" / ")}${lower})${unavailable === undefined ? "" : `。${unavailable}`}`;
173
+ }
174
+ if (source.style === "sdk") {
175
+ const defaults = environment.targetFrameworks.map(defaultCsVersionOf);
176
+ if (environment.targetFrameworks.length === 0 || defaults.some((value) => value === undefined)) {
177
+ return "SDK の既定(LangVersion の指定なし。SDK スタイルはターゲット フレームワークの既定の版になる)";
178
+ }
179
+ const limit = Math.min(...defaults);
180
+ const frameworks = environment.targetFrameworks.join(" / ");
181
+ // 英数字の後は和文との間を空ける(「net8.0 の既定」「net48 / net6.0 のうち低い方の既定」)
182
+ const which = environment.targetFrameworks.length > 1 ? `${frameworks} のうち低い方` : `${frameworks} `;
183
+ const unavailable = unavailableCsFeatures(limit);
184
+ return `${formatCsVersion(limit)} まで(LangVersion の指定なし。SDK スタイルはターゲット フレームワークの既定の版になるため、${which}の既定の C# ${formatCsVersion(limit)} とみなす)${unavailable === undefined ? "" : `。${unavailable}`}`;
185
+ }
186
+ const toolsVersion = environment.toolsVersion;
187
+ const known = toolsVersion === undefined ? undefined : CS_TOOLS_VERSIONS[toolsVersion.toLowerCase()];
188
+ if (toolsVersion === undefined || known === undefined) {
189
+ return toolsVersion === undefined
190
+ ? "不明(ToolsVersion・LangVersion の指定なし)"
191
+ : `不明(ToolsVersion ${toolsVersion}・LangVersion の指定なし)`;
192
+ }
193
+ const unavailable = unavailableCsFeatures(known.cs);
194
+ return `${formatCsVersion(known.cs)} まで(LangVersion の指定なし。ToolsVersion ${toolsVersion} は ${known.studio} の形式のため、${known.note ?? known.studio} の既定の C# ${formatCsVersion(known.cs)} とみなす)${unavailable === undefined ? "" : `。${unavailable}`}`;
195
+ }
196
+ /** C# の Nullable・ImplicitUsings の行 */
197
+ function describeCsOptions(environment) {
198
+ const lines = [];
199
+ const enabled = (values) => values.some((value) => ["enable", "true"].includes(value.trim().toLowerCase()));
200
+ if (environment.nullable.length > 0) {
201
+ lines.push(`Nullable: ${joinValues(environment.nullable)}${enabled(environment.nullable) ? "(null 許容参照型が有効。null になり得る参照型には ? を付ける)" : ""}`);
202
+ }
203
+ if (environment.implicitUsings.length > 0) {
204
+ lines.push(`ImplicitUsings: ${joinValues(environment.implicitUsings)}${enabled(environment.implicitUsings) ? "(System・System.IO・System.Linq など SDK の既定の名前空間は using を書かなくても使える)" : ""}`);
205
+ }
206
+ return lines;
207
+ }
94
208
  function describeFramework(environment) {
95
209
  if (environment.targetFrameworks.length === 0) {
96
210
  return undefined;
@@ -112,6 +226,9 @@ function describeOptions(environment) {
112
226
  return parts.length === 0 ? undefined : `Option: ${parts.join(" / ")}(ファイル先頭の Option 文があればそちらが優先)`;
113
227
  }
114
228
  function describeSource(source) {
229
+ if (source.language === "cs") {
230
+ return describeCsSource(source);
231
+ }
115
232
  const head = `- ${source.label}(${source.projectPath})`;
116
233
  const environment = source.environment;
117
234
  if (environment === undefined) {
@@ -140,6 +257,32 @@ function describeSource(source) {
140
257
  }
141
258
  return [head, ...lines];
142
259
  }
260
+ function describeCsSource(source) {
261
+ const head = `- ${source.label}(${source.projectPath})`;
262
+ const environment = source.environment;
263
+ if (environment === undefined) {
264
+ return [head, " - .csproj を XML として読めなかったため不明"];
265
+ }
266
+ const lines = [
267
+ ` - 形式: ${source.style === "sdk" ? "SDK スタイル" : `旧スタイル${environment.toolsVersion === undefined ? "" : `(ToolsVersion ${environment.toolsVersion})`}`}`,
268
+ ` - C#: ${describeCsLanguage(source, environment)}`,
269
+ ];
270
+ const framework = describeFramework(environment);
271
+ if (framework !== undefined) {
272
+ lines.push(` - ${framework}`);
273
+ }
274
+ lines.push(...describeCsOptions(environment).map((line) => ` - ${line}`));
275
+ if (environment.rootNamespaces.length > 0) {
276
+ lines.push(` - 既定の名前空間: ${joinValues(environment.rootNamespaces)}(C# は各ファイルの namespace 宣言で名前空間が決まる。新しいファイルには同じフォルダの既存ファイルと同じ形で namespace を書く)`);
277
+ }
278
+ if (environment.imports.length > 0) {
279
+ lines.push(` - プロジェクト全体の using(global using): ${joinLimited(environment.imports)}`);
280
+ }
281
+ if (environment.references.length > 0) {
282
+ lines.push(` - 参照: ${joinLimited(environment.references)}`);
283
+ }
284
+ return [head, ...lines];
285
+ }
143
286
  /** <environment> ブロック(閉じタグまで。末尾の改行なし)。プロジェクトが無ければ undefined */
144
287
  export function renderEnvironmentBlock(sources) {
145
288
  if (sources.length === 0) {
@@ -147,7 +290,7 @@ export function renderEnvironmentBlock(sources) {
147
290
  }
148
291
  return [
149
292
  "<environment>",
150
- ".vbproj から読み取ったビルド環境(静的に読んだ値。Condition は評価せず、構成で値が分かれるときは併記):",
293
+ `${projectFilesLabel(sources.map((source) => source.language ?? "vb"))} から読み取ったビルド環境(静的に読んだ値。Condition は評価せず、構成で値が分かれるときは併記):`,
151
294
  ...sources.flatMap(describeSource),
152
295
  "</environment>",
153
296
  ].join("\n");
@@ -27,7 +27,8 @@ import { renderEnvironmentBlock } from "./environmentSummary.js";
27
27
  import { decodeShiftJis } from "../../core/encoding.js";
28
28
  import { maskCredentials } from "../../core/mask.js";
29
29
  import { sourceLanguageOf } from "../../core/source-lexer.js";
30
- import { parseDesignerVb, renderDesignerControlLines, } from "./designerSummary.js";
30
+ import { formatDesignerEvents, parseDesignerCs, parseDesignerVb, renderDesignerControlLines, } from "./designerSummary.js";
31
+ import { LANGUAGES, designerLanguageOf, projectFilesLabel } from "../projectLanguage.js";
31
32
  import { collectExtraRoots, collectGitFiles, GIT_FILE_MAX_BYTES, GIT_FILES_KIND, } from "./extraRootsCollector.js";
32
33
  /**
33
34
  * ソースファイルのバイト列を文字列へデコードする。
@@ -136,7 +137,7 @@ function escapeAttribute(value) {
136
137
  return value.replace(/&/g, "&amp;").replace(/"/g, "&quot;");
137
138
  }
138
139
  /**
139
- * 除外した *.Designer.vb から <ui_summary> エントリを生成する。
140
+ * 除外した *.Designer.vb / *.Designer.cs から <ui_summary> エントリを生成する。
140
141
  * 対象外・読めない・コントロールが取れない場合は undefined
141
142
  * (呼び出し側は通常のスキップ扱いにする)。
142
143
  * maskEnabled 時は要約前の Designer ソースにマスクを適用する
@@ -144,10 +145,12 @@ function escapeAttribute(value) {
144
145
  */
145
146
  function buildUiSummaryEntry(node, displayPath, deps, maskEnabled, strictMask) {
146
147
  const item = node.item;
148
+ const fileName = item.logicalPath.split("\\").pop() ?? item.logicalPath;
149
+ const language = designerLanguageOf(fileName);
147
150
  if (!item.isSensitive ||
148
151
  item.sourcePath === undefined ||
149
152
  !item.exists ||
150
- !/\.designer\.vb$/i.test(item.logicalPath)) {
153
+ language === undefined) {
151
154
  return undefined;
152
155
  }
153
156
  if (deps.ignoreReasonFor?.(item.sourcePath) !== undefined) {
@@ -159,26 +162,30 @@ function buildUiSummaryEntry(node, displayPath, deps, maskEnabled, strictMask) {
159
162
  }
160
163
  let findings = [];
161
164
  if (maskEnabled) {
162
- const masked = maskCredentials(source, {
163
- vbSource: true,
164
- strict: strictMask,
165
- });
165
+ // C# の Designer.cs はパックの .cs と同じく、文字列・コメントの中だけを伏せる
166
+ const masked = language === "vb"
167
+ ? maskCredentials(source, { vbSource: true, strict: strictMask })
168
+ : maskCredentials(source, { vbSource: false, language: sourceLanguageOf(fileName), strict: strictMask });
166
169
  source = masked.content;
167
170
  findings = masked.findings;
168
171
  }
169
- const summary = parseDesignerVb(source);
172
+ const summary = language === "vb" ? parseDesignerVb(source) : parseDesignerCs(source);
170
173
  if (summary.controlCount === 0) {
171
174
  return undefined;
172
175
  }
173
- const fileName = item.logicalPath.split("\\").pop() ?? item.logicalPath;
174
- const formName = summary.className ?? fileName.replace(/\.designer\.vb$/i, "");
176
+ const formName = summary.className ?? fileName.slice(0, fileName.length - LANGUAGES[language].designerSuffix.length);
175
177
  const lines = [
176
178
  `<ui_summary path="${escapeAttribute(displayPath)}" form="${escapeAttribute(formName)}">`,
177
- "Designer 自動生成コードからの要約(コントロール名: 型 — Text。座標・サイズ等のレイアウトは省略):",
179
+ language === "vb"
180
+ ? "Designer 自動生成コードからの要約(コントロール名: 型 — Text。座標・サイズ等のレイアウトは省略):"
181
+ : "Designer 自動生成コードからの要約(コントロール名: 型 — Text — イベント イベント名 → ハンドラー。座標・サイズ等のレイアウトは省略):",
178
182
  ];
179
183
  if (summary.formText !== undefined) {
180
184
  lines.push(`フォームタイトル: "${summary.formText}"`);
181
185
  }
186
+ if (summary.formEvents !== undefined && summary.formEvents.length > 0) {
187
+ lines.push(`フォームのイベント: ${formatDesignerEvents(summary.formEvents)}`);
188
+ }
182
189
  lines.push(...renderDesignerControlLines(summary.rootControls));
183
190
  lines.push("</ui_summary>");
184
191
  return { entry: lines.join("\n"), findings };
@@ -548,6 +555,14 @@ export function buildRepomixOutput(title, sources, deps, options) {
548
555
  const sdkExpandedLabels = sources
549
556
  .filter((source) => source.parseResult.defaultCompileGlobExpanded)
550
557
  .map((source) => source.label);
558
+ // 既定の Compile グロブ(**/*.vb、C# は **/*.cs)。VB だけなら C# 対応の前と同じ表記
559
+ const sdkExpandedGlobs = [
560
+ ...new Set(sources
561
+ .filter((source) => source.parseResult.defaultCompileGlobExpanded)
562
+ .map((source) => LANGUAGES[source.parseResult.language].defaultCompileGlob)),
563
+ ];
564
+ const projectLanguages = sources.map((source) => source.parseResult.language);
565
+ const projectFiles = projectFilesLabel(projectLanguages);
551
566
  const rootName = rootDir === undefined ? undefined : path.basename(rootDir);
552
567
  const generic = options.layout === "generic";
553
568
  const configFileName = options.configFileName ?? CONFIG_FILE_NAME;
@@ -557,6 +572,7 @@ export function buildRepomixOutput(title, sources, deps, options) {
557
572
  label: source.label,
558
573
  projectPath: (rootDir === undefined ? undefined : relativeWithinRoot(rootDir, source.parseResult.projectPath)) ??
559
574
  path.basename(source.parseResult.projectPath),
575
+ language: source.parseResult.language,
560
576
  style: source.parseResult.projectStyle,
561
577
  environment: source.parseResult.environment,
562
578
  })));
@@ -565,7 +581,7 @@ export function buildRepomixOutput(title, sources, deps, options) {
565
581
  ? `このファイルは ${TOOL_NAME} が「${title}」の git が管理しているファイル(git ls-files)に基づき、ソースコードを 1 ファイルにまとめたものです(Repomix 形式)。`
566
582
  : generic
567
583
  ? `このファイルは ${TOOL_NAME} が「${title}」の ${configFileName}(extraRoots)に宣言されたディレクトリに基づき、ソースコードを 1 ファイルにまとめたものです(Repomix 形式)。`
568
- : `このファイルは ${TOOL_NAME} が「${title}」の論理構成(.sln / .vbproj)に基づき、ソースコードを 1 ファイルにまとめたものです(Repomix 形式)。`,
584
+ : `このファイルは ${TOOL_NAME} が「${title}」の論理構成(.sln / ${projectFiles})に基づき、ソースコードを 1 ファイルにまとめたものです(Repomix 形式)。`,
569
585
  "",
570
586
  "<file_summary>",
571
587
  "<purpose>",
@@ -626,7 +642,7 @@ export function buildRepomixOutput(title, sources, deps, options) {
626
642
  : "- .gitignore は考慮していない(設定 exportRespectGitignore で無効化されている)",
627
643
  ...(sdkExpandedLabels.length > 0
628
644
  ? [
629
- `- SDK スタイルのプロジェクト(${sdkExpandedLabels.join(", ")})は Compile を明示列挙しないため、既定の Compile グロブ(**/*.vb)を展開した(bin/ obj/ ドットフォルダ・*.user・<Compile Remove> は除外)。MSBuild の完全評価ではない`,
645
+ `- SDK スタイルのプロジェクト(${sdkExpandedLabels.join(", ")})は Compile を明示列挙しないため、既定の Compile グロブ(${sdkExpandedGlobs.join(" / ")})を展開した(bin/ obj/ ドットフォルダ・*.user・<Compile Remove> は除外)。MSBuild の完全評価ではない`,
630
646
  ]
631
647
  : []),
632
648
  ...(extra !== undefined && gitFiles !== undefined
@@ -638,7 +654,7 @@ export function buildRepomixOutput(title, sources, deps, options) {
638
654
  ? [
639
655
  generic
640
656
  ? `- [${extraRoots.map((r) => r.kind).join("] [")}] のグループは ${configFileName} の extraRoots に宣言されたディレクトリ(<file> の root 属性)。宣言されていないディレクトリは含まれない`
641
- : `- [${extraRoots.map((r) => r.kind).join("] [")}] のグループは .vbproj に乗らない追加ディレクトリ(${configFileName} の extraRoots。<file> の root 属性)。認証情報マスクは VB 側と同様に適用済み`,
657
+ : `- [${extraRoots.map((r) => r.kind).join("] [")}] のグループは ${projectFiles} に乗らない追加ディレクトリ(${configFileName} の extraRoots。<file> の root 属性)。認証情報マスクは ${projectLanguages.includes("cs") ? "プロジェクトのファイル" : "VB 側"}と同様に適用済み`,
642
658
  ]
643
659
  : []),
644
660
  ...(generatedDirs.length > 0