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

Don't generate Unmanaged-to-Managed stubs with diagnostics #88679

Merged
merged 5 commits into from
Jul 13, 2023

Conversation

jkoritzinsky
Copy link
Member

This PR disables our "partial generation" feature for the unmanaged->managed stubs. The partial generation generates many invalid [UnmanagedCallersOnly] method signatures, which causes compiler errors. By disabling the generation, we ensure that the source-generated code doesn't produce any compiler errors itself.

Fixes #82581

…kip generation of the wrappers if we have any diagnostics.
@jkoritzinsky jkoritzinsky added this to the 8.0.0 milestone Jul 11, 2023
@jkoritzinsky jkoritzinsky added area-System.Runtime.InteropServices source-generator Indicates an issue with a source generator feature labels Jul 11, 2023
@ghost ghost assigned jkoritzinsky Jul 11, 2023
@ghost
Copy link

ghost commented Jul 11, 2023

Tagging subscribers to this area: @dotnet/interop-contrib
See info in area-owners.md if you want to be subscribed.

Issue Details

This PR disables our "partial generation" feature for the unmanaged->managed stubs. The partial generation generates many invalid [UnmanagedCallersOnly] method signatures, which causes compiler errors. By disabling the generation, we ensure that the source-generated code doesn't produce any compiler errors itself.

Fixes #82581

Author: jkoritzinsky
Assignees: -
Labels:

area-System.Runtime.InteropServices, source-generator

Milestone: 8.0.0

@jtschuster
Copy link
Member

Should we change all the warnings that would produce invalid code to be errors instead? IIRC one of the warnings looks like "This parameter type is not supported. Generated code won't handle marshaling this parameter." I think it would be confusing if this warning meant that the function pointer in the VTable would be null.

@jkoritzinsky
Copy link
Member Author

Should we change all the warnings that would produce invalid code to be errors instead? IIRC one of the warnings looks like "This parameter type is not supported. Generated code won't handle marshaling this parameter." I think it would be confusing if this warning meant that the function pointer in the VTable would be null.

They already are errors. We have very few warnings generated by the generator nowadays.

@jkoritzinsky
Copy link
Member Author

Failures are unrelated.

@jkoritzinsky jkoritzinsky merged commit e0acb9d into dotnet:main Jul 13, 2023
@jkoritzinsky jkoritzinsky deleted the no-invalid-uco branch July 13, 2023 16:10
@ghost ghost locked as resolved and limited conversation to collaborators Aug 13, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-System.Runtime.InteropServices source-generator Indicates an issue with a source generator feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ComInterfaceGenerator emits method attributed with [UnmanagedCallersOnly] and in out or ref parameters.
3 participants