Skip to content

Commit ed734c7

Browse files
committed
Switch to EquatableArray<T> for command generator
1 parent e31f197 commit ed734c7

File tree

1 file changed

+3
-53
lines changed

1 file changed

+3
-53
lines changed

CommunityToolkit.Mvvm.SourceGenerators/Input/Models/CommandInfo.cs

Lines changed: 3 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -34,60 +34,10 @@ internal sealed record CommandInfo(
3434
string CommandInterfaceType,
3535
string CommandClassType,
3636
string DelegateType,
37-
ImmutableArray<string> CommandTypeArguments,
38-
ImmutableArray<string> DelegateTypeArguments,
37+
EquatableArray<string> CommandTypeArguments,
38+
EquatableArray<string> DelegateTypeArguments,
3939
string? CanExecuteMemberName,
4040
CanExecuteExpressionType? CanExecuteExpressionType,
4141
bool AllowConcurrentExecutions,
4242
bool FlowExceptionsToTaskScheduler,
43-
bool IncludeCancelCommand)
44-
{
45-
/// <inheritdoc/>
46-
public bool Equals(CommandInfo? obj) => Comparer.Default.Equals(this, obj);
47-
48-
/// <inheritdoc/>
49-
public override int GetHashCode() => Comparer.Default.GetHashCode(this);
50-
51-
/// <summary>
52-
/// An <see cref="IEqualityComparer{T}"/> implementation for <see cref="CommandInfo"/>.
53-
/// </summary>
54-
private sealed class Comparer : Comparer<CommandInfo, Comparer>
55-
{
56-
/// <inheritdoc/>
57-
protected override void AddToHashCode(ref HashCode hashCode, CommandInfo obj)
58-
{
59-
hashCode.Add(obj.MethodName);
60-
hashCode.Add(obj.FieldName);
61-
hashCode.Add(obj.PropertyName);
62-
hashCode.Add(obj.CommandInterfaceType);
63-
hashCode.Add(obj.CommandClassType);
64-
hashCode.Add(obj.DelegateType);
65-
hashCode.AddRange(obj.CommandTypeArguments);
66-
hashCode.AddRange(obj.DelegateTypeArguments);
67-
hashCode.Add(obj.CanExecuteMemberName);
68-
hashCode.Add(obj.CanExecuteExpressionType);
69-
hashCode.Add(obj.AllowConcurrentExecutions);
70-
hashCode.Add(obj.FlowExceptionsToTaskScheduler);
71-
hashCode.Add(obj.IncludeCancelCommand);
72-
}
73-
74-
/// <inheritdoc/>
75-
protected override bool AreEqual(CommandInfo x, CommandInfo y)
76-
{
77-
return
78-
x.MethodName == y.MethodName &&
79-
x.FieldName == y.FieldName &&
80-
x.PropertyName == y.PropertyName &&
81-
x.CommandInterfaceType == y.CommandInterfaceType &&
82-
x.CommandClassType == y.CommandClassType &&
83-
x.DelegateType == y.DelegateType &&
84-
x.CommandTypeArguments.SequenceEqual(y.CommandTypeArguments) &&
85-
x.DelegateTypeArguments.SequenceEqual(y.CommandTypeArguments) &&
86-
x.CanExecuteMemberName == y.CanExecuteMemberName &&
87-
x.CanExecuteExpressionType == y.CanExecuteExpressionType &&
88-
x.AllowConcurrentExecutions == y.AllowConcurrentExecutions &&
89-
x.FlowExceptionsToTaskScheduler == y.FlowExceptionsToTaskScheduler &&
90-
x.IncludeCancelCommand == y.IncludeCancelCommand;
91-
}
92-
}
93-
}
43+
bool IncludeCancelCommand);

0 commit comments

Comments
 (0)