Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Report diagnostics in generator #158

Merged

Conversation

elinor-fung
Copy link
Member

@elinor-fung elinor-fung commented Oct 9, 2020

  • Add two diagnostic IDs:
    • DLLIMPORTGEN001: TypeNotSupported
      • We don't have a marshalling generator for the parameter/return type and it has no specific marshalling configuration
    • DLLIMPORTGEN002: ConfigurationNotSupported
      • We don't have a marshalling generator for the parameter/return type and it has some marshalling configuration (MarshalAs)
      • We don't support a specified field or specified value for some marshalling configuration
  • Add GeneratorDiagnostics for use by all stub generation to report diagnostics if necessary
  • Add / update tests
    • The Diagnostics tests use of the DiagnosticResult from the analyzer testing infrastructure for convenience
    • A bunch of the existing Compiles tests now have diagnostics. I have split them into two groups (NoDiagnostics and WithDiagnostics) for now - as we add support for types and different marshalling configurations, they should eventually all become NoDiagnostics
  • Add doc listing currently reported diagnostics

This doesn't deal with all the TODOs we have for reporting diagnostics, but there is now a place to put / report them all.

cc @AaronRobinsonMSFT @jkoritzinsky

Copy link
Member

@AaronRobinsonMSFT AaronRobinsonMSFT left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few comments. Overall it looks good.

@AaronRobinsonMSFT AaronRobinsonMSFT added the area-DllImportGenerator Source Generated stubs for P/Invokes in C# label Oct 9, 2020
Split basic compile tests into with/without diagnostics. As we add
support for different types / configuration, the appropriate snippets
can be moved from expecting diagnostics to not expecting diagnostics.

Enable emitting generated files in demo project.
Update README to point out emitting generated source to disk
Make Compiles test check that all reported diagnostics are DLLIMPORTGEN

Add doc listing diagnostics reported by the P/Invoke source generator
@elinor-fung elinor-fung merged commit 98f55be into dotnet:DllImportGenerator Oct 10, 2020
@elinor-fung elinor-fung deleted the generatorDiagnostics branch October 10, 2020 00:31
jkoritzinsky pushed a commit to jkoritzinsky/runtime that referenced this pull request Sep 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-DllImportGenerator Source Generated stubs for P/Invokes in C#
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants