Add optional warnings for windows-bindgen
to improve diagnostics
#3498
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This adds the ability to retrieve any warnings that the
bindgen
function may decide to collect and return as part of code generation that may or may not be an error depending on the context. For example, let's say you're callingbindgen
as follows from your build script:All goes well until you realize that the
IPersistFile.Load
method was omitted due to a missing dependency. This may or may not be what you wanted. If not, it can be quite tedious to chase down all of the missing dependencies for a larger filter that may span multiple interfaces with many dozens or even hundreds of methods.Fortunately,
windows-bindgen
can gather these up and return this information for you:The resulting
Warnings
type is just a collection of strings. It also provides a convenientunwrap
method to make your build scripts a bit more concise if you prefer:Either way, here's what the panic message contains:
You can then decide to add
STGM
to your filter and theLoad
method will be generated and the "warning" disappears:The solution is generic enough that other warnings can conceivably be added in future. And no you can't turn off some warnings. 🙃 Use it for diagnostics and then turn it off if you'd like to skip some but not all methods. For anything more elaborate, feel free to enumerate the warnings yourself.