Repository: microsoft/onnxruntime
File: csharp/src/Microsoft.ML.OnnxRuntime/NativeMethods.shared.cs (C#)

Code before:
            OrtSyncStream_GetHandle = 
                (DOrtSyncStream_GetHandle)Marshal.GetDelegateForFunctionPointer(
                    api_.SyncStream_GetHandle,
                    typeof(DOrtSyncStream_GetHandle));

            OrtReleaseSyncStream =
                (DOrtReleaseSyncStream)Marshal.GetDelegateForFunctionPointer(
                    api_.ReleaseSyncStream,
                    typeof(DOrtReleaseSyncStream));

            OrtCopyTensors =
                (DOrtCopyTensors)Marshal.GetDelegateForFunctionPointer(
                    api_.CopyTensors,
                    typeof(DOrtCopyTensors));
        }

        internal class NativeLib
        {
#if __ANDROID__
            // define the library name required for android
            internal const string DllName = "libonnxruntime.so";
#elif __IOS__
            // define the library name required for iOS
            internal const string DllName = "__Internal";
#else
            internal const string DllName = "onnxruntime";
#endif
        }

        [DllImport(NativeLib.DllName, CharSet = CharSet.Ansi)]
#if NETSTANDARD2_0
        public static extern IntPtr OrtGetApiBase();
#else
        public static extern ref OrtApiBase OrtGetApiBase();
#endif

        #region Runtime / Environment API

        [UnmanagedFunctionPointer(CallingConvention.Winapi)]
        public delegate IntPtr /* OrtStatus* */ DOrtCreateEnv(
            OrtLoggingLevel defaultLoggingLevel,
            byte[] /*const char* */ logId,
            out IntPtr /*(OrtEnv*)*/ env);

        public static DOrtCreateEnv OrtCreateEnv;

        [UnmanagedFunctionPointer(CallingConvention.Winapi)]
        public delegate IntPtr /* OrtStatus* */ DOrtCreateEnvWithCustomLogger(
            IntPtr /* (OrtLoggingFunction*) */ loggingFunction,
            IntPtr /* (void*) */ loggerParam,
            OrtLoggingLevel defaultLoggingLevel,

Review comment (suggestion):
Shall we also handle linux filename libonnxruntime.so here?
https://nuget.info/packages/Microsoft.ML.OnnxRuntime.Gpu.Linux/1.23.2


Code after:
            OrtSyncStream_GetHandle = 
                (DOrtSyncStream_GetHandle)Marshal.GetDelegateForFunctionPointer(
                    api_.SyncStream_GetHandle,
                    typeof(DOrtSyncStream_GetHandle));

            OrtReleaseSyncStream =
                (DOrtReleaseSyncStream)Marshal.GetDelegateForFunctionPointer(
                    api_.ReleaseSyncStream,
                    typeof(DOrtReleaseSyncStream));

            OrtCopyTensors =
                (DOrtCopyTensors)Marshal.GetDelegateForFunctionPointer(
                    api_.CopyTensors,
                    typeof(DOrtCopyTensors));
        }

        internal class NativeLib
        {
#if __ANDROID__
            // Define the library name required for Android
            internal const string DllName = "libonnxruntime.so";
#elif __IOS__
            // Define the library name required for iOS
            internal const string DllName = "__Internal";
#else
            // Note: the file name in ONNX Runtime nuget package must be onnxruntime.dll instead of onnxruntime.DLL(Windows filesystem can be case sensitive)
            internal const string DllName = "onnxruntime.dll";
#endif
        }

        [DllImport(NativeLib.DllName, CharSet = CharSet.Ansi)]
#if NETSTANDARD2_0
        public static extern IntPtr OrtGetApiBase();
#else
        public static extern ref OrtApiBase OrtGetApiBase();
#endif

        #region Runtime / Environment API

        [UnmanagedFunctionPointer(CallingConvention.Winapi)]
        public delegate IntPtr /* OrtStatus* */ DOrtCreateEnv(
            OrtLoggingLevel defaultLoggingLevel,
            byte[] /*const char* */ logId,
            out IntPtr /*(OrtEnv*)*/ env);

        public static DOrtCreateEnv OrtCreateEnv;

        [UnmanagedFunctionPointer(CallingConvention.Winapi)]
        public delegate IntPtr /* OrtStatus* */ DOrtCreateEnvWithCustomLogger(
            IntPtr /* (OrtLoggingFunction*) */ loggingFunction,
            IntPtr /* (void*) */ loggerParam,