csproj export emits embedded resources flat instead of restoring folder structure from dotted LogicalName

オープン
#3,717 コメント 5 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

  • #3735 @OpenSourcereR-dev による — マージされずにクローズ

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
58/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
静か
技術スタック
csharp

調査の方向性

ilspycmd のプロジェクト エクスポートのエントリポイントから始め、ilspycmd MyApp.exe -p -o ./out で問題を再現します。EmbeddedResource 項目とその LogicalName 値が、どのようにファイルおよび csproj エントリになるかを追跡します。ドットを含むリソース名が期待されるフォルダーにマッピングされ、LogicalName が変更されないこと(文書化されている先頭のアンダースコアおよびドットを含むフォルダーのケースを含む)が完了条件です。

索引モデルが issue の本文から書いたものです。

説明

Enhancement
Summary

When exporting an assembly as a .csproj (ilspycmd <asm> -p), embedded
resources are written to disk as flat files in the project root with their
full dotted manifest names as the filenames, rather than being restored to a
folder hierarchy that matches what the original source tree probably looked
like. The dotted segments of the resource name encode exactly that hierarchy
(modulo SDK name-mangling rules).

Steps to reproduce

Take any assembly built from a project whose source tree organizes assets
into folders (e.g. images/CopyHS.png, payloads/9.01/payloadName.bin), then:

ilspycmd MyApp.exe -p -o ./out
Actual output
out/
├── MyApp.images.CopyHS.png
├── MyApp.images.CutHS.png
├── MyApp.images.donate_full.png
├── MyApp.payloads._9._01.payloadName.bin
└── MyApp.csproj

with corresponding csproj entries:

<None Remove="MyApp.images.CopyHS.png" />
<EmbeddedResource Include="MyApp.images.CopyHS.png"
                  LogicalName="MyApp.images.CopyHS.png" />
Expected output
out/
├── images/
│   ├── CopyHS.png
│   ├── CutHS.png
│   └── donate_full.png
├── payloads/
│   └── 9.01/
│       └── payloadName.bin
└── MyApp.csproj

with csproj entries that preserve the original logical name even though the
file now lives in a folder, so existing
Assembly.GetManifestResourceStream("MyApp.images.CopyHS.png") calls in the
decompiled code keep working unchanged:

<EmbeddedResource Include="images\CopyHS.png"
                  LogicalName="MyApp.images.CopyHS.png" />
Why this matters

Right now, opening the decompiled csproj in Visual Studio shows a project
root with dozens of dotted-name files all jumbled together at the top level.
Reorganizing them into the original folder layout is a purely mechanical
transform (the dot-separated logical name is the encoding of the original
path) but currently has to be done by hand for every decompiled project.

Proposed approach

For each EmbeddedResource whose logical name begins with the project's
root namespace (typically the assembly name), strip that prefix, split the
remainder on ., treat the last segment as the file extension, the
second-to-last as the filename stem, and the rest as folder segments.
Apply the inverse of the SDK's leading-_ mangling for segments that begin
with _<digit>. Preserve the original LogicalName= attribute on the
emitted item so the resource keys stay byte-identical and existing
reflection-based resource lookups in the decompiled code keep working.

There is one inherent ambiguity (a folder name like 9.01 round-trips to
_9._01 which is indistinguishable from a 9/01/ two-folder hierarchy
without external knowledge), but a heuristic that merges consecutive
underscore-digit segments into a single dotted folder name handles the
common case and is no worse than the current behavior for the others.

Details
  • Product in use: ilspycmd
  • Version in use: 10.0.0.8330 (latest stable as of 2026-04-13)
主要言語
C#
スター
27.1k
フォーク
3.8k
平均マージ
1日 23時間
マージ済み PR(30日)
44

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

icsharpcode/ILSpy のほかの issue

icsharpcode/ILSpy の issue をすべて見る

似ている issue

C# の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。