From 8d1cfee963bb3f5dda4e4fc3edc632c2eb997921 Mon Sep 17 00:00:00 2001 From: sonyps5201314 Date: Wed, 22 Oct 2025 02:23:09 +0800 Subject: [PATCH] The internal judgment logic of IsPrimaryConstructor should exclude the copy constructor first, otherwise it will be judged incorrectly whether the NamedParameter type in https://github.com/restsharp/RestSharp/blob/dev/src/RestSharp/Parameters/Parameter.cs uses the primary constructor. --- ICSharpCode.Decompiler/CSharp/RecordDecompiler.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/ICSharpCode.Decompiler/CSharp/RecordDecompiler.cs b/ICSharpCode.Decompiler/CSharp/RecordDecompiler.cs index a47dcf290..2b623c094 100644 --- a/ICSharpCode.Decompiler/CSharp/RecordDecompiler.cs +++ b/ICSharpCode.Decompiler/CSharp/RecordDecompiler.cs @@ -190,13 +190,18 @@ namespace ICSharpCode.Decompiler.CSharp return null; //判定主构造函数的唯一准则是: - //构造函数中前面部分都是类成员属性/字段赋值语句, - //之后是调用基类构造函数的语句即"base..ctor();", - //再之后就是返回语句了,即"base..ctor();"之后不存在任何其他初始化语句。 + //首先它不能是拷贝构造函数, + //然后这个构造函数中前面部分都是类成员属性/字段赋值语句, + //之后是调用基类构造函数的语句即"base..ctor(...);", + //再之后就是返回语句了,即"base..ctor(...);"之后不存在任何其他初始化语句。 //且主构造函数的参数和类成员之间无任何对应关系! bool IsPrimaryConstructor(IMethod method, IMethod unspecializedMethod) { Debug.Assert(method.IsConstructor); + + if (IsCopyConstructor(method)) + return false; + var body = DecompileBody(method); if (body == null) return false;