visual-studiotypelib

Visual Studio 2022 generates invalid syntax from typelib


I used the Project > Add New Item tool in Visual Studio 2022 and selected MFC Class From TypeLib. In the dialog which appeared, I selected "File" from the Implement interface from dropdown list and in the Location field I entered the path to the .tlb file from a third-party package. I selected a handful of interfaces to be used and clicked the OK button to confirm the request. Most of the code generated was as it should be, but in a few places the definitions contained invalid syntax caused by a missing argument specifier. For example:

    LPUNKNOWN get_FX()
    {
        LPUNKNOWN result;
        InvokeHelper(0xa, DISPATCH_PROPERTYGET, , (void*)&result, nullptr);
        return result;
    }

Note the single space character between the two otherwise adjacent commas.

Visual Studio itself recognizes there's a problem with what it has generated when it tries to compile the resulting code.

C2059 syntax error: ','

I have confirmed this behavior with earlier versions of the IDE. Is this a known bug in Visual Studio?


Solution

  • Apologies for not closing the loop sooner. I filed a bug report with Microsoft, and they fixed the bug last month in Visual Studio 2022 version 17.6.