Actual behavior
CsWin32 generates invalid code for some friendly methods, interfaces, and delegates in the Windows.Win32.CsWin32.UI.Accessibility namespace when "allowMarshaling": true in the NativeMethods.json file. The repro below produces 1163 errors in the Error List in the Visual Studio Preview.
Expected behavior
CsWin32 should be able to generate valid code for the UI.Accessibility members and types with "allowMarshaling": true so it will generate interfaces rather than structs.
Repro steps
NativeMethods.txt content:
LPFNACCESSIBLECHILDREN
LPFNACCESSIBLEOBJECTFROMPOINT
IAnnotationProvider
ISelectionProvider2
IStylesProvider
IUIAutomation
IUIAutomation2
IUIAutomation3
IUIAutomation4
IUIAutomation5
IUIAutomation6
IUIAutomationActiveTextPositionChangedEventHandler
IUIAutomationAnnotationPattern
IUIAutomationBoolCondition
IUIAutomationChangesEventHandler
IUIAutomationCustomNavigationPattern
IUIAutomationDragPattern
IUIAutomationElement
IUIAutomationElement2
IUIAutomationElement3
IUIAutomationElement4
IUIAutomationElement5
IUIAutomationElement6
IUIAutomationElement7
IUIAutomationElement8
IUIAutomationElement9
IUIAutomationElementArray
IUIAutomationEventHandler
IUIAutomationEventHandlerGroup
IUIAutomationFocusChangedEventHandler
IUIAutomationGridItemPattern
IUIAutomationGridPattern
IUIAutomationItemContainerPattern
IUIAutomationLegacyIAccessiblePattern
IUIAutomationMultipleViewPattern
IUIAutomationNotificationEventHandler
IUIAutomationObjectModelPattern
IUIAutomationPropertyChangedEventHandler
IUIAutomationRangeValuePattern
IUIAutomationScrollPattern
IUIAutomationSelectionItemPattern
IUIAutomationSelectionPattern
IUIAutomationSelectionPattern2
IUIAutomationSpreadsheetItemPattern
IUIAutomationSpreadsheetPattern
IUIAutomationStructureChangedEventHandler
IUIAutomationStylesPattern
IUIAutomationTableItemPattern
IUIAutomationTablePattern
IUIAutomationTextChildPattern
IUIAutomationTextEditPattern
IUIAutomationTextEditTextChangedEventHandler
IUIAutomationTextPattern
IUIAutomationTextPattern2
IUIAutomationTextRange
IUIAutomationTextRange2
IUIAutomationTextRange3
IUIAutomationTextRangeArray
IUIAutomationTransformPattern2
IUIAutomationTreeWalker
NativeMethods.json content (if present):
{
"$schema": "https://aka.ms/CsWin32.schema.json",
"allowMarshaling": true,
"className": "PInvoke",
"comInterop": {
"preserveSig": true,
"preserveSigMethods": [
"*"
],
"useComSourceGenerators": null
},
"emitSingleFile": false,
"extensionReceiver": "PInvokeExtensions",
"friendlyOverloads": {
"enabled": true,
"includePointerOverloads": true,
"comOutPtrGenericOverloads": true
},
"public": true,
"useSafeHandles": true,
"wideCharOnly": true
}
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net11.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<PublishAot>true</PublishAot>
<ImplicitUsings>enable</ImplicitUsings>
<EnablePreviewFeatures>true</EnablePreviewFeatures>
<InvariantGlobalization>true</InvariantGlobalization>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<CsWin32RunAsBuildTask>true</CsWin32RunAsBuildTask>
<BuiltInComInteropSupport>true</BuiltInComInteropSupport>
<DisableRuntimeMarshalling>true</DisableRuntimeMarshalling>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Windows.CsWin32" Version="0.3.298">
<PrivateAssets>all</PrivateAssets>
<!--
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
-->
</PackageReference>
</ItemGroup>
</Project>
- Any of your own code that should be shared?
Context
- CsWin32 version: 0.3.298
- Win32Metadata version: 70.0.11-preview
- Target Framework: net11.0
LangVersion: preview
Actual behavior
CsWin32 generates invalid code for some friendly methods, interfaces, and delegates in the Windows.Win32.CsWin32.UI.Accessibility namespace when
"allowMarshaling": truein the NativeMethods.json file. The repro below produces 1163 errors in the Error List in the Visual Studio Preview.Expected behavior
CsWin32 should be able to generate valid code for the UI.Accessibility members and types with
"allowMarshaling": trueso it will generate interfaces rather than structs.Repro steps
NativeMethods.txtcontent:NativeMethods.jsoncontent (if present):{ "$schema": "https://aka.ms/CsWin32.schema.json", "allowMarshaling": true, "className": "PInvoke", "comInterop": { "preserveSig": true, "preserveSigMethods": [ "*" ], "useComSourceGenerators": null }, "emitSingleFile": false, "extensionReceiver": "PInvokeExtensions", "friendlyOverloads": { "enabled": true, "includePointerOverloads": true, "comOutPtrGenericOverloads": true }, "public": true, "useSafeHandles": true, "wideCharOnly": true }Context
LangVersion: preview