Browse Source

Adjust RecordDecompiler to changes in Roslyn 3.10.0

pull/2423/head
Daniel Grunwald 4 years ago
parent
commit
55ab2a1739
  1. 15
      ICSharpCode.Decompiler/CSharp/RecordDecompiler.cs
  2. 2
      packages.props

15
ICSharpCode.Decompiler/CSharp/RecordDecompiler.cs

@ -663,6 +663,10 @@ namespace ICSharpCode.Decompiler.CSharp @@ -663,6 +663,10 @@ namespace ICSharpCode.Decompiler.CSharp
// virtual bool Equals(R? other) {
// return other != null && EqualityContract == other.EqualityContract && EqualityComparer<int>.Default.Equals(A, other.A) && ...;
// }
// Starting with Roslyn 3.10, it's:
// virtual bool Equals(R? other) {
// return this == other || other != null && EqualityContract == other.EqualityContract && EqualityComparer<int>.Default.Equals(A, other.A) && ...;
// }
Debug.Assert(method.Name == "Equals" && method.Parameters.Count == 1);
if (method.Parameters.Count != 1)
return false;
@ -680,6 +684,17 @@ namespace ICSharpCode.Decompiler.CSharp @@ -680,6 +684,17 @@ namespace ICSharpCode.Decompiler.CSharp
var variables = body.Ancestors.OfType<ILFunction>().Single().Variables;
var other = variables.Single(v => v.Kind == VariableKind.Parameter && v.Index == 0);
Debug.Assert(IsRecordType(other.Type));
if (returnValue.MatchLogicOr(out var lhs, out var rhs))
{
// this == other || ...
if (!lhs.MatchCompEquals(out var compLeft, out var compRight))
return false;
if (!compLeft.MatchLdThis())
return false;
if (!compRight.MatchLdLoc(other))
return false;
returnValue = rhs;
}
var conditions = UnpackLogicAndChain(returnValue);
Debug.Assert(conditions.Count >= 1);
int pos = 0;

2
packages.props

@ -10,7 +10,7 @@ @@ -10,7 +10,7 @@
<SystemCompilerServicesUnsafeVersion>5.0.0</SystemCompilerServicesUnsafeVersion>
<SystemCompositionVersion>5.0.1</SystemCompositionVersion>
<ILAsmVersion>5.0.0</ILAsmVersion> <!-- Microsoft.NETCore.ILAsm -->
<RoslynVersion>3.9.0</RoslynVersion> <!-- Microsoft.CodeAnalysis.* -->
<RoslynVersion>3.10.0-3.final</RoslynVersion> <!-- Microsoft.CodeAnalysis.* -->
<MonoCecilVersion>0.11.3</MonoCecilVersion>
<AvalonEditVersion>6.1.1</AvalonEditVersion>
<NUnitVersion>3.12.0</NUnitVersion>

Loading…
Cancel
Save