File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed
Microsoft.Toolkit.Mvvm/Messaging Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -638,9 +638,14 @@ public Type2(Type tMessage, Type tToken)
638638 [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
639639 public bool Equals ( Type2 other )
640640 {
641+ // We can't just use reference equality, as that's technically not guaranteed
642+ // to work and might fail in very rare cases (eg. with type forwarding between
643+ // different assemblies). Instead, we can use the == operator to compare for
644+ // equality, which still avoids the callvirt overhead of calling Type.Equals,
645+ // and is also implemented as a JIT intrinsic on runtimes such as .NET Core.
641646 return
642- ReferenceEquals ( this . tMessage , other . tMessage ) &&
643- ReferenceEquals ( this . tToken , other . tToken ) ;
647+ this . tMessage == other . tMessage &&
648+ this . tToken == other . tToken ;
644649 }
645650
646651 /// <inheritdoc/>
You can’t perform that action at this time.
0 commit comments