Update SPCL to use GeneratedDllImport where possible. (#61640)
authorAaron Robinson <arobins@microsoft.com>
Wed, 17 Nov 2021 01:35:01 +0000 (18:35 -0700)
committerGitHub <noreply@github.com>
Wed, 17 Nov 2021 01:35:01 +0000 (18:35 -0700)
* Update SPCL to use GeneratedDllImport where possible.

125 files changed:
src/libraries/Common/src/Interop/Interop.Calendar.cs
src/libraries/Common/src/Interop/Interop.Casing.cs
src/libraries/Common/src/Interop/Interop.Collation.cs
src/libraries/Common/src/Interop/Interop.HostPolicy.cs
src/libraries/Common/src/Interop/Interop.ICU.cs
src/libraries/Common/src/Interop/Interop.Idna.cs
src/libraries/Common/src/Interop/Interop.Locale.cs
src/libraries/Common/src/Interop/Interop.Normalization.cs
src/libraries/Common/src/Interop/Interop.TimeZoneInfo.cs
src/libraries/Common/src/Interop/OSX/Interop.libc.cs
src/libraries/Common/src/Interop/OSX/Interop.libobjc.cs
src/libraries/Common/src/Interop/OSX/System.Native/Interop.AutoreleasePool.cs
src/libraries/Common/src/Interop/SunOS/procfs/Interop.ProcFsStat.TryReadProcessStatusInfo.cs
src/libraries/Common/src/Interop/Unix/System.Native/Interop.ChDir.cs
src/libraries/Common/src/Interop/Unix/System.Native/Interop.ErrNo.cs
src/libraries/Common/src/Interop/Unix/System.Native/Interop.FAllocate.cs
src/libraries/Common/src/Interop/Unix/System.Native/Interop.FSync.cs
src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetCpuUtilization.cs
src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetCwd.cs
src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetEnv.cs
src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetEnviron.cs
src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetPid.cs
src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetProcessPath.cs
src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetRandomBytes.cs
src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetSystemTimeAsTicks.cs
src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetTimestamp.cs
src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetUnixName.cs
src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetUnixRelease.cs
src/libraries/Common/src/Interop/Unix/System.Native/Interop.LChflags.cs
src/libraries/Common/src/Interop/Unix/System.Native/Interop.LockFileRegion.cs
src/libraries/Common/src/Interop/Unix/System.Native/Interop.Log.cs
src/libraries/Common/src/Interop/Unix/System.Native/Interop.LowLevelMonitor.cs
src/libraries/Common/src/Interop/Unix/System.Native/Interop.MemAlloc.cs
src/libraries/Common/src/Interop/Unix/System.Native/Interop.MksTemps.cs
src/libraries/Common/src/Interop/Unix/System.Native/Interop.PRead.cs
src/libraries/Common/src/Interop/Unix/System.Native/Interop.PReadV.cs
src/libraries/Common/src/Interop/Unix/System.Native/Interop.PWrite.cs
src/libraries/Common/src/Interop/Unix/System.Native/Interop.PWriteV.cs
src/libraries/Common/src/Interop/Unix/System.Native/Interop.PosixFAdvise.cs
src/libraries/Common/src/Interop/Unix/System.Native/Interop.PosixSignal.cs
src/libraries/Common/src/Interop/Unix/System.Native/Interop.ReadDir.cs
src/libraries/Common/src/Interop/Unix/System.Native/Interop.SymLink.cs
src/libraries/Common/src/Interop/Unix/System.Native/Interop.SysLog.cs
src/libraries/Common/src/Interop/Unix/System.Native/Interop.UnixFileSystemTypes.cs
src/libraries/Common/src/Interop/Windows/Advapi32/Interop.EventActivityIdControl.cs
src/libraries/Common/src/Interop/Windows/Advapi32/Interop.EventRegister.cs
src/libraries/Common/src/Interop/Windows/Advapi32/Interop.EventSetInformation.cs
src/libraries/Common/src/Interop/Windows/Advapi32/Interop.EventTraceGuidsEx.cs
src/libraries/Common/src/Interop/Windows/Advapi32/Interop.EventUnregister.cs
src/libraries/Common/src/Interop/Windows/Advapi32/Interop.EventWriteString.cs
src/libraries/Common/src/Interop/Windows/Advapi32/Interop.EventWriteTransfer.cs
src/libraries/Common/src/Interop/Windows/Advapi32/Interop.LookupAccountNameW.cs
src/libraries/Common/src/Interop/Windows/BCrypt/Interop.BCryptGenRandom.cs
src/libraries/Common/src/Interop/Windows/Crypt32/Interop.CryptProtectMemory.cs
src/libraries/Common/src/Interop/Windows/Kernel32/Interop.CompletionPort.cs
src/libraries/Common/src/Interop/Windows/Kernel32/Interop.ConditionVariable.cs
src/libraries/Common/src/Interop/Windows/Kernel32/Interop.CreateSymbolicLink.cs
src/libraries/Common/src/Interop/Windows/Kernel32/Interop.CriticalSection.cs
src/libraries/Common/src/Interop/Windows/Kernel32/Interop.DeviceIoControl.cs
src/libraries/Common/src/Interop/Windows/Kernel32/Interop.EventWaitHandle.cs
src/libraries/Common/src/Interop/Windows/Kernel32/Interop.ExpandEnvironmentStrings.cs
src/libraries/Common/src/Interop/Windows/Kernel32/Interop.FileScatterGather.cs
src/libraries/Common/src/Interop/Windows/Kernel32/Interop.FileTimeToSystemTime.cs
src/libraries/Common/src/Interop/Windows/Kernel32/Interop.FindFirstFileEx.cs
src/libraries/Common/src/Interop/Windows/Kernel32/Interop.FindNextFile.cs
src/libraries/Common/src/Interop/Windows/Kernel32/Interop.FreeEnvironmentStrings.cs
src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetCPInfo.cs
src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetCurrentDirectory.cs
src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetEnvironmentStrings.cs
src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetEnvironmentVariable.cs
src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetFileInformationByHandleEx.cs
src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetFinalPathNameByHandle.cs
src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetLastError.cs
src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetModuleFileName.cs
src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetOverlappedResult.cs
src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetProcessMemoryInfo.cs
src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetProcessTimes_IntPtr.cs
src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetSystemDirectoryW.cs
src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetSystemTime.cs
src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetSystemTimes.cs
src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetTempFileNameW.cs
src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetTempPathW.cs
src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GlobalMemoryStatusEx.cs
src/libraries/Common/src/Interop/Windows/Kernel32/Interop.Globalization.cs
src/libraries/Common/src/Interop/Windows/Kernel32/Interop.LocalAlloc.cs
src/libraries/Common/src/Interop/Windows/Kernel32/Interop.LockFile.cs
src/libraries/Common/src/Interop/Windows/Kernel32/Interop.Mutex.cs
src/libraries/Common/src/Interop/Windows/Kernel32/Interop.OutputDebugString.cs
src/libraries/Common/src/Interop/Windows/Kernel32/Interop.QueryPerformanceCounter.cs
src/libraries/Common/src/Interop/Windows/Kernel32/Interop.QueryPerformanceFrequency.cs
src/libraries/Common/src/Interop/Windows/Kernel32/Interop.QueryUnbiasedInterruptTime.cs
src/libraries/Common/src/Interop/Windows/Kernel32/Interop.ResolveLocaleName.cs
src/libraries/Common/src/Interop/Windows/Kernel32/Interop.Semaphore.cs
src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetCurrentDirectory.cs
src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetEnvironmentVariable.cs
src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetFilePointerEx.cs
src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetLastError.cs
src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SystemTimeToFileTime.cs
src/libraries/Common/src/Interop/Windows/Kernel32/Interop.TimeZone.cs
src/libraries/Common/src/Interop/Windows/Kernel32/Interop.TzSpecificLocalTimeToSystemTime.cs
src/libraries/Common/src/Interop/Windows/Kernel32/Interop.VerSetConditionMask.cs
src/libraries/Common/src/Interop/Windows/Kernel32/Interop.VerifyVersionExW.cs
src/libraries/Common/src/Interop/Windows/Kernel32/Interop.VirtualAlloc_Ptr.cs
src/libraries/Common/src/Interop/Windows/Kernel32/Interop.VirtualFree.cs
src/libraries/Common/src/Interop/Windows/Kernel32/Interop.VirtualQuery_Ptr.cs
src/libraries/Common/src/Interop/Windows/Normaliz/Interop.Idna.cs
src/libraries/Common/src/Interop/Windows/Normaliz/Interop.Normalization.cs
src/libraries/Common/src/Interop/Windows/NtDll/Interop.NtCreateFile.cs
src/libraries/Common/src/Interop/Windows/NtDll/Interop.NtQueryDirectoryFile.cs
src/libraries/Common/src/Interop/Windows/NtDll/Interop.NtQueryInformationFile.cs
src/libraries/Common/src/Interop/Windows/NtDll/Interop.RtlGetVersion.cs
src/libraries/Common/src/Interop/Windows/NtDll/Interop.RtlNtStatusToDosError.cs
src/libraries/Common/src/Interop/Windows/Ole32/Interop.CLSIDFromProgID.cs
src/libraries/Common/src/Interop/Windows/Ole32/Interop.CoCreateGuid.cs
src/libraries/Common/src/Interop/Windows/Ole32/Interop.CoGetStandardMarshal.cs
src/libraries/Common/src/Interop/Windows/Ole32/Interop.CoTaskMemAlloc.cs
src/libraries/Common/src/Interop/Windows/OleAut32/Interop.SysAllocStringByteLen.cs
src/libraries/Common/src/Interop/Windows/OleAut32/Interop.SysFreeString.cs
src/libraries/Common/src/Interop/Windows/OleAut32/Interop.VariantClear.cs
src/libraries/Common/src/Interop/Windows/Secur32/Interop.GetUserNameExW.cs
src/libraries/Common/src/Interop/Windows/Shell32/Interop.SHGetKnownFolderPath.cs
src/libraries/Common/src/Interop/Windows/Ucrtbase/Interop.MemAlloc.cs
src/libraries/Common/src/Interop/Windows/User32/Interop.LoadString.cs
src/libraries/System.Runtime.Caching/src/System.Runtime.Caching.csproj
src/libraries/System.Threading.AccessControl/src/System.Threading.AccessControl.csproj

index 6befb03..4cc06c7 100644 (file)
@@ -9,19 +9,26 @@ internal static partial class Interop
 {
     internal static partial class Globalization
     {
-        [DllImport(Libraries.GlobalizationNative, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_GetCalendars")]
-        internal static extern int GetCalendars(string localeName, CalendarId[] calendars, int calendarsCapacity);
+        [GeneratedDllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_GetCalendars", CharSet = CharSet.Unicode)]
+        internal static partial int GetCalendars(string localeName, CalendarId[] calendars, int calendarsCapacity);
 
-        [DllImport(Libraries.GlobalizationNative, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_GetCalendarInfo")]
-        internal static extern unsafe ResultCode GetCalendarInfo(string localeName, CalendarId calendarId, CalendarDataType calendarDataType, char* result, int resultCapacity);
+        [GeneratedDllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_GetCalendarInfo", CharSet = CharSet.Unicode)]
+        internal static unsafe partial ResultCode GetCalendarInfo(string localeName, CalendarId calendarId, CalendarDataType calendarDataType, char* result, int resultCapacity);
 
-        [DllImport(Libraries.GlobalizationNative, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_EnumCalendarInfo")]
-        internal static extern unsafe bool EnumCalendarInfo(delegate* unmanaged<char*, IntPtr, void> callback, string localeName, CalendarId calendarId, CalendarDataType calendarDataType, IntPtr context);
+        internal static unsafe bool EnumCalendarInfo(delegate* unmanaged<char*, IntPtr, void> callback, string localeName, CalendarId calendarId, CalendarDataType calendarDataType, IntPtr context)
+        {
+            return EnumCalendarInfo((IntPtr)callback, localeName, calendarId, calendarDataType, context);
+        }
 
-        [DllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_GetLatestJapaneseEra")]
-        internal static extern int GetLatestJapaneseEra();
+        [GeneratedDllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_EnumCalendarInfo", CharSet = CharSet.Unicode)]
+        // We skip the following DllImport because of 'Parsing function pointer types in signatures is not supported.' for some targeted
+        // platforms (for example, WASM build).
+        private static unsafe partial bool EnumCalendarInfo(IntPtr callback, string localeName, CalendarId calendarId, CalendarDataType calendarDataType, IntPtr context);
 
-        [DllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_GetJapaneseEraStartDate")]
-        internal static extern bool GetJapaneseEraStartDate(int era, out int startYear, out int startMonth, out int startDay);
+        [GeneratedDllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_GetLatestJapaneseEra")]
+        internal static partial int GetLatestJapaneseEra();
+
+        [GeneratedDllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_GetJapaneseEraStartDate")]
+        internal static partial bool GetJapaneseEraStartDate(int era, out int startYear, out int startMonth, out int startDay);
     }
 }
index f02aea3..fcb77ec 100644 (file)
@@ -7,16 +7,16 @@ internal static partial class Interop
 {
     internal static partial class Globalization
     {
-        [DllImport(Libraries.GlobalizationNative, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_ChangeCase")]
-        internal static extern unsafe void ChangeCase(char* src, int srcLen, char* dstBuffer, int dstBufferCapacity, bool bToUpper);
+        [GeneratedDllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_ChangeCase", CharSet = CharSet.Unicode)]
+        internal static unsafe partial void ChangeCase(char* src, int srcLen, char* dstBuffer, int dstBufferCapacity, bool bToUpper);
 
-        [DllImport(Libraries.GlobalizationNative, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_ChangeCaseInvariant")]
-        internal static extern unsafe void ChangeCaseInvariant(char* src, int srcLen, char* dstBuffer, int dstBufferCapacity, bool bToUpper);
+        [GeneratedDllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_ChangeCaseInvariant", CharSet = CharSet.Unicode)]
+        internal static unsafe partial void ChangeCaseInvariant(char* src, int srcLen, char* dstBuffer, int dstBufferCapacity, bool bToUpper);
 
-        [DllImport(Libraries.GlobalizationNative, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_ChangeCaseTurkish")]
-        internal static extern unsafe void ChangeCaseTurkish(char* src, int srcLen, char* dstBuffer, int dstBufferCapacity, bool bToUpper);
+        [GeneratedDllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_ChangeCaseTurkish", CharSet = CharSet.Unicode)]
+        internal static unsafe partial void ChangeCaseTurkish(char* src, int srcLen, char* dstBuffer, int dstBufferCapacity, bool bToUpper);
 
-        [DllImport(Libraries.GlobalizationNative, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_InitOrdinalCasingPage")]
-        internal static extern unsafe void InitOrdinalCasingPage(int pageNumber, char* pTarget);
+        [GeneratedDllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_InitOrdinalCasingPage", CharSet = CharSet.Unicode)]
+        internal static unsafe partial void InitOrdinalCasingPage(int pageNumber, char* pTarget);
     }
 }
index 89dfb5b..41b7f89 100644 (file)
@@ -9,41 +9,41 @@ internal static partial class Interop
 {
     internal static partial class Globalization
     {
-        [DllImport(Libraries.GlobalizationNative, CharSet = CharSet.Ansi, EntryPoint = "GlobalizationNative_GetSortHandle")]
-        internal static extern unsafe ResultCode GetSortHandle(string localeName, out IntPtr sortHandle);
+        [GeneratedDllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_GetSortHandle", CharSet = CharSet.Ansi)]
+        internal static unsafe partial ResultCode GetSortHandle(string localeName, out IntPtr sortHandle);
 
-        [DllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_CloseSortHandle")]
-        internal static extern void CloseSortHandle(IntPtr handle);
+        [GeneratedDllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_CloseSortHandle")]
+        internal static partial void CloseSortHandle(IntPtr handle);
 
-        [DllImport(Libraries.GlobalizationNative, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_CompareString")]
-        internal static extern unsafe int CompareString(IntPtr sortHandle, char* lpStr1, int cwStr1Len, char* lpStr2, int cwStr2Len, CompareOptions options);
+        [GeneratedDllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_CompareString", CharSet = CharSet.Unicode)]
+        internal static unsafe partial int CompareString(IntPtr sortHandle, char* lpStr1, int cwStr1Len, char* lpStr2, int cwStr2Len, CompareOptions options);
 
-        [DllImport(Libraries.GlobalizationNative, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_IndexOf")]
-        internal static extern unsafe int IndexOf(IntPtr sortHandle, char* target, int cwTargetLength, char* pSource, int cwSourceLength, CompareOptions options, int* matchLengthPtr);
+        [GeneratedDllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_IndexOf", CharSet = CharSet.Unicode)]
+        internal static unsafe partial int IndexOf(IntPtr sortHandle, char* target, int cwTargetLength, char* pSource, int cwSourceLength, CompareOptions options, int* matchLengthPtr);
 
-        [DllImport(Libraries.GlobalizationNative, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_LastIndexOf")]
-        internal static extern unsafe int LastIndexOf(IntPtr sortHandle, char* target, int cwTargetLength, char* pSource, int cwSourceLength, CompareOptions options, int* matchLengthPtr);
+        [GeneratedDllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_LastIndexOf", CharSet = CharSet.Unicode)]
+        internal static unsafe partial int LastIndexOf(IntPtr sortHandle, char* target, int cwTargetLength, char* pSource, int cwSourceLength, CompareOptions options, int* matchLengthPtr);
 
-        [DllImport(Libraries.GlobalizationNative, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_StartsWith")]
+        [GeneratedDllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_StartsWith", CharSet = CharSet.Unicode)]
         [return: MarshalAs(UnmanagedType.Bool)]
-        internal static extern unsafe bool StartsWith(IntPtr sortHandle, char* target, int cwTargetLength, char* source, int cwSourceLength, CompareOptions options, int* matchedLength);
+        internal static unsafe partial bool StartsWith(IntPtr sortHandle, char* target, int cwTargetLength, char* source, int cwSourceLength, CompareOptions options, int* matchedLength);
 
-        [DllImport(Libraries.GlobalizationNative, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_EndsWith")]
+        [GeneratedDllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_EndsWith", CharSet = CharSet.Unicode)]
         [return: MarshalAs(UnmanagedType.Bool)]
-        internal static extern unsafe bool EndsWith(IntPtr sortHandle, char* target, int cwTargetLength, char* source, int cwSourceLength, CompareOptions options, int* matchedLength);
+        internal static unsafe partial bool EndsWith(IntPtr sortHandle, char* target, int cwTargetLength, char* source, int cwSourceLength, CompareOptions options, int* matchedLength);
 
-        [DllImport(Libraries.GlobalizationNative, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_StartsWith")]
+        [GeneratedDllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_StartsWith", CharSet = CharSet.Unicode)]
         [return: MarshalAs(UnmanagedType.Bool)]
-        internal static extern bool StartsWith(IntPtr sortHandle, string target, int cwTargetLength, string source, int cwSourceLength, CompareOptions options);
+        internal static partial bool StartsWith(IntPtr sortHandle, string target, int cwTargetLength, string source, int cwSourceLength, CompareOptions options);
 
-        [DllImport(Libraries.GlobalizationNative, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_EndsWith")]
+        [GeneratedDllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_EndsWith", CharSet = CharSet.Unicode)]
         [return: MarshalAs(UnmanagedType.Bool)]
-        internal static extern bool EndsWith(IntPtr sortHandle, string target, int cwTargetLength, string source, int cwSourceLength, CompareOptions options);
+        internal static partial bool EndsWith(IntPtr sortHandle, string target, int cwTargetLength, string source, int cwSourceLength, CompareOptions options);
 
-        [DllImport(Libraries.GlobalizationNative, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_GetSortKey")]
-        internal static extern unsafe int GetSortKey(IntPtr sortHandle, char* str, int strLength, byte* sortKey, int sortKeyLength, CompareOptions options);
+        [GeneratedDllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_GetSortKey", CharSet = CharSet.Unicode)]
+        internal static unsafe partial int GetSortKey(IntPtr sortHandle, char* str, int strLength, byte* sortKey, int sortKeyLength, CompareOptions options);
 
-        [DllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_GetSortVersion")]
-        internal static extern int GetSortVersion(IntPtr sortHandle);
+        [GeneratedDllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_GetSortVersion")]
+        internal static partial int GetSortVersion(IntPtr sortHandle);
     }
 }
index c7f6204..b5e3a21 100644 (file)
@@ -6,7 +6,7 @@ using System.Runtime.InteropServices;
 
 internal static partial class Interop
 {
-    internal static class HostPolicy
+    internal static partial class HostPolicy
     {
         [UnmanagedFunctionPointer(CallingConvention.Cdecl, CharSet = CharSet.Auto)]
         internal delegate void corehost_resolve_component_dependencies_result_fn(string assemblyPaths,
@@ -15,11 +15,15 @@ internal static partial class Interop
         [UnmanagedFunctionPointer(CallingConvention.Cdecl, CharSet = CharSet.Auto)]
         internal delegate void corehost_error_writer_fn(string message);
 
-        [DllImport(Libraries.HostPolicy, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Auto)]
-        internal static extern int corehost_resolve_component_dependencies(string componentMainAssemblyPath,
+#pragma warning disable CS3016 // Arrays as attribute arguments is not CLS-compliant
+        [GeneratedDllImport(Libraries.HostPolicy, CharSet = CharSet.Auto)]
+        [UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
+        internal static partial int corehost_resolve_component_dependencies(string componentMainAssemblyPath,
             corehost_resolve_component_dependencies_result_fn result);
 
-        [DllImport(Libraries.HostPolicy, CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Auto)]
-        internal static extern IntPtr corehost_set_error_writer(IntPtr errorWriter);
+        [GeneratedDllImport(Libraries.HostPolicy, CharSet = CharSet.Auto)]
+        [UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
+        internal static partial IntPtr corehost_set_error_writer(IntPtr errorWriter);
+#pragma warning restore CS3016 // Arrays as attribute arguments is not CLS-compliant
     }
 }
index 957b201..7aa5fba 100644 (file)
@@ -9,8 +9,8 @@ internal static partial class Interop
 {
     internal static partial class Globalization
     {
-        [DllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_LoadICU")]
-        internal static extern int LoadICU();
+        [GeneratedDllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_LoadICU")]
+        internal static partial int LoadICU();
 
         internal static void InitICUFunctions(IntPtr icuuc, IntPtr icuin, ReadOnlySpan<char> version, ReadOnlySpan<char> suffix)
         {
@@ -20,10 +20,10 @@ internal static partial class Interop
             InitICUFunctions(icuuc, icuin, version.ToString(), suffix.Length > 0 ? suffix.ToString() : null);
         }
 
-        [DllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_InitICUFunctions")]
-        internal static extern void InitICUFunctions(IntPtr icuuc, IntPtr icuin, string version, string? suffix);
+        [GeneratedDllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_InitICUFunctions", CharSet = CharSet.Ansi)]
+        internal static partial void InitICUFunctions(IntPtr icuuc, IntPtr icuin, string version, string? suffix);
 
-        [DllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_GetICUVersion")]
-        internal static extern int GetICUVersion();
+        [GeneratedDllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_GetICUVersion")]
+        internal static partial int GetICUVersion();
     }
 }
index 0bc9b41..7bac573 100644 (file)
@@ -10,10 +10,10 @@ internal static partial class Interop
         internal const int AllowUnassigned = 0x1;
         internal const int UseStd3AsciiRules = 0x2;
 
-        [DllImport(Libraries.GlobalizationNative, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_ToAscii")]
-        internal static extern unsafe int ToAscii(uint flags, char* src, int srcLen, char* dstBuffer, int dstBufferCapacity);
+        [GeneratedDllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_ToAscii", CharSet = CharSet.Unicode)]
+        internal static unsafe partial int ToAscii(uint flags, char* src, int srcLen, char* dstBuffer, int dstBufferCapacity);
 
-        [DllImport(Libraries.GlobalizationNative, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_ToUnicode")]
-        internal static extern unsafe int ToUnicode(uint flags, char* src, int srcLen, char* dstBuffer, int dstBufferCapacity);
+        [GeneratedDllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_ToUnicode", CharSet = CharSet.Unicode)]
+        internal static unsafe partial int ToUnicode(uint flags, char* src, int srcLen, char* dstBuffer, int dstBufferCapacity);
     }
 }
index 3a410c4..a4b05dc 100644 (file)
@@ -7,35 +7,35 @@ internal static partial class Interop
 {
     internal static partial class Globalization
     {
-        [DllImport(Libraries.GlobalizationNative, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_GetLocaleName")]
+        [GeneratedDllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_GetLocaleName", CharSet = CharSet.Unicode)]
         [return: MarshalAs(UnmanagedType.Bool)]
-        internal static extern unsafe bool GetLocaleName(string localeName, char* value, int valueLength);
+        internal static unsafe partial bool GetLocaleName(string localeName, char* value, int valueLength);
 
-        [DllImport(Libraries.GlobalizationNative, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_GetLocaleInfoString")]
+        [GeneratedDllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_GetLocaleInfoString", CharSet = CharSet.Unicode)]
         [return: MarshalAs(UnmanagedType.Bool)]
-        internal static extern unsafe bool GetLocaleInfoString(string localeName, uint localeStringData, char* value, int valueLength, string? uiLocaleName = null);
+        internal static unsafe partial bool GetLocaleInfoString(string localeName, uint localeStringData, char* value, int valueLength, string? uiLocaleName = null);
 
-        [DllImport(Libraries.GlobalizationNative, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_GetDefaultLocaleName")]
+        [GeneratedDllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_GetDefaultLocaleName", CharSet = CharSet.Unicode)]
         [return: MarshalAs(UnmanagedType.Bool)]
-        internal static extern unsafe bool GetDefaultLocaleName(char* value, int valueLength);
+        internal static unsafe partial bool GetDefaultLocaleName(char* value, int valueLength);
 
-        [DllImport(Libraries.GlobalizationNative, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_IsPredefinedLocale")]
+        [GeneratedDllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_IsPredefinedLocale", CharSet = CharSet.Unicode)]
         [return: MarshalAs(UnmanagedType.Bool)]
-        internal static extern bool IsPredefinedLocale(string localeName);
+        internal static partial bool IsPredefinedLocale(string localeName);
 
-        [DllImport(Libraries.GlobalizationNative, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_GetLocaleTimeFormat")]
+        [GeneratedDllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_GetLocaleTimeFormat", CharSet = CharSet.Unicode)]
         [return: MarshalAs(UnmanagedType.Bool)]
-        internal static extern unsafe bool GetLocaleTimeFormat(string localeName, bool shortFormat, char* value, int valueLength);
+        internal static unsafe partial bool GetLocaleTimeFormat(string localeName, bool shortFormat, char* value, int valueLength);
 
-        [DllImport(Libraries.GlobalizationNative, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_GetLocaleInfoInt")]
+        [GeneratedDllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_GetLocaleInfoInt", CharSet = CharSet.Unicode)]
         [return: MarshalAs(UnmanagedType.Bool)]
-        internal static extern bool GetLocaleInfoInt(string localeName, uint localeNumberData, ref int value);
+        internal static partial bool GetLocaleInfoInt(string localeName, uint localeNumberData, ref int value);
 
-        [DllImport(Libraries.GlobalizationNative, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_GetLocaleInfoGroupingSizes")]
+        [GeneratedDllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_GetLocaleInfoGroupingSizes", CharSet = CharSet.Unicode)]
         [return: MarshalAs(UnmanagedType.Bool)]
-        internal static extern bool GetLocaleInfoGroupingSizes(string localeName, uint localeGroupingData, ref int primaryGroupSize, ref int secondaryGroupSize);
+        internal static partial bool GetLocaleInfoGroupingSizes(string localeName, uint localeGroupingData, ref int primaryGroupSize, ref int secondaryGroupSize);
 
-        [DllImport(Libraries.GlobalizationNative, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_GetLocales")]
-        internal static extern int GetLocales([Out] char[]? value, int valueLength);
+        [GeneratedDllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_GetLocales", CharSet = CharSet.Unicode)]
+        internal static partial int GetLocales([Out] char[]? value, int valueLength);
     }
 }
index 420e68c..0b24088 100644 (file)
@@ -8,10 +8,10 @@ internal static partial class Interop
 {
     internal static partial class Globalization
     {
-        [DllImport(Libraries.GlobalizationNative, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_IsNormalized")]
-        internal static extern unsafe int IsNormalized(NormalizationForm normalizationForm, char* src, int srcLen);
+        [GeneratedDllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_IsNormalized", CharSet = CharSet.Unicode)]
+        internal static unsafe partial int IsNormalized(NormalizationForm normalizationForm, char* src, int srcLen);
 
-        [DllImport(Libraries.GlobalizationNative, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_NormalizeString")]
-        internal static extern unsafe int NormalizeString(NormalizationForm normalizationForm, char* src, int srcLen, char* dstBuffer, int dstBufferCapacity);
+        [GeneratedDllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_NormalizeString", CharSet = CharSet.Unicode)]
+        internal static unsafe partial int NormalizeString(NormalizationForm normalizationForm, char* src, int srcLen, char* dstBuffer, int dstBufferCapacity);
     }
 }
index 72db59c..6d22304 100644 (file)
@@ -8,18 +8,18 @@ internal static partial class Interop
 {
     internal static partial class Globalization
     {
-        [DllImport(Libraries.GlobalizationNative, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_GetTimeZoneDisplayName")]
-        internal static extern unsafe ResultCode GetTimeZoneDisplayName(
+        [GeneratedDllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_GetTimeZoneDisplayName", CharSet = CharSet.Unicode)]
+        internal static unsafe partial ResultCode GetTimeZoneDisplayName(
             string localeName,
             string timeZoneId,
             TimeZoneDisplayNameType type,
             char* result,
             int resultLength);
 
-        [DllImport(Libraries.GlobalizationNative, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_WindowsIdToIanaId")]
-        internal static extern unsafe int WindowsIdToIanaId(string windowsId, IntPtr region, char* ianaId, int ianaIdLength);
+        [GeneratedDllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_WindowsIdToIanaId", CharSet = CharSet.Unicode)]
+        internal static unsafe partial int WindowsIdToIanaId(string windowsId, IntPtr region, char* ianaId, int ianaIdLength);
 
-        [DllImport(Libraries.GlobalizationNative, CharSet = CharSet.Unicode, EntryPoint = "GlobalizationNative_IanaIdToWindowsId")]
-        internal static extern unsafe int IanaIdToWindowsId(string ianaId, char* windowsId, int windowsIdLength);
+        [GeneratedDllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_IanaIdToWindowsId", CharSet = CharSet.Unicode)]
+        internal static unsafe partial int IanaIdToWindowsId(string ianaId, char* windowsId, int windowsIdLength);
     }
 }
index 89ba513..574faad 100644 (file)
@@ -24,6 +24,7 @@ internal static partial class Interop
         }
 
         [DllImport(Libraries.libc, EntryPoint = "setattrlist", SetLastError = true)]
+        // TODO: [DllImportGenerator] Switch to use GeneratedDllImport once we annotate blittable types used in interop in CoreLib (like Guid)
         internal static unsafe extern int setattrlist(string path, AttrList* attrList, void* attrBuf, nint attrBufSize, CULong options);
 
         internal const uint FSOPT_NOFOLLOW = 0x00000001;
index 66d42a8..175b8ab 100644 (file)
@@ -16,12 +16,12 @@ internal static partial class Interop
             public nint patchVersion;
         }
 
-        [DllImport(Libraries.libobjc)]
-        private static extern IntPtr objc_getClass(string className);
-        [DllImport(Libraries.libobjc)]
-        private static extern IntPtr sel_getUid(string selector);
-        [DllImport(Libraries.libobjc, EntryPoint = "objc_msgSend")]
-        private static extern IntPtr intptr_objc_msgSend(IntPtr basePtr, IntPtr selector);
+        [GeneratedDllImport(Libraries.libobjc, CharSet = CharSet.Ansi)]
+        private static partial IntPtr objc_getClass(string className);
+        [GeneratedDllImport(Libraries.libobjc, CharSet = CharSet.Ansi)]
+        private static partial IntPtr sel_getUid(string selector);
+        [GeneratedDllImport(Libraries.libobjc, EntryPoint = "objc_msgSend")]
+        private static partial IntPtr intptr_objc_msgSend(IntPtr basePtr, IntPtr selector);
 
         internal static Version GetOperatingSystemVersion()
         {
@@ -58,10 +58,10 @@ internal static partial class Interop
             return new Version(major, minor, patch);
         }
 
-        [DllImport(Libraries.libobjc, EntryPoint = "objc_msgSend")]
-        private static extern NSOperatingSystemVersion NSOperatingSystemVersion_objc_msgSend(IntPtr basePtr, IntPtr selector);
+        [GeneratedDllImport(Libraries.libobjc, EntryPoint = "objc_msgSend")]
+        private static partial NSOperatingSystemVersion NSOperatingSystemVersion_objc_msgSend(IntPtr basePtr, IntPtr selector);
 
-        [DllImport(Libraries.libobjc, EntryPoint = "objc_msgSend_stret")]
-        private static extern void NSOperatingSystemVersion_objc_msgSend_stret(out NSOperatingSystemVersion osVersion, IntPtr basePtr, IntPtr selector);
+        [GeneratedDllImport(Libraries.libobjc, EntryPoint = "objc_msgSend_stret")]
+        private static partial void NSOperatingSystemVersion_objc_msgSend_stret(out NSOperatingSystemVersion osVersion, IntPtr basePtr, IntPtr selector);
     }
 }
index e1d005a..c0e78cb 100644 (file)
@@ -10,10 +10,10 @@ internal static partial class Interop
 {
     internal static partial class Sys
     {
-        [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_CreateAutoreleasePool")]
-        internal static extern IntPtr CreateAutoreleasePool();
+        [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_CreateAutoreleasePool")]
+        internal static partial IntPtr CreateAutoreleasePool();
 
-        [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_DrainAutoreleasePool")]
-        internal static extern void DrainAutoreleasePool(IntPtr ptr);
+        [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_DrainAutoreleasePool")]
+        internal static partial void DrainAutoreleasePool(IntPtr ptr);
     }
 }
index 032186e..bbfa14b 100644 (file)
@@ -15,8 +15,8 @@ internal static partial class Interop
         /// <returns>
         /// true if the process status was read; otherwise, false.
         /// </returns>
-        [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_ReadProcessStatusInfo", SetLastError = true)]
-        private static extern unsafe bool TryReadProcessStatusInfo(int pid, ProcessStatusInfo* processStatus);
+        [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_ReadProcessStatusInfo", SetLastError = true)]
+        private static unsafe partial bool TryReadProcessStatusInfo(int pid, ProcessStatusInfo* processStatus);
 
         internal struct ProcessStatusInfo
         {
index ca0e4e0..29e072b 100644 (file)
@@ -7,7 +7,7 @@ internal static partial class Interop
 {
     internal static partial class Sys
     {
-        [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_ChDir", SetLastError = true)]
-        internal static extern int ChDir(string path);
+        [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_ChDir", CharSet = CharSet.Ansi, SetLastError = true)]
+        internal static partial int ChDir(string path);
     }
 }
index 3e321d5..b6c4c21 100644 (file)
@@ -8,12 +8,12 @@ internal static partial class Interop
 {
     internal unsafe partial class Sys
     {
-        [DllImport(Interop.Libraries.SystemNative, EntryPoint = "SystemNative_GetErrNo")]
+        [GeneratedDllImport(Interop.Libraries.SystemNative, EntryPoint = "SystemNative_GetErrNo")]
         [SuppressGCTransition]
-        internal static extern int GetErrNo();
+        internal static partial int GetErrNo();
 
-        [DllImport(Interop.Libraries.SystemNative, EntryPoint = "SystemNative_SetErrNo")]
+        [GeneratedDllImport(Interop.Libraries.SystemNative, EntryPoint = "SystemNative_SetErrNo")]
         [SuppressGCTransition]
-        internal static extern void SetErrNo(int errorCode);
+        internal static partial void SetErrNo(int errorCode);
     }
 }
index 71155e0..8c3508e 100644 (file)
@@ -11,7 +11,7 @@ internal static partial class Interop
         /// <summary>
         /// Returns -1 on error, 0 on success.
         /// </summary>
-        [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_FAllocate", SetLastError = true)]
-        internal static extern int FAllocate(SafeFileHandle fd, long offset, long length);
+        [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_FAllocate", SetLastError = true)]
+        internal static partial int FAllocate(SafeFileHandle fd, long offset, long length);
     }
 }
index 773f867..531ceb5 100644 (file)
@@ -8,7 +8,7 @@ internal static partial class Interop
 {
     internal static partial class Sys
     {
-        [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_FSync", SetLastError = true)]
-        internal static extern int FSync(SafeFileHandle fd);
+        [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_FSync", SetLastError = true)]
+        internal static partial int FSync(SafeFileHandle fd);
     }
 }
index 0e5e3b4..6598dbd 100644 (file)
@@ -15,7 +15,7 @@ internal static partial class Interop
             internal ulong lastRecordedUserTime;
         }
 
-        [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetCpuUtilization")]
-        internal static extern int GetCpuUtilization(ref ProcessCpuInformation previousCpuInfo);
+        [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetCpuUtilization")]
+        internal static partial int GetCpuUtilization(ref ProcessCpuInformation previousCpuInfo);
     }
 }
index 78da5a6..22fb18f 100644 (file)
@@ -9,8 +9,8 @@ internal static partial class Interop
 {
     internal static partial class Sys
     {
-        [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetCwd", SetLastError = true)]
-        private static extern unsafe byte* GetCwd(byte* buffer, int bufferLength);
+        [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetCwd", SetLastError = true)]
+        private static unsafe partial byte* GetCwd(byte* buffer, int bufferLength);
 
         internal static unsafe string GetCwd()
         {
index d83d670..13b5780 100644 (file)
@@ -8,7 +8,7 @@ internal static partial class Interop
 {
     internal unsafe partial class Sys
     {
-        [DllImport(Interop.Libraries.SystemNative, EntryPoint = "SystemNative_GetEnv")]
-        internal static extern unsafe IntPtr GetEnv(string name);
+        [GeneratedDllImport(Interop.Libraries.SystemNative, CharSet = CharSet.Ansi, EntryPoint = "SystemNative_GetEnv")]
+        internal static unsafe partial IntPtr GetEnv(string name);
     }
 }
\ No newline at end of file
index abe8ff0..b88c256 100644 (file)
@@ -8,10 +8,10 @@ internal static partial class Interop
 {
     internal unsafe partial class Sys
     {
-        [DllImport(Interop.Libraries.SystemNative, EntryPoint = "SystemNative_GetEnviron")]
-        internal static extern unsafe IntPtr GetEnviron();
+        [GeneratedDllImport(Interop.Libraries.SystemNative, EntryPoint = "SystemNative_GetEnviron")]
+        internal static unsafe partial IntPtr GetEnviron();
 
-        [DllImport(Interop.Libraries.SystemNative, EntryPoint = "SystemNative_FreeEnviron")]
-        internal static extern unsafe void FreeEnviron(IntPtr environ);
+        [GeneratedDllImport(Interop.Libraries.SystemNative, EntryPoint = "SystemNative_FreeEnviron")]
+        internal static unsafe partial void FreeEnviron(IntPtr environ);
     }
 }
\ No newline at end of file
index 400dc55..6b26b60 100644 (file)
@@ -7,7 +7,7 @@ internal static partial class Interop
 {
     internal static partial class Sys
     {
-        [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetPid")]
-        internal static extern int GetPid();
+        [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetPid")]
+        internal static partial int GetPid();
     }
 }
index c64d21e..ddcd497 100644 (file)
@@ -10,7 +10,7 @@ internal static partial class Interop
         /// <summary>
         /// Returns the full path to the executable for the current process, resolving symbolic links.
         /// </summary>
-        [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetProcessPath", SetLastError = true)]
-        internal static extern string? GetProcessPath();
+        [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetProcessPath", CharSet = CharSet.Ansi, SetLastError = true)]
+        internal static partial string? GetProcessPath();
     }
 }
index 15295e5..76c1323 100644 (file)
@@ -8,11 +8,11 @@ internal static partial class Interop
 {
     internal static partial class Sys
     {
-        [DllImport(Interop.Libraries.SystemNative, EntryPoint = "SystemNative_GetNonCryptographicallySecureRandomBytes")]
-        internal static extern unsafe void GetNonCryptographicallySecureRandomBytes(byte* buffer, int length);
+        [GeneratedDllImport(Interop.Libraries.SystemNative, EntryPoint = "SystemNative_GetNonCryptographicallySecureRandomBytes")]
+        internal static unsafe partial void GetNonCryptographicallySecureRandomBytes(byte* buffer, int length);
 
-        [DllImport(Interop.Libraries.SystemNative, EntryPoint = "SystemNative_GetCryptographicallySecureRandomBytes")]
-        internal static extern unsafe int GetCryptographicallySecureRandomBytes(byte* buffer, int length);
+        [GeneratedDllImport(Interop.Libraries.SystemNative, EntryPoint = "SystemNative_GetCryptographicallySecureRandomBytes")]
+        internal static unsafe partial int GetCryptographicallySecureRandomBytes(byte* buffer, int length);
     }
 
     internal static unsafe void GetRandomBytes(byte* buffer, int length)
index 850ff0a..ca5c01c 100644 (file)
@@ -7,8 +7,8 @@ internal static partial class Interop
 {
     internal static partial class Sys
     {
-        [DllImport(Interop.Libraries.SystemNative, EntryPoint = "SystemNative_GetSystemTimeAsTicks")]
+        [GeneratedDllImport(Interop.Libraries.SystemNative, EntryPoint = "SystemNative_GetSystemTimeAsTicks")]
         [SuppressGCTransition]
-        internal static extern long GetSystemTimeAsTicks();
+        internal static partial long GetSystemTimeAsTicks();
     }
 }
index a374e48..fc0964b 100644 (file)
@@ -7,8 +7,8 @@ internal static partial class Interop
 {
     internal static partial class Sys
     {
-        [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetTimestamp", ExactSpelling = true)]
+        [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetTimestamp", ExactSpelling = true)]
         [SuppressGCTransition]
-        internal static extern ulong GetTimestamp();
+        internal static partial ulong GetTimestamp();
     }
 }
index 8d5063e..276f112 100644 (file)
@@ -8,8 +8,8 @@ internal static partial class Interop
 {
     internal static partial class Sys
     {
-        [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetUnixName")]
-        private static extern IntPtr GetUnixNamePrivate();
+        [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetUnixName")]
+        private static partial IntPtr GetUnixNamePrivate();
 
         internal static string GetUnixName()
         {
index 22ae869..cf47ba3 100644 (file)
@@ -7,7 +7,7 @@ internal static partial class Interop
 {
     internal static partial class Sys
     {
-        [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetUnixRelease", CharSet = CharSet.Ansi, SetLastError = true)]
-        public static extern string GetUnixRelease();
+        [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetUnixRelease", CharSet = CharSet.Ansi, SetLastError = true)]
+        public static partial string GetUnixRelease();
     }
 }
index 17ba8e3..1353fbc 100644 (file)
@@ -19,8 +19,8 @@ internal static partial class Interop
 
         internal static readonly bool CanSetHiddenFlag = (LChflagsCanSetHiddenFlag() != 0);
 
-        [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_LChflagsCanSetHiddenFlag")]
+        [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_LChflagsCanSetHiddenFlag")]
         [SuppressGCTransition]
-        private static extern int LChflagsCanSetHiddenFlag();
+        private static partial int LChflagsCanSetHiddenFlag();
     }
 }
index 3276275..0692aa4 100644 (file)
@@ -14,7 +14,7 @@ internal static partial class Interop
             F_UNLCK = 2     // unlock
         }
 
-        [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_LockFileRegion", SetLastError=true)]
-        internal static extern int LockFileRegion(SafeHandle fd, long offset, long length, LockType lockType);
+        [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_LockFileRegion", SetLastError =true)]
+        internal static partial int LockFileRegion(SafeHandle fd, long offset, long length, LockType lockType);
     }
 }
index 109bfff..474429e 100644 (file)
@@ -8,10 +8,10 @@ internal static partial class Interop
 {
     internal static partial class Sys
     {
-        [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_Log")]
-        internal static extern unsafe void Log(byte* buffer, int count);
+        [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_Log")]
+        internal static unsafe partial void Log(byte* buffer, int count);
 
-        [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_LogError")]
-        internal static extern unsafe void LogError(byte* buffer, int count);
+        [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_LogError")]
+        internal static unsafe partial void LogError(byte* buffer, int count);
     }
 }
index 8544cbe..5132e82 100644 (file)
@@ -8,25 +8,25 @@ internal static partial class Interop
 {
     internal static partial class Sys
     {
-        [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_LowLevelMonitor_Create")]
-        internal static extern IntPtr LowLevelMonitor_Create();
+        [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_LowLevelMonitor_Create")]
+        internal static partial IntPtr LowLevelMonitor_Create();
 
-        [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_LowLevelMonitor_Destroy")]
-        internal static extern void LowLevelMonitor_Destroy(IntPtr monitor);
+        [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_LowLevelMonitor_Destroy")]
+        internal static partial void LowLevelMonitor_Destroy(IntPtr monitor);
 
-        [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_LowLevelMonitor_Acquire")]
-        internal static extern void LowLevelMonitor_Acquire(IntPtr monitor);
+        [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_LowLevelMonitor_Acquire")]
+        internal static partial void LowLevelMonitor_Acquire(IntPtr monitor);
 
-        [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_LowLevelMonitor_Release")]
-        internal static extern void LowLevelMonitor_Release(IntPtr monitor);
+        [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_LowLevelMonitor_Release")]
+        internal static partial void LowLevelMonitor_Release(IntPtr monitor);
 
-        [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_LowLevelMonitor_Wait")]
-        internal static extern void LowLevelMonitor_Wait(IntPtr monitor);
+        [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_LowLevelMonitor_Wait")]
+        internal static partial void LowLevelMonitor_Wait(IntPtr monitor);
 
-        [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_LowLevelMonitor_TimedWait")]
-        internal static extern bool LowLevelMonitor_TimedWait(IntPtr monitor, int timeoutMilliseconds);
+        [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_LowLevelMonitor_TimedWait")]
+        internal static partial bool LowLevelMonitor_TimedWait(IntPtr monitor, int timeoutMilliseconds);
 
-        [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_LowLevelMonitor_Signal_Release")]
-        internal static extern void LowLevelMonitor_Signal_Release(IntPtr monitor);
+        [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_LowLevelMonitor_Signal_Release")]
+        internal static partial void LowLevelMonitor_Signal_Release(IntPtr monitor);
     }
 }
index cb4a38f..9a0a90c 100644 (file)
@@ -8,25 +8,25 @@ internal static partial class Interop
 {
     internal static unsafe partial class Sys
     {
-        [DllImport(Interop.Libraries.SystemNative, EntryPoint = "SystemNative_AlignedAlloc")]
-        internal static extern void* AlignedAlloc(nuint alignment, nuint size);
+        [GeneratedDllImport(Interop.Libraries.SystemNative, EntryPoint = "SystemNative_AlignedAlloc")]
+        internal static partial void* AlignedAlloc(nuint alignment, nuint size);
 
-        [DllImport(Interop.Libraries.SystemNative, EntryPoint = "SystemNative_AlignedFree")]
-        internal static extern void AlignedFree(void* ptr);
+        [GeneratedDllImport(Interop.Libraries.SystemNative, EntryPoint = "SystemNative_AlignedFree")]
+        internal static partial void AlignedFree(void* ptr);
 
-        [DllImport(Interop.Libraries.SystemNative, EntryPoint = "SystemNative_AlignedRealloc")]
-        internal static extern void* AlignedRealloc(void* ptr, nuint alignment, nuint new_size);
+        [GeneratedDllImport(Interop.Libraries.SystemNative, EntryPoint = "SystemNative_AlignedRealloc")]
+        internal static partial void* AlignedRealloc(void* ptr, nuint alignment, nuint new_size);
 
-        [DllImport(Interop.Libraries.SystemNative, EntryPoint = "SystemNative_Calloc")]
-        internal static extern void* Calloc(nuint num, nuint size);
+        [GeneratedDllImport(Interop.Libraries.SystemNative, EntryPoint = "SystemNative_Calloc")]
+        internal static partial void* Calloc(nuint num, nuint size);
 
-        [DllImport(Interop.Libraries.SystemNative, EntryPoint = "SystemNative_Free")]
-        internal static extern void Free(void* ptr);
+        [GeneratedDllImport(Interop.Libraries.SystemNative, EntryPoint = "SystemNative_Free")]
+        internal static partial void Free(void* ptr);
 
-        [DllImport(Interop.Libraries.SystemNative, EntryPoint = "SystemNative_Malloc")]
-        internal static extern void* Malloc(nuint size);
+        [GeneratedDllImport(Interop.Libraries.SystemNative, EntryPoint = "SystemNative_Malloc")]
+        internal static partial void* Malloc(nuint size);
 
-        [DllImport(Interop.Libraries.SystemNative, EntryPoint = "SystemNative_Realloc")]
-        internal static extern void* Realloc(void* ptr, nuint new_size);
+        [GeneratedDllImport(Interop.Libraries.SystemNative, EntryPoint = "SystemNative_Realloc")]
+        internal static partial void* Realloc(void* ptr, nuint new_size);
     }
 }
index f409379..f697cd9 100644 (file)
@@ -8,8 +8,8 @@ internal static partial class Interop
 {
     internal static partial class Sys
     {
-        [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_MksTemps", SetLastError = true)]
-        internal static extern IntPtr MksTemps(
+        [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_MksTemps", SetLastError = true)]
+        internal static partial IntPtr MksTemps(
             byte[] template,
             int suffixlen);
     }
index 664da01..b48dff0 100644 (file)
@@ -7,7 +7,7 @@ internal static partial class Interop
 {
     internal static partial class Sys
     {
-        [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_PRead", SetLastError = true)]
-        internal static extern unsafe int PRead(SafeHandle fd, byte* buffer, int bufferSize, long fileOffset);
+        [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_PRead", SetLastError = true)]
+        internal static unsafe partial int PRead(SafeHandle fd, byte* buffer, int bufferSize, long fileOffset);
     }
 }
index 5d93078..de0f311 100644 (file)
@@ -7,7 +7,7 @@ internal static partial class Interop
 {
     internal static partial class Sys
     {
-        [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_PReadV", SetLastError = true)]
-        internal static extern unsafe long PReadV(SafeHandle fd, IOVector* vectors, int vectorCount, long fileOffset);
+        [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_PReadV", SetLastError = true)]
+        internal static unsafe partial long PReadV(SafeHandle fd, IOVector* vectors, int vectorCount, long fileOffset);
     }
 }
index 721a1c8..d658f4b 100644 (file)
@@ -7,7 +7,7 @@ internal static partial class Interop
 {
     internal static partial class Sys
     {
-        [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_PWrite", SetLastError = true)]
-        internal static extern unsafe int PWrite(SafeHandle fd, byte* buffer, int bufferSize, long fileOffset);
+        [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_PWrite", SetLastError = true)]
+        internal static unsafe partial int PWrite(SafeHandle fd, byte* buffer, int bufferSize, long fileOffset);
     }
 }
index c17e996..baba793 100644 (file)
@@ -7,7 +7,7 @@ internal static partial class Interop
 {
     internal static partial class Sys
     {
-        [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_PWriteV", SetLastError = true)]
-        internal static extern unsafe long PWriteV(SafeHandle fd, IOVector* vectors, int vectorCount, long fileOffset);
+        [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_PWriteV", SetLastError = true)]
+        internal static unsafe partial long PWriteV(SafeHandle fd, IOVector* vectors, int vectorCount, long fileOffset);
     }
 }
index ed9ee76..e2e96df 100644 (file)
@@ -29,7 +29,7 @@ internal static partial class Interop
         /// <returns>
         /// Returns 0 on success; otherwise, the error code is returned
         /// </returns>
-        [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_PosixFAdvise", SetLastError = false /* this is explicitly called out in the man page */)]
-        internal static extern int PosixFAdvise(SafeFileHandle fd, long offset, long length, FileAdvice advice);
+        [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_PosixFAdvise", SetLastError = false /* this is explicitly called out in the man page */)]
+        internal static partial int PosixFAdvise(SafeFileHandle fd, long offset, long length, FileAdvice advice);
     }
 }
index 65e3ca3..bde211d 100644 (file)
@@ -7,21 +7,21 @@ internal static partial class Interop
 {
     internal static partial class Sys
     {
-        [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_SetPosixSignalHandler")]
+        [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_SetPosixSignalHandler")]
         [SuppressGCTransition]
-        internal static extern unsafe void SetPosixSignalHandler(delegate* unmanaged<int, PosixSignal, int> handler);
+        internal static unsafe partial void SetPosixSignalHandler(delegate* unmanaged<int, PosixSignal, int> handler);
 
-        [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_EnablePosixSignalHandling", SetLastError = true)]
-        internal static extern bool EnablePosixSignalHandling(int signal);
+        [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_EnablePosixSignalHandling", SetLastError = true)]
+        internal static partial bool EnablePosixSignalHandling(int signal);
 
-        [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_DisablePosixSignalHandling")]
-        internal static extern void DisablePosixSignalHandling(int signal);
+        [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_DisablePosixSignalHandling")]
+        internal static partial void DisablePosixSignalHandling(int signal);
 
-        [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_HandleNonCanceledPosixSignal")]
-        internal static extern void HandleNonCanceledPosixSignal(int signal);
+        [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_HandleNonCanceledPosixSignal")]
+        internal static partial void HandleNonCanceledPosixSignal(int signal);
 
-        [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetPlatformSignalNumber")]
+        [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetPlatformSignalNumber")]
         [SuppressGCTransition]
-        internal static extern int GetPlatformSignalNumber(PosixSignal signal);
+        internal static partial int GetPlatformSignalNumber(PosixSignal signal);
     }
 }
index 4801498..37a89d8 100644 (file)
@@ -56,12 +56,12 @@ internal static partial class Interop
         [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_OpenDir", CharSet = CharSet.Ansi, SetLastError = true)]
         internal static partial IntPtr OpenDir(string path);
 
-        [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetReadDirRBufferSize", SetLastError = false)]
+        [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetReadDirRBufferSize", SetLastError = false)]
         [SuppressGCTransition]
-        internal static extern int GetReadDirRBufferSize();
+        internal static partial int GetReadDirRBufferSize();
 
-        [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_ReadDirR")]
-        internal static unsafe extern int ReadDirR(IntPtr dir, byte* buffer, int bufferSize, DirectoryEntry* outputEntry);
+        [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_ReadDirR")]
+        internal static unsafe partial int ReadDirR(IntPtr dir, byte* buffer, int bufferSize, DirectoryEntry* outputEntry);
 
         [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_CloseDir", SetLastError = true)]
         internal static partial int CloseDir(IntPtr dir);
index 922ecd5..d0721ee 100644 (file)
@@ -8,7 +8,7 @@ internal static partial class Interop
 {
     internal static partial class Sys
     {
-        [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_SymLink", SetLastError = true)]
-        internal static extern int SymLink(string target, string linkPath);
+        [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_SymLink", CharSet = CharSet.Ansi, SetLastError = true)]
+        internal static partial int SymLink(string target, string linkPath);
     }
 }
index e8809b1..11284f1 100644 (file)
@@ -29,7 +29,7 @@ internal static partial class Interop
         /// </param>
         /// <param name="message">The message to put in the log entry</param>
         /// <param name="arg1">Like printf, the argument is passed to the variadic part of the C++ function to wildcards in the message</param>
-        [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_SysLog")]
-        internal static extern void SysLog(SysLogPriority priority, string message, string arg1);
+        [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_SysLog", CharSet = CharSet.Ansi)]
+        internal static partial void SysLog(SysLogPriority priority, string message, string arg1);
     }
 }
index d86dcfb..5e4d7a6 100644 (file)
@@ -145,8 +145,8 @@ internal static partial class Interop
             zfs = 0x2FC12FC1,
         }
 
-        [DllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetFileSystemType")]
-        private static extern long GetFileSystemType(SafeFileHandle fd);
+        [GeneratedDllImport(Libraries.SystemNative, EntryPoint = "SystemNative_GetFileSystemType")]
+        private static partial long GetFileSystemType(SafeFileHandle fd);
 
         internal static bool TryGetFileSystemType(SafeFileHandle fd, out UnixFileSystemTypes fileSystemType)
         {
index c1c129b..f43a53d 100644 (file)
@@ -9,6 +9,7 @@ internal static partial class Interop
     internal static partial class Advapi32
     {
         [DllImport(Libraries.Advapi32, ExactSpelling = true)]
+        // TODO: [DllImportGenerator] Switch to use GeneratedDllImport once we annotate blittable types used in interop in CoreLib (like Guid)
         internal static extern int EventActivityIdControl(ActivityControl ControlCode, ref Guid ActivityId);
     }
 }
index 8369b5c..99660f1 100644 (file)
@@ -9,7 +9,8 @@ internal static partial class Interop
     internal static partial class Advapi32
     {
         [DllImport(Libraries.Advapi32, ExactSpelling = true)]
-        internal static extern unsafe uint EventRegister(
+        // TODO: [DllImportGenerator] Switch to use GeneratedDllImport once we annotate blittable types used in interop in CoreLib (like Guid)
+        internal static unsafe extern uint EventRegister(
             in Guid providerId,
             EtwEnableCallback enableCallback,
             void* callbackContext,
index a623021..b865aa9 100644 (file)
@@ -7,8 +7,8 @@ internal static partial class Interop
 {
     internal static partial class Advapi32
     {
-        [DllImport(Libraries.Advapi32, ExactSpelling = true)]
-        internal static extern unsafe int EventSetInformation(
+        [GeneratedDllImport(Libraries.Advapi32, ExactSpelling = true)]
+        internal static unsafe partial int EventSetInformation(
             long registrationHandle,
             EVENT_INFO_CLASS informationClass,
             void* eventInformation,
index c0fef91..53b7628 100644 (file)
@@ -45,8 +45,8 @@ internal static partial class Interop
             public long MatchAllKeyword;
         }
 
-        [DllImport(Interop.Libraries.Advapi32, ExactSpelling = true)]
-        internal static extern unsafe int EnumerateTraceGuidsEx(
+        [GeneratedDllImport(Interop.Libraries.Advapi32, ExactSpelling = true)]
+        internal static unsafe partial int EnumerateTraceGuidsEx(
             TRACE_QUERY_INFO_CLASS TraceQueryInfoClass,
             void* InBuffer,
             int InBufferSize,
index e0d0c6b..d717c7d 100644 (file)
@@ -7,7 +7,7 @@ internal static partial class Interop
 {
     internal static partial class Advapi32
     {
-        [DllImport(Libraries.Advapi32, ExactSpelling = true)]
-        internal static extern uint EventUnregister(long registrationHandle);
+        [GeneratedDllImport(Libraries.Advapi32, ExactSpelling = true)]
+        internal static partial uint EventUnregister(long registrationHandle);
     }
 }
index 0513dae..f39a759 100644 (file)
@@ -7,8 +7,8 @@ internal static partial class Interop
 {
     internal static partial class Advapi32
     {
-        [DllImport(Libraries.Advapi32, ExactSpelling = true)]
-        internal static extern int EventWriteString(
+        [GeneratedDllImport(Libraries.Advapi32, CharSet = CharSet.Ansi, ExactSpelling = true)]
+        internal static partial int EventWriteString(
             long registrationHandle,
             byte level,
             long keyword,
index 3cb95ff..3e2b23f 100644 (file)
@@ -36,8 +36,8 @@ internal static partial class Interop
             return HResult;
         }
 
-        [DllImport(Interop.Libraries.Advapi32, ExactSpelling = true, EntryPoint = "EventWriteTransfer")]
-        private static extern unsafe int EventWriteTransfer_PInvoke(
+        [GeneratedDllImport(Interop.Libraries.Advapi32, EntryPoint = "EventWriteTransfer", ExactSpelling = true)]
+        private static unsafe partial int EventWriteTransfer_PInvoke(
             long registrationHandle,
             in EventDescriptor eventDescriptor,
             Guid* activityId,
index 168e80c..ff9fd2d 100644 (file)
@@ -7,8 +7,8 @@ internal static partial class Interop
 {
     internal static partial class Advapi32
     {
-        [DllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, SetLastError = true, ExactSpelling = true)]
-        internal static extern bool LookupAccountNameW(
+        [GeneratedDllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)]
+        internal static partial bool LookupAccountNameW(
             string? lpSystemName,
             ref char lpAccountName,
             ref byte Sid,
index 22d7be3..d7372bc 100644 (file)
@@ -10,7 +10,7 @@ internal static partial class Interop
     {
         internal const int BCRYPT_USE_SYSTEM_PREFERRED_RNG = 0x00000002;
 
-        [DllImport(Libraries.BCrypt, CharSet = CharSet.Unicode)]
-        internal static extern unsafe NTSTATUS BCryptGenRandom(IntPtr hAlgorithm, byte* pbBuffer, int cbBuffer, int dwFlags);
+        [GeneratedDllImport(Libraries.BCrypt, CharSet = CharSet.Unicode)]
+        internal static unsafe partial NTSTATUS BCryptGenRandom(IntPtr hAlgorithm, byte* pbBuffer, int cbBuffer, int dwFlags);
     }
 }
index 644d4e6..81f1b00 100644 (file)
@@ -10,10 +10,10 @@ internal static partial class Interop
         internal const uint CRYPTPROTECTMEMORY_BLOCK_SIZE = 16;
         internal const uint CRYPTPROTECTMEMORY_SAME_PROCESS = 0;
 
-        [DllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)]
-        internal static extern bool CryptProtectMemory(SafeBuffer pData, uint cbData, uint dwFlags);
+        [GeneratedDllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)]
+        internal static partial bool CryptProtectMemory(SafeBuffer pData, uint cbData, uint dwFlags);
 
-        [DllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)]
-        internal static extern bool CryptUnprotectMemory(SafeBuffer pData, uint cbData, uint dwFlags);
+        [GeneratedDllImport(Libraries.Crypt32, CharSet = CharSet.Unicode, SetLastError = true)]
+        internal static partial bool CryptUnprotectMemory(SafeBuffer pData, uint cbData, uint dwFlags);
     }
 }
index dc2c6c4..e33002e 100644 (file)
@@ -8,15 +8,15 @@ internal static partial class Interop
 {
     internal static partial class Kernel32
     {
-        [DllImport(Libraries.Kernel32, SetLastError = true)]
-        internal static extern IntPtr CreateIoCompletionPort(IntPtr FileHandle, IntPtr ExistingCompletionPort, UIntPtr CompletionKey, int NumberOfConcurrentThreads);
+        [GeneratedDllImport(Libraries.Kernel32, SetLastError = true)]
+        internal static partial IntPtr CreateIoCompletionPort(IntPtr FileHandle, IntPtr ExistingCompletionPort, UIntPtr CompletionKey, int NumberOfConcurrentThreads);
 
-        [DllImport(Libraries.Kernel32, SetLastError = true)]
+        [GeneratedDllImport(Libraries.Kernel32, SetLastError = true)]
         [return: MarshalAs(UnmanagedType.Bool)]
-        internal static extern bool PostQueuedCompletionStatus(IntPtr CompletionPort, int dwNumberOfBytesTransferred, UIntPtr CompletionKey, IntPtr lpOverlapped);
+        internal static partial bool PostQueuedCompletionStatus(IntPtr CompletionPort, int dwNumberOfBytesTransferred, UIntPtr CompletionKey, IntPtr lpOverlapped);
 
-        [DllImport(Libraries.Kernel32, SetLastError = true)]
+        [GeneratedDllImport(Libraries.Kernel32, SetLastError = true)]
         [return: MarshalAs(UnmanagedType.Bool)]
-        internal static extern bool GetQueuedCompletionStatus(IntPtr CompletionPort, out int lpNumberOfBytes, out UIntPtr CompletionKey, out IntPtr lpOverlapped, int dwMilliseconds);
+        internal static partial bool GetQueuedCompletionStatus(IntPtr CompletionPort, out int lpNumberOfBytes, out UIntPtr CompletionKey, out IntPtr lpOverlapped, int dwMilliseconds);
     }
 }
index 6f736ee..af96744 100644 (file)
@@ -14,13 +14,13 @@ internal static partial class Interop
             private IntPtr Ptr;
         }
 
-        [DllImport(Libraries.Kernel32, ExactSpelling = true)]
-        internal static extern unsafe void InitializeConditionVariable(CONDITION_VARIABLE* ConditionVariable);
+        [GeneratedDllImport(Libraries.Kernel32, ExactSpelling = true)]
+        internal static unsafe partial void InitializeConditionVariable(CONDITION_VARIABLE* ConditionVariable);
 
-        [DllImport(Libraries.Kernel32, ExactSpelling = true)]
-        internal static extern unsafe void WakeConditionVariable(CONDITION_VARIABLE* ConditionVariable);
+        [GeneratedDllImport(Libraries.Kernel32, ExactSpelling = true)]
+        internal static unsafe partial void WakeConditionVariable(CONDITION_VARIABLE* ConditionVariable);
 
-        [DllImport(Libraries.Kernel32, ExactSpelling = true)]
-        internal static extern unsafe bool SleepConditionVariableCS(CONDITION_VARIABLE* ConditionVariable, CRITICAL_SECTION* CriticalSection, int dwMilliseconds);
+        [GeneratedDllImport(Libraries.Kernel32, ExactSpelling = true)]
+        internal static unsafe partial bool SleepConditionVariableCS(CONDITION_VARIABLE* ConditionVariable, CRITICAL_SECTION* CriticalSection, int dwMilliseconds);
     }
 }
index 9ecd41c..40a9614 100644 (file)
@@ -20,8 +20,8 @@ internal static partial class Interop
         /// </summary>
         internal const int SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE = 0x2;
 
-        [DllImport(Libraries.Kernel32, EntryPoint = "CreateSymbolicLinkW", SetLastError = true, CharSet = CharSet.Unicode, BestFitMapping = false, ExactSpelling = true)]
-        private static extern bool CreateSymbolicLinkPrivate(string lpSymlinkFileName, string lpTargetFileName, int dwFlags);
+        [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "CreateSymbolicLinkW", CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)]
+        private static partial bool CreateSymbolicLinkPrivate(string lpSymlinkFileName, string lpTargetFileName, int dwFlags);
 
         /// <summary>
         /// Creates a symbolic link.
index 1d9a6ef..cfc24f7 100644 (file)
@@ -19,16 +19,16 @@ internal static partial class Interop
             private UIntPtr SpinCount;
         }
 
-        [DllImport(Libraries.Kernel32, ExactSpelling = true)]
-        internal static extern unsafe void InitializeCriticalSection(CRITICAL_SECTION* lpCriticalSection);
+        [GeneratedDllImport(Libraries.Kernel32, ExactSpelling = true)]
+        internal static unsafe partial void InitializeCriticalSection(CRITICAL_SECTION* lpCriticalSection);
 
-        [DllImport(Libraries.Kernel32, ExactSpelling = true)]
-        internal static extern unsafe void EnterCriticalSection(CRITICAL_SECTION* lpCriticalSection);
+        [GeneratedDllImport(Libraries.Kernel32, ExactSpelling = true)]
+        internal static unsafe partial void EnterCriticalSection(CRITICAL_SECTION* lpCriticalSection);
 
-        [DllImport(Libraries.Kernel32, ExactSpelling = true)]
-        internal static extern unsafe void LeaveCriticalSection(CRITICAL_SECTION* lpCriticalSection);
+        [GeneratedDllImport(Libraries.Kernel32, ExactSpelling = true)]
+        internal static unsafe partial void LeaveCriticalSection(CRITICAL_SECTION* lpCriticalSection);
 
-        [DllImport(Libraries.Kernel32, ExactSpelling = true)]
-        internal static extern unsafe void DeleteCriticalSection(CRITICAL_SECTION* lpCriticalSection);
+        [GeneratedDllImport(Libraries.Kernel32, ExactSpelling = true)]
+        internal static unsafe partial void DeleteCriticalSection(CRITICAL_SECTION* lpCriticalSection);
     }
 }
index be8def2..7e6d1da 100644 (file)
@@ -12,8 +12,8 @@ internal static partial class Interop
         // https://docs.microsoft.com/windows/win32/api/winioctl/ni-winioctl-fsctl_get_reparse_point
         internal const int FSCTL_GET_REPARSE_POINT = 0x000900a8;
 
-        [DllImport(Libraries.Kernel32, EntryPoint = "DeviceIoControl", SetLastError = true, CharSet = CharSet.Unicode, ExactSpelling = true)]
-        internal static extern bool DeviceIoControl(
+        [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "DeviceIoControl", CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)]
+        internal static partial bool DeviceIoControl(
             SafeHandle hDevice,
             uint dwIoControlCode,
             IntPtr lpInBuffer,
index 94257ec..07f09df 100644 (file)
@@ -12,16 +12,16 @@ internal static partial class Interop
         internal const uint CREATE_EVENT_INITIAL_SET = 0x2;
         internal const uint CREATE_EVENT_MANUAL_RESET = 0x1;
 
-        [DllImport(Libraries.Kernel32, SetLastError = true)]
-        internal static extern bool SetEvent(SafeWaitHandle handle);
+        [GeneratedDllImport(Libraries.Kernel32, SetLastError = true)]
+        internal static partial bool SetEvent(SafeWaitHandle handle);
 
-        [DllImport(Libraries.Kernel32, SetLastError = true)]
-        internal static extern bool ResetEvent(SafeWaitHandle handle);
+        [GeneratedDllImport(Libraries.Kernel32, SetLastError = true)]
+        internal static partial bool ResetEvent(SafeWaitHandle handle);
 
-        [DllImport(Libraries.Kernel32, EntryPoint = "CreateEventExW", SetLastError = true, CharSet = CharSet.Unicode, ExactSpelling = true)]
-        internal static extern SafeWaitHandle CreateEventEx(IntPtr lpSecurityAttributes, string? name, uint flags, uint desiredAccess);
+        [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "CreateEventExW", CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)]
+        internal static partial SafeWaitHandle CreateEventEx(IntPtr lpSecurityAttributes, string? name, uint flags, uint desiredAccess);
 
-        [DllImport(Libraries.Kernel32, EntryPoint = "OpenEventW", SetLastError = true, CharSet = CharSet.Unicode, ExactSpelling = true)]
-        internal static extern SafeWaitHandle OpenEvent(uint desiredAccess, bool inheritHandle, string name);
+        [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "OpenEventW", CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)]
+        internal static partial SafeWaitHandle OpenEvent(uint desiredAccess, bool inheritHandle, string name);
     }
 }
index 6d47dbb..32d81b6 100644 (file)
@@ -7,7 +7,7 @@ internal static partial class Interop
 {
     internal static partial class Kernel32
     {
-        [DllImport(Libraries.Kernel32, EntryPoint = "ExpandEnvironmentStringsW", CharSet = CharSet.Unicode, SetLastError = true, ExactSpelling = true)]
-        internal static extern uint ExpandEnvironmentStrings(string lpSrc, ref char lpDst, uint nSize);
+        [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "ExpandEnvironmentStringsW", CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)]
+        internal static partial uint ExpandEnvironmentStrings(string lpSrc, ref char lpDst, uint nSize);
     }
 }
index 8e61970..42afb96 100644 (file)
@@ -9,16 +9,16 @@ internal static partial class Interop
 {
     internal static partial class Kernel32
     {
-        [DllImport(Libraries.Kernel32, SetLastError = true)]
-        internal static extern unsafe int ReadFileScatter(
+        [GeneratedDllImport(Libraries.Kernel32, SetLastError = true)]
+        internal static unsafe partial int ReadFileScatter(
             SafeHandle hFile,
             long* aSegmentArray,
             int nNumberOfBytesToRead,
             IntPtr lpReserved,
             NativeOverlapped* lpOverlapped);
 
-        [DllImport(Libraries.Kernel32, SetLastError = true)]
-        internal static extern unsafe int WriteFileGather(
+        [GeneratedDllImport(Libraries.Kernel32, SetLastError = true)]
+        internal static unsafe partial int WriteFileGather(
             SafeHandle hFile,
             long* aSegmentArray,
             int nNumberOfBytesToWrite,
index b22ab21..adab75e 100644 (file)
@@ -7,8 +7,8 @@ internal static partial class Interop
 {
     internal static partial class Kernel32
     {
-        [DllImport(Libraries.Kernel32)]
+        [GeneratedDllImport(Libraries.Kernel32)]
         [SuppressGCTransition]
-        internal static extern unsafe Interop.BOOL FileTimeToSystemTime(ulong* lpFileTime, Interop.Kernel32.SYSTEMTIME* lpSystemTime);
+        internal static unsafe partial Interop.BOOL FileTimeToSystemTime(ulong* lpFileTime, Interop.Kernel32.SYSTEMTIME* lpSystemTime);
     }
 }
index ab002dc..96f4eb5 100644 (file)
@@ -13,8 +13,8 @@ internal static partial class Interop
         /// <summary>
         /// WARNING: This method does not implicitly handle long paths. Use FindFirstFile.
         /// </summary>
-        [DllImport(Libraries.Kernel32, EntryPoint = "FindFirstFileExW", SetLastError = true, CharSet = CharSet.Unicode, ExactSpelling = true)]
-        private static extern SafeFindHandle FindFirstFileExPrivate(string lpFileName, FINDEX_INFO_LEVELS fInfoLevelId, ref WIN32_FIND_DATA lpFindFileData, FINDEX_SEARCH_OPS fSearchOp, IntPtr lpSearchFilter, int dwAdditionalFlags);
+        [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "FindFirstFileExW", CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)]
+        private static partial SafeFindHandle FindFirstFileExPrivate(string lpFileName, FINDEX_INFO_LEVELS fInfoLevelId, ref WIN32_FIND_DATA lpFindFileData, FINDEX_SEARCH_OPS fSearchOp, IntPtr lpSearchFilter, int dwAdditionalFlags);
 
         internal static SafeFindHandle FindFirstFile(string fileName, ref WIN32_FIND_DATA data)
         {
index b947d5d..dc4f9a4 100644 (file)
@@ -8,7 +8,7 @@ internal static partial class Interop
 {
     internal static partial class Kernel32
     {
-        [DllImport(Libraries.Kernel32, EntryPoint = "FindNextFileW", SetLastError = true, CharSet = CharSet.Unicode, BestFitMapping = false)]
-        internal static extern bool FindNextFile(SafeFindHandle hndFindFile, ref WIN32_FIND_DATA lpFindFileData);
+        [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "FindNextFileW", CharSet = CharSet.Unicode, SetLastError = true)]
+        internal static partial bool FindNextFile(SafeFindHandle hndFindFile, ref WIN32_FIND_DATA lpFindFileData);
     }
 }
index 5af20c0..018f15e 100644 (file)
@@ -7,7 +7,7 @@ internal static partial class Interop
 {
     internal static partial class Kernel32
     {
-        [DllImport(Libraries.Kernel32, ExactSpelling = true)]
-        internal static extern unsafe BOOL FreeEnvironmentStringsW(char* lpszEnvironmentBlock);
+        [GeneratedDllImport(Libraries.Kernel32, ExactSpelling = true)]
+        internal static unsafe partial BOOL FreeEnvironmentStringsW(char* lpszEnvironmentBlock);
     }
 }
index 990a43c..0b5f3cc 100644 (file)
@@ -16,7 +16,7 @@ internal static partial class Interop
             internal fixed byte LeadByte[12 /* MAX_LEADBYTES */];
         }
 
-        [DllImport(Libraries.Kernel32)]
-        internal static extern unsafe Interop.BOOL GetCPInfo(uint codePage, CPINFO* lpCpInfo);
+        [GeneratedDllImport(Libraries.Kernel32)]
+        internal static unsafe partial Interop.BOOL GetCPInfo(uint codePage, CPINFO* lpCpInfo);
     }
 }
index a8b30eb..0146786 100644 (file)
@@ -7,7 +7,7 @@ internal static partial class Interop
 {
     internal static partial class Kernel32
     {
-        [DllImport(Libraries.Kernel32, EntryPoint = "GetCurrentDirectoryW", SetLastError = true, CharSet = CharSet.Unicode, BestFitMapping = false, ExactSpelling = true)]
-        internal static extern uint GetCurrentDirectory(uint nBufferLength, ref char lpBuffer);
+        [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "GetCurrentDirectoryW", CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)]
+        internal static partial uint GetCurrentDirectory(uint nBufferLength, ref char lpBuffer);
     }
 }
index 5545201..06b89ce 100644 (file)
@@ -7,7 +7,7 @@ internal static partial class Interop
 {
     internal static partial class Kernel32
     {
-        [DllImport(Libraries.Kernel32, ExactSpelling = true)]
-        internal static extern unsafe char* GetEnvironmentStringsW();
+        [GeneratedDllImport(Libraries.Kernel32, ExactSpelling = true)]
+        internal static unsafe partial char* GetEnvironmentStringsW();
     }
 }
index 425ea9e..60dbfc5 100644 (file)
@@ -8,7 +8,7 @@ internal static partial class Interop
 {
     internal static partial class Kernel32
     {
-        [DllImport(Libraries.Kernel32, EntryPoint = "GetEnvironmentVariableW", SetLastError = true, CharSet = CharSet.Unicode, ExactSpelling = true)]
-        internal static extern uint GetEnvironmentVariable(string lpName, ref char lpBuffer, uint nSize);
+        [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "GetEnvironmentVariableW", CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)]
+        internal static partial uint GetEnvironmentVariable(string lpName, ref char lpBuffer, uint nSize);
     }
 }
index f91af06..6eb1052 100644 (file)
@@ -8,7 +8,7 @@ internal static partial class Interop
 {
     internal static partial class Kernel32
     {
-        [DllImport(Libraries.Kernel32, SetLastError = true, ExactSpelling = true)]
-        internal static extern unsafe bool GetFileInformationByHandleEx(SafeFileHandle hFile, int FileInformationClass, void* lpFileInformation, uint dwBufferSize);
+        [GeneratedDllImport(Libraries.Kernel32, ExactSpelling = true, SetLastError = true)]
+        internal static unsafe partial bool GetFileInformationByHandleEx(SafeFileHandle hFile, int FileInformationClass, void* lpFileInformation, uint dwBufferSize);
     }
 }
index 756b1bb..26ded9e 100644 (file)
@@ -13,8 +13,8 @@ internal static partial class Interop
         internal const uint FILE_NAME_NORMALIZED = 0x0;
 
         // https://docs.microsoft.com/windows/desktop/api/fileapi/nf-fileapi-getfinalpathnamebyhandlew (kernel32)
-        [DllImport(Libraries.Kernel32, EntryPoint = "GetFinalPathNameByHandleW", CharSet = CharSet.Unicode, SetLastError = true, ExactSpelling = true)]
-        internal static unsafe extern uint GetFinalPathNameByHandle(
+        [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "GetFinalPathNameByHandleW", CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)]
+        internal static unsafe partial uint GetFinalPathNameByHandle(
             SafeFileHandle hFile,
             char* lpszFilePath,
             uint cchFilePath,
index 6dec98d..55a8417 100644 (file)
@@ -7,8 +7,8 @@ internal static partial class Interop
 {
     internal static partial class Kernel32
     {
-        [DllImport(Libraries.Kernel32)]
+        [GeneratedDllImport(Libraries.Kernel32)]
         [SuppressGCTransition]
-        internal static extern int GetLastError();
+        internal static partial int GetLastError();
     }
 }
index 3973f97..1bf4e59 100644 (file)
@@ -10,7 +10,7 @@ internal static partial class Interop
 {
     internal static partial class Kernel32
     {
-        [DllImport(Libraries.Kernel32, EntryPoint = "GetModuleFileNameW", SetLastError = true, CharSet = CharSet.Unicode, ExactSpelling = true)]
-        internal static extern uint GetModuleFileName(IntPtr hModule, ref char lpFilename, uint nSize);
+        [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "GetModuleFileNameW", CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)]
+        internal static partial uint GetModuleFileName(IntPtr hModule, ref char lpFilename, uint nSize);
     }
 }
index 6d52bff..1375d0e 100644 (file)
@@ -9,8 +9,8 @@ internal static partial class Interop
 {
     internal static partial class Kernel32
     {
-        [DllImport(Libraries.Kernel32, SetLastError = true, CharSet = CharSet.Auto)]
-        internal static extern unsafe bool GetOverlappedResult(
+        [GeneratedDllImport(Libraries.Kernel32, CharSet = CharSet.Auto, SetLastError = true)]
+        internal static unsafe partial bool GetOverlappedResult(
             SafeFileHandle hFile,
             NativeOverlapped* lpOverlapped,
             ref int lpNumberOfBytesTransferred,
index cc15f5d..8bc8826 100644 (file)
@@ -23,7 +23,7 @@ internal static partial class Interop
             public UIntPtr PeakPagefileUsage;
         }
 
-        [DllImport(Libraries.Kernel32, EntryPoint="K32GetProcessMemoryInfo")]
-        internal static extern bool GetProcessMemoryInfo(IntPtr Process, ref PROCESS_MEMORY_COUNTERS ppsmemCounters, uint cb);
+        [GeneratedDllImport(Libraries.Kernel32, EntryPoint ="K32GetProcessMemoryInfo")]
+        internal static partial bool GetProcessMemoryInfo(IntPtr Process, ref PROCESS_MEMORY_COUNTERS ppsmemCounters, uint cb);
     }
 }
index 89489a5..8422232 100644 (file)
@@ -8,7 +8,7 @@ internal static partial class Interop
 {
     internal static partial class Kernel32
     {
-        [DllImport(Libraries.Kernel32, SetLastError = true)]
-        internal static extern bool GetProcessTimes(IntPtr handleProcess, out long creation, out long exit, out long kernel, out long user);
+        [GeneratedDllImport(Libraries.Kernel32, SetLastError = true)]
+        internal static partial bool GetProcessTimes(IntPtr handleProcess, out long creation, out long exit, out long kernel, out long user);
     }
 }
index bf835ab..625d689 100644 (file)
@@ -7,7 +7,7 @@ internal static partial class Interop
 {
     internal static partial class Kernel32
     {
-        [DllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, SetLastError = true, ExactSpelling = true)]
-        internal static extern uint GetSystemDirectoryW(ref char lpBuffer, uint uSize);
+        [GeneratedDllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)]
+        internal static partial uint GetSystemDirectoryW(ref char lpBuffer, uint uSize);
     }
 }
index 8f49121..e97c565 100644 (file)
@@ -7,8 +7,8 @@ internal static partial class Interop
 {
     internal static partial class Kernel32
     {
-        [DllImport(Libraries.Kernel32)]
+        [GeneratedDllImport(Libraries.Kernel32)]
         [SuppressGCTransition]
-        internal static extern unsafe void GetSystemTime(Interop.Kernel32.SYSTEMTIME* lpSystemTime);
+        internal static unsafe partial void GetSystemTime(Interop.Kernel32.SYSTEMTIME* lpSystemTime);
     }
 }
index 7c1cc62..29000a9 100644 (file)
@@ -7,7 +7,7 @@ internal static partial class Interop
 {
     internal static partial class Kernel32
     {
-        [DllImport(Libraries.Kernel32, SetLastError = true)]
-        internal static extern bool GetSystemTimes(out long idle, out long kernel, out long user);
+        [GeneratedDllImport(Libraries.Kernel32, SetLastError = true)]
+        internal static partial bool GetSystemTimes(out long idle, out long kernel, out long user);
     }
 }
index 79807ff..4d08aac 100644 (file)
@@ -7,7 +7,7 @@ internal static partial class Interop
 {
     internal static partial class Kernel32
     {
-        [DllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, SetLastError = true, BestFitMapping = false, ExactSpelling = true)]
-        internal static extern uint GetTempFileNameW(ref char lpPathName, string lpPrefixString, uint uUnique, ref char lpTempFileName);
+        [GeneratedDllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)]
+        internal static partial uint GetTempFileNameW(ref char lpPathName, string lpPrefixString, uint uUnique, ref char lpTempFileName);
     }
 }
index 5d555df..f27a00a 100644 (file)
@@ -7,7 +7,7 @@ internal static partial class Interop
 {
     internal static partial class Kernel32
     {
-        [DllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, BestFitMapping = false, ExactSpelling = true)]
-        internal static extern uint GetTempPathW(int bufferLen, ref char buffer);
+        [GeneratedDllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, ExactSpelling = true)]
+        internal static partial uint GetTempPathW(int bufferLen, ref char buffer);
     }
 }
index 662cab8..9704e1c 100644 (file)
@@ -7,7 +7,7 @@ internal static partial class Interop
 {
     internal static partial class Kernel32
     {
-        [DllImport(Libraries.Kernel32)]
-        internal static unsafe extern BOOL GlobalMemoryStatusEx(MEMORYSTATUSEX* lpBuffer);
+        [GeneratedDllImport(Libraries.Kernel32)]
+        internal static unsafe partial BOOL GlobalMemoryStatusEx(MEMORYSTATUSEX* lpBuffer);
     }
 }
index cda3b0b..fd08870 100644 (file)
@@ -47,14 +47,14 @@ internal static partial class Interop
         internal const string LOCALE_NAME_USER_DEFAULT = null;
         internal const string LOCALE_NAME_SYSTEM_DEFAULT = "!x-sys-default-locale";
 
-        [DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
-        internal static extern unsafe int LCIDToLocaleName(int locale, char* pLocaleName, int cchName, uint dwFlags);
+        [GeneratedDllImport("kernel32.dll", CharSet = CharSet.Unicode)]
+        internal static unsafe partial int LCIDToLocaleName(int locale, char* pLocaleName, int cchName, uint dwFlags);
 
-        [DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
-        internal static extern int LocaleNameToLCID(string lpName, uint dwFlags);
+        [GeneratedDllImport("kernel32.dll", CharSet = CharSet.Unicode)]
+        internal static partial int LocaleNameToLCID(string lpName, uint dwFlags);
 
-        [DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
-        internal static extern unsafe int LCMapStringEx(
+        [GeneratedDllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
+        internal static unsafe partial int LCMapStringEx(
                     string? lpLocaleName,
                     uint dwMapFlags,
                     char* lpSrcStr,
@@ -65,8 +65,8 @@ internal static partial class Interop
                     void* lpReserved,
                     IntPtr sortHandle);
 
-        [DllImport("kernel32.dll", EntryPoint = "FindNLSStringEx", SetLastError = SetLastErrorForDebug)]
-        internal static extern unsafe int FindNLSStringEx(
+        [GeneratedDllImport("kernel32.dll", EntryPoint = "FindNLSStringEx", SetLastError = SetLastErrorForDebug)]
+        internal static unsafe partial int FindNLSStringEx(
                     char* lpLocaleName,
                     uint dwFindNLSStringFlags,
                     char* lpStringSource,
@@ -78,8 +78,8 @@ internal static partial class Interop
                     void* lpReserved,
                     IntPtr sortHandle);
 
-        [DllImport("kernel32.dll", EntryPoint = "CompareStringEx")]
-        internal static extern unsafe int CompareStringEx(
+        [GeneratedDllImport("kernel32.dll", EntryPoint = "CompareStringEx")]
+        internal static unsafe partial int CompareStringEx(
                     char* lpLocaleName,
                     uint dwCmpFlags,
                     char* lpString1,
@@ -90,16 +90,16 @@ internal static partial class Interop
                     void* lpReserved,
                     IntPtr lParam);
 
-        [DllImport("kernel32.dll", EntryPoint = "CompareStringOrdinal")]
-        internal static extern unsafe int CompareStringOrdinal(
+        [GeneratedDllImport("kernel32.dll", EntryPoint = "CompareStringOrdinal")]
+        internal static unsafe partial int CompareStringOrdinal(
                     char* lpString1,
                     int cchCount1,
                     char* lpString2,
                     int cchCount2,
                     bool bIgnoreCase);
 
-        [DllImport("kernel32.dll", EntryPoint = "FindStringOrdinal", SetLastError = SetLastErrorForDebug)]
-        internal static extern unsafe int FindStringOrdinal(
+        [GeneratedDllImport("kernel32.dll", EntryPoint = "FindStringOrdinal", SetLastError = SetLastErrorForDebug)]
+        internal static unsafe partial int FindStringOrdinal(
                     uint dwFindStringOrdinalFlags,
                     char* lpStringSource,
                     int cchSource,
@@ -107,40 +107,40 @@ internal static partial class Interop
                     int cchValue,
                     BOOL bIgnoreCase);
 
-        [DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
-        internal static extern unsafe bool IsNLSDefinedString(
+        [GeneratedDllImport("kernel32.dll", CharSet = CharSet.Unicode)]
+        internal static unsafe partial bool IsNLSDefinedString(
                     int Function,
                     uint dwFlags,
                     IntPtr lpVersionInformation,
                     char* lpString,
                     int cchStr);
 
-        [DllImport("kernel32.dll", CharSet = CharSet.Auto)]
-        internal static extern unsafe Interop.BOOL GetUserPreferredUILanguages(uint dwFlags, uint* pulNumLanguages, char* pwszLanguagesBuffer, uint* pcchLanguagesBuffer);
+        [GeneratedDllImport("kernel32.dll", CharSet = CharSet.Auto)]
+        internal static unsafe partial Interop.BOOL GetUserPreferredUILanguages(uint dwFlags, uint* pulNumLanguages, char* pwszLanguagesBuffer, uint* pcchLanguagesBuffer);
 
-        [DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
-        internal static extern unsafe int GetLocaleInfoEx(string lpLocaleName, uint LCType, void* lpLCData, int cchData);
+        [GeneratedDllImport("kernel32.dll", CharSet = CharSet.Unicode)]
+        internal static unsafe partial int GetLocaleInfoEx(string lpLocaleName, uint LCType, void* lpLCData, int cchData);
 
-        [DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
-        internal static extern unsafe bool EnumSystemLocalesEx(delegate* unmanaged<char*, uint, void*, BOOL> lpLocaleEnumProcEx, uint dwFlags, void* lParam, IntPtr reserved);
+        [GeneratedDllImport("kernel32.dll", CharSet = CharSet.Unicode)]
+        internal static unsafe partial bool EnumSystemLocalesEx(delegate* unmanaged<char*, uint, void*, BOOL> lpLocaleEnumProcEx, uint dwFlags, void* lParam, IntPtr reserved);
 
-        [DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
-        internal static extern unsafe bool EnumTimeFormatsEx(delegate* unmanaged<char*, void*, BOOL> lpTimeFmtEnumProcEx, string lpLocaleName, uint dwFlags, void* lParam);
+        [GeneratedDllImport("kernel32.dll", CharSet = CharSet.Unicode)]
+        internal static unsafe partial bool EnumTimeFormatsEx(delegate* unmanaged<char*, void*, BOOL> lpTimeFmtEnumProcEx, string lpLocaleName, uint dwFlags, void* lParam);
 
-        [DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
-        internal static extern int GetCalendarInfoEx(string? lpLocaleName, uint Calendar, IntPtr lpReserved, uint CalType, IntPtr lpCalData, int cchData, out int lpValue);
+        [GeneratedDllImport("kernel32.dll", CharSet = CharSet.Unicode)]
+        internal static partial int GetCalendarInfoEx(string? lpLocaleName, uint Calendar, IntPtr lpReserved, uint CalType, IntPtr lpCalData, int cchData, out int lpValue);
 
-        [DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
-        internal static extern int GetCalendarInfoEx(string? lpLocaleName, uint Calendar, IntPtr lpReserved, uint CalType, IntPtr lpCalData, int cchData, IntPtr lpValue);
+        [GeneratedDllImport("kernel32.dll", CharSet = CharSet.Unicode)]
+        internal static partial int GetCalendarInfoEx(string? lpLocaleName, uint Calendar, IntPtr lpReserved, uint CalType, IntPtr lpCalData, int cchData, IntPtr lpValue);
 
-        [DllImport("kernel32.dll")]
-        internal static extern int GetUserGeoID(int geoClass);
+        [GeneratedDllImport("kernel32.dll")]
+        internal static partial int GetUserGeoID(int geoClass);
 
-        [DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
-        internal static extern unsafe int GetGeoInfo(int location, int geoType, char* lpGeoData, int cchData, int LangId);
+        [GeneratedDllImport("kernel32.dll", CharSet = CharSet.Unicode)]
+        internal static unsafe partial int GetGeoInfo(int location, int geoType, char* lpGeoData, int cchData, int LangId);
 
-        [DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
-        internal static extern unsafe bool EnumCalendarInfoExEx(delegate* unmanaged<char*, uint, IntPtr, void*, BOOL> pCalInfoEnumProcExEx, string lpLocaleName, uint Calendar, string? lpReserved, uint CalType, void* lParam);
+        [GeneratedDllImport("kernel32.dll", CharSet = CharSet.Unicode)]
+        internal static unsafe partial bool EnumCalendarInfoExEx(delegate* unmanaged<char*, uint, IntPtr, void*, BOOL> pCalInfoEnumProcExEx, string lpLocaleName, uint Calendar, string? lpReserved, uint CalType, void* lParam);
 
         [StructLayout(LayoutKind.Sequential)]
         internal struct NlsVersionInfoEx
@@ -152,7 +152,7 @@ internal static partial class Interop
             internal Guid guidCustomVersion;
         }
 
-        [DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
-        internal static extern unsafe bool GetNLSVersionEx(int function, string localeName, NlsVersionInfoEx* lpVersionInformation);
+        [GeneratedDllImport("kernel32.dll", CharSet = CharSet.Unicode)]
+        internal static unsafe partial bool GetNLSVersionEx(int function, string localeName, NlsVersionInfoEx* lpVersionInformation);
     }
 }
index 4883779..0bcd7e3 100644 (file)
@@ -12,13 +12,13 @@ internal static partial class Interop
         internal const uint LMEM_MOVEABLE = 0x0002;
         internal const uint LMEM_ZEROINIT = 0x0040;
 
-        [DllImport(Libraries.Kernel32)]
-        internal static extern IntPtr LocalAlloc(uint uFlags, nuint uBytes);
+        [GeneratedDllImport(Libraries.Kernel32)]
+        internal static partial IntPtr LocalAlloc(uint uFlags, nuint uBytes);
 
-        [DllImport(Libraries.Kernel32)]
-        internal static extern IntPtr LocalReAlloc(IntPtr hMem, nuint uBytes, uint uFlags);
+        [GeneratedDllImport(Libraries.Kernel32)]
+        internal static partial IntPtr LocalReAlloc(IntPtr hMem, nuint uBytes, uint uFlags);
 
-        [DllImport(Libraries.Kernel32)]
-        internal static extern IntPtr LocalFree(IntPtr hMem);
+        [GeneratedDllImport(Libraries.Kernel32)]
+        internal static partial IntPtr LocalFree(IntPtr hMem);
     }
 }
index b00cb73..574960a 100644 (file)
@@ -8,10 +8,10 @@ internal static partial class Interop
 {
     internal static partial class Kernel32
     {
-        [DllImport(Libraries.Kernel32, SetLastError = true)]
-        internal static extern bool LockFile(SafeFileHandle handle, int offsetLow, int offsetHigh, int countLow, int countHigh);
+        [GeneratedDllImport(Libraries.Kernel32, SetLastError = true)]
+        internal static partial bool LockFile(SafeFileHandle handle, int offsetLow, int offsetHigh, int countLow, int countHigh);
 
-        [DllImport(Libraries.Kernel32, SetLastError = true)]
-        internal static extern bool UnlockFile(SafeFileHandle handle, int offsetLow, int offsetHigh, int countLow, int countHigh);
+        [GeneratedDllImport(Libraries.Kernel32, SetLastError = true)]
+        internal static partial bool UnlockFile(SafeFileHandle handle, int offsetLow, int offsetHigh, int countLow, int countHigh);
     }
 }
index 3988d7b..4c09f29 100644 (file)
@@ -11,13 +11,13 @@ internal static partial class Interop
     {
         internal const uint CREATE_MUTEX_INITIAL_OWNER = 0x1;
 
-        [DllImport(Libraries.Kernel32, EntryPoint = "OpenMutexW", SetLastError = true, CharSet = CharSet.Unicode, ExactSpelling = true)]
-        internal static extern SafeWaitHandle OpenMutex(uint desiredAccess, bool inheritHandle, string name);
+        [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "OpenMutexW", CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)]
+        internal static partial SafeWaitHandle OpenMutex(uint desiredAccess, bool inheritHandle, string name);
 
-        [DllImport(Libraries.Kernel32, EntryPoint = "CreateMutexExW", SetLastError = true, CharSet = CharSet.Unicode, ExactSpelling = true)]
-        internal static extern SafeWaitHandle CreateMutexEx(IntPtr lpMutexAttributes, string? name, uint flags, uint desiredAccess);
+        [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "CreateMutexExW", CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)]
+        internal static partial SafeWaitHandle CreateMutexEx(IntPtr lpMutexAttributes, string? name, uint flags, uint desiredAccess);
 
-        [DllImport(Libraries.Kernel32, SetLastError = true)]
-        internal static extern bool ReleaseMutex(SafeWaitHandle handle);
+        [GeneratedDllImport(Libraries.Kernel32, SetLastError = true)]
+        internal static partial bool ReleaseMutex(SafeWaitHandle handle);
     }
 }
index 4d1f889..e7ee12e 100644 (file)
@@ -7,7 +7,7 @@ internal static partial class Interop
 {
     internal static partial class Kernel32
     {
-        [DllImport(Interop.Libraries.Kernel32, CharSet = CharSet.Unicode, EntryPoint = "OutputDebugStringW", ExactSpelling = true)]
-        internal static extern void OutputDebugString(string message);
+        [GeneratedDllImport(Interop.Libraries.Kernel32, EntryPoint = "OutputDebugStringW", CharSet = CharSet.Unicode, ExactSpelling = true)]
+        internal static partial void OutputDebugString(string message);
     }
 }
index 9f396d0..241ab3f 100644 (file)
@@ -15,8 +15,8 @@ internal static partial class Interop
         // We take a long* (rather than a out long) to avoid the pinning overhead.
         // We don't set last error since we don't need the extended error info.
 
-        [DllImport(Libraries.Kernel32, ExactSpelling = true)]
+        [GeneratedDllImport(Libraries.Kernel32, ExactSpelling = true)]
         [SuppressGCTransition]
-        internal static extern unsafe BOOL QueryPerformanceCounter(long* lpPerformanceCount);
+        internal static unsafe partial BOOL QueryPerformanceCounter(long* lpPerformanceCount);
     }
 }
index cf5f975..f6c7e9e 100644 (file)
@@ -15,7 +15,7 @@ internal static partial class Interop
         // We take a long* (rather than a out long) to avoid the pinning overhead.
         // We don't set last error since we don't need the extended error info.
 
-        [DllImport(Libraries.Kernel32, ExactSpelling = true)]
-        internal static extern unsafe BOOL QueryPerformanceFrequency(long* lpFrequency);
+        [GeneratedDllImport(Libraries.Kernel32, ExactSpelling = true)]
+        internal static unsafe partial BOOL QueryPerformanceFrequency(long* lpFrequency);
     }
 }
index a93dcec..efb57ea 100644 (file)
@@ -7,7 +7,7 @@ internal static partial class Interop
 {
     internal static partial class Kernel32
     {
-        [DllImport(Libraries.Kernel32)]
-        internal static extern bool QueryUnbiasedInterruptTime(out ulong UnbiasedTime);
+        [GeneratedDllImport(Libraries.Kernel32)]
+        internal static partial bool QueryUnbiasedInterruptTime(out ulong UnbiasedTime);
     }
 }
index 5e0d8df..cf01ba6 100644 (file)
@@ -9,7 +9,7 @@ internal static partial class Interop
     {
         internal const int LOCALE_NAME_MAX_LENGTH = 85;
 
-        [DllImport("kernel32.dll", CharSet = CharSet.Unicode)]
-        internal static extern int ResolveLocaleName(string lpNameToResolve, char* lpLocaleName, int cchLocaleName);
+        [GeneratedDllImport("kernel32.dll", CharSet = CharSet.Unicode)]
+        internal static partial int ResolveLocaleName(string lpNameToResolve, char* lpLocaleName, int cchLocaleName);
     }
 }
index 435c47e..44034fb 100644 (file)
@@ -9,13 +9,13 @@ internal static partial class Interop
 {
     internal static partial class Kernel32
     {
-        [DllImport(Libraries.Kernel32, EntryPoint = "OpenSemaphoreW", SetLastError = true, CharSet = CharSet.Unicode, ExactSpelling = true)]
-        internal static extern SafeWaitHandle OpenSemaphore(uint desiredAccess, bool inheritHandle, string name);
+        [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "OpenSemaphoreW", CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)]
+        internal static partial SafeWaitHandle OpenSemaphore(uint desiredAccess, bool inheritHandle, string name);
 
-        [DllImport(Libraries.Kernel32, EntryPoint = "CreateSemaphoreExW", SetLastError = true, CharSet = CharSet.Unicode, ExactSpelling = true)]
-        internal static extern SafeWaitHandle CreateSemaphoreEx(IntPtr lpSecurityAttributes, int initialCount, int maximumCount, string? name, uint flags, uint desiredAccess);
+        [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "CreateSemaphoreExW", CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)]
+        internal static partial SafeWaitHandle CreateSemaphoreEx(IntPtr lpSecurityAttributes, int initialCount, int maximumCount, string? name, uint flags, uint desiredAccess);
 
-        [DllImport(Libraries.Kernel32, SetLastError = true)]
-        internal static extern bool ReleaseSemaphore(SafeWaitHandle handle, int releaseCount, out int previousCount);
+        [GeneratedDllImport(Libraries.Kernel32, SetLastError = true)]
+        internal static partial bool ReleaseSemaphore(SafeWaitHandle handle, int releaseCount, out int previousCount);
     }
 }
index 51cc5da..46af9a9 100644 (file)
@@ -7,7 +7,7 @@ internal static partial class Interop
 {
     internal static partial class Kernel32
     {
-        [DllImport(Libraries.Kernel32, EntryPoint = "SetCurrentDirectoryW", SetLastError = true, CharSet = CharSet.Unicode, BestFitMapping = false, ExactSpelling = true)]
-        internal static extern bool SetCurrentDirectory(string path);
+        [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "SetCurrentDirectoryW", CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)]
+        internal static partial bool SetCurrentDirectory(string path);
     }
 }
index 9c7d2eb..63b0971 100644 (file)
@@ -7,7 +7,7 @@ internal static partial class Interop
 {
     internal static partial class Kernel32
     {
-        [DllImport(Libraries.Kernel32, EntryPoint = "SetEnvironmentVariableW", SetLastError = true, CharSet = CharSet.Unicode, BestFitMapping = false, ExactSpelling = true)]
-        internal static extern bool SetEnvironmentVariable(string lpName, string? lpValue);
+        [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "SetEnvironmentVariableW", CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)]
+        internal static partial bool SetEnvironmentVariable(string lpName, string? lpValue);
     }
 }
index 7f8b472..028a0ff 100644 (file)
@@ -8,7 +8,7 @@ internal static partial class Interop
 {
     internal static partial class Kernel32
     {
-        [DllImport(Libraries.Kernel32, SetLastError = true)]
-        internal static extern bool SetFilePointerEx(SafeFileHandle hFile, long liDistanceToMove, out long lpNewFilePointer, uint dwMoveMethod);
+        [GeneratedDllImport(Libraries.Kernel32, SetLastError = true)]
+        internal static partial bool SetFilePointerEx(SafeFileHandle hFile, long liDistanceToMove, out long lpNewFilePointer, uint dwMoveMethod);
     }
 }
index 1a43948..baf852e 100644 (file)
@@ -7,8 +7,8 @@ internal partial class Interop
 {
     internal static partial class Kernel32
     {
-        [DllImport(Libraries.Kernel32)]
+        [GeneratedDllImport(Libraries.Kernel32)]
         [SuppressGCTransition]
-        internal static extern void SetLastError(int errorCode);
+        internal static partial void SetLastError(int errorCode);
     }
 }
index 41d4b06..10fe408 100644 (file)
@@ -7,8 +7,8 @@ internal static partial class Interop
 {
     internal static partial class Kernel32
     {
-        [DllImport(Libraries.Kernel32)]
+        [GeneratedDllImport(Libraries.Kernel32)]
         [SuppressGCTransition]
-        internal static extern unsafe Interop.BOOL SystemTimeToFileTime(Interop.Kernel32.SYSTEMTIME* lpSystemTime, ulong* lpFileTime);
+        internal static unsafe partial Interop.BOOL SystemTimeToFileTime(Interop.Kernel32.SYSTEMTIME* lpSystemTime, ulong* lpFileTime);
     }
 }
index 3ed4708..7ad0dde 100644 (file)
@@ -83,10 +83,10 @@ internal static partial class Interop
 
         internal const uint TIME_ZONE_ID_INVALID = unchecked((uint)-1);
 
-        [DllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, SetLastError = true, ExactSpelling = true)]
-        internal static extern uint GetDynamicTimeZoneInformation(out TIME_DYNAMIC_ZONE_INFORMATION pTimeZoneInformation);
+        [GeneratedDllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)]
+        internal static partial uint GetDynamicTimeZoneInformation(out TIME_DYNAMIC_ZONE_INFORMATION pTimeZoneInformation);
 
-        [DllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, SetLastError = true, ExactSpelling = true)]
-        internal static extern uint GetTimeZoneInformation(out TIME_ZONE_INFORMATION lpTimeZoneInformation);
+        [GeneratedDllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)]
+        internal static partial uint GetTimeZoneInformation(out TIME_ZONE_INFORMATION lpTimeZoneInformation);
     }
 }
index 2e5e264..7fc3013 100644 (file)
@@ -8,8 +8,8 @@ internal static partial class Interop
 {
     internal static partial class Kernel32
     {
-        [DllImport(Libraries.Kernel32)]
-        internal static extern unsafe Interop.BOOL TzSpecificLocalTimeToSystemTime(
+        [GeneratedDllImport(Libraries.Kernel32)]
+        internal static unsafe partial Interop.BOOL TzSpecificLocalTimeToSystemTime(
             IntPtr lpTimeZoneInformation,
             Interop.Kernel32.SYSTEMTIME* lpLocalTime,
             Interop.Kernel32.SYSTEMTIME* lpUniversalTime);
index e2aba5e..6ca6d77 100644 (file)
@@ -7,7 +7,7 @@ internal static partial class Interop
 {
     internal static partial class Kernel32
     {
-        [DllImport(Libraries.Kernel32)]
-        internal static extern ulong VerSetConditionMask(ulong ConditionMask, uint TypeMask, byte Condition);
+        [GeneratedDllImport(Libraries.Kernel32)]
+        internal static partial ulong VerSetConditionMask(ulong ConditionMask, uint TypeMask, byte Condition);
     }
 }
index 3af8fa7..7ca8227 100644 (file)
@@ -13,7 +13,7 @@ internal static partial class Interop
         internal const uint VER_SERVICEPACKMAJOR = 0x0000020;
         internal const uint VER_SERVICEPACKMINOR = 0x0000010;
 
-        [DllImport(Libraries.Kernel32)]
-        internal static extern bool VerifyVersionInfoW(ref OSVERSIONINFOEX lpVersionInfo, uint dwTypeMask, ulong dwlConditionMask);
+        [GeneratedDllImport(Libraries.Kernel32)]
+        internal static partial bool VerifyVersionInfoW(ref OSVERSIONINFOEX lpVersionInfo, uint dwTypeMask, ulong dwlConditionMask);
     }
 }
index 6f37972..d432f56 100644 (file)
@@ -8,7 +8,7 @@ internal static partial class Interop
 {
     internal static partial class Kernel32
     {
-        [DllImport(Libraries.Kernel32, ExactSpelling = true)]
-        internal static extern unsafe void* VirtualAlloc(void* lpAddress, UIntPtr dwSize, int flAllocationType, int flProtect);
+        [GeneratedDllImport(Libraries.Kernel32, ExactSpelling = true)]
+        internal static unsafe partial void* VirtualAlloc(void* lpAddress, UIntPtr dwSize, int flAllocationType, int flProtect);
     }
 }
index 3ff002e..6e75b25 100644 (file)
@@ -8,7 +8,7 @@ internal static partial class Interop
 {
     internal static partial class Kernel32
     {
-        [DllImport(Libraries.Kernel32, ExactSpelling = true)]
-        internal static extern unsafe bool VirtualFree(void* lpAddress, UIntPtr dwSize, int dwFreeType);
+        [GeneratedDllImport(Libraries.Kernel32, ExactSpelling = true)]
+        internal static unsafe partial bool VirtualFree(void* lpAddress, UIntPtr dwSize, int dwFreeType);
     }
 }
index 59622e8..f3fdf78 100644 (file)
@@ -8,7 +8,7 @@ internal static partial class Interop
 {
     internal static partial class Kernel32
     {
-        [DllImport(Libraries.Kernel32, SetLastError = true, ExactSpelling = true)]
-        internal static extern unsafe UIntPtr VirtualQuery(void* lpAddress, ref MEMORY_BASIC_INFORMATION lpBuffer, UIntPtr dwLength);
+        [GeneratedDllImport(Libraries.Kernel32, ExactSpelling = true, SetLastError = true)]
+        internal static unsafe partial UIntPtr VirtualQuery(void* lpAddress, ref MEMORY_BASIC_INFORMATION lpBuffer, UIntPtr dwLength);
     }
 }
index 9bc7631..d796f9e 100644 (file)
@@ -11,16 +11,16 @@ internal static partial class Interop
         //  Idn APIs
         //
 
-        [DllImport("Normaliz.dll", CharSet = CharSet.Unicode, SetLastError = true)]
-        internal static extern unsafe int IdnToAscii(
+        [GeneratedDllImport("Normaliz.dll", CharSet = CharSet.Unicode, SetLastError = true)]
+        internal static unsafe partial int IdnToAscii(
                                         uint dwFlags,
                                         char* lpUnicodeCharStr,
                                         int cchUnicodeChar,
                                         char* lpASCIICharStr,
                                         int cchASCIIChar);
 
-        [DllImport("Normaliz.dll", CharSet = CharSet.Unicode, SetLastError = true)]
-        internal static extern unsafe int IdnToUnicode(
+        [GeneratedDllImport("Normaliz.dll", CharSet = CharSet.Unicode, SetLastError = true)]
+        internal static unsafe partial int IdnToUnicode(
                                         uint dwFlags,
                                         char* lpASCIICharStr,
                                         int cchASCIIChar,
index dee9a17..09a5bd0 100644 (file)
@@ -8,11 +8,11 @@ internal static partial class Interop
 {
     internal static partial class Normaliz
     {
-        [DllImport("Normaliz.dll", CharSet = CharSet.Unicode, SetLastError = true)]
-        internal static extern unsafe BOOL IsNormalizedString(NormalizationForm normForm, char* source, int length);
+        [GeneratedDllImport("Normaliz.dll", CharSet = CharSet.Unicode, SetLastError = true)]
+        internal static unsafe partial BOOL IsNormalizedString(NormalizationForm normForm, char* source, int length);
 
-        [DllImport("Normaliz.dll", CharSet = CharSet.Unicode, SetLastError = true)]
-        internal static extern unsafe int NormalizeString(
+        [GeneratedDllImport("Normaliz.dll", CharSet = CharSet.Unicode, SetLastError = true)]
+        internal static unsafe partial int NormalizeString(
                                         NormalizationForm normForm,
                                         char* source,
                                         int sourceLength,
index 7d6ab13..ad3f3c7 100644 (file)
@@ -12,8 +12,8 @@ internal static partial class Interop
     {
         // https://msdn.microsoft.com/en-us/library/bb432380.aspx
         // https://msdn.microsoft.com/en-us/library/windows/hardware/ff566424.aspx
-        [DllImport(Libraries.NtDll, CharSet = CharSet.Unicode, ExactSpelling = true)]
-        private static extern unsafe uint NtCreateFile(
+        [GeneratedDllImport(Libraries.NtDll, CharSet = CharSet.Unicode, ExactSpelling = true)]
+        private static unsafe partial uint NtCreateFile(
             IntPtr* FileHandle,
             DesiredAccess DesiredAccess,
             OBJECT_ATTRIBUTES* ObjectAttributes,
index 25d5f5f..11fd068 100644 (file)
@@ -10,8 +10,8 @@ internal static partial class Interop
     {
         // https://msdn.microsoft.com/en-us/library/windows/hardware/ff556633.aspx
         // https://msdn.microsoft.com/en-us/library/windows/hardware/ff567047.aspx
-        [DllImport(Libraries.NtDll, CharSet = CharSet.Unicode, ExactSpelling = true)]
-        public static unsafe extern int NtQueryDirectoryFile(
+        [GeneratedDllImport(Libraries.NtDll, CharSet = CharSet.Unicode, ExactSpelling = true)]
+        public static unsafe partial int NtQueryDirectoryFile(
             IntPtr FileHandle,
             IntPtr Event,
             IntPtr ApcRoutine,
index 402443b..bf8517a 100644 (file)
@@ -8,8 +8,8 @@ internal static partial class Interop
 {
     internal static partial class NtDll
     {
-        [DllImport(Libraries.NtDll, ExactSpelling = true)]
-        internal static extern unsafe int NtQueryInformationFile(
+        [GeneratedDllImport(Libraries.NtDll, ExactSpelling = true)]
+        internal static unsafe partial int NtQueryInformationFile(
             SafeFileHandle FileHandle,
             out IO_STATUS_BLOCK IoStatusBlock,
             void* FileInformation,
index ee82a86..399d0cc 100644 (file)
@@ -7,8 +7,8 @@ internal static partial class Interop
 {
     internal static partial class NtDll
     {
-        [DllImport(Libraries.NtDll, ExactSpelling = true)]
-        private static extern int RtlGetVersion(ref RTL_OSVERSIONINFOEX lpVersionInformation);
+        [GeneratedDllImport(Libraries.NtDll, ExactSpelling = true)]
+        private static partial int RtlGetVersion(ref RTL_OSVERSIONINFOEX lpVersionInformation);
 
         internal static unsafe int RtlGetVersionEx(out RTL_OSVERSIONINFOEX osvi)
         {
index d41e2eb..909aa9d 100644 (file)
@@ -9,7 +9,7 @@ internal static partial class Interop
     internal static partial class NtDll
     {
         // https://msdn.microsoft.com/en-us/library/windows/desktop/ms680600(v=vs.85).aspx
-        [DllImport(Libraries.NtDll, ExactSpelling = true)]
-        public static extern uint RtlNtStatusToDosError(int Status);
+        [GeneratedDllImport(Libraries.NtDll, ExactSpelling = true)]
+        public static partial uint RtlNtStatusToDosError(int Status);
     }
 }
index dfdd12b..e5769df 100644 (file)
@@ -9,6 +9,7 @@ internal static partial class Interop
     internal static partial class Ole32
     {
         [DllImport(Interop.Libraries.Ole32, CharSet = CharSet.Unicode)]
+        // TODO: [DllImportGenerator] Switch to use GeneratedDllImport once we annotate blittable types used in interop in CoreLib (like Guid)
         internal static extern int CLSIDFromProgID(string lpszProgID, out Guid lpclsid);
     }
 }
index 7f3cd37..89dc423 100644 (file)
@@ -9,6 +9,7 @@ internal static partial class Interop
     internal static partial class Ole32
     {
         [DllImport(Interop.Libraries.Ole32)]
+        // TODO: [DllImportGenerator] Switch to use GeneratedDllImport once we annotate blittable types used in interop in CoreLib (like Guid)
         internal static extern int CoCreateGuid(out Guid guid);
     }
 }
index cc958e6..2d5a166 100644 (file)
@@ -9,6 +9,7 @@ internal static partial class Interop
     internal static partial class Ole32
     {
         [DllImport(Interop.Libraries.Ole32)]
+        // TODO: [DllImportGenerator] Switch to use GeneratedDllImport once we annotate blittable types used in interop in CoreLib (like Guid)
         internal static extern int CoGetStandardMarshal(ref Guid riid, IntPtr pv, int dwDestContext, IntPtr pvDestContext, int mshlflags, out IntPtr ppMarshal);
     }
 }
index 9bce558..6053602 100644 (file)
@@ -8,13 +8,13 @@ internal static partial class Interop
 {
     internal static partial class Ole32
     {
-        [DllImport(Libraries.Ole32)]
-        internal static extern IntPtr CoTaskMemAlloc(nuint cb);
+        [GeneratedDllImport(Libraries.Ole32)]
+        internal static partial IntPtr CoTaskMemAlloc(nuint cb);
 
-        [DllImport(Libraries.Ole32)]
-        internal static extern IntPtr CoTaskMemRealloc(IntPtr pv, nuint cb);
+        [GeneratedDllImport(Libraries.Ole32)]
+        internal static partial IntPtr CoTaskMemRealloc(IntPtr pv, nuint cb);
 
-        [DllImport(Libraries.Ole32)]
-        internal static extern void CoTaskMemFree(IntPtr ptr);
+        [GeneratedDllImport(Libraries.Ole32)]
+        internal static partial void CoTaskMemFree(IntPtr ptr);
     }
 }
index 9869497..7da0659 100644 (file)
@@ -8,7 +8,7 @@ internal static partial class Interop
 {
     internal static partial class OleAut32
     {
-        [DllImport(Libraries.OleAut32)]
-        internal static extern IntPtr SysAllocStringByteLen(byte[]? str, uint len);
+        [GeneratedDllImport(Libraries.OleAut32)]
+        internal static partial IntPtr SysAllocStringByteLen(byte[]? str, uint len);
     }
 }
index 8c02bcf..09b31d1 100644 (file)
@@ -8,7 +8,7 @@ internal static partial class Interop
 {
     internal static partial class OleAut32
     {
-        [DllImport(Libraries.OleAut32)]
-        internal static extern void SysFreeString(IntPtr bstr);
+        [GeneratedDllImport(Libraries.OleAut32)]
+        internal static partial void SysFreeString(IntPtr bstr);
     }
 }
index ce046b7..bc32786 100644 (file)
@@ -8,7 +8,7 @@ internal static partial class Interop
 {
     internal static partial class OleAut32
     {
-        [DllImport(Libraries.OleAut32)]
-        internal static extern void VariantClear(IntPtr variant);
+        [GeneratedDllImport(Libraries.OleAut32)]
+        internal static partial void VariantClear(IntPtr variant);
     }
 }
index c0ac515..5de9607 100644 (file)
@@ -7,8 +7,8 @@ internal static partial class Interop
 {
     internal static partial class Secur32
     {
-        [DllImport(Libraries.Secur32, CharSet = CharSet.Unicode, SetLastError = true, ExactSpelling = true)]
-        internal static extern BOOLEAN GetUserNameExW(int NameFormat, ref char lpNameBuffer, ref uint lpnSize);
+        [GeneratedDllImport(Libraries.Secur32, CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)]
+        internal static partial BOOLEAN GetUserNameExW(int NameFormat, ref char lpNameBuffer, ref uint lpnSize);
 
         internal const int NameSamCompatible = 2;
     }
index d224d28..9dad160 100644 (file)
@@ -11,7 +11,8 @@ internal static partial class Interop
         internal const int COR_E_PLATFORMNOTSUPPORTED = unchecked((int)0x80131539);
 
         // https://msdn.microsoft.com/en-us/library/windows/desktop/bb762188.aspx
-        [DllImport(Libraries.Shell32, CharSet = CharSet.Unicode, SetLastError = false, BestFitMapping = false, ExactSpelling = true)]
+        [DllImport(Libraries.Shell32, CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = false)]
+        // TODO: [DllImportGenerator] Switch to use GeneratedDllImport once we annotate blittable types used in interop in CoreLib (like Guid)
         internal static extern int SHGetKnownFolderPath(
             [MarshalAs(UnmanagedType.LPStruct)] Guid rfid,
             uint dwFlags,
index 23fe143..cdff436 100644 (file)
@@ -8,25 +8,34 @@ internal static partial class Interop
 {
     internal static unsafe partial class Ucrtbase
     {
-        [DllImport(Libraries.Ucrtbase, CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
-        internal static extern void* _aligned_malloc(nuint size, nuint alignment);
-
-        [DllImport(Libraries.Ucrtbase, CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
-        internal static extern void _aligned_free(void* ptr);
-
-        [DllImport(Libraries.Ucrtbase, CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
-        internal static extern void* _aligned_realloc(void* ptr, nuint size, nuint alignment);
-
-        [DllImport(Libraries.Ucrtbase, CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
-        internal static extern void* calloc(nuint num, nuint size);
-
-        [DllImport(Libraries.Ucrtbase, CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
-        internal static extern void free(void* ptr);
-
-        [DllImport(Libraries.Ucrtbase, CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
-        internal static extern void* malloc(nuint size);
-
-        [DllImport(Libraries.Ucrtbase, CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
-        internal static extern void* realloc(void* ptr, nuint new_size);
+#pragma warning disable CS3016 // Arrays as attribute arguments is not CLS-compliant
+        [GeneratedDllImport(Libraries.Ucrtbase, ExactSpelling = true)]
+        [UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
+        internal static partial void* _aligned_malloc(nuint size, nuint alignment);
+
+        [GeneratedDllImport(Libraries.Ucrtbase, ExactSpelling = true)]
+        [UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
+        internal static partial void _aligned_free(void* ptr);
+
+        [GeneratedDllImport(Libraries.Ucrtbase, ExactSpelling = true)]
+        [UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
+        internal static partial void* _aligned_realloc(void* ptr, nuint size, nuint alignment);
+
+        [GeneratedDllImport(Libraries.Ucrtbase, ExactSpelling = true)]
+        [UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
+        internal static partial void* calloc(nuint num, nuint size);
+
+        [GeneratedDllImport(Libraries.Ucrtbase, ExactSpelling = true)]
+        [UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
+        internal static partial void free(void* ptr);
+
+        [GeneratedDllImport(Libraries.Ucrtbase, ExactSpelling = true)]
+        [UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
+        internal static partial void* malloc(nuint size);
+
+        [GeneratedDllImport(Libraries.Ucrtbase, ExactSpelling = true)]
+        [UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })]
+        internal static partial void* realloc(void* ptr, nuint new_size);
+#pragma warning restore CS3016 // Arrays as attribute arguments is not CLS-compliant
     }
 }
index de9d960..7a74a2f 100644 (file)
@@ -8,7 +8,7 @@ internal static partial class Interop
 {
     internal static partial class User32
     {
-        [DllImport(Libraries.User32, SetLastError = true, EntryPoint = "LoadStringW", CharSet = CharSet.Unicode, ExactSpelling = true)]
-        internal static extern unsafe int LoadString(IntPtr hInstance, uint uID, char* lpBuffer, int cchBufferMax);
+        [GeneratedDllImport(Libraries.User32, EntryPoint = "LoadStringW", CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)]
+        internal static unsafe partial int LoadString(IntPtr hInstance, uint uID, char* lpBuffer, int cchBufferMax);
     }
 }
index 2a764b0..8742a91 100644 (file)
@@ -3,6 +3,7 @@
     <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
     <TargetFrameworks>$(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent);$(NetCoreAppMinimum)-windows;$(NetCoreAppMinimum);netstandard2.0-windows;netstandard2.0</TargetFrameworks>
     <IsPackable>true</IsPackable>
+    <Nullable>Annotations</Nullable>
     <AddNETFrameworkPlaceholderFileToPackage>true</AddNETFrameworkPlaceholderFileToPackage>
     <AddXamarinPlaceholderFilesToPackage>true</AddXamarinPlaceholderFilesToPackage>
     <AddNETFrameworkAssemblyReferenceToPackage>true</AddNETFrameworkAssemblyReferenceToPackage>
@@ -91,9 +92,11 @@ System.Runtime.Caching.ObjectCache</PackageDescription>
     <Reference Include="System.Diagnostics.Tracing" />
     <Reference Include="System.IO.FileSystem" />
     <Reference Include="System.IO.FileSystem.Watcher" />
+    <Reference Include="System.Memory" />
     <Reference Include="System.ObjectModel" />
     <Reference Include="System.Resources.ResourceManager" />
     <Reference Include="System.Runtime" />
+    <Reference Include="System.Runtime.CompilerServices.Unsafe" />
     <Reference Include="System.Runtime.Extensions" />
     <Reference Include="System.Runtime.InteropServices" />
     <Reference Include="System.Runtime.InteropServices.RuntimeInformation" />
index 4ca5ab6..577a87e 100644 (file)
@@ -61,7 +61,9 @@ System.Security.AccessControl.SemaphoreSecurity</PackageDescription>
     <Compile Include="System\Threading\ThreadingAclExtensions.net46.cs" />
   </ItemGroup>
   <ItemGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp'">
+    <Reference Include="System.Memory" />
     <Reference Include="System.Runtime" />
+    <Reference Include="System.Runtime.CompilerServices.Unsafe" />
     <Reference Include="System.Runtime.InteropServices" />
     <Reference Include="System.Security.AccessControl" />
     <Reference Include="System.Security.Principal.Windows" />