[closes gh-9] Unrolled array and collection initializers.

This commit is contained in:
Andrey Shchekin 2017-06-25 15:48:46 +12:00
Родитель 0ed1bd4be8
Коммит c0f1f800c6
4 изменённых файлов: 46 добавлений и 17 удалений

@ -1 +1 @@
Subproject commit 1c66a85cfa9f4ca9793d96a8d1187a0bc21bc8be Subproject commit 1e338e0fdc676a005522ae6a10adb627a6b94b11

Просмотреть файл

@ -29,7 +29,9 @@ namespace SharpLab.Server.Decompilation {
YieldReturn = false, YieldReturn = false,
AsyncAwait = false, AsyncAwait = false,
AutomaticProperties = false, AutomaticProperties = false,
ExpressionTrees = false ExpressionTrees = false,
ArrayInitializers = false,
ObjectOrCollectionInitializers = false
} }
}; };

Просмотреть файл

@ -29,6 +29,8 @@ namespace SharpLab.Tests {
[InlineData("Simple.cs2il")] [InlineData("Simple.cs2il")]
[InlineData("Simple.vb2vb")] [InlineData("Simple.vb2vb")]
[InlineData("Module.vb2vb")] [InlineData("Module.vb2vb")]
// https://github.com/ashmind/SharpLab/issues/9
[InlineData("Lambda.CallInArray.cs2cs")]
public async Task SlowUpdate_ReturnsExpectedDecompiledCode(string resourceName) { public async Task SlowUpdate_ReturnsExpectedDecompiledCode(string resourceName) {
var data = TestData.FromResource(resourceName); var data = TestData.FromResource(resourceName);
var driver = await NewTestDriverAsync(data); var driver = await NewTestDriverAsync(data);

Просмотреть файл

@ -7,14 +7,18 @@ public class C {
} }
} }
?=> #=>
using System; using System;
using System.Diagnostics;
using System.Reflection; using System.Reflection;
using System.Runtime.CompilerServices; using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Security; using System.Security;
using System.Security.Permissions; using System.Security.Permissions;
[assembly: AssemblyVersion("0.0.0.0")] [assembly: AssemblyVersion("0.0.0.0")]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: CompilationRelaxations(8)] [assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
@ -22,25 +26,46 @@ using System.Security.Permissions;
public class C public class C
{ {
[CompilerGenerated] [CompilerGenerated]
private static Func<int, int> CS$<>9__CachedAnonymousMethodDelegate1; [Serializable]
private sealed class <>c
{
public static readonly C.<>c <>9;
public static Func<int, int> <>9__0_0;
static <>c()
{
// Note: this type is marked as 'beforefieldinit'.
C.<>c.<>9 = new C.<>c();
}
internal int <M>b__0_0(int s)
{
return s;
}
}
public void M() public void M()
{ {
Func<int, int> arg_1B_0; Func<int, int> arg_1F_0;
if (arg_1B_0 = C.CS$<>9__CachedAnonymousMethodDelegate1 == null) if (arg_1F_0 = C.<>c.<>9__0_0 == null)
{ {
C.CS$<>9__CachedAnonymousMethodDelegate1 = new Func<int, int>(C.<M>b__0); arg_1F_0 = C.<>c.<>9__0_0 = new Func<int, int>(C.<>c.<>9.<M>b__0_0);
} }
int[] array = new int[] { Func<int, int> func = arg_1F_0;
1, int[] expr_26 = new int[4];
2, RuntimeHelpers.InitializeArray(expr_26, fieldof(<PrivateImplementationDetails>.7C7D749A182D008FD83D960F228CB2B1A0177992).FieldHandle);
3, expr_26[3] = func(1);
0 Console.WriteLine(expr_26[3]);
};
Console.WriteLine(array[3]);
} }
[CompilerGenerated] }
private static int <M>b__0(int s) [CompilerGenerated]
internal sealed class <PrivateImplementationDetails>
{
[StructLayout(LayoutKind.Explicit, Pack = 1, Size = 16)]
private struct __StaticArrayInitTypeSize=16
{ {
return s;
} }
internal static readonly <PrivateImplementationDetails>.__StaticArrayInitTypeSize=16 7C7D749A182D008FD83D960F228CB2B1A0177992 = bytearray(1, 0, 0, 0, 2, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0);
} }