src/Microsoft.DotNet.Darc/src/DarcLib/Helpers/GitFileManager.cs
/// <summary>
///     Verify that any dependency that exists in both Version.props and Version.Details.xml has matching version numbers.
/// </summary>
/// <param name="dependencies">Parsed dependencies in the repository.</param>
/// <param name="versionProps">Parsed version props file</param>
/// <returns></returns>
Verify that any dependency that exists in both Version.props and Version.Details.xml has matching version numbers.
Verify that any dependency that exists in both Version . props and Version . Details . xml has matching version numbers .
private Task<bool> VerifyMatchingVersionProps(IEnumerable<DependencyDetail> dependencies, XmlDocument versionProps, out Task<HashSet<string>> utilizedDependencies)
        {
            HashSet<string> utilizedSet = new HashSet<string>();
            bool result = true;
            foreach (var dependency in dependencies)
            {
                string versionElementName = VersionFiles.GetVersionPropsPackageVersionElementName(dependency.Name);
                string alternateVersionElementName = VersionFiles.GetVersionPropsAlternatePackageVersionElementName(dependency.Name);
                XmlNode versionNode = versionProps.DocumentElement.SelectSingleNode($"//*[local-name()='{versionElementName}']");
                if (versionNode == null)
                {
                    versionNode = versionProps.DocumentElement.SelectSingleNode($"////*[local-name()='{alternateVersionElementName}']");
                }
                if (versionNode != null)
                {
                    if (versionNode.Name != versionElementName)
                    {
                        _logger.LogError($"The dependency '{dependency.Name}' has a case mismatch between " +
                            $"'{VersionFiles.VersionProps}' and '{VersionFiles.VersionDetailsXml}' " +
                            $"('{versionNode.Name}' vs. '{versionElementName}')");
                        result = false;
                    }
                    if (versionNode.InnerText != dependency.Version)
                    {
                        _logger.LogError($"The dependency '{dependency.Name}' has a version mismatch between " +
                            $"'{VersionFiles.VersionProps}' and '{VersionFiles.VersionDetailsXml}' " +
                            $"('{versionNode.InnerText}' vs. '{dependency.Version}')");
                        result = false;
                    }
                    utilizedSet.Add(dependency.Name);
                }
            }
            utilizedDependencies = Task.FromResult(utilizedSet);
            return Task.FromResult(result);
        }
private Task < bool > VerifyMatchingVersionProps ( IEnumerable < DependencyDetail > dependencies , XmlDocument versionProps , out Task < HashSet < string > > utilizedDependencies ) { HashSet < string > utilizedSet = new HashSet < string > ( ) ; bool result = true ; foreach ( var dependency in dependencies ) { string versionElementName = VersionFiles . GetVersionPropsPackageVersionElementName ( dependency . Name ) ; string alternateVersionElementName = VersionFiles . GetVersionPropsAlternatePackageVersionElementName ( dependency . Name ) ; XmlNode versionNode = versionProps . DocumentElement . SelectSingleNode ( $" //*[local-name()=' { versionElementName } '] " ) ; if ( versionNode == null ) { versionNode = versionProps . DocumentElement . SelectSingleNode ( $" ////*[local-name()=' { alternateVersionElementName } '] " ) ; } if ( versionNode != null ) { if ( versionNode . Name != versionElementName ) { _logger . LogError ( $" The dependency ' { dependency . Name } ' has a case mismatch between  " + $" ' { VersionFiles . VersionProps } ' and ' { VersionFiles . VersionDetailsXml } '  " + $" (' { versionNode . Name } ' vs. ' { versionElementName } ') " ) ; result = false ; } if ( versionNode . InnerText != dependency . Version ) { _logger . LogError ( $" The dependency ' { dependency . Name } ' has a version mismatch between  " + $" ' { VersionFiles . VersionProps } ' and ' { VersionFiles . VersionDetailsXml } '  " + $" (' { versionNode . InnerText } ' vs. ' { dependency . Version } ') " ) ; result = false ; } utilizedSet . Add ( dependency . Name ) ; } } utilizedDependencies = Task . FromResult ( utilizedSet ) ; return Task . FromResult ( result ) ; }
Verify that any dependency that exists in both Version.props and Version.Details.xml has matching version numbers.
Verify that any dependency that exists in both Version . props and Version . Details . xml has matching version numbers .
// Validate that the casing matches for consistency // Validate innner version matches
None
dependencies
IEnumerable<DependencyDetail>
Parsed dependencies in the repository.
Parsed dependencies in the repository .
versionProps
XmlDocument
Parsed version props file
Parsed version props file
Task<HashSet<string>>
out