microsoft / win32metadata

Tooling to generate metadata for Win32 APIs in the Windows SDK.
Other
1.34k stars 116 forks source link

Trim whitespace when parsing `<TraverseFiles>` contents? #1838

Open MarijnS95 opened 9 months ago

MarijnS95 commented 9 months ago

For https://github.com/Tsukisoft/direct-storage-rs/pull/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?

https://github.com/microsoft/win32metadata/blob/3d2ba1e501e46f078e4b4670a52ed68890870f8a/sources/GeneratorSdk/MetadataTasks/ScrapeHeaders.cs#L476-L488

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 commented 2 months ago

@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 commented 2 months ago

@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!