Skip to content

Improved error message to help diagnose invalid winmd files #351

Merged
kennykerr merged 2 commits into
masterfrom
kennykerr-diag
Apr 24, 2019
Merged

Improved error message to help diagnose invalid winmd files #351
kennykerr merged 2 commits into
masterfrom
kennykerr-diag

Conversation

@kennykerr

Copy link
Copy Markdown
Contributor

This is a small targeted improvement to the diagnostics produced by cppwinrt.exe to help apply the blame accurately when encountering types in a winmd that use non-WinRT types in an ABI context. For example, given this invalid C++/CX code (that sadly compiles):

namespace BadCppCxComponent
{
    public ref struct Class sealed
    {
        Class()
        {
        }

        Platform::Type^ GetInvalidType()
        {
            return nullptr;
        }
    };
}

The cppwinrt compiler now produces a more helpful diagnostic pinpointing the source of the problem:

C:\scratch>cppwinrt.exe -in BadCppCxComponent.winmd
 error: Type 'System.Type' could not be found
 method: GetInvalidType
 type: BadCppCxComponent.__IClassPublicNonVirtuals
 database: C:\scratch\BadCppCxComponent.winmd

Given a large winmd with hundreds of types, this can make a world of difference.

@DefaultRyan

Copy link
Copy Markdown
Member

Nice. The other place where this sort of thing frequently seems to comes up is when trying to resolve base types. Any chance of adding an improved diagnostic there as well?

@kennykerr

Copy link
Copy Markdown
Contributor Author

Thanks Ryan, send me the repro steps for that scenario I can certainly add something to help diagnose.

@kennykerr kennykerr merged commit 13f43d0 into master Apr 24, 2019
@kennykerr kennykerr deleted the kennykerr-diag branch April 24, 2019 19:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants