|
|
|
@ -709,15 +709,13 @@ namespace ICSharpCode.Decompiler.CSharp
@@ -709,15 +709,13 @@ namespace ICSharpCode.Decompiler.CSharp
|
|
|
|
|
while (inst.Parent is UnboxAny || inst.Parent is CastClass) |
|
|
|
|
inst = inst.Parent; |
|
|
|
|
// One variable was found.
|
|
|
|
|
if (inst.Parent is StLoc stloc) { |
|
|
|
|
if (inst.Parent is StLoc stloc && (stloc.Variable.Kind == VariableKind.Local || stloc.Variable.Kind == VariableKind.StackSlot)) { |
|
|
|
|
// Must be a plain assignment expression and variable must only be used in 'body' + only assigned once.
|
|
|
|
|
if (stloc.Parent == loopBody && VariableIsOnlyUsedInBlock(stloc, usingContainer)) { |
|
|
|
|
foreachVariable = stloc.Variable; |
|
|
|
|
if (foreachVariable.Kind == VariableKind.Local) { |
|
|
|
|
return RequiredGetCurrentTransformation.UseExistingVariable; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
// In optimized Roslyn code it can happen that the foreach variable is referenced via addressof
|
|
|
|
|
// We only do this unwrapping if where dealing with a custom struct type.
|
|
|
|
|
if (CurrentIsStructSetterTarget(inst, singleGetter)) { |
|
|
|
|