Incorrect decompilation for some language versions
paulo_morgado
Posts: 97 Silver 2
Given this code:
The decompilation for .NET 1.0 / C# 1 / VB 7 is correct:
But not for versions above that:
The code setting the fields of class_ is missing.
public class Auxiliar2 { public IEnumerable<char> PercorreCaracteres(char start, char end) { if ((start < 'a') || (start > 'z')) { throw new ArgumentOutOfRangeException(nameof(start), "Carácter início incorreto."); } if ((end < 'a') || (end > 'z')) { throw new ArgumentOutOfRangeException(nameof(end), "Carácter final incorreto."); } if (end <= start) { throw new ArgumentException($"{nameof(end)} não pode ser inferior a {nameof(start)}"); } return Cria(); IEnumerable<char> Cria() { for (var c = start; c < end; c++) yield return c; } } }
The decompilation for .NET 1.0 / C# 1 / VB 7 is correct:
public class Auxiliar2 { // Methods public IEnumerable<char> PercorreCaracteres(char start, char end) { <>c__DisplayClass0_0 class_ = new <>c__DisplayClass0_0(); class_.start = start; class_.end = end; if ((class_.start < 'a') || (class_.start > 'z')) { throw new ArgumentOutOfRangeException("start", "Car\x00e1cter in\x00edcio incorreto."); } if ((class_.end < 'a') || (class_.end > 'z')) { throw new ArgumentOutOfRangeException("end", "Car\x00e1cter final incorreto."); } if (class_.end <= class_.start) { throw new ArgumentException(string.Format("{0} n\x00e3o pode ser inferior a {1}", "end", "start")); } return class_.<PercorreCaracteres>g__Cria0(); } }
But not for versions above that:
public class Auxiliar2 { // Methods public IEnumerable<char> PercorreCaracteres(char start, char end) { <>c__DisplayClass0_0 class_; if ((start < 'a') || (start > 'z')) { throw new ArgumentOutOfRangeException("start", "Car\x00e1cter in\x00edcio incorreto."); } if ((end < 'a') || (end > 'z')) { throw new ArgumentOutOfRangeException("end", "Car\x00e1cter final incorreto."); } if (end <= start) { throw new ArgumentException(string.Format("{0} n\x00e3o pode ser inferior a {1}", "end", "start")); } return class_.<PercorreCaracteres>g__Cria0(); } }
The code setting the fields of class_ is missing.
Tagged:
Comments
Apologies for this and thanks for reporting it!
I have gone ahead and logged this in our internal bug tracking system as RP-4039.
I will post here once I have an update on this.
Jessica Ramos | Product Support Engineer | Redgate Software
Have you visited our Help Center?