Skip to content

Fix ELEMDESC native interop definition #896

@weltkante

Description

@weltkante

This is a follow-up issue to PR #818 where it was noted (link to comment) that the definition of ELEMDESC that WinForms uses seems to be wrong.

Currently the definition is embedding the TYPEDESC by reference (it was a class before, so the interop rules should already have been embedding it as a pointer before PR #818)

public unsafe struct tagELEMDESC {
    public NativeMethods.tagTYPEDESC* tdesc;
    public NativeMethods.tagPARAMDESC paramdesc;
}

while the definition of ELEMDESC and TYPEDESC on msdn is

typedef struct tagELEMDESC {
  TYPEDESC tdesc;
  PARAMDESC paramdesc;
} ELEMDESC, *LPELEMDESC;

typedef struct tagTYPEDESC {
  union {
    struct tagTYPEDESC  *lptdesc;
    struct tagARRAYDESC *lpadesc;
    HREFTYPE            hreftype;
  } DUMMYUNIONNAME;
  VARTYPE vt;
} TYPEDESC;

Notes taken from the previous discussion in the PR

  • @sharwell wants to have tests to make sure nothing breaks, because fixing this likely requires also correcting all usage of ELEMDESC in WinForms
  • @zsd4yr suggests taking a look into the old source control system to see if there's any history to the definition explaining the way it is
  • @JeremyKuhne suggests using the version in System.Runtime.InteropServices.ComTypes - note that this still requires reviewing and adjusting callers in WinForms which previously used the broken version

Metadata

Metadata

Assignees

No one assigned

    Labels

    🪲 bugProduct bug (most likely)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions