mirror of
https://github.com/chylex/.NET-Community-Toolkit.git
synced 2025-08-16 05:31:46 +02:00
.github
CommunityToolkit.Common
CommunityToolkit.Diagnostics
CommunityToolkit.HighPerformance
CommunityToolkit.Mvvm
CommunityToolkit.Mvvm.SourceGenerators
Attributes
ComponentModel
Models
AttributeInfo.cs
INotifyPropertyChangedInfo.cs
ObservableRecipientInfo.cs
PropertyAccess.cs
PropertyInfo.cs
TypedConstantInfo.Comparer.cs
TypedConstantInfo.Factory.cs
TypedConstantInfo.cs
ValidationInfo.cs
INotifyPropertyChangedGenerator.cs
ObservableObjectGenerator.cs
ObservablePropertyGenerator.Execute.cs
ObservablePropertyGenerator.cs
ObservableRecipientGenerator.cs
ObservableValidatorValidateAllPropertiesGenerator.Execute.cs
ObservableValidatorValidateAllPropertiesGenerator.cs
TransitiveMembersGenerator.Execute.cs
TransitiveMembersGenerator.cs
Diagnostics
EmbeddedResources
Extensions
Helpers
Input
Messaging
Models
System.Runtime.CompilerServices
AnalyzerReleases.Shipped.md
AnalyzerReleases.Unshipped.md
CommunityToolkit.Mvvm.SourceGenerators.csproj
build
tests
.editorconfig
.git-blame-ignore-revs
.gitattributes
.gitignore
.runsettings
CODE_OF_CONDUCT.md
Contributing.md
Directory.Build.props
Directory.Build.targets
License.md
README.md
ThirdPartyNotices.txt
azure-pipelines.yml
dotnet Community Toolkit.sln
toolkit.snk
version.json
48 lines
1.7 KiB
C#
48 lines
1.7 KiB
C#
// Licensed to the .NET Foundation under one or more agreements.
|
|
// The .NET Foundation licenses this file to you under the MIT license.
|
|
// See the LICENSE file in the project root for more information.
|
|
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Collections.Immutable;
|
|
using System.Linq;
|
|
using CommunityToolkit.Mvvm.SourceGenerators.Extensions;
|
|
using CommunityToolkit.Mvvm.SourceGenerators.Helpers;
|
|
|
|
namespace CommunityToolkit.Mvvm.SourceGenerators.Input.Models;
|
|
|
|
/// <summary>
|
|
/// A model with gathered info on all validatable properties in a given type.
|
|
/// </summary>
|
|
/// <param name="FilenameHint">The filename hint for the current type.</param>
|
|
/// <param name="TypeName">The fully qualified type name of the target type.</param>
|
|
/// <param name="PropertyNames">The name of validatable properties.</param>
|
|
internal sealed record ValidationInfo(
|
|
string FilenameHint,
|
|
string TypeName,
|
|
ImmutableArray<string> PropertyNames)
|
|
{
|
|
/// <summary>
|
|
/// An <see cref="IEqualityComparer{T}"/> implementation for <see cref="ValidationInfo"/>.
|
|
/// </summary>
|
|
public sealed class Comparer : Comparer<ValidationInfo, Comparer>
|
|
{
|
|
/// <inheritdoc/>
|
|
protected override void AddToHashCode(ref HashCode hashCode, ValidationInfo obj)
|
|
{
|
|
hashCode.Add(obj.FilenameHint);
|
|
hashCode.Add(obj.TypeName);
|
|
hashCode.AddRange(obj.PropertyNames);
|
|
}
|
|
|
|
/// <inheritdoc/>
|
|
protected override bool AreEqual(ValidationInfo x, ValidationInfo y)
|
|
{
|
|
return
|
|
x.FilenameHint == y.FilenameHint &&
|
|
x.TypeName == y.TypeName &&
|
|
x.PropertyNames.SequenceEqual(y.PropertyNames);
|
|
}
|
|
}
|
|
}
|