diff --git a/src/coreclr/nativeaot/Runtime.Base/src/System/Runtime/InternalCalls.cs b/src/coreclr/nativeaot/Runtime.Base/src/System/Runtime/InternalCalls.cs index 9eb227e70f201..1abbe8b16f795 100644 --- a/src/coreclr/nativeaot/Runtime.Base/src/System/Runtime/InternalCalls.cs +++ b/src/coreclr/nativeaot/Runtime.Base/src/System/Runtime/InternalCalls.cs @@ -66,7 +66,7 @@ internal static void RhCollect(int generation, InternalGCCollectionMode mode, bo } [DllImport(Redhawk.BaseName)] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] private static extern void RhpCollect(int generation, InternalGCCollectionMode mode, Interop.BOOL lowMemoryP); [RuntimeExport("RhGetGcTotalMemory")] @@ -76,7 +76,7 @@ internal static long RhGetGcTotalMemory() } [DllImport(Redhawk.BaseName)] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] private static extern long RhpGetGcTotalMemory(); [RuntimeExport("RhStartNoGCRegion")] @@ -278,28 +278,28 @@ internal static extern unsafe IntPtr RhpCallPropagateExceptionCallback( // Block the current thread until at least one object needs to be finalized (returns true) or // memory is low (returns false and the finalizer thread should initiate a garbage collection). [DllImport(Redhawk.BaseName)] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] internal static extern uint RhpWaitForFinalizerRequest(); // Indicate that the current round of finalizations is complete. [DllImport(Redhawk.BaseName)] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] internal static extern void RhpSignalFinalizationComplete(uint fCount); [DllImport(Redhawk.BaseName)] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] internal static extern ulong RhpGetTickCount64(); // Enters a no GC region, possibly doing a blocking GC if there is not enough // memory available to satisfy the caller's request. [DllImport(Redhawk.BaseName)] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] internal static extern int RhpStartNoGCRegion(long totalSize, Interop.BOOL hasLohSize, long lohSize, Interop.BOOL disallowFullBlockingGC); // Exits a no GC region, possibly doing a GC to clean up the garbage that // the caller allocated. [DllImport(Redhawk.BaseName)] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] internal static extern int RhpEndNoGCRegion(); } } diff --git a/src/coreclr/nativeaot/Runtime.Base/src/System/Runtime/RuntimeExports.cs b/src/coreclr/nativeaot/Runtime.Base/src/System/Runtime/RuntimeExports.cs index b1092eb2aca6d..abeb0c09b46ab 100644 --- a/src/coreclr/nativeaot/Runtime.Base/src/System/Runtime/RuntimeExports.cs +++ b/src/coreclr/nativeaot/Runtime.Base/src/System/Runtime/RuntimeExports.cs @@ -288,7 +288,7 @@ public static unsafe int RhGetCurrentThreadStackTrace(IntPtr[] outputBuffer) #pragma warning disable SYSLIB1054 // Use DllImport here instead of LibraryImport because this file is used by Test.CoreLib. [DllImport(Redhawk.BaseName)] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] private static extern unsafe int RhpGetCurrentThreadStackTrace(IntPtr* pOutputBuffer, uint outputBufferLength, UIntPtr addressInCurrentFrame); #pragma warning restore SYSLIB1054 diff --git a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Runtime/RuntimeImports.cs b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Runtime/RuntimeImports.cs index 33dbf18e3d8d9..05f48424e5916 100644 --- a/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Runtime/RuntimeImports.cs +++ b/src/coreclr/nativeaot/System.Private.CoreLib/src/System/Runtime/RuntimeImports.cs @@ -42,11 +42,11 @@ public static partial class RuntimeImports [LibraryImport(RuntimeLibrary)] [SuppressGCTransition] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] internal static partial ulong RhpGetTickCount64(); [LibraryImport(RuntimeLibrary)] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] internal static partial IntPtr RhpGetCurrentThread(); [MethodImpl(MethodImplOptions.InternalCall)] @@ -166,15 +166,15 @@ internal static void RhWaitForPendingFinalizers(bool allowReentrantWait) internal static extern long RhGetLastGCDuration(int generation); [LibraryImport(RuntimeLibrary)] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] internal static unsafe partial IntPtr RhRegisterFrozenSegment(void* pSegmentStart, nuint allocSize, nuint commitSize, nuint reservedSize); [LibraryImport(RuntimeLibrary)] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] internal static unsafe partial void RhUpdateFrozenSegment(IntPtr seg, void* allocated, void* committed); [LibraryImport(RuntimeLibrary)] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] internal static partial void RhUnregisterFrozenSegment(IntPtr pSegmentHandle); [MethodImpl(MethodImplOptions.InternalCall)] @@ -221,7 +221,7 @@ internal enum GCConfigurationType } [LibraryImport(RuntimeLibrary)] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] internal static unsafe partial void RhEnumerateConfigurationValues(void* configurationContext, delegate* unmanaged callback); internal struct GCHeapHardLimitInfo @@ -237,19 +237,19 @@ internal struct GCHeapHardLimitInfo } [LibraryImport(RuntimeLibrary)] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] internal static partial int RhRefreshMemoryLimit(GCHeapHardLimitInfo heapHardLimitInfo); [LibraryImport(RuntimeLibrary)] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] internal static unsafe partial int RhEnableNoGCRegionCallback(void* callback, long totalSize); [LibraryImport(RuntimeLibrary)] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] internal static partial long RhGetGenerationBudget(int generation); [LibraryImport(RuntimeLibrary)] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] internal static partial long RhGetTotalAllocatedBytesPrecise(); [MethodImpl(MethodImplOptions.InternalCall)] @@ -375,7 +375,7 @@ internal static IntPtr RhHandleAllocDependent(object primary, object secondary) internal static extern int RhpGetThunkBlockSize(); [LibraryImport(RuntimeLibrary, EntryPoint = "RhAllocateThunksMapping")] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] internal static partial IntPtr RhAllocateThunksMapping(); // @@ -448,22 +448,22 @@ internal static unsafe void RhUnbox(object? obj, ref byte data, EETypePtr pUnbox // Busy spin for the given number of iterations. [LibraryImport(RuntimeLibrary, EntryPoint = "RhSpinWait")] [SuppressGCTransition] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] internal static partial void RhSpinWait(int iterations); // Call RhSpinWait with a GC transition [LibraryImport(RuntimeLibrary, EntryPoint = "RhSpinWait")] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] internal static partial void RhLongSpinWait(int iterations); // Yield the cpu to another thread ready to process, if one is available. [LibraryImport(RuntimeLibrary, EntryPoint = "RhYield")] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] private static partial int _RhYield(); internal static bool RhYield() { return (_RhYield() != 0); } [LibraryImport(RuntimeLibrary, EntryPoint = "RhFlushProcessWriteBuffers")] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] internal static partial void RhFlushProcessWriteBuffers(); #if !TARGET_UNIX @@ -679,7 +679,7 @@ internal static IntPtr RhGetModuleSection(TypeManagerHandle module, ReadyToRunSe // EventPipeInternal helpers. // [LibraryImport(RuntimeLibrary)] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] internal static unsafe partial ulong RhEventPipeInternal_Enable( char* outputFile, int format, @@ -688,15 +688,15 @@ internal static unsafe partial ulong RhEventPipeInternal_Enable( uint numProviders); [LibraryImport(RuntimeLibrary)] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] internal static partial void RhEventPipeInternal_Disable(ulong sessionID); [LibraryImport(RuntimeLibrary)] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] internal static unsafe partial IntPtr RhEventPipeInternal_CreateProvider(char* providerName, IntPtr callbackFunc, IntPtr callbackContext); [LibraryImport(RuntimeLibrary)] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] internal static unsafe partial IntPtr RhEventPipeInternal_DefineEvent( IntPtr provHandle, uint eventID, @@ -707,19 +707,19 @@ internal static unsafe partial IntPtr RhEventPipeInternal_DefineEvent( uint metadataLength); [LibraryImport(RuntimeLibrary)] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] internal static unsafe partial IntPtr RhEventPipeInternal_GetProvider(char* providerName); [LibraryImport(RuntimeLibrary)] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] internal static partial void RhEventPipeInternal_DeleteProvider(IntPtr provHandle); [LibraryImport(RuntimeLibrary)] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] internal static unsafe partial int RhEventPipeInternal_EventActivityIdControl(uint controlCode, Guid* activityId); [LibraryImport(RuntimeLibrary)] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] internal static unsafe partial void RhEventPipeInternal_WriteEventData( IntPtr eventHandle, void* pEventData, @@ -728,59 +728,59 @@ internal static unsafe partial void RhEventPipeInternal_WriteEventData( Guid* relatedActivityId); [LibraryImport(RuntimeLibrary)] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] internal static unsafe partial uint RhEventPipeInternal_GetSessionInfo(ulong sessionID, void* pSessionInfo); [LibraryImport(RuntimeLibrary)] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] internal static unsafe partial uint RhEventPipeInternal_GetNextEvent(ulong sessionID, void* pInstance); [LibraryImport(RuntimeLibrary)] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] internal static partial uint RhEventPipeInternal_SignalSession(ulong sessionID); [LibraryImport(RuntimeLibrary)] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] internal static partial uint RhEventPipeInternal_WaitForSessionSignal(ulong sessionID, int timeoutMs); [LibraryImport(RuntimeLibrary)] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] internal static partial void NativeRuntimeEventSource_LogContentionLockCreated(nint LockID, nint AssociatedObjectID, ushort ClrInstanceID); [LibraryImport(RuntimeLibrary)] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] internal static partial void NativeRuntimeEventSource_LogContentionStart(byte ContentionFlags, ushort ClrInstanceID, nint LockID, nint AssociatedObjectID, ulong LockOwnerThreadID); [LibraryImport(RuntimeLibrary)] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] internal static partial void NativeRuntimeEventSource_LogContentionStop(byte ContentionFlags, ushort ClrInstanceID, double DurationNs); [LibraryImport(RuntimeLibrary)] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] internal static partial void NativeRuntimeEventSource_LogThreadPoolWorkerThreadStart(uint ActiveWorkerThreadCount, uint RetiredWorkerThreadCount, ushort ClrInstanceID); [LibraryImport(RuntimeLibrary)] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] internal static partial void NativeRuntimeEventSource_LogThreadPoolWorkerThreadStop(uint ActiveWorkerThreadCount, uint RetiredWorkerThreadCount, ushort ClrInstanceID); [LibraryImport(RuntimeLibrary)] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] internal static partial void NativeRuntimeEventSource_LogThreadPoolWorkerThreadWait(uint ActiveWorkerThreadCount, uint RetiredWorkerThreadCount, ushort ClrInstanceID); [LibraryImport(RuntimeLibrary)] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] internal static partial void NativeRuntimeEventSource_LogThreadPoolMinMaxThreads(ushort MinWorkerThreads, ushort MaxWorkerThreads, ushort MinIOCompletionThreads, ushort MaxIOCompletionThreads, ushort ClrInstanceID); [LibraryImport(RuntimeLibrary)] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] internal static partial void NativeRuntimeEventSource_LogThreadPoolWorkerThreadAdjustmentSample(double Throughput, ushort ClrInstanceID); [LibraryImport(RuntimeLibrary)] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] internal static partial void NativeRuntimeEventSource_LogThreadPoolWorkerThreadAdjustmentAdjustment(double AverageThroughput, uint NewWorkerThreadCount, uint Reason, ushort ClrInstanceID); [LibraryImport(RuntimeLibrary)] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] internal static partial void NativeRuntimeEventSource_LogThreadPoolWorkerThreadAdjustmentStats( double Duration, double Throughput, @@ -795,7 +795,7 @@ internal static partial void NativeRuntimeEventSource_LogThreadPoolWorkerThreadA ushort ClrInstanceID); [LibraryImport(RuntimeLibrary)] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] internal static partial void NativeRuntimeEventSource_LogThreadPoolIOEnqueue( IntPtr NativeOverlapped, IntPtr Overlapped, @@ -803,39 +803,39 @@ internal static partial void NativeRuntimeEventSource_LogThreadPoolIOEnqueue( ushort ClrInstanceID); [LibraryImport(RuntimeLibrary)] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] internal static partial void NativeRuntimeEventSource_LogThreadPoolIODequeue( IntPtr NativeOverlapped, IntPtr Overlapped, ushort ClrInstanceID); [LibraryImport(RuntimeLibrary)] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] internal static partial void NativeRuntimeEventSource_LogThreadPoolWorkingThreadCount( uint Count, ushort ClrInstanceID ); [LibraryImport(RuntimeLibrary)] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] internal static partial void NativeRuntimeEventSource_LogThreadPoolIOPack( IntPtr NativeOverlapped, IntPtr Overlapped, ushort ClrInstanceID); [LibraryImport(RuntimeLibrary)] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] internal static unsafe partial void NativeRuntimeEventSource_LogExceptionThrown(char* exceptionTypeName, char* exceptionMessage, IntPtr faultingIP, long hresult); [LibraryImport(RuntimeLibrary)] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] internal static partial void NativeRuntimeEventSource_LogWaitHandleWaitStart( byte WaitSource, IntPtr AssociatedObjectID, ushort ClrInstanceID); [LibraryImport(RuntimeLibrary)] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] internal static partial void NativeRuntimeEventSource_LogWaitHandleWaitStop(ushort ClrInstanceID); #endif // FEATURE_PERFTRACING @@ -1116,7 +1116,7 @@ internal static partial void NativeRuntimeEventSource_LogWaitHandleWaitStart( #if TARGET_X86 || TARGET_AMD64 [LibraryImport(RuntimeLibrary)] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] internal static unsafe partial void RhCpuIdEx(int* cpuInfo, int functionId, int subFunctionId); #endif diff --git a/src/libraries/Common/src/Interop/Interop.HostPolicy.cs b/src/libraries/Common/src/Interop/Interop.HostPolicy.cs index 60ca3b979c859..b77d568b7b781 100644 --- a/src/libraries/Common/src/Interop/Interop.HostPolicy.cs +++ b/src/libraries/Common/src/Interop/Interop.HostPolicy.cs @@ -21,12 +21,12 @@ internal delegate void corehost_resolve_component_dependencies_result_fn(IntPtr #else [LibraryImport(Libraries.HostPolicy, StringMarshalling = StringMarshalling.Utf8)] #endif - [UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(System.Runtime.CompilerServices.CallConvCdecl)])] internal static partial int corehost_resolve_component_dependencies(string componentMainAssemblyPath, corehost_resolve_component_dependencies_result_fn result); [LibraryImport(Libraries.HostPolicy)] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [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/Windows/Ucrtbase/Interop.MemAlloc.cs b/src/libraries/Common/src/Interop/Windows/Ucrtbase/Interop.MemAlloc.cs index 89481e2d49256..5d3f6d9357523 100644 --- a/src/libraries/Common/src/Interop/Windows/Ucrtbase/Interop.MemAlloc.cs +++ b/src/libraries/Common/src/Interop/Windows/Ucrtbase/Interop.MemAlloc.cs @@ -3,6 +3,7 @@ using System; using System.Runtime.InteropServices; +using System.Runtime.CompilerServices; internal static partial class Interop { @@ -10,31 +11,31 @@ internal static unsafe partial class Ucrtbase { #pragma warning disable CS3016 // Arrays as attribute arguments is not CLS-compliant [LibraryImport(Libraries.Ucrtbase)] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] internal static partial void* _aligned_malloc(nuint size, nuint alignment); [LibraryImport(Libraries.Ucrtbase)] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] internal static partial void _aligned_free(void* ptr); [LibraryImport(Libraries.Ucrtbase)] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] internal static partial void* _aligned_realloc(void* ptr, nuint size, nuint alignment); [LibraryImport(Libraries.Ucrtbase)] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] internal static partial void* calloc(nuint num, nuint size); [LibraryImport(Libraries.Ucrtbase)] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] internal static partial void free(void* ptr); [LibraryImport(Libraries.Ucrtbase)] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] internal static partial void* malloc(nuint size); [LibraryImport(Libraries.Ucrtbase)] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(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/Wldap32/Interop.Ber.cs b/src/libraries/Common/src/Interop/Windows/Wldap32/Interop.Ber.cs index 9d5d8387883ab..c76d439ad7df9 100644 --- a/src/libraries/Common/src/Interop/Windows/Wldap32/Interop.Ber.cs +++ b/src/libraries/Common/src/Interop/Windows/Wldap32/Interop.Ber.cs @@ -3,6 +3,7 @@ using System; using System.DirectoryServices.Protocols; +using System.Runtime.CompilerServices; using System.Runtime.InteropServices; internal static partial class Interop @@ -10,63 +11,63 @@ internal static partial class Interop internal static partial class Ldap { [LibraryImport(Libraries.Wldap32, EntryPoint = "ber_free", StringMarshalling = StringMarshalling.Utf16)] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial IntPtr ber_free(IntPtr berelement, int option); [LibraryImport(Libraries.Wldap32, EntryPoint = "ber_alloc_t", StringMarshalling = StringMarshalling.Utf16)] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial IntPtr ber_alloc(int option); [LibraryImport(Libraries.Wldap32, EntryPoint = "ber_printf", StringMarshalling = StringMarshalling.Utf16)] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial int ber_printf(SafeBerHandle berElement, string format, IntPtr value); [LibraryImport(Libraries.Wldap32, EntryPoint = "ber_printf", StringMarshalling = StringMarshalling.Utf16)] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial int ber_printf(SafeBerHandle berElement, string format, HGlobalMemHandle value, uint length); [LibraryImport(Libraries.Wldap32, EntryPoint = "ber_printf", StringMarshalling = StringMarshalling.Utf16)] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial int ber_printf(SafeBerHandle berElement, string format); [LibraryImport(Libraries.Wldap32, EntryPoint = "ber_printf", StringMarshalling = StringMarshalling.Utf16)] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial int ber_printf(SafeBerHandle berElement, string format, int value); [LibraryImport(Libraries.Wldap32, EntryPoint = "ber_printf", StringMarshalling = StringMarshalling.Utf16)] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial int ber_printf(SafeBerHandle berElement, string format, uint tag); [LibraryImport(Libraries.Wldap32, EntryPoint = "ber_flatten", StringMarshalling = StringMarshalling.Utf16)] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial int ber_flatten(SafeBerHandle berElement, ref IntPtr value); [LibraryImport(Libraries.Wldap32, EntryPoint = "ber_init", StringMarshalling = StringMarshalling.Utf16)] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial IntPtr ber_init(BerVal value); [LibraryImport(Libraries.Wldap32, EntryPoint = "ber_scanf", StringMarshalling = StringMarshalling.Utf16)] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial int ber_scanf(SafeBerHandle berElement, string format); [LibraryImport(Libraries.Wldap32, EntryPoint = "ber_scanf", StringMarshalling = StringMarshalling.Utf16)] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial int ber_scanf(SafeBerHandle berElement, string format, ref IntPtr ptrResult, ref uint bitLength); [LibraryImport(Libraries.Wldap32, EntryPoint = "ber_scanf", StringMarshalling = StringMarshalling.Utf16)] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial int ber_scanf(SafeBerHandle berElement, string format, ref int result); [LibraryImport(Libraries.Wldap32, EntryPoint = "ber_scanf", StringMarshalling = StringMarshalling.Utf16)] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial int ber_scanf(SafeBerHandle berElement, string format, ref IntPtr value); [LibraryImport(Libraries.Wldap32, EntryPoint = "ber_bvfree", StringMarshalling = StringMarshalling.Utf16)] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial int ber_bvfree(IntPtr value); [LibraryImport(Libraries.Wldap32, EntryPoint = "ber_bvecfree", StringMarshalling = StringMarshalling.Utf16)] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial int ber_bvecfree(IntPtr value); } } diff --git a/src/libraries/Common/src/Interop/Windows/Wldap32/Interop.Ldap.cs b/src/libraries/Common/src/Interop/Windows/Wldap32/Interop.Ldap.cs index a65c9a8a5273c..8af474fe948ba 100644 --- a/src/libraries/Common/src/Interop/Windows/Wldap32/Interop.Ldap.cs +++ b/src/libraries/Common/src/Interop/Windows/Wldap32/Interop.Ldap.cs @@ -3,6 +3,7 @@ using System; using System.DirectoryServices.Protocols; +using System.Runtime.CompilerServices; using System.Runtime.InteropServices; internal static partial class Interop @@ -10,194 +11,194 @@ internal static partial class Interop internal static partial class Ldap { [LibraryImport(Libraries.Wldap32, EntryPoint = "ldap_bind_sW", StringMarshalling = StringMarshalling.Utf16)] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial int ldap_bind_s(ConnectionHandle ldapHandle, string dn, in SEC_WINNT_AUTH_IDENTITY_EX credentials, BindMethod method); [LibraryImport(Libraries.Wldap32, EntryPoint = "ldap_initW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial IntPtr ldap_init(string hostName, int portNumber); [LibraryImport(Libraries.Wldap32, EntryPoint = "ldap_connect")] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial int ldap_connect(ConnectionHandle ldapHandle, in LDAP_TIMEVAL timeout); [LibraryImport(Libraries.Wldap32, EntryPoint = "ldap_unbind")] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial int ldap_unbind(IntPtr ldapHandle); [LibraryImport(Libraries.Wldap32, EntryPoint = "ldap_get_optionW")] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial int ldap_get_option_int(ConnectionHandle ldapHandle, LdapOption option, ref int outValue); [LibraryImport(Libraries.Wldap32, EntryPoint = "ldap_set_optionW")] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial int ldap_set_option_int(ConnectionHandle ldapHandle, LdapOption option, ref int inValue); [LibraryImport(Libraries.Wldap32, EntryPoint = "ldap_get_optionW")] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial int ldap_get_option_ptr(ConnectionHandle ldapHandle, LdapOption option, ref IntPtr outValue); [LibraryImport(Libraries.Wldap32, EntryPoint = "ldap_set_optionW")] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial int ldap_set_option_ptr(ConnectionHandle ldapHandle, LdapOption option, ref IntPtr inValue); [LibraryImport(Libraries.Wldap32, EntryPoint = "ldap_get_optionW")] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial int ldap_get_option_sechandle(ConnectionHandle ldapHandle, LdapOption option, ref SecurityHandle outValue); [LibraryImport(Libraries.Wldap32, EntryPoint = "ldap_get_optionW")] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static unsafe partial int ldap_get_option_secInfo(ConnectionHandle ldapHandle, LdapOption option, void* outValue); [LibraryImport(Libraries.Wldap32, EntryPoint = "ldap_set_optionW")] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial int ldap_set_option_referral(ConnectionHandle ldapHandle, LdapOption option, ref LdapReferralCallback outValue); [LibraryImport(Libraries.Wldap32, EntryPoint = "ldap_set_optionW")] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial int ldap_set_option_clientcert(ConnectionHandle ldapHandle, LdapOption option, QUERYCLIENTCERT outValue); [LibraryImport(Libraries.Wldap32, EntryPoint = "ldap_set_optionW")] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial int ldap_set_option_servercert(ConnectionHandle ldapHandle, LdapOption option, VERIFYSERVERCERT outValue); [LibraryImport(Libraries.Wldap32, EntryPoint = "LdapGetLastError")] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial int LdapGetLastError(); [LibraryImport(Libraries.Wldap32, EntryPoint = "cldap_openW", SetLastError = true, StringMarshalling = StringMarshalling.Utf16)] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial IntPtr cldap_open(string hostName, int portNumber); [LibraryImport(Libraries.Wldap32, EntryPoint = "ldap_simple_bind_sW", StringMarshalling = StringMarshalling.Utf16)] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial int ldap_simple_bind_s(ConnectionHandle ldapHandle, string distinguishedName, string password); [LibraryImport(Libraries.Wldap32, EntryPoint = "ldap_delete_extW", StringMarshalling = StringMarshalling.Utf16)] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial int ldap_delete_ext(ConnectionHandle ldapHandle, string dn, IntPtr servercontrol, IntPtr clientcontrol, ref int messageNumber); [LibraryImport(Libraries.Wldap32, EntryPoint = "ldap_result", SetLastError = true)] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial int ldap_result(ConnectionHandle ldapHandle, int messageId, int all, in LDAP_TIMEVAL timeout, ref IntPtr Mesage); [LibraryImport(Libraries.Wldap32, EntryPoint = "ldap_parse_resultW")] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial int ldap_parse_result(ConnectionHandle ldapHandle, IntPtr result, ref int serverError, ref IntPtr dn, ref IntPtr message, ref IntPtr referral, ref IntPtr control, byte freeIt); [LibraryImport(Libraries.Wldap32, EntryPoint = "ldap_parse_resultW")] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial int ldap_parse_result_referral(ConnectionHandle ldapHandle, IntPtr result, IntPtr serverError, IntPtr dn, IntPtr message, ref IntPtr referral, IntPtr control, byte freeIt); [LibraryImport(Libraries.Wldap32, EntryPoint = "ldap_memfreeW")] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial void ldap_memfree(IntPtr value); [LibraryImport(Libraries.Wldap32, EntryPoint = "ldap_value_freeW")] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial int ldap_value_free(IntPtr value); [LibraryImport(Libraries.Wldap32, EntryPoint = "ldap_controls_freeW")] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial int ldap_controls_free(IntPtr value); [LibraryImport(Libraries.Wldap32, EntryPoint = "ldap_abandon")] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial int ldap_abandon(ConnectionHandle ldapHandle, int messagId); [LibraryImport(Libraries.Wldap32, EntryPoint = "ldap_start_tls_sW")] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial int ldap_start_tls(ConnectionHandle ldapHandle, ref int ServerReturnValue, ref IntPtr Message, IntPtr ServerControls, IntPtr ClientControls); [LibraryImport(Libraries.Wldap32, EntryPoint = "ldap_stop_tls_s")] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial byte ldap_stop_tls(ConnectionHandle ldapHandle); [LibraryImport(Libraries.Wldap32, EntryPoint = "ldap_rename_extW", StringMarshalling = StringMarshalling.Utf16)] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial int ldap_rename(ConnectionHandle ldapHandle, string dn, string newRdn, string newParentDn, int deleteOldRdn, IntPtr servercontrol, IntPtr clientcontrol, ref int messageNumber); [LibraryImport(Libraries.Wldap32, EntryPoint = "ldap_compare_extW", StringMarshalling = StringMarshalling.Utf16)] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial int ldap_compare(ConnectionHandle ldapHandle, string dn, string attributeName, string strValue, BerVal binaryValue, IntPtr servercontrol, IntPtr clientcontrol, ref int messageNumber); [LibraryImport(Libraries.Wldap32, EntryPoint = "ldap_add_extW", StringMarshalling = StringMarshalling.Utf16)] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial int ldap_add(ConnectionHandle ldapHandle, string dn, IntPtr attrs, IntPtr servercontrol, IntPtr clientcontrol, ref int messageNumber); [LibraryImport(Libraries.Wldap32, EntryPoint = "ldap_modify_extW", StringMarshalling = StringMarshalling.Utf16)] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial int ldap_modify(ConnectionHandle ldapHandle, string dn, IntPtr attrs, IntPtr servercontrol, IntPtr clientcontrol, ref int messageNumber); [LibraryImport(Libraries.Wldap32, EntryPoint = "ldap_extended_operationW", StringMarshalling = StringMarshalling.Utf16)] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial int ldap_extended_operation(ConnectionHandle ldapHandle, string oid, BerVal data, IntPtr servercontrol, IntPtr clientcontrol, ref int messageNumber); [LibraryImport(Libraries.Wldap32, EntryPoint = "ldap_parse_extended_resultW")] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial int ldap_parse_extended_result(ConnectionHandle ldapHandle, IntPtr result, ref IntPtr oid, ref IntPtr data, byte freeIt); [LibraryImport(Libraries.Wldap32, EntryPoint = "ldap_msgfree")] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial int ldap_msgfree(IntPtr result); [LibraryImport(Libraries.Wldap32, EntryPoint = "ldap_search_extW", StringMarshalling = StringMarshalling.Utf16)] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial int ldap_search(ConnectionHandle ldapHandle, string dn, int scope, string filter, IntPtr attributes, [MarshalAs(UnmanagedType.Bool)] bool attributeOnly, IntPtr servercontrol, IntPtr clientcontrol, int timelimit, int sizelimit, ref int messageNumber); [LibraryImport(Libraries.Wldap32, EntryPoint = "ldap_first_entry")] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial IntPtr ldap_first_entry(ConnectionHandle ldapHandle, IntPtr result); [LibraryImport(Libraries.Wldap32, EntryPoint = "ldap_next_entry")] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial IntPtr ldap_next_entry(ConnectionHandle ldapHandle, IntPtr result); [LibraryImport(Libraries.Wldap32, EntryPoint = "ldap_first_reference")] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial IntPtr ldap_first_reference(ConnectionHandle ldapHandle, IntPtr result); [LibraryImport(Libraries.Wldap32, EntryPoint = "ldap_next_reference")] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial IntPtr ldap_next_reference(ConnectionHandle ldapHandle, IntPtr result); [LibraryImport(Libraries.Wldap32, EntryPoint = "ldap_get_dnW")] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial IntPtr ldap_get_dn(ConnectionHandle ldapHandle, IntPtr result); [LibraryImport(Libraries.Wldap32, EntryPoint = "ldap_first_attributeW")] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial IntPtr ldap_first_attribute(ConnectionHandle ldapHandle, IntPtr result, ref IntPtr address); [LibraryImport(Libraries.Wldap32, EntryPoint = "ldap_next_attributeW")] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial IntPtr ldap_next_attribute(ConnectionHandle ldapHandle, IntPtr result, IntPtr address); [LibraryImport(Libraries.Wldap32, EntryPoint = "ldap_get_values_lenW", StringMarshalling = StringMarshalling.Utf16)] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial IntPtr ldap_get_values_len(ConnectionHandle ldapHandle, IntPtr result, string name); [LibraryImport(Libraries.Wldap32, EntryPoint = "ldap_value_free_len")] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial IntPtr ldap_value_free_len(IntPtr berelement); [LibraryImport(Libraries.Wldap32, EntryPoint = "ldap_parse_referenceW")] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial int ldap_parse_reference(ConnectionHandle ldapHandle, IntPtr result, ref IntPtr referrals); [LibraryImport(Libraries.Wldap32, EntryPoint = "ldap_create_sort_controlW")] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial int ldap_create_sort_control(ConnectionHandle handle, IntPtr keys, byte critical, ref IntPtr control); [LibraryImport(Libraries.Wldap32, EntryPoint = "ldap_control_freeW")] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial int ldap_control_free(IntPtr control); [LibraryImport("Crypt32.dll", EntryPoint = "CertFreeCRLContext")] public static partial int CertFreeCRLContext(IntPtr certContext); [LibraryImport(Libraries.Wldap32, EntryPoint = "ldap_result2error")] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(System.Runtime.CompilerServices.CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] public static partial int ldap_result2error(ConnectionHandle ldapHandle, IntPtr result, int freeIt); } } diff --git a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Swift/SwiftTypes.cs b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Swift/SwiftTypes.cs index f64df4da17b26..a07be15ad44ca 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Swift/SwiftTypes.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Runtime/InteropServices/Swift/SwiftTypes.cs @@ -13,7 +13,7 @@ namespace System.Runtime.InteropServices.Swift /// /// Here's an example of how a SwiftSelf context can be declared: /// - /// [UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvSwift) })] + /// [UnmanagedCallConv(CallConvs = [typeof(CallConvSwift)])] /// [DllImport("SwiftLibrary", EntryPoint = "export")] /// public static extern void swiftFunction(SwiftSelf self); /// @@ -46,7 +46,7 @@ public SwiftSelf(void* value) /// /// Here's an example of how a SwiftError can be declared: /// - /// [UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvSwift) })] + /// [UnmanagedCallConv(CallConvs = [typeof(CallConvSwift)])] /// [DllImport("SwiftLibrary", EntryPoint = "export")] /// public static extern void swiftFunction(SwiftError* error); /// diff --git a/src/tests/Interop/UnmanagedCallConv/PInvokesCS.cs b/src/tests/Interop/UnmanagedCallConv/PInvokesCS.cs index 52e1d47e4f722..7a6f84fbced14 100644 --- a/src/tests/Interop/UnmanagedCallConv/PInvokesCS.cs +++ b/src/tests/Interop/UnmanagedCallConv/PInvokesCS.cs @@ -38,11 +38,11 @@ public static class Default public static class Cdecl { - [UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] [DllImport(nameof(UnmanagedCallConvNative), EntryPoint = Double_Cdecl)] public static extern int Blittable_Double_CdeclUnmanagedCallConv(int a, int* b); - [UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] [DllImport(nameof(UnmanagedCallConvNative), EntryPoint = Double_Cdecl)] public static extern bool NotBlittable_Double_CdeclUnmanagedCallConv(int a, int* b); } @@ -50,20 +50,20 @@ public static class Cdecl public static class Stdcall { // Mismatch - [UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] [DllImport(nameof(UnmanagedCallConvNative), EntryPoint = Double_Stdcall)] public static extern int Blittable_Double_CdeclUnmanagedCallConv(int a, int* b); - [UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvStdcall) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvStdcall)])] [DllImport(nameof(UnmanagedCallConvNative), EntryPoint = Double_Stdcall)] public static extern int Blittable_Double_StdcallUnmanagedCallConv(int a, int* b); // Mismatch - [UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] [DllImport(nameof(UnmanagedCallConvNative), EntryPoint = Double_Stdcall)] public static extern bool NotBlittable_Double_CdeclUnmanagedCallConv(int a, int* b); - [UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvStdcall) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvStdcall)])] [DllImport(nameof(UnmanagedCallConvNative), EntryPoint = Double_Stdcall)] public static extern bool NotBlittable_Double_StdcallUnmanagedCallConv(int a, int* b); } @@ -84,11 +84,11 @@ public static class Default public static class Cdecl { - [UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] [DllImport(nameof(UnmanagedCallConvNative), EntryPoint = Double_Cdecl, CallingConvention = CallingConvention.Winapi)] public static extern int Blittable_Double_CdeclUnmanagedCallConv(int a, int* b); - [UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] [DllImport(nameof(UnmanagedCallConvNative), EntryPoint = Double_Cdecl, CallingConvention = CallingConvention.Winapi)] public static extern bool NotBlittable_Double_CdeclUnmanagedCallConv(int a, int* b); } @@ -96,20 +96,20 @@ public static class Cdecl public static class Stdcall { // Mismatch - [UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] [DllImport(nameof(UnmanagedCallConvNative), EntryPoint = Double_Stdcall, CallingConvention = CallingConvention.Winapi)] public static extern int Blittable_Double_CdeclUnmanagedCallConv(int a, int* b); - [UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvStdcall) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvStdcall)])] [DllImport(nameof(UnmanagedCallConvNative), EntryPoint = Double_Stdcall, CallingConvention = CallingConvention.Winapi)] public static extern int Blittable_Double_StdcallUnmanagedCallConv(int a, int* b); // Mismatch - [UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] [DllImport(nameof(UnmanagedCallConvNative), EntryPoint = Double_Stdcall, CallingConvention = CallingConvention.Winapi)] public static extern bool NotBlittable_Double_CdeclUnmanagedCallConv(int a, int* b); - [UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvStdcall) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvStdcall)])] [DllImport(nameof(UnmanagedCallConvNative), EntryPoint = Double_Stdcall, CallingConvention = CallingConvention.Winapi)] public static extern bool NotBlittable_Double_StdcallUnmanagedCallConv(int a, int* b); } @@ -124,7 +124,7 @@ public static class Default [DllImport(nameof(UnmanagedCallConvNative), EntryPoint = Double_Default)] public static extern int Blittable_Double_DefaultUnmanagedCallConv_SuppressGCAttr(int a, int* b); - [UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvSuppressGCTransition) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvSuppressGCTransition)])] [DllImport(nameof(UnmanagedCallConvNative), EntryPoint = Double_Default)] public static extern int Blittable_Double_DefaultUnmanagedCallConv_SuppressGC(int a, int* b); @@ -133,7 +133,7 @@ public static class Default [DllImport(nameof(UnmanagedCallConvNative), EntryPoint = Double_Default)] public static extern bool NotBlittable_Double_DefaultUnmanagedCallConv_SuppressGCAttr(int a, int* b); - [UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvSuppressGCTransition) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvSuppressGCTransition)])] [DllImport(nameof(UnmanagedCallConvNative), EntryPoint = Double_Default)] public static extern bool NotBlittable_Double_DefaultUnmanagedCallConv_SuppressGC(int a, int* b); } @@ -141,20 +141,20 @@ public static class Default public static class Cdecl { [SuppressGCTransition] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] [DllImport(nameof(UnmanagedCallConvNative), EntryPoint = Double_Cdecl)] public static extern int Blittable_Double_CdeclUnmanagedCallConv_SuppressGCAttr(int a, int* b); - [UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl), typeof(CallConvSuppressGCTransition) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl), typeof(CallConvSuppressGCTransition)])] [DllImport(nameof(UnmanagedCallConvNative), EntryPoint = Double_Cdecl)] public static extern int Blittable_Double_CdeclUnmanagedCallConv_SuppressGC(int a, int* b); [SuppressGCTransition] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] [DllImport(nameof(UnmanagedCallConvNative), EntryPoint = Double_Cdecl)] public static extern bool NotBlittable_Double_CdeclUnmanagedCallConv_SuppressGCAttr(int a, int* b); - [UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl), typeof(CallConvSuppressGCTransition) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl), typeof(CallConvSuppressGCTransition)])] [DllImport(nameof(UnmanagedCallConvNative), EntryPoint = Double_Cdecl)] public static extern bool NotBlittable_Double_CdeclUnmanagedCallConv_SuppressGC(int a, int* b); } @@ -162,20 +162,20 @@ public static class Cdecl public static class Stdcall { [SuppressGCTransition] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvStdcall) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvStdcall)])] [DllImport(nameof(UnmanagedCallConvNative), EntryPoint = Double_Stdcall)] public static extern int Blittable_Double_StdcallUnmanagedCallConv_SuppressGCAttr(int a, int* b); - [UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvStdcall), typeof(CallConvSuppressGCTransition) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvStdcall), typeof(CallConvSuppressGCTransition)])] [DllImport(nameof(UnmanagedCallConvNative), EntryPoint = Double_Stdcall)] public static extern int Blittable_Double_StdcallUnmanagedCallConv_SuppressGC(int a, int* b); [SuppressGCTransition] - [UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvStdcall) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvStdcall)])] [DllImport(nameof(UnmanagedCallConvNative), EntryPoint = Double_Stdcall)] public static extern bool NotBlittable_Double_StdcallUnmanagedCallConv_SuppressGCAttr(int a, int* b); - [UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvStdcall), typeof(CallConvSuppressGCTransition) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvStdcall), typeof(CallConvSuppressGCTransition)])] [DllImport(nameof(UnmanagedCallConvNative), EntryPoint = Double_Stdcall)] public static extern bool NotBlittable_Double_StdcallUnmanagedCallConv_SuppressGC(int a, int* b); } @@ -186,22 +186,22 @@ public static class MatchingDllImport public static class Cdecl { // UnmanagedCallConv should not be used - [UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvStdcall) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvStdcall)])] [DllImport(nameof(UnmanagedCallConvNative), EntryPoint = Double_Cdecl, CallingConvention = CallingConvention.Cdecl)] public static extern int Blittable_Double_StdcallUnmanagedCallConv(int a, int* b); // UnmanagedCallConv should not be used - [UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvSuppressGCTransition) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvSuppressGCTransition)])] [DllImport(nameof(UnmanagedCallConvNative), EntryPoint = Double_Cdecl, CallingConvention = CallingConvention.Cdecl)] public static extern int Blittable_Double_SuppressGCUnmanagedCallConv(int a, int* b); // UnmanagedCallConv should not be used - [UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvStdcall) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvStdcall)])] [DllImport(nameof(UnmanagedCallConvNative), EntryPoint = Double_Cdecl, CallingConvention = CallingConvention.Cdecl)] public static extern bool NotBlittable_Double_StdcallUnmanagedCallConv(int a, int* b); // UnmanagedCallConv should not be used - [UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvSuppressGCTransition) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvSuppressGCTransition)])] [DllImport(nameof(UnmanagedCallConvNative), EntryPoint = Double_Cdecl, CallingConvention = CallingConvention.Cdecl)] public static extern bool NotBlittable_Double_SuppressGCUnmanagedCallConv(int a, int* b); } @@ -209,22 +209,22 @@ public static class Cdecl public static class Stdcall { // UnmanagedCallConv should not be used - [UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] [DllImport(nameof(UnmanagedCallConvNative), EntryPoint = Double_Stdcall, CallingConvention = CallingConvention.StdCall)] public static extern int Blittable_Double_CdeclUnmanagedCallConv(int a, int* b); // UnmanagedCallConv should not be used - [UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvSuppressGCTransition) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvSuppressGCTransition)])] [DllImport(nameof(UnmanagedCallConvNative), EntryPoint = Double_Stdcall, CallingConvention = CallingConvention.StdCall)] public static extern int Blittable_Double_SuppressGCUnmanagedCallConv(int a, int* b); // UnmanagedCallConv should not be used - [UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvCdecl) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvCdecl)])] [DllImport(nameof(UnmanagedCallConvNative), EntryPoint = Double_Stdcall, CallingConvention = CallingConvention.StdCall)] public static extern bool NotBlittable_Double_CdeclUnmanagedCallConv(int a, int* b); // UnmanagedCallConv should not be used - [UnmanagedCallConv(CallConvs = new Type[] { typeof(CallConvSuppressGCTransition) })] + [UnmanagedCallConv(CallConvs = [typeof(CallConvSuppressGCTransition)])] [DllImport(nameof(UnmanagedCallConvNative), EntryPoint = Double_Stdcall, CallingConvention = CallingConvention.StdCall)] public static extern bool NotBlittable_Double_SuppressGCUnmanagedCallConv(int a, int* b); }