From 461ffe57feeb93caabb16c97d9075880743645b3 Mon Sep 17 00:00:00 2001 From: sonyps5201314 Date: Wed, 29 Oct 2025 23:35:21 +0800 Subject: [PATCH] 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`. --- .../Transforms/TransformFieldAndConstructorInitializers.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ICSharpCode.Decompiler/CSharp/Transforms/TransformFieldAndConstructorInitializers.cs b/ICSharpCode.Decompiler/CSharp/Transforms/TransformFieldAndConstructorInitializers.cs index 6bbd82096..72b1efe8f 100644 --- a/ICSharpCode.Decompiler/CSharp/Transforms/TransformFieldAndConstructorInitializers.cs +++ b/ICSharpCode.Decompiler/CSharp/Transforms/TransformFieldAndConstructorInitializers.cs @@ -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()?.Variable; + if (v == null) + { + v = (initializer.Annotation()?.ElementResult as ILVariableResolveResult)?.Variable; + } if (v?.Kind == IL.VariableKind.Parameter) { isStructPrimaryCtor = record?.PrimaryConstructor != null;