Browse Source

Add ValueTypeCall foreach testcase.

pull/925/merge
Daniel Grunwald 8 years ago
parent
commit
6d8d37f8fc
  1. 38
      ICSharpCode.Decompiler.Tests/TestCases/Correctness/ValueTypeCall.cs
  2. 1
      ICSharpCode.Decompiler/IL/Transforms/SplitVariables.cs

38
ICSharpCode.Decompiler.Tests/TestCases/Correctness/ValueTypeCall.cs

@ -1,4 +1,5 @@ @@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
namespace ICSharpCode.Decompiler.Tests.TestCases.Correctness
{
@ -59,6 +60,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Correctness @@ -59,6 +60,7 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Correctness
var gvt = new GenericValueType<string>("Test");
gvt.Call(ref gvt);
new ValueTypeCall().InstanceFieldTests();
ForEach();
}
static void RefParameter(ref MutValueType m)
@ -153,5 +155,41 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Correctness @@ -153,5 +155,41 @@ namespace ICSharpCode.Decompiler.Tests.TestCases.Correctness
z.Increment();
}
}
static void ForEach()
{
var list = new List<MutValueType> {
new MutValueType { val = 10 },
new MutValueType { val = 20 },
new MutValueType { val = 30 },
};
ForEach1(list);
var array = new MutValueType[] {
new MutValueType { val = 100 },
new MutValueType { val = 200 },
new MutValueType { val = 300 },
};
ForEachArray1(array);
}
static void ForEach1(List<MutValueType> list)
{
Console.WriteLine("ForEach1:");
foreach (var val in list) {
val.Increment();
val.Increment();
}
Console.WriteLine("after: " + list[0].val);
}
static void ForEachArray1(MutValueType[] list)
{
Console.WriteLine("ForEachArray1:");
foreach (var val in list) {
val.Increment();
val.Increment();
}
Console.WriteLine("after: " + list[0].val);
}
}
}

1
ICSharpCode.Decompiler/IL/Transforms/SplitVariables.cs

@ -33,7 +33,6 @@ namespace ICSharpCode.Decompiler.IL.Transforms @@ -33,7 +33,6 @@ namespace ICSharpCode.Decompiler.IL.Transforms
{
var groupStores = new GroupStores(function, context.CancellationToken);
function.Body.AcceptVisitor(groupStores);
var newVariables = new Dictionary<ILInstruction, ILVariable>();
// Replace analyzed variables with their split versions:
foreach (var inst in function.Descendants.OfType<IInstructionWithVariableOperand>()) {
if (groupStores.IsAnalyzedVariable(inst.Variable)) {

Loading…
Cancel
Save