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

Emit helpful error when a NativeMethods.txt request with no match contains unexpected non-ANSI characters #392

Closed
AliveDevil opened this issue Sep 15, 2021 · 3 comments · Fixed by #548
Assignees
Labels
enhancement New feature or request

Comments

@AliveDevil
Copy link

Actual behavior

Adding

SHGetKnownFolderItem

NativeMethods.txt fails with

warning PInvoke001: Method, type or constant "SHGet­Known­Folder­Item" not found.

Using Shell32.* does generate SHGetKnownFolderItem correctly.

Expected behavior

SHGetKnownFolderItem is generated the same as it is with Shell32.*.

Repro steps

  1. NativeMethods.txt content:
SHGetKnownFolderItem

Context

  • CsWin32 version: 0.1.560-beta
  • Target Framework: net5.0-windows10.0.17763.0
@AliveDevil AliveDevil added the bug Something isn't working label Sep 15, 2021
@AArnott
Copy link
Member

AArnott commented Sep 15, 2021

It works for me.

There is something wrong with your e.
Copy and paste SHGet­Known­Folder­Item from this very sentence and search for it with your browser. On mine it only match 3 times in your issue description.
Now copy and paste SHGetKnownFolderItem from this very sentence and search for it with your browser. On mine it matches 5 times in your issue description.

Visually I can't see what's wrong. But I suggest you re-type the method name yourself into your NativeMethods.txt file (or copy-paste it from here: SHGetKnownFolderItem) and I expect it will work for you.

You may have some weird unicode character for or around your e.

@AliveDevil
Copy link
Author

AliveDevil commented Sep 15, 2021

It's not around the "e", its basically SH <Soft Hyphen> Get <Soft Hyphen> Known <Soft Hyphen> Folder <Soft Hyphen> Item. (0xAD, ASCII). I'm unsure where I got that string from, though. I just tried Microsoft-docs and it works with copy&paste there without issue. Strange. Yeah, Chromium is the culprit for even including the soft hyphen in the first place: https://bugs.chromium.org/p/chromium/issues/detail?id=767950

Eventually some better output for hidden unicode characters scrambling the input?

@AArnott
Copy link
Member

AArnott commented Sep 15, 2021

Sure. I recently learned that function names are limited to the ANSI charset. Or at least, GetProcAddress never won a W variant. Emitting a guiding error about unexpected characters being there sounds like a good idea, as I doubt you're the only one who will hit this.

@AArnott AArnott added enhancement New feature or request and removed bug Something isn't working labels Sep 15, 2021
@AArnott AArnott changed the title SHGetFolderKnownItem is not generated if added explicitely Emit helpful error when a NativeMethods.txt request with no match contains unexpected non-ANSI characters Sep 15, 2021
@AArnott AArnott self-assigned this May 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants