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

MethodCallingConvention lacks entry for "default unmanaged calling convention" #842

Closed
Zastai opened this issue Feb 27, 2022 · 3 comments · Fixed by #852
Closed

MethodCallingConvention lacks entry for "default unmanaged calling convention" #842

Zastai opened this issue Feb 27, 2022 · 3 comments · Fixed by #852

Comments

@Zastai
Copy link
Contributor

Zastai commented Feb 27, 2022

When using a function pointer in C#, the following syntax is available, with corresponding calling convention values:

  delegate* managed<type, ..., return-type> // same as leaving off the "managed"; value = 0
  delegate* unmanaged<type, ..., return-type> // means "use the default unmanaged calling convention for the platform; value 9
  delegate* unmanaged[Cdecl]<type, ..., return-type> // cdecl; value 1
  delegate* unmanaged[Fastcall]<type, ..., return-type> // cdecl; value 4
  delegate* unmanaged[Stdcall]<type, ..., return-type> // cdecl; value 2
  delegate* unmanaged[Thiscall]<type, ..., return-type> // cdecl; value 3
  delegate* unmanaged[xxx, yyy, ...]<type, ..., return-type> // also uses 9, and adds modopts to the return type for the listed conventions

So the "unmanaged without explicit calling convention" case currently does not have a name in the enum yet.

Suggested name: DefaultUnmanaged (I'd prefer Default with the current Default becoming Managed, because all values other than 0 imply unmanaged calls, but that's an API break).

(I can't find anything that suggests the enum values VarArg and Generic are usable in C# (perhaps they are a Mono-only thing?).)

@Zastai
Copy link
Contributor Author

Zastai commented Feb 27, 2022

Ah I see here that default is used in CallKind for the "managed" case, so that's fine. And it also lists varargs as specifically unsupported by C#.

So the entry needed is for what is called unmanaged ext in that section. Unmanaged or DefaultUnmanaged seem like decent choices then.

@Zastai
Copy link
Contributor Author

Zastai commented Feb 27, 2022

Oh, looks like the canonical name is Unmanaged: dotnet/runtime#38133

@Zastai
Copy link
Contributor Author

Zastai commented Feb 27, 2022

Wish MS was better at documenting things properly in one place once a language proposal is accepted.

Zastai added a commit to Zastai/cecil that referenced this issue Jun 8, 2022
Zastai added a commit to Zastai/cecil that referenced this issue Jun 8, 2022
jbevain pushed a commit that referenced this issue Jun 15, 2022
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 a pull request may close this issue.

1 participant