Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix doc collection for structs ending in 32 or 64 #175

Merged
merged 1 commit into from
Mar 9, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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