|
|
|
@ -53,8 +53,8 @@ namespace ICSharpCode.Decompiler.CSharp
@@ -53,8 +53,8 @@ namespace ICSharpCode.Decompiler.CSharp
|
|
|
|
|
this.settings = settings; |
|
|
|
|
this.cancellationToken = cancellationToken; |
|
|
|
|
this.baseClass = recordTypeDef.DirectBaseTypes.FirstOrDefault(b => b.Kind == TypeKind.Class); |
|
|
|
|
this.isStruct = baseClass.IsKnownType(KnownTypeCode.ValueType); |
|
|
|
|
this.isInheritedRecord = !isStruct && !baseClass.IsKnownType(KnownTypeCode.Object); |
|
|
|
|
this.isStruct = baseClass?.IsKnownType(KnownTypeCode.ValueType) ?? false; |
|
|
|
|
this.isInheritedRecord = !isStruct && !(baseClass?.IsKnownType(KnownTypeCode.Object) ?? false); |
|
|
|
|
this.isSealed = recordTypeDef.IsSealed; |
|
|
|
|
DetectAutomaticProperties(); |
|
|
|
|
this.orderedMembers = DetectMemberOrder(recordTypeDef, backingFieldToAutoProperty); |
|
|
|
@ -292,7 +292,7 @@ namespace ICSharpCode.Decompiler.CSharp
@@ -292,7 +292,7 @@ namespace ICSharpCode.Decompiler.CSharp
|
|
|
|
|
// virtual bool Equals(R? other): generated unless user-declared
|
|
|
|
|
return IsGeneratedEquals(method); |
|
|
|
|
} |
|
|
|
|
else if (isInheritedRecord && NormalizeTypeVisitor.TypeErasure.EquivalentTypes(paramType, baseClass) && method.IsOverride) |
|
|
|
|
else if (isInheritedRecord && baseClass != null && NormalizeTypeVisitor.TypeErasure.EquivalentTypes(paramType, baseClass) && method.IsOverride) |
|
|
|
|
{ |
|
|
|
|
// override bool Equals(BaseClass? obj): always generated
|
|
|
|
|
return true; |
|
|
|
@ -772,7 +772,7 @@ namespace ICSharpCode.Decompiler.CSharp
@@ -772,7 +772,7 @@ namespace ICSharpCode.Decompiler.CSharp
|
|
|
|
|
return false; |
|
|
|
|
if (!(conditions[pos] is Call { Method: { Name: "Equals" } } call)) |
|
|
|
|
return false; |
|
|
|
|
if (!NormalizeTypeVisitor.TypeErasure.EquivalentTypes(call.Method.DeclaringType, baseClass)) |
|
|
|
|
if (baseClass != null && !NormalizeTypeVisitor.TypeErasure.EquivalentTypes(call.Method.DeclaringType, baseClass)) |
|
|
|
|
return false; |
|
|
|
|
if (call.Arguments.Count != 2) |
|
|
|
|
return false; |
|
|
|
|