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

Adds a 'preview-codegen' config option #123

Merged
merged 4 commits into from
Apr 16, 2020

Conversation

tannergooding
Copy link
Member

This adds a 'preview-codegen' config option that can be used to generate code compatible with the latest C# Preview Compiler. For example, it supports this PR allows it to use the nint/nuint types and function pointers.

nameBuilder.Append("delegate");
nameBuilder.Append('*');
nameBuilder.Append(' ');
nameBuilder.Append((callConv != "winapi") ? callConv : "unmanaged");
Copy link
Member

Choose a reason for hiding this comment

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

Unmanaged is not currently supported, this will fail.

Copy link
Member Author

Choose a reason for hiding this comment

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

I might just keep this for now since its a preview feature and the code will get flagged in the compilation.
We have a few cases where the generated code isn't quite right and where devs may need to manually fixup or adjust the generated code.
They can workaround it by passing in the --with-callconv RemappedName=CallConv arg on the command line

Copy link
Member

Choose a reason for hiding this comment

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

Alright, but it's going to be weird when people get a CS8XXX for this.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll adjust if the language ends up not allowing the keyword in the final implementation. It also shouldn't be hit today unless they are targeting something using a non-standard calling convention.

This case will already print a Unsupported calling convention diagnostic since it isn't something we can support for P/Invoke calls or Delegates w/ UnmanagedFunctionPointerAttribute: https://github.com/microsoft/ClangSharp/blob/master/sources/ClangSharp.PInvokeGenerator/PInvokeGenerator.cs#L560

@tannergooding tannergooding merged commit 9fbfa57 into dotnet:master Apr 16, 2020
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.

3 participants