From f2d3f259fde5e5fecc64f379fd08866113004d56 Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Wed, 24 Feb 2021 12:56:12 +0100 Subject: [PATCH] #2311: Adjust test case for #1292 -- fixed statement is now correctly detected --- .../TestCases/ILPretty/Unsafe.cs | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/ICSharpCode.Decompiler.Tests/TestCases/ILPretty/Unsafe.cs b/ICSharpCode.Decompiler.Tests/TestCases/ILPretty/Unsafe.cs index a0a33c755..1a126fd9c 100644 --- a/ICSharpCode.Decompiler.Tests/TestCases/ILPretty/Unsafe.cs +++ b/ICSharpCode.Decompiler.Tests/TestCases/ILPretty/Unsafe.cs @@ -40,19 +40,9 @@ internal sealed class ExtraUnsafeTests public unsafe static byte[] Issue1292(int val, byte[] arr) { - //The blocks IL_0019 are reachable both inside and outside the pinned region starting at IL_0013. ILSpy has duplicated these blocks in order to place them both within and outside the `fixed` statement. - byte[] array; - if ((array = arr) != null && array.Length != 0) + fixed (byte* ptr = arr) { - fixed (byte* ptr = &array[0]) - { - *(int*)ptr = val; - } - } - else - { - /*pinned*/ref byte reference = ref *(byte*)null; - *(int*)Unsafe.AsPointer(ref reference) = val; + *(int*)ptr = val; } return arr; }