Skip to content

Commit

Permalink
Merge pull request #175 from microsoft/fix49
Browse files Browse the repository at this point in the history
Fix doc collection for structs ending in 32 or 64
  • Loading branch information
AArnott committed Mar 9, 2021
2 parents 9c8668d + 0a39b6c commit d614da8
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/ScrapeDocs/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -307,13 +307,13 @@ private void Worker(CancellationToken cancellationToken)
}

YamlSequenceNode methodNames = (YamlSequenceNode)yaml.Documents[0].RootNode["api_name"];
bool TryGetProperName(string searchFor, char? suffix, [NotNullWhen(true)] out string? match)
bool TryGetProperName(string searchFor, string? suffix, [NotNullWhen(true)] out string? match)
{
if (suffix.HasValue)
if (suffix is string)
{
if (searchFor.EndsWith(suffix.Value))
if (searchFor.EndsWith(suffix, StringComparison.Ordinal))
{
searchFor = searchFor.Substring(0, searchFor.Length - 1);
searchFor = searchFor.Substring(0, searchFor.Length - suffix.Length);
}
else
{
Expand All @@ -324,9 +324,9 @@ bool TryGetProperName(string searchFor, char? suffix, [NotNullWhen(true)] out st

match = methodNames.Children.Cast<YamlScalarNode>().FirstOrDefault(c => string.Equals(c.Value?.Replace('.', '-'), searchFor, StringComparison.OrdinalIgnoreCase))?.Value;

if (suffix.HasValue && match is object)
if (suffix is string && match is object)
{
match += char.ToUpper(suffix.Value, CultureInfo.InvariantCulture);
match += suffix.ToUpper(CultureInfo.InvariantCulture);
}

return match is object;
Expand All @@ -336,8 +336,10 @@ bool TryGetProperName(string searchFor, char? suffix, [NotNullWhen(true)] out st

// Some structures have filenames that include the W or A suffix when the content doesn't. So try some fuzzy matching.
if (!TryGetProperName(presumedMethodName, null, out string? properName) &&
!TryGetProperName(presumedMethodName, 'a', out properName) &&
!TryGetProperName(presumedMethodName, 'w', out properName))
!TryGetProperName(presumedMethodName, "a", out properName) &&
!TryGetProperName(presumedMethodName, "w", out properName) &&
!TryGetProperName(presumedMethodName, "32", out properName) &&
!TryGetProperName(presumedMethodName, "64", out properName))
{
Debug.WriteLine("WARNING: Could not find proper API name in: {0}", filePath);
return null;
Expand Down

0 comments on commit d614da8

Please sign in to comment.