From 89c7e59176817d8f4f4be8c340096af827295277 Mon Sep 17 00:00:00 2001 From: sonyps5201314 Date: Tue, 28 Oct 2025 01:16:04 +0800 Subject: [PATCH] Fixed an issue where the `record struct` type declared with a primary constructor could not be decompiled correctly. The reason was that `HandleInstanceFieldInitializers` did not support the `struct` type, but `DetectPrimaryConstructor` did not exclude it in advance. Here's an example: ```cs public record struct CopilotContextId_RecordStruct(Guid id) { public Guid guid { get; } = id; public CopilotContextId_RecordStruct() : this(Guid.NewGuid()) { } } ``` --- ICSharpCode.Decompiler/CSharp/RecordDecompiler.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ICSharpCode.Decompiler/CSharp/RecordDecompiler.cs b/ICSharpCode.Decompiler/CSharp/RecordDecompiler.cs index b8d55eb83..c811485f0 100644 --- a/ICSharpCode.Decompiler/CSharp/RecordDecompiler.cs +++ b/ICSharpCode.Decompiler/CSharp/RecordDecompiler.cs @@ -210,6 +210,8 @@ namespace ICSharpCode.Decompiler.CSharp { if (!settings.UsePrimaryConstructorSyntax) return null; + if (isStruct) + return null; } else {