Browse Source

Fixed an issue in unit tests where the `RefFields` type would be decompiled into incorrect code when the return value of the `IsPrimaryConstructor` function was forcibly changed to `false`.

pull/3598/head
sonyps5201314 2 months ago
parent
commit
461ffe57fe
  1. 4
      ICSharpCode.Decompiler/CSharp/Transforms/TransformFieldAndConstructorInitializers.cs

4
ICSharpCode.Decompiler/CSharp/Transforms/TransformFieldAndConstructorInitializers.cs

@ -230,6 +230,10 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms @@ -230,6 +230,10 @@ namespace ICSharpCode.Decompiler.CSharp.Transforms
if (initializer.DescendantsAndSelf.Any(n => n is ThisReferenceExpression || n is BaseReferenceExpression))
break;
var v = initializer.Annotation<ILVariableResolveResult>()?.Variable;
if (v == null)
{
v = (initializer.Annotation<ByReferenceResolveResult>()?.ElementResult as ILVariableResolveResult)?.Variable;
}
if (v?.Kind == IL.VariableKind.Parameter)
{
isStructPrimaryCtor = record?.PrimaryConstructor != null;

Loading…
Cancel
Save