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 · 2 comments · May be fixed by #1992
Open

Trim whitespace when parsing <TraverseFiles> contents? #1838

MarijnS95 opened this issue Jan 29, 2024 · 2 comments · May be fixed by #1992

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.

@riverar
Copy link
Collaborator

riverar commented Aug 30, 2024

@MarijnS95 Did this one already get merged as part of a separate PR? If not, maybe a tiny one we can get in to close this out.

@MarijnS95
Copy link
Contributor Author

@riverar no it did not (and it took me to do a clean build in the target project to reproduce this). Will open a PR!

MarijnS95 added a commit to MarijnS95/win32metadata that referenced this issue Sep 3, 2024
MarijnS95 added a commit to MarijnS95/win32metadata that referenced this issue Sep 3, 2024
@MarijnS95 MarijnS95 linked a pull request Sep 3, 2024 that will close this issue
MarijnS95 added a commit to MarijnS95/win32metadata that referenced this issue Sep 3, 2024
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

Successfully merging a pull request may close this issue.

2 participants