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

Generated metadata is missing values #1837

Open
ghilac opened this issue Jan 28, 2024 · 5 comments
Open

Generated metadata is missing values #1837

ghilac opened this issue Jan 28, 2024 · 5 comments

Comments

@ghilac
Copy link

ghilac commented Jan 28, 2024

Hello,

I am trying to generate the winmd metadata for some .h file which has a non-primitive const variable of type PROPERTYKEY (part of the namespace Windows.Win32.UI.Shell.PropertiesSystem) and defined in the wtypes.h file of the Windows SDK.

EXTERN_C const PROPERTYKEY my_prop_key= {{0x89f1fe39, 0x3acc, 0x4b73, 0x88, 0x8d, 0x3f, 0x70, 0xb1, 0x6f, 0x32, 0xac}};
``

I am following the instructions as documented here and these variables are missing from my metadata. Other kids of variables are successfully generated, such as

EXTERN_C const GUID my_guid = {0x89f1fe39, 0x3acc, 0x4b73, 0x88, 0x8d, 0x3f, 0x70, 0xb1, 0x6f, 0x32, 0xac};

What am I doing wrong? Should I add anything specific in the .proj file for this kind of type? I do see properties in the Windows.win32 metadata so I guess it should be possible.

Thanks a lot,

Ghila

@kennykerr
Copy link
Contributor

Looks like the scraper may not be able to parse the constant directly but is hardcoded to only deal with the macros like DEFINE_PROPERTYKEY.

private static readonly Regex DefineGuidConstRegex =
new Regex(
@"^\s*(DEFINE_GUID|DEFINE_DEVPROPKEY|DEFINE_PROPERTYKEY|DEFINE_KNOWN_FOLDER|OUR_GUID_ENTRY)\s*\((.*)");

@kennykerr
Copy link
Contributor

Spoke to @riverar - he's taking a look.

@riverar
Copy link
Collaborator

riverar commented Jan 29, 2024

That's some of the ancillary work to handle edge cases. ClangSharpPInvokeGenerator and related tooling already supports PROPERTYKEY natively.

The property key above (implicit PID of 0) is actually getting parsed correctly. Here's the intermediate output:

[NativeTypeName("const PROPERTYKEY")]
public static readonly PROPERTYKEY my_prop_key = new PROPERTYKEY
{
    fmtid = new Guid(0x89f1fe39, 0x3acc, 0x4b73, 0x88, 0x8d, 0x3f, 0x70, 0xb1, 0x6f, 0x32, 0xac),
};

But it's not making it into the .winmd, which is odd. Investigating that now.

@riverar
Copy link
Collaborator

riverar commented Jan 29, 2024

Related: #1337

I don't know why the tooling goes through the C# tree, grabs the fields, seemingly drops them on the floor, then runs through the headers with regex. But we can fix this up as Kenny suggested.

@ghilac
Copy link
Author

ghilac commented Jan 30, 2024

so is this a bug? I thought I was doing something wrong :) anyway it's not a real blocker for us, I can add these properties manually. but I'd appreciate if you can fix that in the future.
but how did you do that in the windows metadata? I do see property keys in the winmd .

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

3 participants