Skip to content

Invalid Code Generated for CsWin32.UI.Accessibility methods/interfaces/Delegates With "allowMarshaling": true #1745

Description

@Shkyrockett

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

  1. 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
  1. 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>
  1. 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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions