Skip to content

Commit

Permalink
Update incorrect examples.
Browse files Browse the repository at this point in the history
  • Loading branch information
333fred committed Aug 26, 2020
1 parent 3e179c0 commit 3213aa0
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions proposals/csharp-9.0/function-pointers.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ The ECMA-335 definition of method pointers includes the calling convention as pa
The default calling convention will be `managed`. Unmanaged calling conventions can by specified by putting an `unmanaged`
keyword afer the `delegate*` syntax, which will use the runtime platform default. Specific unmanaged conventions can then
be specified in brackets to the `unmanaged` keyword by specifying any type starting with `CallConv` in the
`System.Runtime.CompilerServices` namespace. These types must come from the program's core library, and the set of valid
combinations is platform-dependent.
`System.Runtime.CompilerServices` namespace, leaving off the `CallConv` prefix. These types must come from the program's
core library, and the set of valid combinations is platform-dependent.

``` csharp
//This method has a managed calling convention. This is the same as leaving the managed keyword off.
Expand All @@ -51,10 +51,13 @@ delegate* managed<int, int>;
delegate* unmanaged<int, int>;

// This method will be invoked using the cdecl calling convention
delegate* unmanaged[CallConvCdecl] <int, int>;
// Cdecl maps to System.Runtime.CompilerServices.CallConvCdecl
delegate* unmanaged[Cdecl] <int, int>;

// This method will be invoked using the stdcall calling convention, and suppresses GC transition
delegate* unmanaged[CallConvStdCall, CallConvSuppressGCTransition] <int, int>;
// Stdcall maps to System.Runtime.CompilerServices.CallConvStdcall
// SuppressGCTransition maps to System.Runtime.CompilerServices.CallConvSuppressGCTransition
delegate* unmanaged[Stdcall, SuppressGCTransition] <int, int>;
```

Conversions between `delegate*` types is done based on their signature including the calling convention.
Expand Down

0 comments on commit 3213aa0

Please sign in to comment.