Skip to content

Commit eb09343

Browse files
committed
Remove external comparer for RecipientInfo
1 parent a8fd1db commit eb09343

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

CommunityToolkit.Mvvm.SourceGenerators/Messaging/IMessengerRegisterAllGenerator.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,7 @@ public void Initialize(IncrementalGeneratorInitializationContext context)
6161

6262
return Execute.GetInfo(typeSymbol, interfaceSymbols);
6363
})
64-
.Where(static item => item is not null)!
65-
.WithComparer(RecipientInfo.Comparer.Default);
64+
.Where(static item => item is not null)!;
6665

6766
// Check whether the header file is needed
6867
IncrementalValueProvider<bool> isHeaderFileNeeded =

CommunityToolkit.Mvvm.SourceGenerators/Messaging/Models/RecipientInfo.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,16 @@ internal sealed record RecipientInfo(
2222
string TypeName,
2323
ImmutableArray<string> MessageTypes)
2424
{
25+
/// <inheritdoc/>
26+
public bool Equals(RecipientInfo? obj) => Comparer.Default.Equals(this, obj);
27+
28+
/// <inheritdoc/>
29+
public override int GetHashCode() => Comparer.Default.GetHashCode(this);
30+
2531
/// <summary>
2632
/// An <see cref="IEqualityComparer{T}"/> implementation for <see cref="RecipientInfo"/>.
2733
/// </summary>
28-
public sealed class Comparer : Comparer<RecipientInfo, Comparer>
34+
private sealed class Comparer : Comparer<RecipientInfo, Comparer>
2935
{
3036
/// <inheritdoc/>
3137
protected override void AddToHashCode(ref HashCode hashCode, RecipientInfo obj)

0 commit comments

Comments
 (0)