[closes gh-128] Suppressed variable inlining.

This commit is contained in:
Andrey Shchekin 2017-06-25 20:44:51 +12:00
Родитель 237ab5b467
Коммит c77c232430
8 изменённых файлов: 48 добавлений и 14 удалений

@ -1 +1 @@
Subproject commit e4edcffab101aa0660e8fd83a5c7278c03924d6e
Subproject commit 90a8646497e6171cd4c12f49e170b31bb742affd

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

@ -1,15 +1,11 @@
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using AshMind.Extensions;
using ICSharpCode.Decompiler;
using ICSharpCode.Decompiler.Ast;
using ICSharpCode.Decompiler.Ast.Transforms;
using ICSharpCode.NRefactory.CSharp;
using Mono.Cecil;
using SharpLab.Server.Decompilation.Internal;
namespace SharpLab.Server.Decompilation {
public abstract class AstBasedDecompiler : IDecompiler {
@ -24,7 +20,8 @@ namespace SharpLab.Server.Decompilation {
});
var context = new DecompilerContext(module) {
Settings = {
Settings = {
CanInlineVariables = false,
OperatorOverloading = false,
AnonymousMethods = false,
YieldReturn = false,

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

@ -1,8 +1,5 @@
using System.Collections.Generic;
using System.IO;
using ICSharpCode.Decompiler;
using System.IO;
using ICSharpCode.Decompiler.Ast;
using ICSharpCode.NRefactory.CSharp;
using Microsoft.CodeAnalysis;
using SharpLab.Server.Decompilation.Internal;

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

@ -51,6 +51,8 @@ namespace SharpLab.Tests {
[Theory]
// https://github.com/ashmind/SharpLab/issues/25
[InlineData("Condition.SimpleSwitch.cs2cs")]
// https://github.com/ashmind/SharpLab/issues/128
[InlineData("Variable.FromArgumentToCall.cs2cs")]
public async Task SlowUpdate_ReturnsExpectedDecompiledCode_InDebug(string resourceName) {
var data = TestData.FromResource(resourceName);
var driver = await NewTestDriverAsync(data, OptimizationLevel.Debug);

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

@ -25,7 +25,8 @@ public class C
{
public void M(string n)
{
if (!(n == "foo"))
string a = n;
if (!(a == "foo"))
{
}
}

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

@ -44,13 +44,14 @@ public class C
Func<int, int> arg_1F_0;
if ((arg_1F_0 = C.<>c.<>9__0_0) == null)
{
arg_1F_0 = (C.<>c.<>9__0_0 = new Func<int, int>(C.<>c.<>9.<M>b__0_0));
C.<>c.<>9__0_0 = (arg_1F_0 = new Func<int, int>(C.<>c.<>9.<M>b__0_0));
}
Func<int, int> func = arg_1F_0;
int[] expr_26 = new int[4];
RuntimeHelpers.InitializeArray(expr_26, fieldof(<PrivateImplementationDetails>.7C7D749A182D008FD83D960F228CB2B1A0177992).FieldHandle);
expr_26[3] = func(1);
Console.WriteLine(expr_26[3]);
int[] expr_31 = expr_26;
expr_31[3] = func(1);
Console.WriteLine(expr_31[3]);
}
}
[CompilerGenerated]

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

@ -0,0 +1,32 @@
using System;
public class C {
public void M(int argument) {
var newVariableForArgument = argument;
Console.WriteLine(newVariableForArgument);
}
}
#=>
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
[assembly: AssemblyVersion("0.0.0.0")]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[module: UnverifiableCode]
public class C
{
public void M(int argument)
{
int value = argument;
Console.WriteLine(value);
}
}

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

@ -28,6 +28,10 @@
<None Remove="TestCode\Simple.vb2vb" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="TestCode\Variable.FromArgumentToCall.cs2cs" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="TestCode\Condition.SimpleSwitch.cs2cs" />
</ItemGroup>