Browse Source

Fix #1524: Adjust expression trees transform to work with async code as well.

pull/1556/head
Siegfried Pammer 6 years ago
parent
commit
0e638dcb28
  1. 18
      ICSharpCode.Decompiler.Tests/TestCases/Pretty/ExpressionTrees.cs
  2. 4
      ICSharpCode.Decompiler/IL/Transforms/TransformExpressionTrees.cs

18
ICSharpCode.Decompiler.Tests/TestCases/Pretty/ExpressionTrees.cs

@ -22,6 +22,7 @@ using System.Linq;
using System.Linq.Expressions; using System.Linq.Expressions;
using System.Reflection; using System.Reflection;
using System.Threading; using System.Threading;
using System.Threading.Tasks;
using System.Xml; using System.Xml;
namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
@ -1026,6 +1027,23 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty
Field = 3 Field = 3
}); });
} }
public async Task Issue1524(string str)
{
await Task.Delay(100);
if (string.IsNullOrEmpty(str)) {
#if ROSLYN
if (int.TryParse(str, out int id)) {
#else
int id;
if (int.TryParse(str, out id)) {
#endif
(from a in new List<int>().AsQueryable()
where a == id
select a).FirstOrDefault();
}
}
}
} }
internal static class Extensions internal static class Extensions

4
ICSharpCode.Decompiler/IL/Transforms/TransformExpressionTrees.cs

@ -1072,9 +1072,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
return new LdLoca(v); return new LdLoca(v);
return null; return null;
} else { } else {
if (ldloc.Variable.Kind != VariableKind.StackSlot) return ldloc;
return ldloc;
return null;
} }
default: default:
return value.Clone(); return value.Clone();

Loading…
Cancel
Save