diff --git a/eng/generators.targets b/eng/generators.targets
index 757a91ac9d90c..53a0286da7e36 100644
--- a/eng/generators.targets
+++ b/eng/generators.targets
@@ -32,7 +32,7 @@
and '$(IsFrameworkSupportFacade)' != 'true'
and '$(IsSourceProject)' == 'true'
and '$(MSBuildProjectExtension)' == '.csproj'
- and '$(TargetFrameworkIdentifier)' == '.NETStandard'" />
+ and ('$(TargetFrameworkIdentifier)' == '.NETStandard' or '$(TargetFrameworkIdentifier)' == '.NETFramework')" />
diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.ConvertStringSecurityDescriptorToSecurityDescriptor.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.ConvertStringSecurityDescriptorToSecurityDescriptor.cs
index 1cda9c2b58304..eb87d49e0fdbf 100644
--- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.ConvertStringSecurityDescriptorToSecurityDescriptor.cs
+++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.ConvertStringSecurityDescriptorToSecurityDescriptor.cs
@@ -9,11 +9,11 @@ internal static partial class Interop
{
internal static partial class Advapi32
{
- [DllImport(Interop.Libraries.Advapi32, CharSet = CharSet.Unicode, SetLastError = true, BestFitMapping = false)]
- internal static extern bool ConvertStringSecurityDescriptorToSecurityDescriptor(
- string StringSecurityDescriptor,
- int StringSDRevision,
- out SafeLocalAllocHandle pSecurityDescriptor,
- IntPtr SecurityDescriptorSize);
+ [GeneratedDllImport(Interop.Libraries.Advapi32, CharSet = CharSet.Unicode, SetLastError = true)]
+ internal static partial bool ConvertStringSecurityDescriptorToSecurityDescriptor(
+ string StringSecurityDescriptor,
+ int StringSDRevision,
+ out SafeLocalAllocHandle pSecurityDescriptor,
+ IntPtr SecurityDescriptorSize);
}
}
diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.GetSecurityDescriptorLength.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.GetSecurityDescriptorLength.cs
index e94bd4b0f18c2..854c2c6055aed 100644
--- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.GetSecurityDescriptorLength.cs
+++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.GetSecurityDescriptorLength.cs
@@ -8,8 +8,7 @@ internal static partial class Interop
{
internal static partial class Advapi32
{
- [DllImport(Interop.Libraries.Advapi32, EntryPoint = "GetSecurityDescriptorLength", CallingConvention = CallingConvention.Winapi,
- CharSet = CharSet.Unicode, ExactSpelling = true)]
- internal static extern /*DWORD*/ uint GetSecurityDescriptorLength(IntPtr byteArray);
+ [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "GetSecurityDescriptorLength", CharSet = CharSet.Unicode, ExactSpelling = true)]
+ internal static partial uint GetSecurityDescriptorLength(IntPtr byteArray);
}
}
diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.GetTokenInformation.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.GetTokenInformation.cs
index d881a59ac0551..22ee2407525e2 100644
--- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.GetTokenInformation.cs
+++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.GetTokenInformation.cs
@@ -9,39 +9,24 @@ internal static partial class Interop
{
internal static partial class Advapi32
{
-#if DLLIMPORTGENERATOR_ENABLED
[GeneratedDllImport(Interop.Libraries.Advapi32, SetLastError = true)]
internal static partial bool GetTokenInformation(
-#else
- [DllImport(Interop.Libraries.Advapi32, SetLastError = true)]
- internal static extern bool GetTokenInformation(
-#endif
SafeAccessTokenHandle TokenHandle,
uint TokenInformationClass,
SafeLocalAllocHandle TokenInformation,
uint TokenInformationLength,
out uint ReturnLength);
-#if DLLIMPORTGENERATOR_ENABLED
[GeneratedDllImport(Interop.Libraries.Advapi32, SetLastError = true)]
internal static partial bool GetTokenInformation(
-#else
- [DllImport(Interop.Libraries.Advapi32, SetLastError = true)]
- internal static extern bool GetTokenInformation(
-#endif
IntPtr TokenHandle,
uint TokenInformationClass,
SafeLocalAllocHandle TokenInformation,
uint TokenInformationLength,
out uint ReturnLength);
-#if DLLIMPORTGENERATOR_ENABLED
- [GeneratedDllImport(Interop.Libraries.Advapi32, CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Interop.Libraries.Advapi32, SetLastError = true)]
internal static partial bool GetTokenInformation(
-#else
- [DllImport(Interop.Libraries.Advapi32, CharSet = CharSet.Unicode, SetLastError = true)]
- internal static extern bool GetTokenInformation(
-#endif
IntPtr TokenHandle,
uint TokenInformationClass,
IntPtr TokenInformation,
diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.LsaNtStatusToWinError.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.LsaNtStatusToWinError.cs
index 524600d62ce89..2da367aababc3 100644
--- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.LsaNtStatusToWinError.cs
+++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.LsaNtStatusToWinError.cs
@@ -8,7 +8,7 @@ internal static partial class Interop
{
internal static partial class Advapi32
{
- [DllImport(Interop.Libraries.Advapi32, SetLastError = false)]
- internal static extern uint LsaNtStatusToWinError(uint status);
+ [GeneratedDllImport(Interop.Libraries.Advapi32, SetLastError = false)]
+ internal static partial uint LsaNtStatusToWinError(uint status);
}
}
diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegCloseKey.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegCloseKey.cs
index 5d27b90afa963..23bc17bad23cc 100644
--- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegCloseKey.cs
+++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegCloseKey.cs
@@ -8,7 +8,7 @@ internal static partial class Interop
{
internal static partial class Advapi32
{
- [DllImport(Libraries.Advapi32)]
- internal static extern int RegCloseKey(IntPtr hKey);
+ [GeneratedDllImport(Libraries.Advapi32)]
+ internal static partial int RegCloseKey(IntPtr hKey);
}
}
diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegConnectRegistry.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegConnectRegistry.cs
index 83206d9f75ced..4d0fbbb415c1d 100644
--- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegConnectRegistry.cs
+++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegConnectRegistry.cs
@@ -14,13 +14,8 @@ internal static partial class Interop
{
internal static partial class Advapi32
{
-#if DLLIMPORTGENERATOR_ENABLED
[GeneratedDllImport(Libraries.Advapi32, EntryPoint = "RegConnectRegistryW", CharSet = CharSet.Unicode)]
internal static partial int RegConnectRegistry(
-#else
- [DllImport(Libraries.Advapi32, EntryPoint = "RegConnectRegistryW", CharSet = CharSet.Unicode, BestFitMapping = false)]
- internal static extern int RegConnectRegistry(
-#endif
string machineName,
SafeRegistryHandle key,
out SafeRegistryHandle result);
diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegEnumKeyEx.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegEnumKeyEx.cs
index cf24e64193835..b5b2742c213e8 100644
--- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegEnumKeyEx.cs
+++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegEnumKeyEx.cs
@@ -12,11 +12,11 @@ internal static partial class Interop
{
internal static partial class Advapi32
{
- [DllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, BestFitMapping = false, EntryPoint = "RegEnumKeyExW", ExactSpelling = true)]
- internal static extern int RegEnumKeyEx(
+ [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "RegEnumKeyExW", CharSet = CharSet.Unicode, ExactSpelling = true)]
+ internal static partial int RegEnumKeyEx(
SafeRegistryHandle hKey,
int dwIndex,
- char[] lpName,
+ [Out] char[] lpName,
ref int lpcbName,
int[]? lpReserved,
[Out] char[]? lpClass,
diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegEnumValue.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegEnumValue.cs
index 39543b2249495..bb74b7b0cf8a1 100644
--- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegEnumValue.cs
+++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegEnumValue.cs
@@ -13,11 +13,11 @@ internal static partial class Interop
{
internal static partial class Advapi32
{
- [DllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, BestFitMapping = false, EntryPoint = "RegEnumValueW", ExactSpelling = true)]
- internal static extern int RegEnumValue(
+ [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "RegEnumValueW", CharSet = CharSet.Unicode, ExactSpelling = true)]
+ internal static partial int RegEnumValue(
SafeRegistryHandle hKey,
int dwIndex,
- char[] lpValueName,
+ [Out] char[] lpValueName,
ref int lpcbValueName,
IntPtr lpReserved_MustBeZero,
int[]? lpType,
diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegQueryInfoKey.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegQueryInfoKey.cs
index 6870d0d45e94f..1bcc4ef2ddb25 100644
--- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegQueryInfoKey.cs
+++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegQueryInfoKey.cs
@@ -14,8 +14,8 @@ internal static partial class Interop
{
internal static partial class Advapi32
{
- [DllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, BestFitMapping = false, EntryPoint = "RegQueryInfoKeyW")]
- internal static extern int RegQueryInfoKey(
+ [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "RegQueryInfoKeyW", CharSet = CharSet.Unicode, ExactSpelling = true)]
+ internal static partial int RegQueryInfoKey(
SafeRegistryHandle hKey,
[Out] char[]? lpClass,
int[]? lpcbClass,
diff --git a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegQueryValueEx.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegQueryValueEx.cs
index f05122613da04..3ee7567b873fc 100644
--- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegQueryValueEx.cs
+++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegQueryValueEx.cs
@@ -13,17 +13,17 @@ internal static partial class Interop
{
internal static partial class Advapi32
{
- [DllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, BestFitMapping = false, EntryPoint = "RegQueryValueExW", ExactSpelling = true)]
- internal static extern int RegQueryValueEx(
+ [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "RegQueryValueExW", CharSet = CharSet.Unicode, ExactSpelling = true)]
+ internal static partial int RegQueryValueEx(
SafeRegistryHandle hKey,
string? lpValueName,
int[]? lpReserved,
ref int lpType,
- [Out] byte[]? lpData,
+ byte[]? lpData,
ref int lpcbData);
- [DllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, BestFitMapping = false, EntryPoint = "RegQueryValueExW", ExactSpelling = true)]
- internal static extern int RegQueryValueEx(
+ [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "RegQueryValueExW", CharSet = CharSet.Unicode, ExactSpelling = true)]
+ internal static partial int RegQueryValueEx(
SafeRegistryHandle hKey,
string? lpValueName,
int[]? lpReserved,
@@ -31,8 +31,8 @@ internal static extern int RegQueryValueEx(
ref int lpData,
ref int lpcbData);
- [DllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, BestFitMapping = false, EntryPoint = "RegQueryValueExW", ExactSpelling = true)]
- internal static extern int RegQueryValueEx(
+ [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "RegQueryValueExW", CharSet = CharSet.Unicode, ExactSpelling = true)]
+ internal static partial int RegQueryValueEx(
SafeRegistryHandle hKey,
string? lpValueName,
int[]? lpReserved,
@@ -40,8 +40,8 @@ internal static extern int RegQueryValueEx(
ref long lpData,
ref int lpcbData);
- [DllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, BestFitMapping = false, EntryPoint = "RegQueryValueExW", ExactSpelling = true)]
- internal static extern int RegQueryValueEx(
+ [GeneratedDllImport(Libraries.Advapi32, EntryPoint = "RegQueryValueExW", CharSet = CharSet.Unicode, ExactSpelling = true)]
+ internal static partial int RegQueryValueEx(
SafeRegistryHandle hKey,
string? lpValueName,
int[]? lpReserved,
diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.CreateFileMapping.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.CreateFileMapping.cs
index 81ffec311fbc6..ba3f74ac8fd1c 100644
--- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.CreateFileMapping.cs
+++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.CreateFileMapping.cs
@@ -10,13 +10,8 @@ internal static partial class Interop
{
internal static partial class Kernel32
{
-#if DLLIMPORTGENERATOR_ENABLED
- [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "CreateFileMappingW", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "CreateFileMappingW", CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)]
internal static partial SafeMemoryMappedFileHandle CreateFileMapping(
-#else
- [DllImport(Libraries.Kernel32, EntryPoint = "CreateFileMappingW", CharSet = CharSet.Unicode, SetLastError = true)]
- internal static extern SafeMemoryMappedFileHandle CreateFileMapping(
-#endif
SafeFileHandle hFile,
ref SECURITY_ATTRIBUTES lpFileMappingAttributes,
int flProtect,
@@ -24,13 +19,8 @@ internal static extern SafeMemoryMappedFileHandle CreateFileMapping(
int dwMaximumSizeLow,
string? lpName);
-#if DLLIMPORTGENERATOR_ENABLED
- [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "CreateFileMappingW", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "CreateFileMappingW", CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)]
internal static partial SafeMemoryMappedFileHandle CreateFileMapping(
-#else
- [DllImport(Libraries.Kernel32, EntryPoint = "CreateFileMappingW", CharSet = CharSet.Unicode, SetLastError = true)]
- internal static extern SafeMemoryMappedFileHandle CreateFileMapping(
-#endif
IntPtr hFile,
ref SECURITY_ATTRIBUTES lpFileMappingAttributes,
int flProtect,
diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.DuplicateHandle_SafeWaitHandle.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.DuplicateHandle_SafeWaitHandle.cs
index f68f28bc1eadc..69dc66c54ff86 100644
--- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.DuplicateHandle_SafeWaitHandle.cs
+++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.DuplicateHandle_SafeWaitHandle.cs
@@ -9,13 +9,8 @@ internal static partial class Interop
{
internal static partial class Kernel32
{
-#if DLLIMPORTGENERATOR_ENABLED
[GeneratedDllImport(Libraries.Kernel32, SetLastError = true)]
internal static partial bool DuplicateHandle(
-#else
- [DllImport(Libraries.Kernel32, SetLastError = true)]
- internal static extern bool DuplicateHandle(
-#endif
IntPtr hSourceProcessHandle,
SafeHandle hSourceHandle,
IntPtr hTargetProcess,
diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.FreeLibrary.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.FreeLibrary.cs
index 7863e2417e003..9d8e18219c9d9 100644
--- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.FreeLibrary.cs
+++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.FreeLibrary.cs
@@ -8,7 +8,7 @@ internal static partial class Interop
{
internal static partial class Kernel32
{
- [DllImport(Libraries.Kernel32, ExactSpelling = true, SetLastError = true)]
- internal static extern bool FreeLibrary(IntPtr hModule);
+ [GeneratedDllImport(Libraries.Kernel32, ExactSpelling = true, SetLastError = true)]
+ internal static partial bool FreeLibrary(IntPtr hModule);
}
}
diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetComputerName.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetComputerName.cs
index e186ac2be5725..d82305b7f992e 100644
--- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetComputerName.cs
+++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetComputerName.cs
@@ -9,8 +9,8 @@ internal static partial class Interop
{
internal static partial class Kernel32
{
- [DllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, EntryPoint = "GetComputerNameW", ExactSpelling = true)]
- private static unsafe extern int GetComputerName(char* lpBuffer, uint* nSize);
+ [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "GetComputerNameW", CharSet = CharSet.Unicode, ExactSpelling = true)]
+ private static unsafe partial int GetComputerName(char* lpBuffer, uint* nSize);
// maximum length of the NETBIOS name (not including NULL)
private const int MAX_COMPUTERNAME_LENGTH = 15;
diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetCurrentProcess.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetCurrentProcess.cs
index 3f7482f5385a6..89f04ad9ff080 100644
--- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetCurrentProcess.cs
+++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetCurrentProcess.cs
@@ -8,7 +8,7 @@ internal static partial class Interop
{
internal static partial class Kernel32
{
- [DllImport(Libraries.Kernel32)]
- internal static extern IntPtr GetCurrentProcess();
+ [GeneratedDllImport(Libraries.Kernel32)]
+ internal static partial IntPtr GetCurrentProcess();
}
}
diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetCurrentProcessId.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetCurrentProcessId.cs
index 70009c6f93235..be0fd40730358 100644
--- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetCurrentProcessId.cs
+++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetCurrentProcessId.cs
@@ -7,7 +7,7 @@ internal static partial class Interop
{
internal static partial class Kernel32
{
- [DllImport(Libraries.Kernel32)]
- internal static extern uint GetCurrentProcessId();
+ [GeneratedDllImport(Libraries.Kernel32)]
+ internal static partial uint GetCurrentProcessId();
}
}
diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetCurrentThread.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetCurrentThread.cs
index cefb82cbd3fbb..73d33398d5a0f 100644
--- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetCurrentThread.cs
+++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetCurrentThread.cs
@@ -8,7 +8,7 @@ internal static partial class Interop
{
internal static partial class Kernel32
{
- [DllImport(Interop.Libraries.Kernel32)]
- internal static extern IntPtr GetCurrentThread();
+ [GeneratedDllImport(Interop.Libraries.Kernel32)]
+ internal static partial IntPtr GetCurrentThread();
}
}
diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetProcessTimes.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetProcessTimes.cs
index e76f80712ba4a..dc019f330d871 100644
--- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetProcessTimes.cs
+++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetProcessTimes.cs
@@ -8,13 +8,8 @@ internal static partial class Interop
{
internal static partial class Kernel32
{
-#if DLLIMPORTGENERATOR_ENABLED
[GeneratedDllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, SetLastError = true)]
internal static partial bool GetProcessTimes(
-#else
- [DllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, SetLastError = true)]
- internal static extern bool GetProcessTimes(
-#endif
SafeProcessHandle handle, out long creation, out long exit, out long kernel, out long user);
}
}
diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.LoadLibrary.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.LoadLibrary.cs
index a65062ad682b1..93f0bedf5432c 100644
--- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.LoadLibrary.cs
+++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.LoadLibrary.cs
@@ -8,7 +8,7 @@ internal static partial class Interop
{
internal static partial class Kernel32
{
- [DllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, SetLastError = true)]
- public static extern IntPtr LoadLibrary(string libFilename);
+ [GeneratedDllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, SetLastError = true)]
+ public static partial IntPtr LoadLibrary(string libFilename);
}
}
diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.MapViewOfFile.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.MapViewOfFile.cs
index 764a6ad8080a9..ed29c33acca48 100644
--- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.MapViewOfFile.cs
+++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.MapViewOfFile.cs
@@ -9,13 +9,8 @@ internal static partial class Interop
{
internal static partial class Kernel32
{
-#if DLLIMPORTGENERATOR_ENABLED
[GeneratedDllImport(Libraries.Kernel32, EntryPoint = "MapViewOfFile", CharSet = CharSet.Unicode, SetLastError = true)]
internal static partial SafeMemoryMappedViewHandle MapViewOfFile(
-#else
- [DllImport(Libraries.Kernel32, EntryPoint = "MapViewOfFile", CharSet = CharSet.Unicode, SetLastError = true)]
- internal static extern SafeMemoryMappedViewHandle MapViewOfFile(
-#endif
SafeMemoryMappedFileHandle hFileMappingObject,
int dwDesiredAccess,
int dwFileOffsetHigh,
diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.OpenFileMapping.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.OpenFileMapping.cs
index 6ac60a8fa558f..08ce6fc8917d5 100644
--- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.OpenFileMapping.cs
+++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.OpenFileMapping.cs
@@ -8,13 +8,8 @@ internal static partial class Interop
{
internal static partial class Kernel32
{
-#if DLLIMPORTGENERATOR_ENABLED
- [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "OpenFileMappingW", CharSet = CharSet.Unicode, SetLastError = true)]
+ [GeneratedDllImport(Libraries.Kernel32, EntryPoint = "OpenFileMappingW", CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)]
internal static partial SafeMemoryMappedFileHandle OpenFileMapping(
-#else
- [DllImport(Libraries.Kernel32, EntryPoint = "OpenFileMappingW", CharSet = CharSet.Unicode, SetLastError = true)]
- internal static extern SafeMemoryMappedFileHandle OpenFileMapping(
-#endif
int dwDesiredAccess,
[MarshalAs(UnmanagedType.Bool)] bool bInheritHandle,
string lpName);
diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.OpenProcess.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.OpenProcess.cs
index 2eaa7a9e5f597..2cd405129dbf9 100644
--- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.OpenProcess.cs
+++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.OpenProcess.cs
@@ -8,13 +8,8 @@ internal static partial class Interop
{
internal static partial class Kernel32
{
-#if DLLIMPORTGENERATOR_ENABLED
[GeneratedDllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, SetLastError = true)]
internal static partial SafeProcessHandle OpenProcess(
-#else
- [DllImport(Libraries.Kernel32, CharSet = CharSet.Unicode, SetLastError = true)]
- internal static extern SafeProcessHandle OpenProcess(
-#endif
int access, bool inherit, int processId);
}
}
diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.UnmapViewOfFile.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.UnmapViewOfFile.cs
index dd519a7f1f87f..4f41d03faba16 100644
--- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.UnmapViewOfFile.cs
+++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.UnmapViewOfFile.cs
@@ -8,12 +8,7 @@ internal static partial class Interop
{
internal static partial class Kernel32
{
-#if DLLIMPORTGENERATOR_ENABLED
[GeneratedDllImport(Libraries.Kernel32, SetLastError = true)]
internal static partial bool UnmapViewOfFile(IntPtr lpBaseAddress);
-#else
- [DllImport(Libraries.Kernel32, SetLastError = true)]
- internal static extern bool UnmapViewOfFile(IntPtr lpBaseAddress);
-#endif
}
}
diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.VirtualQuery.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.VirtualQuery.cs
index 9ede606895a45..1dd2029a5f57f 100644
--- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.VirtualQuery.cs
+++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.VirtualQuery.cs
@@ -8,13 +8,8 @@ internal static partial class Interop
{
internal static partial class Kernel32
{
-#if DLLIMPORTGENERATOR_ENABLED
[GeneratedDllImport(Libraries.Kernel32, ExactSpelling = true, SetLastError = true)]
internal static partial UIntPtr VirtualQuery(
-#else
- [DllImport(Libraries.Kernel32, ExactSpelling = true, SetLastError = true)]
- internal static extern UIntPtr VirtualQuery(
-#endif
SafeHandle lpAddress,
ref MEMORY_BASIC_INFORMATION lpBuffer,
UIntPtr dwLength);
diff --git a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.WaitForSingleObject.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.WaitForSingleObject.cs
index 2a81da9a5a1c8..5f3f964a60a42 100644
--- a/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.WaitForSingleObject.cs
+++ b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.WaitForSingleObject.cs
@@ -8,7 +8,7 @@ internal static partial class Interop
{
internal static partial class Kernel32
{
- [DllImport(Libraries.Kernel32, ExactSpelling = true, SetLastError = true)]
- internal static extern int WaitForSingleObject(SafeWaitHandle handle, int timeout);
+ [GeneratedDllImport(Libraries.Kernel32, ExactSpelling = true, SetLastError = true)]
+ internal static partial int WaitForSingleObject(SafeWaitHandle handle, int timeout);
}
}
diff --git a/src/libraries/Common/src/Interop/Windows/Pdh/Interop.PdhFormatFromRawValue.cs b/src/libraries/Common/src/Interop/Windows/Pdh/Interop.PdhFormatFromRawValue.cs
index 11a1556a5230d..b9ab8b10d0976 100644
--- a/src/libraries/Common/src/Interop/Windows/Pdh/Interop.PdhFormatFromRawValue.cs
+++ b/src/libraries/Common/src/Interop/Windows/Pdh/Interop.PdhFormatFromRawValue.cs
@@ -7,8 +7,8 @@ internal static partial class Interop
{
internal static partial class Pdh
{
- [DllImport(Libraries.Pdh, CharSet = CharSet.Unicode)]
- public static extern int PdhFormatFromRawValue(
+ [GeneratedDllImport(Libraries.Pdh, CharSet = CharSet.Unicode)]
+ public static partial int PdhFormatFromRawValue(
uint dwCounterType,
uint dwFormat,
ref long pTimeBase,
diff --git a/src/libraries/Common/src/Interop/Windows/PerfCounter/Interop.PerformanceData.cs b/src/libraries/Common/src/Interop/Windows/PerfCounter/Interop.PerformanceData.cs
index 5b95bd08795a6..ce978ad6fab1a 100644
--- a/src/libraries/Common/src/Interop/Windows/PerfCounter/Interop.PerformanceData.cs
+++ b/src/libraries/Common/src/Interop/Windows/PerfCounter/Interop.PerformanceData.cs
@@ -9,8 +9,8 @@ internal static partial class Interop
{
internal static partial class PerfCounter
{
- [DllImport(Libraries.Advapi32, ExactSpelling = true)]
- internal static extern uint PerfStopProvider(
+ [GeneratedDllImport(Libraries.Advapi32, ExactSpelling = true)]
+ internal static partial uint PerfStopProvider(
IntPtr hProvider
);
@@ -53,6 +53,7 @@ internal struct PerfCounterSetInstanceStruct
internal uint InstanceNameSize;
}
+ // TODO: [DllImportGenerator] Switch to use GeneratedDllImport once we annotate blittable types used in interop in CoreLib (like Guid)
[DllImport(Libraries.Advapi32, ExactSpelling = true)]
internal static extern uint PerfStartProvider(
ref Guid ProviderGuid,
@@ -60,6 +61,7 @@ internal static extern uint PerfStartProvider(
out SafePerfProviderHandle phProvider
);
+ // TODO: [DllImportGenerator] Switch to use GeneratedDllImport once we annotate blittable types used in interop in CoreLib (like Guid)
[DllImport(Libraries.Advapi32, SetLastError = true, ExactSpelling = true, CharSet = CharSet.Unicode)]
internal static extern unsafe PerfCounterSetInstanceStruct* PerfCreateInstance(
SafePerfProviderHandle hProvider,
@@ -68,21 +70,21 @@ out SafePerfProviderHandle phProvider
uint dwInstance
);
- [DllImport(Libraries.Advapi32, ExactSpelling = true)]
- internal static extern unsafe uint PerfSetCounterSetInfo(
+ [GeneratedDllImport(Libraries.Advapi32, ExactSpelling = true)]
+ internal static unsafe partial uint PerfSetCounterSetInfo(
SafePerfProviderHandle hProvider,
PerfCounterSetInfoStruct* pTemplate,
uint dwTemplateSize
);
- [DllImport(Libraries.Advapi32, ExactSpelling = true)]
- internal static extern unsafe uint PerfDeleteInstance(
+ [GeneratedDllImport(Libraries.Advapi32, ExactSpelling = true)]
+ internal static unsafe partial uint PerfDeleteInstance(
SafePerfProviderHandle hProvider,
PerfCounterSetInstanceStruct* InstanceBlock
);
- [DllImport(Libraries.Advapi32, ExactSpelling = true)]
- internal static extern unsafe uint PerfSetCounterRefValue(
+ [GeneratedDllImport(Libraries.Advapi32, ExactSpelling = true)]
+ internal static unsafe partial uint PerfSetCounterRefValue(
SafePerfProviderHandle hProvider,
PerfCounterSetInstanceStruct* pInstance,
uint CounterId,
diff --git a/src/libraries/Common/src/Interop/Windows/SspiCli/Interop.LsaDeregisterLogonProcess.cs b/src/libraries/Common/src/Interop/Windows/SspiCli/Interop.LsaDeregisterLogonProcess.cs
index 352d7763ea518..8cc158ef64570 100644
--- a/src/libraries/Common/src/Interop/Windows/SspiCli/Interop.LsaDeregisterLogonProcess.cs
+++ b/src/libraries/Common/src/Interop/Windows/SspiCli/Interop.LsaDeregisterLogonProcess.cs
@@ -8,7 +8,7 @@ internal static partial class Interop
{
internal static partial class SspiCli
{
- [DllImport(Interop.Libraries.SspiCli)]
- internal static extern int LsaDeregisterLogonProcess(IntPtr LsaHandle);
+ [GeneratedDllImport(Interop.Libraries.SspiCli)]
+ internal static partial int LsaDeregisterLogonProcess(IntPtr LsaHandle);
}
}
diff --git a/src/libraries/Common/src/Interop/Windows/SspiCli/Interop.SSPI.cs b/src/libraries/Common/src/Interop/Windows/SspiCli/Interop.SSPI.cs
index cc4ee4b7b5904..c22ae17d4edb4 100644
--- a/src/libraries/Common/src/Interop/Windows/SspiCli/Interop.SSPI.cs
+++ b/src/libraries/Common/src/Interop/Windows/SspiCli/Interop.SSPI.cs
@@ -475,7 +475,7 @@ internal static partial SECURITY_STATUS SspiEncodeStringsAsAuthIdentity(
string password,
out SafeSspiAuthDataHandle authData);
- // TODO: Switch to use GeneratedDllImport once we annotate blittable types used in interop in CoreLib (like Guid)
+ // TODO: [DllImportGenerator] Switch to use GeneratedDllImport once we annotate blittable types used in interop in CoreLib (like Guid)
[DllImport(Interop.Libraries.SspiCli, CharSet = CharSet.Unicode, ExactSpelling = true, SetLastError = true)]
internal static extern SECURITY_STATUS SetCredentialsAttributesW(
in CredHandle handlePtr,
diff --git a/src/libraries/Common/tests/TestUtilities/TestUtilities.csproj b/src/libraries/Common/tests/TestUtilities/TestUtilities.csproj
index e46ba8375110e..ecb7f715559ff 100644
--- a/src/libraries/Common/tests/TestUtilities/TestUtilities.csproj
+++ b/src/libraries/Common/tests/TestUtilities/TestUtilities.csproj
@@ -8,6 +8,7 @@
and instead use runtime checks.
-->
$(NetCoreAppMinimum);$(NetFrameworkMinimum)
+ true
+
+
diff --git a/src/libraries/System.Diagnostics.EventLog/src/System.Diagnostics.EventLog.csproj b/src/libraries/System.Diagnostics.EventLog/src/System.Diagnostics.EventLog.csproj
index 33c1953ecdcd5..c6f39b3ddf8fe 100644
--- a/src/libraries/System.Diagnostics.EventLog/src/System.Diagnostics.EventLog.csproj
+++ b/src/libraries/System.Diagnostics.EventLog/src/System.Diagnostics.EventLog.csproj
@@ -3,6 +3,11 @@
true
$(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent);$(NetCoreAppMinimum)-windows;$(NetCoreAppMinimum);netstandard2.0;$(NetFrameworkMinimum)
$(NoWarn);CA1838;CA1847
+
+ $(NoWarn);CA1845;CA1846
+ annotations
true
Provides the System.Diagnostics.EventLog class, which allows the applications to use the windows event log service.
@@ -125,8 +130,10 @@ System.Diagnostics.EventLog
+
+
diff --git a/src/libraries/System.Diagnostics.EventLog/tests/System.Diagnostics.EventLog.Tests.csproj b/src/libraries/System.Diagnostics.EventLog/tests/System.Diagnostics.EventLog.Tests.csproj
index a1bc84d9c3958..a03f4dea58048 100644
--- a/src/libraries/System.Diagnostics.EventLog/tests/System.Diagnostics.EventLog.Tests.csproj
+++ b/src/libraries/System.Diagnostics.EventLog/tests/System.Diagnostics.EventLog.Tests.csproj
@@ -2,6 +2,7 @@
$(NetCoreAppCurrent)-windows;$(NetFrameworkMinimum)
true
+ true
diff --git a/src/libraries/System.Diagnostics.PerformanceCounter/src/System.Diagnostics.PerformanceCounter.csproj b/src/libraries/System.Diagnostics.PerformanceCounter/src/System.Diagnostics.PerformanceCounter.csproj
index dfb057725b802..28133feec83ed 100644
--- a/src/libraries/System.Diagnostics.PerformanceCounter/src/System.Diagnostics.PerformanceCounter.csproj
+++ b/src/libraries/System.Diagnostics.PerformanceCounter/src/System.Diagnostics.PerformanceCounter.csproj
@@ -3,6 +3,7 @@
true
$(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent);$(NetCoreAppMinimum)-windows;$(NetCoreAppMinimum);netstandard2.0;$(NetFrameworkMinimum)
$(NoWarn);CA1847
+ annotations
true
Provides the System.Diagnostics.PerformanceCounter class, which allows access to Windows performance counters.
@@ -144,6 +145,7 @@ System.Diagnostics.PerformanceCounter
+
diff --git a/src/libraries/System.Diagnostics.Process/tests/System.Diagnostics.Process.Tests.csproj b/src/libraries/System.Diagnostics.Process/tests/System.Diagnostics.Process.Tests.csproj
index bfcfb2cc3b71c..783e4ad21e9c7 100644
--- a/src/libraries/System.Diagnostics.Process/tests/System.Diagnostics.Process.Tests.csproj
+++ b/src/libraries/System.Diagnostics.Process/tests/System.Diagnostics.Process.Tests.csproj
@@ -5,6 +5,7 @@
true
$(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-Browser
true
+ true
true
true
$(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-Browser
+ true
diff --git a/src/libraries/System.Management/src/System.Management.csproj b/src/libraries/System.Management/src/System.Management.csproj
index 3078de74ffc79..a90719285f052 100644
--- a/src/libraries/System.Management/src/System.Management.csproj
+++ b/src/libraries/System.Management/src/System.Management.csproj
@@ -2,6 +2,10 @@
true
$(NoWarn);0618
+
+ $(NoWarn);CA1845
+ annotations
true
$(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent);$(NetCoreAppMinimum)-windows;$(NetCoreAppMinimum);netstandard2.0
true
@@ -70,9 +74,11 @@ System.Management.SelectQuery
+
+
diff --git a/src/libraries/System.Reflection.Metadata/tests/System.Reflection.Metadata.Tests.csproj b/src/libraries/System.Reflection.Metadata/tests/System.Reflection.Metadata.Tests.csproj
index 7138184f5bd94..df738508c902d 100644
--- a/src/libraries/System.Reflection.Metadata/tests/System.Reflection.Metadata.Tests.csproj
+++ b/src/libraries/System.Reflection.Metadata/tests/System.Reflection.Metadata.Tests.csproj
@@ -4,6 +4,7 @@
false
436
$(NetCoreAppCurrent);$(NetFrameworkMinimum)
+ true