|
|
|
|
@ -58,6 +58,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
@@ -58,6 +58,7 @@ namespace ICSharpCode.Decompiler.IL.Transforms
|
|
|
|
|
{ |
|
|
|
|
case NewObj newObjInst: |
|
|
|
|
if (newObjInst.ILStackWasEmpty && v.Kind == VariableKind.Local |
|
|
|
|
&& !TypeContainsInitOnlyProperties(newObjInst.Method.DeclaringTypeDefinition) |
|
|
|
|
&& !currentMethod.IsConstructor |
|
|
|
|
&& !currentMethod.IsCompilerGeneratedOrIsInCompilerGeneratedClass()) |
|
|
|
|
{ |
|
|
|
|
@ -187,6 +188,18 @@ namespace ICSharpCode.Decompiler.IL.Transforms
@@ -187,6 +188,18 @@ namespace ICSharpCode.Decompiler.IL.Transforms
|
|
|
|
|
ILInlining.InlineIfPossible(block, pos, context); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private static bool TypeContainsInitOnlyProperties(ITypeDefinition? typeDefinition) |
|
|
|
|
{ |
|
|
|
|
foreach (var property in typeDefinition?.Properties ?? []) |
|
|
|
|
{ |
|
|
|
|
if (property.Setter?.IsInitOnly ?? false) |
|
|
|
|
{ |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
internal static bool IsRecordCloneMethodCall(CallInstruction ci) |
|
|
|
|
{ |
|
|
|
|
if (ci.Method.DeclaringTypeDefinition?.IsRecord != true) |
|
|
|
|
|