|
|
@ -51,7 +51,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms |
|
|
|
bool modified = false; |
|
|
|
int i = 0; |
|
|
|
while (i < block.Instructions.Count) { |
|
|
|
if (InlineOneIfPossible(block, i, aggressive: IsCatchWhenBlock(block) || IsInConstructurInitializer(i, block), context: context)) { |
|
|
|
if (InlineOneIfPossible(block, i, aggressive: IsCatchWhenBlock(block) || IsInConstructorInitializer(i, block), context: context)) { |
|
|
|
modified = true; |
|
|
|
i = Math.Max(0, i - 1); |
|
|
|
// Go back one step
|
|
|
@ -62,7 +62,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms |
|
|
|
return modified; |
|
|
|
} |
|
|
|
|
|
|
|
static bool IsInConstructurInitializer(int i, Block block) |
|
|
|
static bool IsInConstructorInitializer(int i, Block block) |
|
|
|
{ |
|
|
|
var inst = block.Instructions[i]; |
|
|
|
var topLevelBlock = inst.Ancestors.OfType<Block>().LastOrDefault(); |
|
|
@ -70,7 +70,10 @@ namespace ICSharpCode.Decompiler.IL.Transforms |
|
|
|
if (topLevelBlock == null || function == null || !function.Method.IsConstructor) |
|
|
|
return false; |
|
|
|
var topLevelInst = inst.Ancestors.FirstOrDefault(instr => instr.Parent == topLevelBlock); |
|
|
|
var ctorCall = function.Descendants.OfType<CallInstruction>().FirstOrDefault(call => !(call is NewObj) && call.Method.IsConstructor); |
|
|
|
var ctorCall = function.Descendants.OfType<CallInstruction>().FirstOrDefault(call => !(call is NewObj) |
|
|
|
&& call.Method.IsConstructor |
|
|
|
&& call.Method.DeclaringType.IsReferenceType == true |
|
|
|
&& call.Parent is Block); |
|
|
|
if (topLevelInst == null || ctorCall == null) |
|
|
|
return false; |
|
|
|
return topLevelInst.ILRange.InclusiveEnd < ctorCall.ILRange.Start; |
|
|
|