Skip to content

Commit 9023043

Browse files
authored
Update GetDelegateForFunctionPointer docs (#3707)
1 parent e479b0a commit 9023043

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

xml/System.Runtime.InteropServices/Marshal.xml

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3090,17 +3090,15 @@
30903090

30913091
In the .NET Framework 2.0 and later versions, you can use the <xref:System.Runtime.InteropServices.Marshal.GetDelegateForFunctionPointer%2A> and <xref:System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate%2A> methods to marshal delegates in both directions. With <xref:System.Runtime.InteropServices.Marshal.GetDelegateForFunctionPointer%2A>, `ptr` is imported as a <xref:System.IntPtr?displayProperty=nameWithType>. A <xref:System.IntPtr?displayProperty=nameWithType> can be obtained for a managed delegate by calling <xref:System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate%2A> and passed as a parameter; it can then be called from inside the unmanaged method. Note that the parameter marshaler can also marshal function pointers to delegates in the .NET Framework 2.0 and later versions.
30923092

3093-
The <xref:System.Runtime.InteropServices.Marshal.GetDelegateForFunctionPointer%2A> method has the following restrictions:
3093+
`ptr` is converted to a delegate that invokes the unmanaged method using the [__stdcall](/cpp/cpp/stdcall) calling convention on Windows, or the [__cdecl](/cpp/cpp/cdecl) calling convention on Linux and macOS. You can set the calling convention by applying the <xref:System.Runtime.InteropServices.UnmanagedFunctionPointerAttribute> to the delegate.
30943094

3095-
- Generics are not supported in interop scenarios.
3095+
The <xref:System.Runtime.InteropServices.Marshal.GetDelegateForFunctionPointer%2A> method has the following restrictions:
30963096

3097-
- You cannot pass an invalid function pointer to this method.
3097+
- Generics are not supported in interop scenarios.
30983098

30993099
- You can use this method only for pure unmanaged function pointers.
31003100

3101-
- You cannot use this method with function pointers obtained through C++ or from the <xref:System.RuntimeMethodHandle.GetFunctionPointer%2A> method.
3102-
3103-
- You cannot use this method to create a delegate from a function pointer to another managed delegate.
3101+
- You cannot use this method with function pointers obtained through C++.
31043102

31053103
]]></format>
31063104
</remarks>
@@ -3167,15 +3165,15 @@
31673165
## Remarks
31683166
You can use the <xref:System.Runtime.InteropServices.Marshal.GetDelegateForFunctionPointer%60%601%28System.IntPtr%29> and <xref:System.Runtime.InteropServices.Marshal.GetFunctionPointerForDelegate%60%601%28%60%600%29> methods to marshal delegates in both directions.
31693167

3168+
`ptr` is converted to a delegate that invokes the unmanaged method using the [__stdcall](/cpp/cpp/stdcall) calling convention on Windows, or the [__cdecl](/cpp/cpp/cdecl) calling convention on Linux and macOS. You can set the calling convention by applying the <xref:System.Runtime.InteropServices.UnmanagedFunctionPointerAttribute> to the delegate.
3169+
31703170
The <xref:System.Runtime.InteropServices.Marshal.GetDelegateForFunctionPointer%60%601%28System.IntPtr%29> method has the following restrictions:
31713171

3172-
- You cannot pass an invalid function pointer to this method.
3172+
- Generics are not supported in interop scenarios.
31733173

31743174
- You can use this method only for pure unmanaged function pointers.
31753175

3176-
- You cannot use this method with function pointers obtained through C++ or from the <xref:System.RuntimeMethodHandle.GetFunctionPointer%2A> method.
3177-
3178-
- You cannot use this method to create a delegate from a function pointer to another managed delegate.
3176+
- You cannot use this method with function pointers obtained through C++.
31793177

31803178
]]></format>
31813179
</remarks>

0 commit comments

Comments
 (0)