Skip to content

Commit 0af04b3

Browse files
committed
Switch to EquatableArray<T> for ObservableValidator generator
1 parent ff4cb35 commit 0af04b3

File tree

1 file changed

+1
-34
lines changed

1 file changed

+1
-34
lines changed

CommunityToolkit.Mvvm.SourceGenerators/ComponentModel/Models/ValidationInfo.cs

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -17,37 +17,4 @@ namespace CommunityToolkit.Mvvm.SourceGenerators.Input.Models;
1717
/// <param name="FilenameHint">The filename hint for the current type.</param>
1818
/// <param name="TypeName">The fully qualified type name of the target type.</param>
1919
/// <param name="PropertyNames">The name of validatable properties.</param>
20-
internal sealed record ValidationInfo(
21-
string FilenameHint,
22-
string TypeName,
23-
ImmutableArray<string> PropertyNames)
24-
{
25-
/// <inheritdoc/>
26-
public bool Equals(ValidationInfo? obj) => Comparer.Default.Equals(this, obj);
27-
28-
/// <inheritdoc/>
29-
public override int GetHashCode() => Comparer.Default.GetHashCode(this);
30-
31-
/// <summary>
32-
/// An <see cref="IEqualityComparer{T}"/> implementation for <see cref="ValidationInfo"/>.
33-
/// </summary>
34-
private sealed class Comparer : Comparer<ValidationInfo, Comparer>
35-
{
36-
/// <inheritdoc/>
37-
protected override void AddToHashCode(ref HashCode hashCode, ValidationInfo obj)
38-
{
39-
hashCode.Add(obj.FilenameHint);
40-
hashCode.Add(obj.TypeName);
41-
hashCode.AddRange(obj.PropertyNames);
42-
}
43-
44-
/// <inheritdoc/>
45-
protected override bool AreEqual(ValidationInfo x, ValidationInfo y)
46-
{
47-
return
48-
x.FilenameHint == y.FilenameHint &&
49-
x.TypeName == y.TypeName &&
50-
x.PropertyNames.SequenceEqual(y.PropertyNames);
51-
}
52-
}
53-
}
20+
internal sealed record ValidationInfo(string FilenameHint, string TypeName, EquatableArray<string> PropertyNames);

0 commit comments

Comments
 (0)