-
Notifications
You must be signed in to change notification settings - Fork 524
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
windows-bindgen: functions not generated from winmd after upgrade to 0.57 #3100
Comments
This is likely related to #2735 and is by design. |
@kennykerr This does not happen for 0.56 but only in 0.57. Seems to be not caused from the commit you mentioned. This caused those functions not generated and not accessible. |
Taking this winmd file: https://github.com/Azure/service-fabric-metadata/blob/main/.windows/winmd/Microsoft.ServiceFabric.winmd I see the definition for [Guid(2216108223u, 51688, 20079, 156, 63, 107, 127, 74, 199, 59, 205)]
[Agile]
public interface IFabricAsyncOperationContext : IUnknown
{
BOOLEAN IsCompleted();
BOOLEAN CompletedSynchronously();
[SpecialName]
unsafe HRESULT get_Callback([Out][RetVal] IFabricAsyncOperationCallback* callback);
HRESULT Cancel();
} And running this command: [dependencies.windows-bindgen]
version = "0.57" fn main() {
windows_bindgen::bindgen([
"--in",
"/git/Microsoft.ServiceFabric.winmd",
"--out",
"src/bindings.rs",
"--filter",
"Microsoft",
"--config",
"implement",
])
.unwrap();
} This generates bindings that includes: impl IFabricAsyncOperationContext {
pub unsafe fn IsCompleted(&self) -> windows::Win32::Foundation::BOOLEAN {
(windows_core::Interface::vtable(self).IsCompleted)(
windows_core::Interface::as_raw(self),
)
}
pub unsafe fn CompletedSynchronously(&self) -> windows::Win32::Foundation::BOOLEAN {
(windows_core::Interface::vtable(self).CompletedSynchronously)(
windows_core::Interface::as_raw(self),
)
}
pub unsafe fn Callback(&self) -> windows_core::Result<IFabricAsyncOperationCallback> {
let mut result__ = core::mem::zeroed();
(windows_core::Interface::vtable(self).Callback)(
windows_core::Interface::as_raw(self),
&mut result__,
)
.and_then(|| windows_core::Type::from_abi(result__))
}
pub unsafe fn Cancel(&self) -> windows_core::Result<()> {
(windows_core::Interface::vtable(self).Cancel)(windows_core::Interface::as_raw(
self,
))
.ok()
}
} Compiling the bindings with the following dependencies seems to work fine: [dependencies.windows]
version = "0.57"
features = [
"Win32_Foundation",
]
[dependencies.windows-core]
version = "0.57" In future, please include a repro of this sort. That being said, what's missing? |
Bindgen config=implement generates correct functions.
package=true generates the code with functions missing in this issue. |
Ah, the |
windows-rs version 0.57 has various improvements for generated com bindings and the code size reduces. We have been using win-bindgen with config=package, which is not publicly supported, and we are advised to switch to config=implement that is supported external to windows-rs. See microsoft/windows-rs#3100 for details. The generated code are reorganized due to the generation config mode, and the mod structures are remapped so that there is no unwanted nesting of mods, for example, FabricRuntime is no longer inside FabricCommon but they are siblings now. The generation of the code and remapping of the mods are still hacky, and we still need Azure/service-fabric-metadata#1 to improve this. Previously all mods are generated once, but now, each mod like FabricCommon and FabricRuntime is generated separately from the winmd file per pass. The generation speed maybe slowed but in practice it is not observable. This upgrade will cause break in down stream because of the mod layout change. But it is easy to fix: just change the imports(use) with different path.
Summary
After upgrading to version 0.57, functions previously marked with feature "Win32_Foundation" no longer exists. The function refers to the type windows::Win32::Foundation::BOOLEAN.
See: Azure/service-fabric-rs#38 for example.
Crate manifest
No response
Crate code
No response
The text was updated successfully, but these errors were encountered: