C# decompilation uses ternary conditional operator instead of if else, and causes desync on IL with C#.
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
リンクされている TMP_FontAsset.cs の 619–625 行から始め、issue に示されている IL を使って C# のデコンパイル結果を再現します。この条件分岐に対する ILSpy の C# デコンパイルパスを追跡し、その出力を dnSpyEx による期待される if/else 形式と比較します。完了とは、出力が IL と同期したままになり、誤った三項式を出力しなくなることです。
索引モデルが issue の本文から書いたものです。
説明
Input code
if (texFormat == TextureFormat.Alpha8)
tmp_material = new Material(ShaderUtilities.ShaderRef_MobileBitmap);
else
tmp_material = new Material(Shader.Find("TextMeshPro/Sprite"));
//tmp_material.name = texture.name + " Material";
tmp_material.SetTexture(ShaderUtilities.ID_MainTex, texture);
Erroneous output
Instead of doing if else, it decompiles as ternarny conditional, and desyncs the IL when using mixed.
// material = ((textureFormat != TextureFormat.Alpha8) ? new Material(Shader.Find("TextMeshPro/Sprite")) : new Material(ShaderUtilities.ShaderRef_MobileBitmap));
IL_00a8: ldloc.1
IL_00a9: ldc.i4.1
IL_00aa: bne.un.s IL_00ba
IL_00ac: call class [UnityEngine.CoreModule]UnityEngine.Shader TMPro.ShaderUtilities::get_ShaderRef_MobileBitmap()
IL_00b1: newobj instance void [UnityEngine.CoreModule]UnityEngine.Material::.ctor(class [UnityEngine.CoreModule]UnityEngine.Shader)
IL_00b6: stloc.s 4
// (no C# code)
IL_00b8: br.s IL_00cb
// material.SetTexture(ShaderUtilities.ID_MainTex, texture2D);
IL_00ba: ldstr "TextMeshPro/Sprite"
IL_00bf: call class [UnityEngine.CoreModule]UnityEngine.Shader [UnityEngine.CoreModule]UnityEngine.Shader::Find(string)
IL_00c4: newobj instance void [UnityEngine.CoreModule]UnityEngine.Material::.ctor(class [UnityEngine.CoreModule]UnityEngine.Shader)
IL_00c9: stloc.s 4
IL_00cb: ldloc.s 4
IL_00cd: ldsfld int32 TMPro.ShaderUtilities::ID_MainTex
IL_00d2: ldloc.2
IL_00d3: callvirt instance void [UnityEngine.CoreModule]UnityEngine.Material::SetTexture(int32, class [UnityEngine.CoreModule]UnityEngine.Texture)
Expected decompilation
Example is from using DnSpyEx v6.5.1
Details
- Product in use: ILSpy 10.0 Preview 2
- Version in use: Latest one, but same problem is also on older versions.
- The correct behaviour happens on DnSpyEx.
- 主要言語
- 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 日以内に返信
-
Misdecompilation of a lazy initialization pattern対応中かも @siegfriedpammer が 5 日前に担当しました。 オープンBug Decompiler
難易度 4/5 3〜5日 初心者へのやさしさ 20/100
icsharpcode/ILSpy#4349 ·
メンテナーはふだん 1 日以内に返信
-
Bug
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
icsharpcode/ILSpy#4343 ·
メンテナーはふだん 1 日以内に返信
-
AI
難易度 4/5 1〜2日 初心者へのやさしさ 55/100
icsharpcode/ILSpy#4300 ·
メンテナーはふだん 1 日以内に返信
icsharpcode/ILSpy の issue をすべて見る
似ている issue
-
type:task ux
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
elsa-workflows/elsa-foundation#5253 ·
メンテナーはふだん 1 日以内に返信