From 0ed0d0c36cf4c00159b5cacbee4aec847c30f06f Mon Sep 17 00:00:00 2001 From: Aaron Robinson Date: Mon, 15 Nov 2021 16:12:23 -0800 Subject: [PATCH 1/3] Update SPCL to use GeneratedDllImport where possible. --- .../Common/src/Interop/Interop.Calendar.cs | 20 +++--- .../Common/src/Interop/Interop.Casing.cs | 16 ++--- .../Common/src/Interop/Interop.Collation.cs | 44 ++++++------ .../Common/src/Interop/Interop.HostPolicy.cs | 14 ++-- .../Common/src/Interop/Interop.ICU.cs | 12 ++-- .../Common/src/Interop/Interop.Idna.cs | 8 +-- .../Common/src/Interop/Interop.Locale.cs | 32 ++++----- .../src/Interop/Interop.Normalization.cs | 8 +-- .../src/Interop/Interop.TimeZoneInfo.cs | 12 ++-- .../Interop.EventActivityIdControl.cs | 1 + .../Windows/Advapi32/Interop.EventRegister.cs | 3 +- .../Advapi32/Interop.EventSetInformation.cs | 4 +- .../Advapi32/Interop.EventTraceGuidsEx.cs | 4 +- .../Advapi32/Interop.EventUnregister.cs | 4 +- .../Advapi32/Interop.EventWriteString.cs | 4 +- .../Advapi32/Interop.EventWriteTransfer.cs | 4 +- .../Advapi32/Interop.LookupAccountNameW.cs | 4 +- .../Windows/BCrypt/Interop.BCryptGenRandom.cs | 4 +- .../Crypt32/Interop.CryptProtectMemory.cs | 8 +-- .../Kernel32/Interop.CompletionPort.cs | 12 ++-- .../Kernel32/Interop.ConditionVariable.cs | 12 ++-- .../Kernel32/Interop.CreateSymbolicLink.cs | 4 +- .../Kernel32/Interop.CriticalSection.cs | 16 ++--- .../Kernel32/Interop.DeviceIoControl.cs | 4 +- .../Kernel32/Interop.EventWaitHandle.cs | 16 ++--- .../Interop.ExpandEnvironmentStrings.cs | 4 +- .../Kernel32/Interop.FileScatterGather.cs | 8 +-- .../Kernel32/Interop.FileTimeToSystemTime.cs | 4 +- .../Kernel32/Interop.FindFirstFileEx.cs | 4 +- .../Windows/Kernel32/Interop.FindNextFile.cs | 4 +- .../Interop.FreeEnvironmentStrings.cs | 4 +- .../Windows/Kernel32/Interop.GetCPInfo.cs | 4 +- .../Kernel32/Interop.GetCurrentDirectory.cs | 4 +- .../Kernel32/Interop.GetEnvironmentStrings.cs | 4 +- .../Interop.GetEnvironmentVariable.cs | 4 +- .../Interop.GetFileInformationByHandleEx.cs | 4 +- .../Interop.GetFinalPathNameByHandle.cs | 4 +- .../Windows/Kernel32/Interop.GetLastError.cs | 4 +- .../Kernel32/Interop.GetModuleFileName.cs | 4 +- .../Kernel32/Interop.GetOverlappedResult.cs | 4 +- .../Kernel32/Interop.GetProcessMemoryInfo.cs | 4 +- .../Interop.GetProcessTimes_IntPtr.cs | 4 +- .../Kernel32/Interop.GetSystemDirectoryW.cs | 4 +- .../Windows/Kernel32/Interop.GetSystemTime.cs | 4 +- .../Kernel32/Interop.GetSystemTimes.cs | 4 +- .../Kernel32/Interop.GetTempFileNameW.cs | 4 +- .../Windows/Kernel32/Interop.GetTempPathW.cs | 4 +- .../Kernel32/Interop.GlobalMemoryStatusEx.cs | 4 +- .../Windows/Kernel32/Interop.Globalization.cs | 72 +++++++++---------- .../Windows/Kernel32/Interop.LocalAlloc.cs | 12 ++-- .../Windows/Kernel32/Interop.LockFile.cs | 8 +-- .../Interop/Windows/Kernel32/Interop.Mutex.cs | 12 ++-- .../Kernel32/Interop.OutputDebugString.cs | 4 +- .../Interop.QueryPerformanceCounter.cs | 4 +- .../Interop.QueryPerformanceFrequency.cs | 4 +- .../Interop.QueryUnbiasedInterruptTime.cs | 4 +- .../Kernel32/Interop.ResolveLocaleName.cs | 4 +- .../Windows/Kernel32/Interop.Semaphore.cs | 12 ++-- .../Kernel32/Interop.SetCurrentDirectory.cs | 4 +- .../Interop.SetEnvironmentVariable.cs | 4 +- .../Kernel32/Interop.SetFilePointerEx.cs | 4 +- .../Windows/Kernel32/Interop.SetLastError.cs | 4 +- .../Kernel32/Interop.SystemTimeToFileTime.cs | 4 +- .../Windows/Kernel32/Interop.TimeZone.cs | 8 +-- ...Interop.TzSpecificLocalTimeToSystemTime.cs | 4 +- .../Kernel32/Interop.VerSetConditionMask.cs | 4 +- .../Kernel32/Interop.VerifyVersionExW.cs | 4 +- .../Kernel32/Interop.VirtualAlloc_Ptr.cs | 4 +- .../Windows/Kernel32/Interop.VirtualFree.cs | 4 +- .../Kernel32/Interop.VirtualQuery_Ptr.cs | 4 +- .../Interop/Windows/Normaliz/Interop.Idna.cs | 8 +-- .../Windows/Normaliz/Interop.Normalization.cs | 8 +-- .../Windows/NtDll/Interop.NtCreateFile.cs | 4 +- .../NtDll/Interop.NtQueryDirectoryFile.cs | 4 +- .../NtDll/Interop.NtQueryInformationFile.cs | 4 +- .../Windows/NtDll/Interop.RtlGetVersion.cs | 4 +- .../NtDll/Interop.RtlNtStatusToDosError.cs | 4 +- .../Windows/Ole32/Interop.CLSIDFromProgID.cs | 1 + .../Windows/Ole32/Interop.CoCreateGuid.cs | 1 + .../Ole32/Interop.CoGetStandardMarshal.cs | 1 + .../Windows/Ole32/Interop.CoTaskMemAlloc.cs | 12 ++-- .../OleAut32/Interop.SysAllocStringByteLen.cs | 4 +- .../Windows/OleAut32/Interop.SysFreeString.cs | 4 +- .../Windows/OleAut32/Interop.VariantClear.cs | 4 +- .../Windows/Secur32/Interop.GetUserNameExW.cs | 4 +- .../Shell32/Interop.SHGetKnownFolderPath.cs | 3 +- .../Windows/Ucrtbase/Interop.MemAlloc.cs | 49 +++++++------ .../Windows/User32/Interop.LoadString.cs | 4 +- .../src/System.Runtime.Caching.csproj | 3 + .../src/System.Threading.AccessControl.csproj | 2 + 90 files changed, 353 insertions(+), 329 deletions(-) diff --git a/src/libraries/Common/src/Interop/Interop.Calendar.cs b/src/libraries/Common/src/Interop/Interop.Calendar.cs index 6befb033d68bc..07852b2c5631b 100644 --- a/src/libraries/Common/src/Interop/Interop.Calendar.cs +++ b/src/libraries/Common/src/Interop/Interop.Calendar.cs @@ -9,19 +9,19 @@ 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 callback, string localeName, CalendarId calendarId, CalendarDataType calendarDataType, IntPtr context); + [GeneratedDllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_EnumCalendarInfo", CharSet = CharSet.Unicode)] + internal static unsafe partial bool EnumCalendarInfo(delegate* unmanaged callback, string localeName, CalendarId calendarId, CalendarDataType calendarDataType, IntPtr context); - [DllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_GetLatestJapaneseEra")] - internal static extern int GetLatestJapaneseEra(); + [GeneratedDllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_GetLatestJapaneseEra")] + internal static partial int GetLatestJapaneseEra(); - [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_GetJapaneseEraStartDate")] + internal static partial bool GetJapaneseEraStartDate(int era, out int startYear, out int startMonth, out int startDay); } } diff --git a/src/libraries/Common/src/Interop/Interop.Casing.cs b/src/libraries/Common/src/Interop/Interop.Casing.cs index f02aea3d2374c..fcb77ec3bd63d 100644 --- a/src/libraries/Common/src/Interop/Interop.Casing.cs +++ b/src/libraries/Common/src/Interop/Interop.Casing.cs @@ -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); } } diff --git a/src/libraries/Common/src/Interop/Interop.Collation.cs b/src/libraries/Common/src/Interop/Interop.Collation.cs index 89dfb5bcd98ec..41b7f890ada89 100644 --- a/src/libraries/Common/src/Interop/Interop.Collation.cs +++ b/src/libraries/Common/src/Interop/Interop.Collation.cs @@ -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); } } diff --git a/src/libraries/Common/src/Interop/Interop.HostPolicy.cs b/src/libraries/Common/src/Interop/Interop.HostPolicy.cs index c7f62047f5b0c..b5e3a2109f4ae 100644 --- a/src/libraries/Common/src/Interop/Interop.HostPolicy.cs +++ b/src/libraries/Common/src/Interop/Interop.HostPolicy.cs @@ -6,7 +6,7 @@ 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 delegate void corehost_resolve_component_dependencies_result_fn(string [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 } } diff --git a/src/libraries/Common/src/Interop/Interop.ICU.cs b/src/libraries/Common/src/Interop/Interop.ICU.cs index 957b201aa2222..7aa5fba7ec284 100644 --- a/src/libraries/Common/src/Interop/Interop.ICU.cs +++ b/src/libraries/Common/src/Interop/Interop.ICU.cs @@ -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 version, ReadOnlySpan suffix) { @@ -20,10 +20,10 @@ internal static void InitICUFunctions(IntPtr icuuc, IntPtr icuin, ReadOnlySpan 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(); } } diff --git a/src/libraries/Common/src/Interop/Interop.Idna.cs b/src/libraries/Common/src/Interop/Interop.Idna.cs index 0bc9b41dfd8cd..7bac573f2942a 100644 --- a/src/libraries/Common/src/Interop/Interop.Idna.cs +++ b/src/libraries/Common/src/Interop/Interop.Idna.cs @@ -10,10 +10,10 @@ internal static partial class Globalization 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); } } diff --git a/src/libraries/Common/src/Interop/Interop.Locale.cs b/src/libraries/Common/src/Interop/Interop.Locale.cs index 3a410c4e76953..a4b05dcc9bf70 100644 --- a/src/libraries/Common/src/Interop/Interop.Locale.cs +++ b/src/libraries/Common/src/Interop/Interop.Locale.cs @@ -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); } } diff --git a/src/libraries/Common/src/Interop/Interop.Normalization.cs b/src/libraries/Common/src/Interop/Interop.Normalization.cs index 420e68c0e75a5..0b240884514d9 100644 --- a/src/libraries/Common/src/Interop/Interop.Normalization.cs +++ b/src/libraries/Common/src/Interop/Interop.Normalization.cs @@ -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); } } diff --git a/src/libraries/Common/src/Interop/Interop.TimeZoneInfo.cs b/src/libraries/Common/src/Interop/Interop.TimeZoneInfo.cs index 72db59c74402c..6d223046927de 100644 --- a/src/libraries/Common/src/Interop/Interop.TimeZoneInfo.cs +++ b/src/libraries/Common/src/Interop/Interop.TimeZoneInfo.cs @@ -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); } } diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.EventActivityIdControl.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.EventActivityIdControl.cs index c1c129b6a4dbe..f43a53d338fad 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.EventActivityIdControl.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.EventActivityIdControl.cs @@ -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); } } diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.EventRegister.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.EventRegister.cs index 8369b5c0f7f56..99660f1f2ba62 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.EventRegister.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.EventRegister.cs @@ -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, diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.EventSetInformation.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.EventSetInformation.cs index a6230216aee02..b865aa9fedec4 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.EventSetInformation.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.EventSetInformation.cs @@ -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, diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.EventTraceGuidsEx.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.EventTraceGuidsEx.cs index c0fef912e99c5..53b76286ac9ae 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.EventTraceGuidsEx.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.EventTraceGuidsEx.cs @@ -45,8 +45,8 @@ internal struct TRACE_ENABLE_INFO 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, diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.EventUnregister.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.EventUnregister.cs index e0d0c6b501e99..d717c7d817340 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.EventUnregister.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.EventUnregister.cs @@ -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); } } diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.EventWriteString.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.EventWriteString.cs index 0513daeacf008..f39a759ac6f99 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.EventWriteString.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.EventWriteString.cs @@ -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, diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.EventWriteTransfer.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.EventWriteTransfer.cs index 3cb95ffc699b5..3e2b23fc99087 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.EventWriteTransfer.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.EventWriteTransfer.cs @@ -36,8 +36,8 @@ internal static unsafe int EventWriteTransfer( 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, diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.LookupAccountNameW.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.LookupAccountNameW.cs index 168e80cd61463..ff9fd2dd3d988 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.LookupAccountNameW.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.LookupAccountNameW.cs @@ -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, diff --git a/src/libraries/Common/src/Interop/Windows/BCrypt/Interop.BCryptGenRandom.cs b/src/libraries/Common/src/Interop/Windows/BCrypt/Interop.BCryptGenRandom.cs index 22d7be39e5afb..d7372bc653271 100644 --- a/src/libraries/Common/src/Interop/Windows/BCrypt/Interop.BCryptGenRandom.cs +++ b/src/libraries/Common/src/Interop/Windows/BCrypt/Interop.BCryptGenRandom.cs @@ -10,7 +10,7 @@ internal static partial class BCrypt { 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); } } diff --git a/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.CryptProtectMemory.cs b/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.CryptProtectMemory.cs index 644d4e62191bb..81f1b00ff2310 100644 --- a/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.CryptProtectMemory.cs +++ b/src/libraries/Common/src/Interop/Windows/Crypt32/Interop.CryptProtectMemory.cs @@ -10,10 +10,10 @@ internal static partial class Crypt32 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); } } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.CompletionPort.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.CompletionPort.cs index dc2c6c4193f7d..e33002e4b0914 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.CompletionPort.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.CompletionPort.cs @@ -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); } } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.ConditionVariable.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.ConditionVariable.cs index 6f736eebcb2db..af96744ce1482 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.ConditionVariable.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.ConditionVariable.cs @@ -14,13 +14,13 @@ internal struct CONDITION_VARIABLE 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); } } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.CreateSymbolicLink.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.CreateSymbolicLink.cs index 9ecd41c46bd6b..40a96147995ac 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.CreateSymbolicLink.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.CreateSymbolicLink.cs @@ -20,8 +20,8 @@ internal static partial class Kernel32 /// 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); /// /// Creates a symbolic link. diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.CriticalSection.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.CriticalSection.cs index 1d9a6ef5c7aca..cfc24f7d32b04 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.CriticalSection.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.CriticalSection.cs @@ -19,16 +19,16 @@ internal struct CRITICAL_SECTION 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); } } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.DeviceIoControl.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.DeviceIoControl.cs index be8def215178f..7e6d1da4e73d8 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.DeviceIoControl.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.DeviceIoControl.cs @@ -12,8 +12,8 @@ internal static partial class Kernel32 // 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, diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.EventWaitHandle.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.EventWaitHandle.cs index 94257ecaf02a3..07f09df664de9 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.EventWaitHandle.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.EventWaitHandle.cs @@ -12,16 +12,16 @@ internal static partial class Kernel32 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); } } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.ExpandEnvironmentStrings.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.ExpandEnvironmentStrings.cs index 6d47dbb5c6074..32d81b6e54700 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.ExpandEnvironmentStrings.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.ExpandEnvironmentStrings.cs @@ -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); } } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.FileScatterGather.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.FileScatterGather.cs index 8e61970c3c242..42afb969b0ef1 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.FileScatterGather.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.FileScatterGather.cs @@ -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, diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.FileTimeToSystemTime.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.FileTimeToSystemTime.cs index b22ab21c065b6..adab75ec1081f 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.FileTimeToSystemTime.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.FileTimeToSystemTime.cs @@ -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); } } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.FindFirstFileEx.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.FindFirstFileEx.cs index ab002dc28d6ab..96f4eb5dbceea 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.FindFirstFileEx.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.FindFirstFileEx.cs @@ -13,8 +13,8 @@ internal static partial class Kernel32 /// /// WARNING: This method does not implicitly handle long paths. Use FindFirstFile. /// - [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) { diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.FindNextFile.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.FindNextFile.cs index b947d5d229c09..dc4f9a4dec172 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.FindNextFile.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.FindNextFile.cs @@ -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); } } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.FreeEnvironmentStrings.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.FreeEnvironmentStrings.cs index 5af20c071ca1d..018f15e28aae7 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.FreeEnvironmentStrings.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.FreeEnvironmentStrings.cs @@ -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); } } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetCPInfo.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetCPInfo.cs index 990a43c827b6b..0b5f3cc070329 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetCPInfo.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetCPInfo.cs @@ -16,7 +16,7 @@ internal unsafe struct CPINFO 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); } } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetCurrentDirectory.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetCurrentDirectory.cs index a8b30eb06d7f0..0146786e3cb7e 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetCurrentDirectory.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetCurrentDirectory.cs @@ -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); } } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetEnvironmentStrings.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetEnvironmentStrings.cs index 55452013da027..06b89ceb4b48f 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetEnvironmentStrings.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetEnvironmentStrings.cs @@ -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(); } } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetEnvironmentVariable.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetEnvironmentVariable.cs index 425ea9ef1e2c8..60dbfc5889f7b 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetEnvironmentVariable.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetEnvironmentVariable.cs @@ -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); } } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetFileInformationByHandleEx.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetFileInformationByHandleEx.cs index f91af06bb7a81..6eb10526da9eb 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetFileInformationByHandleEx.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetFileInformationByHandleEx.cs @@ -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); } } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetFinalPathNameByHandle.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetFinalPathNameByHandle.cs index 756b1bbd72db1..26ded9e92f076 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetFinalPathNameByHandle.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetFinalPathNameByHandle.cs @@ -13,8 +13,8 @@ internal static partial class Kernel32 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, diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetLastError.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetLastError.cs index 6dec98d0d7518..55a84179887f5 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetLastError.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetLastError.cs @@ -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(); } } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetModuleFileName.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetModuleFileName.cs index 3973f9747937f..1bf4e59b76c1a 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetModuleFileName.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetModuleFileName.cs @@ -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); } } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetOverlappedResult.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetOverlappedResult.cs index 6d52bfff0adf5..1375d0edfc57d 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetOverlappedResult.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetOverlappedResult.cs @@ -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, diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetProcessMemoryInfo.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetProcessMemoryInfo.cs index cc15f5d138187..8bc8826f5e06c 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetProcessMemoryInfo.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetProcessMemoryInfo.cs @@ -23,7 +23,7 @@ internal struct PROCESS_MEMORY_COUNTERS 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); } } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetProcessTimes_IntPtr.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetProcessTimes_IntPtr.cs index 89489a513a7e0..8422232385975 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetProcessTimes_IntPtr.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetProcessTimes_IntPtr.cs @@ -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); } } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetSystemDirectoryW.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetSystemDirectoryW.cs index bf835ab71f834..625d689c0e667 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetSystemDirectoryW.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetSystemDirectoryW.cs @@ -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); } } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetSystemTime.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetSystemTime.cs index 8f49121906c02..e97c5658df543 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetSystemTime.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetSystemTime.cs @@ -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); } } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetSystemTimes.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetSystemTimes.cs index 7c1cc6232ed32..29000a94b859b 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetSystemTimes.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetSystemTimes.cs @@ -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); } } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetTempFileNameW.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetTempFileNameW.cs index 79807ff32b511..4d08aac13bd38 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetTempFileNameW.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetTempFileNameW.cs @@ -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); } } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetTempPathW.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetTempPathW.cs index 5d555df58cd23..f27a00a633b3a 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetTempPathW.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetTempPathW.cs @@ -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); } } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GlobalMemoryStatusEx.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GlobalMemoryStatusEx.cs index 662cab8383cc7..9704e1c737900 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GlobalMemoryStatusEx.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GlobalMemoryStatusEx.cs @@ -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); } } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.Globalization.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.Globalization.cs index cda3b0b2009dc..fd08870009a58 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.Globalization.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.Globalization.cs @@ -47,14 +47,14 @@ internal static partial class Kernel32 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 extern unsafe int LCMapStringEx( 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 extern unsafe int FindNLSStringEx( 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 extern unsafe int CompareStringEx( 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 extern unsafe int FindStringOrdinal( 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 lpLocaleEnumProcEx, uint dwFlags, void* lParam, IntPtr reserved); + [GeneratedDllImport("kernel32.dll", CharSet = CharSet.Unicode)] + internal static unsafe partial bool EnumSystemLocalesEx(delegate* unmanaged lpLocaleEnumProcEx, uint dwFlags, void* lParam, IntPtr reserved); - [DllImport("kernel32.dll", CharSet = CharSet.Unicode)] - internal static extern unsafe bool EnumTimeFormatsEx(delegate* unmanaged lpTimeFmtEnumProcEx, string lpLocaleName, uint dwFlags, void* lParam); + [GeneratedDllImport("kernel32.dll", CharSet = CharSet.Unicode)] + internal static unsafe partial bool EnumTimeFormatsEx(delegate* unmanaged 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 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 pCalInfoEnumProcExEx, string lpLocaleName, uint Calendar, string? lpReserved, uint CalType, void* lParam); [StructLayout(LayoutKind.Sequential)] internal struct NlsVersionInfoEx @@ -152,7 +152,7 @@ internal struct NlsVersionInfoEx 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); } } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.LocalAlloc.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.LocalAlloc.cs index 4883779a8e258..0bcd7e356a9ba 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.LocalAlloc.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.LocalAlloc.cs @@ -12,13 +12,13 @@ internal static partial class Kernel32 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); } } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.LockFile.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.LockFile.cs index b00cb73b4128f..574960ac35be2 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.LockFile.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.LockFile.cs @@ -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); } } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.Mutex.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.Mutex.cs index 3988d7bfe1b01..4c09f291114d6 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.Mutex.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.Mutex.cs @@ -11,13 +11,13 @@ internal static partial class Kernel32 { 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); } } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.OutputDebugString.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.OutputDebugString.cs index 4d1f88983dd39..e7ee12eb0f9d7 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.OutputDebugString.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.OutputDebugString.cs @@ -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); } } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.QueryPerformanceCounter.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.QueryPerformanceCounter.cs index 9f396d046af8b..241ab3f99ac8f 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.QueryPerformanceCounter.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.QueryPerformanceCounter.cs @@ -15,8 +15,8 @@ internal static partial class Kernel32 // 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); } } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.QueryPerformanceFrequency.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.QueryPerformanceFrequency.cs index cf5f9753bd641..f6c7e9e656f58 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.QueryPerformanceFrequency.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.QueryPerformanceFrequency.cs @@ -15,7 +15,7 @@ internal static partial class Kernel32 // 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); } } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.QueryUnbiasedInterruptTime.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.QueryUnbiasedInterruptTime.cs index a93dcecd1e1e6..efb57eaa7c2a1 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.QueryUnbiasedInterruptTime.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.QueryUnbiasedInterruptTime.cs @@ -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); } } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.ResolveLocaleName.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.ResolveLocaleName.cs index 5e0d8dfcd45aa..cf01ba66e8b3b 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.ResolveLocaleName.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.ResolveLocaleName.cs @@ -9,7 +9,7 @@ internal static unsafe partial class Kernel32 { 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); } } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.Semaphore.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.Semaphore.cs index 435c47ead3215..44034fbb5a2fa 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.Semaphore.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.Semaphore.cs @@ -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); } } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetCurrentDirectory.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetCurrentDirectory.cs index 51cc5da3b7b85..46af9a9ad2b0a 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetCurrentDirectory.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetCurrentDirectory.cs @@ -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); } } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetEnvironmentVariable.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetEnvironmentVariable.cs index 9c7d2ebd0724e..63b09719009a4 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetEnvironmentVariable.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetEnvironmentVariable.cs @@ -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); } } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetFilePointerEx.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetFilePointerEx.cs index 7f8b472359948..028a0ff56114f 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetFilePointerEx.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetFilePointerEx.cs @@ -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); } } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetLastError.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetLastError.cs index 1a4394800ce99..baf852e6be6a0 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetLastError.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SetLastError.cs @@ -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); } } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SystemTimeToFileTime.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SystemTimeToFileTime.cs index 41d4b068a7325..10fe4080a00d9 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SystemTimeToFileTime.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.SystemTimeToFileTime.cs @@ -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); } } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.TimeZone.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.TimeZone.cs index 3ed47085af6c0..7ad0dde089190 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.TimeZone.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.TimeZone.cs @@ -83,10 +83,10 @@ internal string GetDaylightName() 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); } } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.TzSpecificLocalTimeToSystemTime.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.TzSpecificLocalTimeToSystemTime.cs index 2e5e264b0a715..7fc3013ae687d 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.TzSpecificLocalTimeToSystemTime.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.TzSpecificLocalTimeToSystemTime.cs @@ -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); diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.VerSetConditionMask.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.VerSetConditionMask.cs index e2aba5eea77d7..6ca6d7797a5fb 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.VerSetConditionMask.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.VerSetConditionMask.cs @@ -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); } } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.VerifyVersionExW.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.VerifyVersionExW.cs index 3af8fa7eadbc1..7ca822779e6ae 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.VerifyVersionExW.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.VerifyVersionExW.cs @@ -13,7 +13,7 @@ internal static partial class Kernel32 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); } } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.VirtualAlloc_Ptr.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.VirtualAlloc_Ptr.cs index 6f3797218f3e0..d432f568e4048 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.VirtualAlloc_Ptr.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.VirtualAlloc_Ptr.cs @@ -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); } } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.VirtualFree.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.VirtualFree.cs index 3ff002e0cd7df..6e75b25bafe03 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.VirtualFree.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.VirtualFree.cs @@ -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); } } diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.VirtualQuery_Ptr.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.VirtualQuery_Ptr.cs index 59622e85319ac..f3fdf7883b868 100644 --- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.VirtualQuery_Ptr.cs +++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.VirtualQuery_Ptr.cs @@ -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); } } diff --git a/src/libraries/Common/src/Interop/Windows/Normaliz/Interop.Idna.cs b/src/libraries/Common/src/Interop/Windows/Normaliz/Interop.Idna.cs index 9bc7631ad81db..d796f9e2f0c26 100644 --- a/src/libraries/Common/src/Interop/Windows/Normaliz/Interop.Idna.cs +++ b/src/libraries/Common/src/Interop/Windows/Normaliz/Interop.Idna.cs @@ -11,16 +11,16 @@ internal static partial class Normaliz // 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, diff --git a/src/libraries/Common/src/Interop/Windows/Normaliz/Interop.Normalization.cs b/src/libraries/Common/src/Interop/Windows/Normaliz/Interop.Normalization.cs index dee9a17834280..09a5bd0d10922 100644 --- a/src/libraries/Common/src/Interop/Windows/Normaliz/Interop.Normalization.cs +++ b/src/libraries/Common/src/Interop/Windows/Normaliz/Interop.Normalization.cs @@ -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, diff --git a/src/libraries/Common/src/Interop/Windows/NtDll/Interop.NtCreateFile.cs b/src/libraries/Common/src/Interop/Windows/NtDll/Interop.NtCreateFile.cs index 7d6ab13b6633d..ad3f3c72335fb 100644 --- a/src/libraries/Common/src/Interop/Windows/NtDll/Interop.NtCreateFile.cs +++ b/src/libraries/Common/src/Interop/Windows/NtDll/Interop.NtCreateFile.cs @@ -12,8 +12,8 @@ internal static partial class NtDll { // 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, diff --git a/src/libraries/Common/src/Interop/Windows/NtDll/Interop.NtQueryDirectoryFile.cs b/src/libraries/Common/src/Interop/Windows/NtDll/Interop.NtQueryDirectoryFile.cs index 25d5f5f925bc4..11fd068457fd7 100644 --- a/src/libraries/Common/src/Interop/Windows/NtDll/Interop.NtQueryDirectoryFile.cs +++ b/src/libraries/Common/src/Interop/Windows/NtDll/Interop.NtQueryDirectoryFile.cs @@ -10,8 +10,8 @@ internal static partial class NtDll { // 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, diff --git a/src/libraries/Common/src/Interop/Windows/NtDll/Interop.NtQueryInformationFile.cs b/src/libraries/Common/src/Interop/Windows/NtDll/Interop.NtQueryInformationFile.cs index 402443b05e944..bf8517a375730 100644 --- a/src/libraries/Common/src/Interop/Windows/NtDll/Interop.NtQueryInformationFile.cs +++ b/src/libraries/Common/src/Interop/Windows/NtDll/Interop.NtQueryInformationFile.cs @@ -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, diff --git a/src/libraries/Common/src/Interop/Windows/NtDll/Interop.RtlGetVersion.cs b/src/libraries/Common/src/Interop/Windows/NtDll/Interop.RtlGetVersion.cs index ee82a86be12d1..399d0cc553d84 100644 --- a/src/libraries/Common/src/Interop/Windows/NtDll/Interop.RtlGetVersion.cs +++ b/src/libraries/Common/src/Interop/Windows/NtDll/Interop.RtlGetVersion.cs @@ -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) { diff --git a/src/libraries/Common/src/Interop/Windows/NtDll/Interop.RtlNtStatusToDosError.cs b/src/libraries/Common/src/Interop/Windows/NtDll/Interop.RtlNtStatusToDosError.cs index d41e2eb7f3327..909aa9d968986 100644 --- a/src/libraries/Common/src/Interop/Windows/NtDll/Interop.RtlNtStatusToDosError.cs +++ b/src/libraries/Common/src/Interop/Windows/NtDll/Interop.RtlNtStatusToDosError.cs @@ -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); } } diff --git a/src/libraries/Common/src/Interop/Windows/Ole32/Interop.CLSIDFromProgID.cs b/src/libraries/Common/src/Interop/Windows/Ole32/Interop.CLSIDFromProgID.cs index dfdd12b9eef66..e5769df6bf41f 100644 --- a/src/libraries/Common/src/Interop/Windows/Ole32/Interop.CLSIDFromProgID.cs +++ b/src/libraries/Common/src/Interop/Windows/Ole32/Interop.CLSIDFromProgID.cs @@ -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); } } diff --git a/src/libraries/Common/src/Interop/Windows/Ole32/Interop.CoCreateGuid.cs b/src/libraries/Common/src/Interop/Windows/Ole32/Interop.CoCreateGuid.cs index 7f3cd37b36bd7..89dc423e96b78 100644 --- a/src/libraries/Common/src/Interop/Windows/Ole32/Interop.CoCreateGuid.cs +++ b/src/libraries/Common/src/Interop/Windows/Ole32/Interop.CoCreateGuid.cs @@ -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); } } diff --git a/src/libraries/Common/src/Interop/Windows/Ole32/Interop.CoGetStandardMarshal.cs b/src/libraries/Common/src/Interop/Windows/Ole32/Interop.CoGetStandardMarshal.cs index cc958e694432c..2d5a1661771e4 100644 --- a/src/libraries/Common/src/Interop/Windows/Ole32/Interop.CoGetStandardMarshal.cs +++ b/src/libraries/Common/src/Interop/Windows/Ole32/Interop.CoGetStandardMarshal.cs @@ -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); } } diff --git a/src/libraries/Common/src/Interop/Windows/Ole32/Interop.CoTaskMemAlloc.cs b/src/libraries/Common/src/Interop/Windows/Ole32/Interop.CoTaskMemAlloc.cs index 9bce558be0e10..605360233f139 100644 --- a/src/libraries/Common/src/Interop/Windows/Ole32/Interop.CoTaskMemAlloc.cs +++ b/src/libraries/Common/src/Interop/Windows/Ole32/Interop.CoTaskMemAlloc.cs @@ -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); } } diff --git a/src/libraries/Common/src/Interop/Windows/OleAut32/Interop.SysAllocStringByteLen.cs b/src/libraries/Common/src/Interop/Windows/OleAut32/Interop.SysAllocStringByteLen.cs index 9869497d71729..7da06597f9b4b 100644 --- a/src/libraries/Common/src/Interop/Windows/OleAut32/Interop.SysAllocStringByteLen.cs +++ b/src/libraries/Common/src/Interop/Windows/OleAut32/Interop.SysAllocStringByteLen.cs @@ -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); } } diff --git a/src/libraries/Common/src/Interop/Windows/OleAut32/Interop.SysFreeString.cs b/src/libraries/Common/src/Interop/Windows/OleAut32/Interop.SysFreeString.cs index 8c02bcfa4f834..09b31d14d44eb 100644 --- a/src/libraries/Common/src/Interop/Windows/OleAut32/Interop.SysFreeString.cs +++ b/src/libraries/Common/src/Interop/Windows/OleAut32/Interop.SysFreeString.cs @@ -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); } } diff --git a/src/libraries/Common/src/Interop/Windows/OleAut32/Interop.VariantClear.cs b/src/libraries/Common/src/Interop/Windows/OleAut32/Interop.VariantClear.cs index ce046b72ce1ac..bc327864c6362 100644 --- a/src/libraries/Common/src/Interop/Windows/OleAut32/Interop.VariantClear.cs +++ b/src/libraries/Common/src/Interop/Windows/OleAut32/Interop.VariantClear.cs @@ -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); } } diff --git a/src/libraries/Common/src/Interop/Windows/Secur32/Interop.GetUserNameExW.cs b/src/libraries/Common/src/Interop/Windows/Secur32/Interop.GetUserNameExW.cs index c0ac51596ca5f..5de96072a1761 100644 --- a/src/libraries/Common/src/Interop/Windows/Secur32/Interop.GetUserNameExW.cs +++ b/src/libraries/Common/src/Interop/Windows/Secur32/Interop.GetUserNameExW.cs @@ -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; } diff --git a/src/libraries/Common/src/Interop/Windows/Shell32/Interop.SHGetKnownFolderPath.cs b/src/libraries/Common/src/Interop/Windows/Shell32/Interop.SHGetKnownFolderPath.cs index d224d2821f2f1..9dad160932bd7 100644 --- a/src/libraries/Common/src/Interop/Windows/Shell32/Interop.SHGetKnownFolderPath.cs +++ b/src/libraries/Common/src/Interop/Windows/Shell32/Interop.SHGetKnownFolderPath.cs @@ -11,7 +11,8 @@ internal static partial class Shell32 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, diff --git a/src/libraries/Common/src/Interop/Windows/Ucrtbase/Interop.MemAlloc.cs b/src/libraries/Common/src/Interop/Windows/Ucrtbase/Interop.MemAlloc.cs index 23fe143abad30..cdff4368744a6 100644 --- a/src/libraries/Common/src/Interop/Windows/Ucrtbase/Interop.MemAlloc.cs +++ b/src/libraries/Common/src/Interop/Windows/Ucrtbase/Interop.MemAlloc.cs @@ -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 } } diff --git a/src/libraries/Common/src/Interop/Windows/User32/Interop.LoadString.cs b/src/libraries/Common/src/Interop/Windows/User32/Interop.LoadString.cs index de9d9601696f9..7a74a2f43d4f4 100644 --- a/src/libraries/Common/src/Interop/Windows/User32/Interop.LoadString.cs +++ b/src/libraries/Common/src/Interop/Windows/User32/Interop.LoadString.cs @@ -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); } } diff --git a/src/libraries/System.Runtime.Caching/src/System.Runtime.Caching.csproj b/src/libraries/System.Runtime.Caching/src/System.Runtime.Caching.csproj index 2a764b0052626..8742a91f18a16 100644 --- a/src/libraries/System.Runtime.Caching/src/System.Runtime.Caching.csproj +++ b/src/libraries/System.Runtime.Caching/src/System.Runtime.Caching.csproj @@ -3,6 +3,7 @@ true $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent);$(NetCoreAppMinimum)-windows;$(NetCoreAppMinimum);netstandard2.0-windows;netstandard2.0 true + Annotations true true true @@ -91,9 +92,11 @@ System.Runtime.Caching.ObjectCache + + diff --git a/src/libraries/System.Threading.AccessControl/src/System.Threading.AccessControl.csproj b/src/libraries/System.Threading.AccessControl/src/System.Threading.AccessControl.csproj index 4ca5ab65e37a9..577a87e846157 100644 --- a/src/libraries/System.Threading.AccessControl/src/System.Threading.AccessControl.csproj +++ b/src/libraries/System.Threading.AccessControl/src/System.Threading.AccessControl.csproj @@ -61,7 +61,9 @@ System.Security.AccessControl.SemaphoreSecurity + + From 4f6a8f5bf295e146cda6b6c9d7205f4af12b7fdc Mon Sep 17 00:00:00 2001 From: Aaron Robinson Date: Mon, 15 Nov 2021 17:17:15 -0800 Subject: [PATCH 2/3] Other platforms and mono builds. --- .../Common/src/Interop/OSX/Interop.libc.cs | 1 + .../Common/src/Interop/OSX/Interop.libobjc.cs | 20 ++++++------- .../System.Native/Interop.AutoreleasePool.cs | 8 +++--- ...rop.ProcFsStat.TryReadProcessStatusInfo.cs | 4 +-- .../Unix/System.Native/Interop.ChDir.cs | 4 +-- .../Unix/System.Native/Interop.ErrNo.cs | 8 +++--- .../Unix/System.Native/Interop.FAllocate.cs | 4 +-- .../Unix/System.Native/Interop.FSync.cs | 4 +-- .../Interop.GetCpuUtilization.cs | 4 +-- .../Unix/System.Native/Interop.GetCwd.cs | 4 +-- .../Unix/System.Native/Interop.GetEnv.cs | 4 +-- .../Unix/System.Native/Interop.GetEnviron.cs | 8 +++--- .../Unix/System.Native/Interop.GetPid.cs | 4 +-- .../System.Native/Interop.GetProcessPath.cs | 4 +-- .../System.Native/Interop.GetRandomBytes.cs | 8 +++--- .../Interop.GetSystemTimeAsTicks.cs | 4 +-- .../System.Native/Interop.GetTimestamp.cs | 4 +-- .../Unix/System.Native/Interop.GetUnixName.cs | 4 +-- .../System.Native/Interop.GetUnixRelease.cs | 4 +-- .../Unix/System.Native/Interop.LChflags.cs | 4 +-- .../System.Native/Interop.LockFileRegion.cs | 4 +-- .../Interop/Unix/System.Native/Interop.Log.cs | 8 +++--- .../System.Native/Interop.LowLevelMonitor.cs | 28 +++++++++---------- .../Unix/System.Native/Interop.MemAlloc.cs | 28 +++++++++---------- .../Unix/System.Native/Interop.MksTemps.cs | 4 +-- .../Unix/System.Native/Interop.PRead.cs | 4 +-- .../Unix/System.Native/Interop.PReadV.cs | 4 +-- .../Unix/System.Native/Interop.PWrite.cs | 4 +-- .../Unix/System.Native/Interop.PWriteV.cs | 4 +-- .../System.Native/Interop.PosixFAdvise.cs | 4 +-- .../Unix/System.Native/Interop.PosixSignal.cs | 20 ++++++------- .../Unix/System.Native/Interop.ReadDir.cs | 8 +++--- .../Unix/System.Native/Interop.SymLink.cs | 4 +-- .../Unix/System.Native/Interop.SysLog.cs | 4 +-- .../Interop.UnixFileSystemTypes.cs | 4 +-- 35 files changed, 121 insertions(+), 120 deletions(-) diff --git a/src/libraries/Common/src/Interop/OSX/Interop.libc.cs b/src/libraries/Common/src/Interop/OSX/Interop.libc.cs index 89ba51305689f..574faadcd1f4b 100644 --- a/src/libraries/Common/src/Interop/OSX/Interop.libc.cs +++ b/src/libraries/Common/src/Interop/OSX/Interop.libc.cs @@ -24,6 +24,7 @@ internal struct AttrList } [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; diff --git a/src/libraries/Common/src/Interop/OSX/Interop.libobjc.cs b/src/libraries/Common/src/Interop/OSX/Interop.libobjc.cs index 66d42a8d0f026..175b8abd3d790 100644 --- a/src/libraries/Common/src/Interop/OSX/Interop.libobjc.cs +++ b/src/libraries/Common/src/Interop/OSX/Interop.libobjc.cs @@ -16,12 +16,12 @@ private struct NSOperatingSystemVersion 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 Version GetOperatingSystemVersion() 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); } } diff --git a/src/libraries/Common/src/Interop/OSX/System.Native/Interop.AutoreleasePool.cs b/src/libraries/Common/src/Interop/OSX/System.Native/Interop.AutoreleasePool.cs index e1d005a3d42ea..c0e78cb5d152c 100644 --- a/src/libraries/Common/src/Interop/OSX/System.Native/Interop.AutoreleasePool.cs +++ b/src/libraries/Common/src/Interop/OSX/System.Native/Interop.AutoreleasePool.cs @@ -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); } } diff --git a/src/libraries/Common/src/Interop/SunOS/procfs/Interop.ProcFsStat.TryReadProcessStatusInfo.cs b/src/libraries/Common/src/Interop/SunOS/procfs/Interop.ProcFsStat.TryReadProcessStatusInfo.cs index 032186eb6a7e8..bbfa14b3f7b12 100644 --- a/src/libraries/Common/src/Interop/SunOS/procfs/Interop.ProcFsStat.TryReadProcessStatusInfo.cs +++ b/src/libraries/Common/src/Interop/SunOS/procfs/Interop.ProcFsStat.TryReadProcessStatusInfo.cs @@ -15,8 +15,8 @@ internal static partial class procfs /// /// true if the process status was read; otherwise, false. /// - [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 { diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.ChDir.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.ChDir.cs index ca0e4e089b2c7..29e072b856bc4 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.ChDir.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.ChDir.cs @@ -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); } } diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.ErrNo.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.ErrNo.cs index 3e321d512635a..b6c4c21a1689a 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.ErrNo.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.ErrNo.cs @@ -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); } } diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.FAllocate.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.FAllocate.cs index 71155e0f35e67..8c3508ef46c58 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.FAllocate.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.FAllocate.cs @@ -11,7 +11,7 @@ internal static partial class Sys /// /// Returns -1 on error, 0 on success. /// - [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); } } diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.FSync.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.FSync.cs index 773f867f37fe4..531ceb55de73e 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.FSync.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.FSync.cs @@ -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); } } diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetCpuUtilization.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetCpuUtilization.cs index 0e5e3b4fb6fd6..6598dbdf55f2c 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetCpuUtilization.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetCpuUtilization.cs @@ -15,7 +15,7 @@ internal struct ProcessCpuInformation 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); } } diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetCwd.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetCwd.cs index 78da5a667310f..22fb18f05a9f7 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetCwd.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetCwd.cs @@ -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() { diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetEnv.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetEnv.cs index d83d6700b5162..13b578053820c 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetEnv.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetEnv.cs @@ -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 diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetEnviron.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetEnviron.cs index abe8ff0e1916e..b88c2560838b8 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetEnviron.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetEnviron.cs @@ -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 diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetPid.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetPid.cs index 400dc554a366d..6b26b6064341f 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetPid.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetPid.cs @@ -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(); } } diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetProcessPath.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetProcessPath.cs index c64d21e5054b8..ddcd49790aaae 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetProcessPath.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetProcessPath.cs @@ -10,7 +10,7 @@ internal static partial class Sys /// /// Returns the full path to the executable for the current process, resolving symbolic links. /// - [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(); } } diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetRandomBytes.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetRandomBytes.cs index 15295e5053b62..76c1323761a88 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetRandomBytes.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetRandomBytes.cs @@ -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) diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetSystemTimeAsTicks.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetSystemTimeAsTicks.cs index 850ff0af9e567..ca5c01cb61e79 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetSystemTimeAsTicks.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetSystemTimeAsTicks.cs @@ -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(); } } diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetTimestamp.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetTimestamp.cs index a374e485f9cce..fc0964bf98f91 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetTimestamp.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetTimestamp.cs @@ -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(); } } diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetUnixName.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetUnixName.cs index 8d5063ead9bed..276f1129112c1 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetUnixName.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetUnixName.cs @@ -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() { diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetUnixRelease.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetUnixRelease.cs index 22ae8691fcf46..cf47ba34fe14c 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetUnixRelease.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.GetUnixRelease.cs @@ -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(); } } diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.LChflags.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.LChflags.cs index 17ba8e3233223..1353fbc3acec6 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.LChflags.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.LChflags.cs @@ -19,8 +19,8 @@ internal enum UserFlags : uint 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(); } } diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.LockFileRegion.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.LockFileRegion.cs index 3276275f284c2..0692aa48fff1a 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.LockFileRegion.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.LockFileRegion.cs @@ -14,7 +14,7 @@ internal enum LockType : short 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); } } diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Log.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Log.cs index 109bfff2b271c..474429e1233c4 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Log.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.Log.cs @@ -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); } } diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.LowLevelMonitor.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.LowLevelMonitor.cs index 8544cbefb7b3b..5132e827cc708 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.LowLevelMonitor.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.LowLevelMonitor.cs @@ -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); } } diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.MemAlloc.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.MemAlloc.cs index cb4a38ff4ea0f..9a0a90cd8abc0 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.MemAlloc.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.MemAlloc.cs @@ -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); } } diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.MksTemps.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.MksTemps.cs index f40937907b8f3..f697cd93bcdae 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.MksTemps.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.MksTemps.cs @@ -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); } diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.PRead.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.PRead.cs index 664da015febb2..b48dff07b274b 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.PRead.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.PRead.cs @@ -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); } } diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.PReadV.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.PReadV.cs index 5d93078161f05..de0f311e93a9f 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.PReadV.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.PReadV.cs @@ -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); } } diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.PWrite.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.PWrite.cs index 721a1c8706fd7..d658f4b9be6cf 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.PWrite.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.PWrite.cs @@ -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); } } diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.PWriteV.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.PWriteV.cs index c17e9964d8fe9..baba793575a3a 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.PWriteV.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.PWriteV.cs @@ -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); } } diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.PosixFAdvise.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.PosixFAdvise.cs index ed9ee769ac8b0..e2e96df6bfa52 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.PosixFAdvise.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.PosixFAdvise.cs @@ -29,7 +29,7 @@ internal enum FileAdvice : int /// /// Returns 0 on success; otherwise, the error code is returned /// - [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); } } diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.PosixSignal.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.PosixSignal.cs index 65e3ca35f4844..bde211dcacc0e 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.PosixSignal.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.PosixSignal.cs @@ -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 handler); + internal static unsafe partial void SetPosixSignalHandler(delegate* unmanaged 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); } } diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.ReadDir.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.ReadDir.cs index 4801498489d61..37a89d871c25e 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.ReadDir.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.ReadDir.cs @@ -56,12 +56,12 @@ internal ReadOnlySpan GetName(Span buffer) [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); diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.SymLink.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.SymLink.cs index 922ecd5bc6625..d0721eef785d9 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.SymLink.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.SymLink.cs @@ -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); } } diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.SysLog.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.SysLog.cs index e8809b1369664..11284f1073821 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.SysLog.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.SysLog.cs @@ -29,7 +29,7 @@ internal enum SysLogPriority : int /// /// The message to put in the log entry /// Like printf, the argument is passed to the variadic part of the C++ function to wildcards in the message - [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); } } diff --git a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.UnixFileSystemTypes.cs b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.UnixFileSystemTypes.cs index d86dcfbe4e59a..5e4d7a6aa99de 100644 --- a/src/libraries/Common/src/Interop/Unix/System.Native/Interop.UnixFileSystemTypes.cs +++ b/src/libraries/Common/src/Interop/Unix/System.Native/Interop.UnixFileSystemTypes.cs @@ -145,8 +145,8 @@ internal enum UnixFileSystemTypes : long 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) { From 2c85f41b3d65623b022b5cd3202181ab5286b300 Mon Sep 17 00:00:00 2001 From: Aaron Robinson Date: Tue, 16 Nov 2021 13:07:54 -0800 Subject: [PATCH 3/3] Fix WASM build. --- src/libraries/Common/src/Interop/Interop.Calendar.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/libraries/Common/src/Interop/Interop.Calendar.cs b/src/libraries/Common/src/Interop/Interop.Calendar.cs index 07852b2c5631b..4cc06c7702d74 100644 --- a/src/libraries/Common/src/Interop/Interop.Calendar.cs +++ b/src/libraries/Common/src/Interop/Interop.Calendar.cs @@ -15,8 +15,15 @@ internal static partial class Globalization [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); + internal static unsafe bool EnumCalendarInfo(delegate* unmanaged callback, string localeName, CalendarId calendarId, CalendarDataType calendarDataType, IntPtr context) + { + return EnumCalendarInfo((IntPtr)callback, localeName, calendarId, calendarDataType, context); + } + [GeneratedDllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_EnumCalendarInfo", CharSet = CharSet.Unicode)] - internal static unsafe partial bool EnumCalendarInfo(delegate* unmanaged callback, string localeName, CalendarId calendarId, CalendarDataType calendarDataType, IntPtr context); + // 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); [GeneratedDllImport(Libraries.GlobalizationNative, EntryPoint = "GlobalizationNative_GetLatestJapaneseEra")] internal static partial int GetLatestJapaneseEra();