From c3b9fd63c10be640896de05d3d299237d77f48af Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Thu, 16 Feb 2012 14:19:37 +0100 Subject: [PATCH] Fix array creation with unsigned integers. --- ICSharpCode.Decompiler/ILAst/PeepholeTransform.cs | 4 +++- ICSharpCode.Decompiler/Tests/TypeAnalysisTests.cs | 10 ++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/ICSharpCode.Decompiler/ILAst/PeepholeTransform.cs b/ICSharpCode.Decompiler/ILAst/PeepholeTransform.cs index 0094f5378..f514aa45f 100644 --- a/ICSharpCode.Decompiler/ILAst/PeepholeTransform.cs +++ b/ICSharpCode.Decompiler/ILAst/PeepholeTransform.cs @@ -96,7 +96,9 @@ namespace ICSharpCode.Decompiler.ILAst ILExpression length; ILExpression input; if (expr.Match(ILCode.Newarr, out typeRef, out length)) { - if (length.Match(ILCode.Conv_Ovf_I, out input) || length.Match(ILCode.Conv_I, out input)) { + if (length.Match(ILCode.Conv_Ovf_I, out input) || length.Match(ILCode.Conv_I, out input) + || length.Match(ILCode.Conv_Ovf_I_Un, out input) || length.Match(ILCode.Conv_U, out input)) + { expr.Arguments[0] = input; return true; } diff --git a/ICSharpCode.Decompiler/Tests/TypeAnalysisTests.cs b/ICSharpCode.Decompiler/Tests/TypeAnalysisTests.cs index 71048f736..3c0ffc4b9 100644 --- a/ICSharpCode.Decompiler/Tests/TypeAnalysisTests.cs +++ b/ICSharpCode.Decompiler/Tests/TypeAnalysisTests.cs @@ -130,4 +130,14 @@ public class TypeAnalysisTests { return new byte[length]; } + + public byte[] CreateArrayWithUInt(uint length) + { + return new byte[length]; + } + + public byte[] CreateArrayWithULong(ulong length) + { + return new byte[length]; + } }