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

Implement support for configurable generator options. #458

Merged

Conversation

jkoritzinsky
Copy link
Member

Implement support for a "forwarder" mode and implement an option to emit references to the Marshal type when the MarshalEx type is requested to support perf testing and integration with dotnet/runtime respectively.

Uses https://github.com/dotnet/roslyn/blob/master/docs/features/source-generators.cookbook.md#consume-msbuild-properties-and-metadata as the basis for the feature.

The DllImportGenerator_UseMarshalType MSBuild property changes usages of the MarshalEx type to be the Marshal type.

The DllImportGenerator_GenerateForwarders MSBuild property causes the generator to emit functions that forward to built-in P/Invoke stubs instead of handling the marshalling in the generated code.

Signed-off-by: Jeremy Koritzinsky <jekoritz@microsoft.com>
{
public static class OptionsHelper
{
public const string UseMarshalTypeOption = "build_property.DllImportGenerator_UseMarshalType";
Copy link
Member

Choose a reason for hiding this comment

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

If this can be private please mark them as such.

Copy link
Member Author

Choose a reason for hiding this comment

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

These are public so the tests can access them.

@jkoritzinsky jkoritzinsky merged commit 9649d43 into dotnet:feature/DllImportGenerator Jan 4, 2021
@jkoritzinsky jkoritzinsky deleted the msbuild-options branch January 4, 2021 20:28
jkoritzinsky added 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