public bool Equals(ProjectRestoreMetadata other)
        {
            if (other == null)
            {
                return(false);
            }

            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return(ProjectStyle == other.ProjectStyle &&
                   PathUtility.GetStringComparerBasedOnOS().Equals(ProjectPath, other.ProjectPath) &&
                   PathUtility.GetStringComparerBasedOnOS().Equals(ProjectJsonPath, other.ProjectJsonPath) &&
                   PathUtility.GetStringComparerBasedOnOS().Equals(OutputPath, other.OutputPath) &&
                   PathUtility.GetStringComparerBasedOnOS().Equals(ProjectName, other.ProjectName) &&
                   PathUtility.GetStringComparerBasedOnOS().Equals(ProjectUniqueName, other.ProjectUniqueName) &&
                   Sources.OrderedEquals(other.Sources.Distinct(), source => source.Source, StringComparer.OrdinalIgnoreCase) &&
                   PathUtility.GetStringComparerBasedOnOS().Equals(PackagesPath, other.PackagesPath) &&
                   ConfigFilePaths.OrderedEquals(other.ConfigFilePaths, filePath => filePath, PathUtility.GetStringComparerBasedOnOS(), PathUtility.GetStringComparerBasedOnOS()) &&
                   FallbackFolders.OrderedEquals(other.FallbackFolders, fallbackFolder => fallbackFolder, PathUtility.GetStringComparerBasedOnOS(), PathUtility.GetStringComparerBasedOnOS()) &&
                   EqualityUtility.SequenceEqualWithNullCheck(TargetFrameworks, other.TargetFrameworks) &&
                   OriginalTargetFrameworks.OrderedEquals(other.OriginalTargetFrameworks, fw => fw, StringComparer.OrdinalIgnoreCase, StringComparer.OrdinalIgnoreCase) &&
                   CrossTargeting == other.CrossTargeting &&
                   LegacyPackagesDirectory == other.LegacyPackagesDirectory &&
                   ValidateRuntimeAssets == other.ValidateRuntimeAssets &&
                   SkipContentFileWrite == other.SkipContentFileWrite &&
                   EqualityUtility.SequenceEqualWithNullCheck(Files, other.Files) &&
                   EqualityUtility.EqualsWithNullCheck(ProjectWideWarningProperties, other.ProjectWideWarningProperties));
        }
예제 #2
0
        public override int GetHashCode()
        {
            var hashCode = new HashCodeCombiner();

            hashCode.AddStruct(ProjectStyle);

            StringComparer osStringComparer = PathUtility.GetStringComparerBasedOnOS();

            if (ProjectPath != null)
            {
                hashCode.AddObject(osStringComparer.GetHashCode(ProjectPath));
            }
            if (ProjectJsonPath != null)
            {
                hashCode.AddObject(osStringComparer.GetHashCode(ProjectJsonPath));
            }
            if (OutputPath != null)
            {
                hashCode.AddObject(osStringComparer.GetHashCode(OutputPath));
            }
            if (ProjectName != null)
            {
                hashCode.AddObject(osStringComparer.GetHashCode(ProjectName));
            }
            if (ProjectUniqueName != null)
            {
                hashCode.AddObject(osStringComparer.GetHashCode(ProjectUniqueName));
            }
            hashCode.AddSequence(Sources.OrderBy(e => e.Source, StringComparer.OrdinalIgnoreCase));
            if (PackagesPath != null)
            {
                hashCode.AddObject(osStringComparer.GetHashCode(PackagesPath));
            }
            foreach (var reference in ConfigFilePaths.OrderBy(s => s, osStringComparer))
            {
                hashCode.AddObject(osStringComparer.GetHashCode(reference));
            }
            foreach (var reference in FallbackFolders.OrderBy(s => s, osStringComparer))
            {
                hashCode.AddObject(osStringComparer.GetHashCode(reference));
            }
            hashCode.AddSequence(TargetFrameworks.OrderBy(dep => dep.TargetAlias, StringComparer.OrdinalIgnoreCase));
            foreach (var reference in OriginalTargetFrameworks.OrderBy(s => s, StringComparer.OrdinalIgnoreCase))
            {
                hashCode.AddObject(StringComparer.OrdinalIgnoreCase.GetHashCode(reference));
            }
            hashCode.AddObject(CrossTargeting);
            hashCode.AddObject(LegacyPackagesDirectory);
            hashCode.AddSequence(Files);
            hashCode.AddObject(ValidateRuntimeAssets);
            hashCode.AddObject(SkipContentFileWrite);
            hashCode.AddObject(ProjectWideWarningProperties);
            hashCode.AddObject(RestoreLockProperties);
            hashCode.AddObject(CentralPackageVersionsEnabled);
            hashCode.AddObject(CentralPackageVersionOverrideDisabled);
            hashCode.AddObject(CentralPackageTransitivePinningEnabled);

            return(hashCode.CombinedHash);
        }