diff --git a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/CS73_StackAllocInitializers.cs b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/CS73_StackAllocInitializers.cs index 1acbd5449..5a571f6aa 100644 --- a/ICSharpCode.Decompiler.Tests/TestCases/Pretty/CS73_StackAllocInitializers.cs +++ b/ICSharpCode.Decompiler.Tests/TestCases/Pretty/CS73_StackAllocInitializers.cs @@ -379,11 +379,33 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Pretty return UseSpan(span); } + public string GetSpan3() + { + Span span = stackalloc decimal[GetSize()]; + return UseSpan(span); + } + + public string GetSpan4() + { + Span span = stackalloc decimal[4] { + 1m, + 2m, + 3m, + 4m + }; + return UseSpan(span); + } + public string UseSpan(Span span) { throw new NotImplementedException(); } + public string UseSpan(Span span) + { + throw new NotImplementedException(); + } + public int GetSize() { throw new NotImplementedException(); diff --git a/ICSharpCode.Decompiler/IL/PointerArithmeticOffset.cs b/ICSharpCode.Decompiler/IL/PointerArithmeticOffset.cs index d8048b2ed..4a32b9358 100644 --- a/ICSharpCode.Decompiler/IL/PointerArithmeticOffset.cs +++ b/ICSharpCode.Decompiler/IL/PointerArithmeticOffset.cs @@ -77,6 +77,8 @@ namespace ICSharpCode.Decompiler.IL case KnownTypeCode.UInt64: case KnownTypeCode.Double: return 8; + case KnownTypeCode.Decimal: + return 16; } return null; } diff --git a/ICSharpCode.Decompiler/IL/Transforms/ExpressionTransforms.cs b/ICSharpCode.Decompiler/IL/Transforms/ExpressionTransforms.cs index 0d73b2586..061ee7721 100644 --- a/ICSharpCode.Decompiler/IL/Transforms/ExpressionTransforms.cs +++ b/ICSharpCode.Decompiler/IL/Transforms/ExpressionTransforms.cs @@ -405,7 +405,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms { var pointerType = new PointerType(elementType); var elementCountInstr = PointerArithmeticOffset.Detect(sizeInBytesInstr, pointerType.ElementType, checkForOverflow: true, unwrapZeroExtension: true); - if (!elementCountInstr.Match(elementCountInstr2).Success) + if (elementCountInstr == null || !elementCountInstr.Match(elementCountInstr2).Success) return false; return true; }