[英]C# how to decompile yield-return enumerators
我試圖反編譯一些使用帶有yield-return的IEnumerators的C#代碼,但沒有反編譯器將變量重命名為有效的C#名稱。 我試過ILSpy,JustDecompile,dotPeek和Reflector但都沒有成功。
到目前為止的反編譯示例:
private IEnumerator _WaitForSecondsThenStop(float startToFadeTime, float fadeOutLength)
{
AudioObject.<_WaitForSecondsThenStop>c__Iterator0 <_WaitForSecondsThenStop>c__Iterator = new AudioObject.<_WaitForSecondsThenStop>c__Iterator0();
<_WaitForSecondsThenStop>c__Iterator.startToFadeTime = startToFadeTime;
<_WaitForSecondsThenStop>c__Iterator.fadeOutLength = fadeOutLength;
<_WaitForSecondsThenStop>c__Iterator.<$>startToFadeTime = startToFadeTime;
<_WaitForSecondsThenStop>c__Iterator.<$>fadeOutLength = fadeOutLength;
<_WaitForSecondsThenStop>c__Iterator.<>f__this = this;
return <_WaitForSecondsThenStop>c__Iterator;
}
據推測,ILSpy 能夠正確地反編譯枚舉器,但它對我不起作用。 我讀過的地方可能是由於代碼的一些優化導致ILSpy無法識別模式,因此可能是由此造成的。
但是,我想問的是:是否有一個C#反編譯器將所有字段,變量和類重命名為有效的C#名稱? 我對狀態自動機瘋狂很好,只要它編譯為正確的C#代碼。
我最終改變了這4個正則表達式的名稱:
Pattern Replacement What it fixes
<(\w+)>c__Iterator Iter_$1 <_WaitForSecondsThenStop>c__Iterator
<(\w+)>_ _L_$1_ <form>__2
<\$?> _S_ <$>startToFadeTime
\$(\w+) _SS_$1 $current
編輯:經過一番檢查后,它仍然沒有完全覆蓋所有內容,我會在修復后更新表格。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.