Skip to content

Trim whitespace when parsing <TraverseFiles> contents? #1838

@MarijnS95

Description

@MarijnS95

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions