Misdecompilation of a lazy initialization pattern
メンテナーはふだん 1 日以内に返信
@siegfriedpammer がすでに取り組んでいます。
2026年11月16日 から。
評価
調査の方向性
The report is precise: the Release-mode IL for _func ?? (_func = DefFunc) decompiles as => DefFunc, so operations are dropped. First reproduce by building the snippet with dotnet build -c Release and decompiling the assembly, then compare the IL of Func against the decompiled C# to see which null-coalescing and assignment nodes disappear. The work then sits in ILSpy's decompiler transformation pipeline (ICSharpCode.Decompiler), where the delegate-typed ?? pattern is not recognized; done means the round-trip output keeps the read of and assignment to _func. Expect to read the existing transform/pattern-matching stages before changing anything, and add a regression test case for this pattern.
索引モデルが issue の本文から書いたものです。
説明
A specific combination of delegates, null-coalescing operator, assignment expression and compiling in Release configuration causes decompiler to lose some operations. This pattern seems to be broken only for delegates. It is not limited to getters as in example below, the pattern is broken in general.
Input code
Compiled with dotnet build -c Release.
internal class Bug
{
private Action _func;
public Action Func => _func ?? (_func = DefFunc);
private void DefFunc() {}
}
Erroneous output
internal class Bug
{
private Action _func;
public Action Func => DefFunc;
private void DefFunc()
{
}
}
Func is decompiled without null-coalescing read from or assignment to _func.
Details
- ILSpy version: 11.2.0.10050+c86190ef4e24f3137c13a9275316042842d2fada
- Dotnet SDK: 10.0.401
- 主要言語
- C#
- スター
- 27.1k
- フォーク
- 3.8k
- 平均マージ
- 1日 23時間
- マージ済み PR(30日)
- 44
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
icsharpcode/ILSpy のほかの issue
-
External UI
難易度 1/5 1〜3時間 初心者へのやさしさ 75/100
icsharpcode/ILSpy#4284 ·
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 55/100
icsharpcode/ILSpy#4357 ·
メンテナーはふだん 1 日以内に返信
-
Bug
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
icsharpcode/ILSpy#4343 ·
メンテナーはふだん 1 日以内に返信
-
AI
難易度 4/5 1〜2日 初心者へのやさしさ 55/100
icsharpcode/ILSpy#4300 ·
メンテナーはふだん 1 日以内に返信
-
Enhancement
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
icsharpcode/ILSpy#4298 · コメント 1 件 · リアクション 2 件 ·
メンテナーはふだん 1 日以内に返信
icsharpcode/ILSpy の issue をすべて見る
似ている issue
-
type:task ux
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
elsa-workflows/elsa-foundation#5253 ·
メンテナーはふだん 1 日以内に返信