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

Trim whitespace when parsing <TraverseFiles> contents? #1838

Open
MarijnS95 opened this issue Jan 29, 2024 · 0 comments
Open

Trim whitespace when parsing <TraverseFiles> contents? #1838

MarijnS95 opened this issue Jan 29, 2024 · 0 comments

Comments

@MarijnS95
Copy link
Contributor

For Tsukisoft/direct-storage-rs#5

We had a list of the form:

            <TraverseFiles>
                $(PkgMicrosoft_Direct3D_DirectStorage)\native\include\dstorage.h;
                $(PkgMicrosoft_Direct3D_DirectStorage)\native\include\dstorageerr.h
            </TraverseFiles>

But no constants from dstorageerr.h were parsed. Swapping the filenames makes it so that #defines from dstorage.h are lost, but defines from dstorageerr.h are parsed.

I believe the raw string it's parsing here is: dstorage.h;\ndstorageerr.h\n, splitting this on ; causes the last filename to never match. Perhaps a string item = items[i].Trim(); is missing here to make multiline filename strings work more naturally?

private string[] GetFilesFromMetadata(ITaskItem item, string name)
{
string[] items = item.GetMetadata(name).Split(';', System.StringSplitOptions.RemoveEmptyEntries);
for (int i = 0; i < items.Length; i++)
{
if (!Path.IsPathRooted(items[i]))
{
items[i] = Path.Combine(this.MSBuildProjectDirectory, items[i]);
}
}
return items;
}

After all, when merging this into one line:

            <TraverseFiles>$(PkgMicrosoft_Direct3D_DirectStorage)\native\include\dstorage.h;$(PkgMicrosoft_Direct3D_DirectStorage)\native\include\dstorageerr.h</TraverseFiles>

Both files were finally parsed correctly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant