From 53b049c3d98d04e3b03150b76e6344aaeec49fa1 Mon Sep 17 00:00:00 2001 From: Jan Kotas Date: Thu, 30 Nov 2023 16:58:59 -0800 Subject: [PATCH 1/2] Add best practice for avoiding native symbol name collisions --- .../UnmanagedCallersOnlyAttribute.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/xml/System.Runtime.InteropServices/UnmanagedCallersOnlyAttribute.xml b/xml/System.Runtime.InteropServices/UnmanagedCallersOnlyAttribute.xml index 8bbe096c301..0c944d74b10 100644 --- a/xml/System.Runtime.InteropServices/UnmanagedCallersOnlyAttribute.xml +++ b/xml/System.Runtime.InteropServices/UnmanagedCallersOnlyAttribute.xml @@ -138,6 +138,7 @@ Supplied types must be from the official ## Remarks The export name must be a valid identifier for a native symbol on the target platform. The identifier must not conflict with system-provided native identifiers (for example, names of methods in the C standard library, or POSIX/Win32 API names). +Using prefix for symbols is a common way to avoid name collisions of native symbols. For example, you can name your native symbols `mylibrary_free`, `mylibrary_isdigit` and `mylibrary_copy` to avoid name collisions. Target-dependent name mangling will be performed on the symbol name such as prepending or appending `_` or `@` characters to distinguish calling conventions on x86 Windows. From bb9e354aba460e4b18cbf22b365e702284bb7bce Mon Sep 17 00:00:00 2001 From: Jan Kotas Date: Thu, 30 Nov 2023 18:18:26 -0800 Subject: [PATCH 2/2] Update xml/System.Runtime.InteropServices/UnmanagedCallersOnlyAttribute.xml Co-authored-by: Aaron Robinson --- .../UnmanagedCallersOnlyAttribute.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xml/System.Runtime.InteropServices/UnmanagedCallersOnlyAttribute.xml b/xml/System.Runtime.InteropServices/UnmanagedCallersOnlyAttribute.xml index 0c944d74b10..62540e1172c 100644 --- a/xml/System.Runtime.InteropServices/UnmanagedCallersOnlyAttribute.xml +++ b/xml/System.Runtime.InteropServices/UnmanagedCallersOnlyAttribute.xml @@ -138,7 +138,7 @@ Supplied types must be from the official ## Remarks The export name must be a valid identifier for a native symbol on the target platform. The identifier must not conflict with system-provided native identifiers (for example, names of methods in the C standard library, or POSIX/Win32 API names). -Using prefix for symbols is a common way to avoid name collisions of native symbols. For example, you can name your native symbols `mylibrary_free`, `mylibrary_isdigit` and `mylibrary_copy` to avoid name collisions. +Using a prefix for symbols is a common way to avoid name collisions of native symbols. For example, you can name the exported functions as `mylibrary_free`, `mylibrary_isdigit` and `mylibrary_copy` to avoid name collisions. Target-dependent name mangling will be performed on the symbol name such as prepending or appending `_` or `@` characters to distinguish calling conventions on x86 Windows.