From dc24a842f0b0b1124554dba2cbf2b7e20549616f Mon Sep 17 00:00:00 2001 From: Rafael Rivera Date: Wed, 28 Aug 2024 21:34:19 -0700 Subject: [PATCH] Remove StructSizeField from BLOB, BSTRBLOB --- generation/WinSDK/emitter.settings.rsp | 2 ++ scripts/ChangesSinceLastRelease.txt | 3 ++ .../MetadataSyntaxTreeCleaner.cs | 30 +++++++++---------- 3 files changed, 20 insertions(+), 15 deletions(-) diff --git a/generation/WinSDK/emitter.settings.rsp b/generation/WinSDK/emitter.settings.rsp index d6c5d246..0cb5afbf 100644 --- a/generation/WinSDK/emitter.settings.rsp +++ b/generation/WinSDK/emitter.settings.rsp @@ -1871,3 +1871,5 @@ StartServiceCtrlDispatcherA::lpServiceStartTable=[NativeArrayInfo] StartServiceCtrlDispatcherW::lpServiceStartTable=[NativeArrayInfo] PMPRADMINCONNECTIONHANGUPNOTIFICATION3::param3=RAS_CONNECTION_3* DEVPROPKEY=[AlsoUsableFor("PROPERTYKEY")] +BLOB=[-StructSizeField] +BSTRBLOB=[-StructSizeField] diff --git a/scripts/ChangesSinceLastRelease.txt b/scripts/ChangesSinceLastRelease.txt index 83c9a0f1..5d535437 100644 --- a/scripts/ChangesSinceLastRelease.txt +++ b/scripts/ChangesSinceLastRelease.txt @@ -2589,3 +2589,6 @@ Windows.Win32.System.Ioctl.Apis.DEVPKEY_Storage_Portable...Windows.Win32.Devices Windows.Win32.System.Ioctl.Apis.DEVPKEY_Storage_Removable_Media...Windows.Win32.Devices.Properties.DEVPROPKEY => Windows.Win32.Foundation.DEVPROPKEY Windows.Win32.System.Ioctl.Apis.DEVPKEY_Storage_System_Critical...Windows.Win32.Devices.Properties.DEVPROPKEY => Windows.Win32.Foundation.DEVPROPKEY Windows.Win32.System.Power.Apis.PROCESSOR_NUMBER_PKEY...Windows.Win32.Devices.Properties.DEVPROPKEY => Windows.Win32.Foundation.DEVPROPKEY +# Remove StructSizeField from BLOB, BSTRBLOB +Windows.Win32.System.Com.BLOB : [Documentation(https://learn.microsoft.com/windows/win32/api/nspapi/ns-nspapi-blob),StructSizeField(cbSize)] => [Documentation(https://learn.microsoft.com/windows/win32/api/nspapi/ns-nspapi-blob)] +Windows.Win32.System.Com.StructuredStorage.BSTRBLOB : [StructSizeField(cbSize)] => \ No newline at end of file diff --git a/sources/ClangSharpSourceToWinmd/MetadataSyntaxTreeCleaner.cs b/sources/ClangSharpSourceToWinmd/MetadataSyntaxTreeCleaner.cs index fad7e882..47ed2e27 100644 --- a/sources/ClangSharpSourceToWinmd/MetadataSyntaxTreeCleaner.cs +++ b/sources/ClangSharpSourceToWinmd/MetadataSyntaxTreeCleaner.cs @@ -219,21 +219,6 @@ public override SyntaxNode VisitStructDeclaration(StructDeclarationSyntax node) node = node.AddAttributeLists(attributeList); } - if (this.GetRemapInfo(fullName, node.AttributeLists, out var listAttributes, null, out _, out string newName)) - { - node = (StructDeclarationSyntax)base.VisitStructDeclaration(node); - node = node.WithAttributeLists(FixRemappedAttributes(node.AttributeLists, listAttributes)); - - if (newName != null) - { - node = node.WithIdentifier(SyntaxFactory.Identifier(newName)); - } - } - else - { - node = (StructDeclarationSyntax)base.VisitStructDeclaration(node); - } - foreach (var member in node.Members) { if (!(member is FieldDeclarationSyntax)) @@ -254,6 +239,21 @@ public override SyntaxNode VisitStructDeclaration(StructDeclarationSyntax node) } } + if (this.GetRemapInfo(fullName, node.AttributeLists, out var listAttributes, null, out _, out string newName)) + { + node = (StructDeclarationSyntax)base.VisitStructDeclaration(node); + node = node.WithAttributeLists(FixRemappedAttributes(node.AttributeLists, listAttributes)); + + if (newName != null) + { + node = node.WithIdentifier(SyntaxFactory.Identifier(newName)); + } + } + else + { + node = (StructDeclarationSyntax)base.VisitStructDeclaration(node); + } + return node; }