From cd8d6fe7a93e50c062ab3eec4c3d053d1d6ed33c Mon Sep 17 00:00:00 2001 From: Elinor Fung Date: Tue, 9 Nov 2021 17:04:39 -0800 Subject: [PATCH 1/4] Use DllImportGenerator in System.Diagnostics.PerformanceCounter --- eng/generators.targets | 2 +- ...ngSecurityDescriptorToSecurityDescriptor.cs | 12 ++++++------ .../Interop.GetSecurityDescriptorLength.cs | 5 ++--- .../Advapi32/Interop.LsaNtStatusToWinError.cs | 4 ++-- .../Windows/Advapi32/Interop.RegCloseKey.cs | 4 ++-- .../Windows/Advapi32/Interop.RegEnumKeyEx.cs | 4 ++-- .../Windows/Advapi32/Interop.RegEnumValue.cs | 4 ++-- .../Advapi32/Interop.RegQueryInfoKey.cs | 4 ++-- .../Advapi32/Interop.RegQueryValueEx.cs | 18 +++++++++--------- .../Windows/Kernel32/Interop.FreeLibrary.cs | 4 ++-- .../Kernel32/Interop.GetComputerName.cs | 4 ++-- .../Kernel32/Interop.GetCurrentProcess.cs | 4 ++-- .../Kernel32/Interop.GetCurrentProcessId.cs | 4 ++-- .../Kernel32/Interop.GetCurrentThread.cs | 4 ++-- .../Windows/Kernel32/Interop.LoadLibrary.cs | 4 ++-- .../Kernel32/Interop.WaitForSingleObject.cs | 4 ++-- .../Pdh/Interop.PdhFormatFromRawValue.cs | 4 ++-- .../PerfCounter/Interop.PerformanceData.cs | 18 ++++++++++-------- .../Interop.LsaDeregisterLogonProcess.cs | 4 ++-- .../Interop/Windows/SspiCli/Interop.SSPI.cs | 2 +- .../Runtime/InteropServices/ArrayMarshaller.cs | 2 ++ .../GeneratedMarshallingAttribute.cs | 2 ++ .../tests/TestUtilities/TestUtilities.csproj | 1 + .../src/Microsoft.Win32.SystemEvents.csproj | 2 ++ .../src/System.Diagnostics.EventLog.csproj | 6 ++++++ .../System.Diagnostics.EventLog.Tests.csproj | 1 + ...ystem.Diagnostics.PerformanceCounter.csproj | 1 + .../System.Diagnostics.Process.Tests.csproj | 1 + .../src/System.Management.csproj | 5 +++++ .../System.Reflection.Metadata.Tests.csproj | 1 + 30 files changed, 79 insertions(+), 56 deletions(-) diff --git a/eng/generators.targets b/eng/generators.targets index 757a91ac9d90c3..53a0286da7e36f 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 1cda9c2b583044..eb87d49e0fdbf6 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 e94bd4b0f18c25..854c2c6055aed6 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.LsaNtStatusToWinError.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.LsaNtStatusToWinError.cs index 524600d62ce89c..2da367aababc35 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 5d27b90afa963c..23bc17bad23ccf 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.RegEnumKeyEx.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegEnumKeyEx.cs index cf24e641938356..05c6919b2f8449 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegEnumKeyEx.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegEnumKeyEx.cs @@ -12,8 +12,8 @@ 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, 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 39543b22494952..21478308289506 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegEnumValue.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegEnumValue.cs @@ -13,8 +13,8 @@ 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, 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 6870d0d45e94f8..1bcc4ef2ddb255 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 f05122613da04b..3ee7567b873fce 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.FreeLibrary.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.FreeLibrary.cs index 7863e2417e0033..9d8e18219c9d9e 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 e186ac2be5725c..d82305b7f992e2 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 3f7482f5385a6b..89f04ad9ff0806 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 70009c6f932359..be0fd40730358e 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 cefb82cbd3fbbd..73d33398d5a0fb 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.LoadLibrary.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.LoadLibrary.cs index a65062ad682b14..93f0bedf5432c0 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.WaitForSingleObject.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.WaitForSingleObject.cs index 2a81da9a5a1c86..5f3f964a60a425 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 11a1556a5230d3..b9ab8b10d0976f 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 5b95bd08795a6f..ce978ad6fab1aa 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 352d7763ea5180..8cc158ef64570d 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 cc4ee4b7b59042..c22ae17d4edb46 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/src/System/Runtime/InteropServices/ArrayMarshaller.cs b/src/libraries/Common/src/System/Runtime/InteropServices/ArrayMarshaller.cs index 2293743aa87fe0..3828364dcb0b94 100644 --- a/src/libraries/Common/src/System/Runtime/InteropServices/ArrayMarshaller.cs +++ b/src/libraries/Common/src/System/Runtime/InteropServices/ArrayMarshaller.cs @@ -1,6 +1,8 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +#nullable enable + // // Types in this file are used for generated p/invokes (docs/design/features/source-generator-pinvokes.md). // See the DllImportGenerator experiment in https://github.com/dotnet/runtimelab. diff --git a/src/libraries/Common/src/System/Runtime/InteropServices/GeneratedMarshallingAttribute.cs b/src/libraries/Common/src/System/Runtime/InteropServices/GeneratedMarshallingAttribute.cs index 2fc73b41e3cb8d..d27ed6f642322f 100644 --- a/src/libraries/Common/src/System/Runtime/InteropServices/GeneratedMarshallingAttribute.cs +++ b/src/libraries/Common/src/System/Runtime/InteropServices/GeneratedMarshallingAttribute.cs @@ -1,6 +1,8 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +#nullable enable + // // Types in this file are used for generated p/invokes (docs/design/features/source-generator-pinvokes.md). // See the DllImportGenerator experiment in https://github.com/dotnet/runtimelab. diff --git a/src/libraries/Common/tests/TestUtilities/TestUtilities.csproj b/src/libraries/Common/tests/TestUtilities/TestUtilities.csproj index e46ba8375110ed..ecb7f715559ff9 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 33c1953ecdcd5a..90fc2965d9c0aa 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,10 @@ true $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent);$(NetCoreAppMinimum)-windows;$(NetCoreAppMinimum);netstandard2.0;$(NetFrameworkMinimum) $(NoWarn);CA1838;CA1847 + + $(NoWarn);CA1845;CA1846 true Provides the System.Diagnostics.EventLog class, which allows the applications to use the windows event log service. @@ -125,8 +129,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 a1bc84d9c3958a..a03f4dea580489 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 dfb057725b8020..9652a9a7bb0849 100644 --- a/src/libraries/System.Diagnostics.PerformanceCounter/src/System.Diagnostics.PerformanceCounter.csproj +++ b/src/libraries/System.Diagnostics.PerformanceCounter/src/System.Diagnostics.PerformanceCounter.csproj @@ -144,6 +144,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 bfcfb2cc3b71ca..783e4ad21e9c70 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 $(NoWarn);0618 + + $(NoWarn);CA1845 true $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent);$(NetCoreAppMinimum)-windows;$(NetCoreAppMinimum);netstandard2.0 true @@ -70,9 +73,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 7138184f5bd94e..df738508c902d8 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 Date: Tue, 9 Nov 2021 18:02:50 -0800 Subject: [PATCH 2/4] Remove ifdefs --- .../Advapi32/Interop.GetTokenInformation.cs | 17 +---------------- .../Advapi32/Interop.RegConnectRegistry.cs | 5 ----- .../Kernel32/Interop.CreateFileMapping.cs | 14 ++------------ .../Interop.DuplicateHandle_SafeWaitHandle.cs | 5 ----- .../Windows/Kernel32/Interop.GetProcessTimes.cs | 5 ----- .../Windows/Kernel32/Interop.MapViewOfFile.cs | 5 ----- .../Windows/Kernel32/Interop.OpenFileMapping.cs | 7 +------ .../Windows/Kernel32/Interop.OpenProcess.cs | 5 ----- .../Windows/Kernel32/Interop.UnmapViewOfFile.cs | 5 ----- .../Windows/Kernel32/Interop.VirtualQuery.cs | 5 ----- .../System.IO.MemoryMappedFiles.Tests.csproj | 1 + 11 files changed, 5 insertions(+), 69 deletions(-) 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 d881a59ac0551f..22ee2407525e21 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.RegConnectRegistry.cs b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegConnectRegistry.cs index 83206d9f75ced3..4d0fbbb415c1de 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/Kernel32/Interop.CreateFileMapping.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.CreateFileMapping.cs index 81ffec311fbc64..ba3f74ac8fd1c9 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 f68f28bc1eadc6..69dc66c54ff861 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.GetProcessTimes.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.GetProcessTimes.cs index e76f80712ba4ab..dc019f330d8712 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.MapViewOfFile.cs b/src/libraries/Common/src/Interop/Windows/Kernel32/Interop.MapViewOfFile.cs index 764a6ad8080a9d..ed29c33acca486 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 6ac60a8fa558fd..08ce6fc8917d5a 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 2eaa7a9e5f5971..2cd405129dbf93 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 dd519a7f1f87f5..4f41d03faba169 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 9ede606895a455..1dd2029a5f57fa 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/System.IO.MemoryMappedFiles/tests/System.IO.MemoryMappedFiles.Tests.csproj b/src/libraries/System.IO.MemoryMappedFiles/tests/System.IO.MemoryMappedFiles.Tests.csproj index 81fe94cf1e975a..9d75e10c13bd6c 100644 --- a/src/libraries/System.IO.MemoryMappedFiles/tests/System.IO.MemoryMappedFiles.Tests.csproj +++ b/src/libraries/System.IO.MemoryMappedFiles/tests/System.IO.MemoryMappedFiles.Tests.csproj @@ -3,6 +3,7 @@ true true $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent)-Unix;$(NetCoreAppCurrent)-Browser + true From fa10cbbfad603754f48b210d7c46be3934fbfa5c Mon Sep 17 00:00:00 2001 From: Elinor Fung Date: Tue, 9 Nov 2021 20:32:24 -0800 Subject: [PATCH 3/4] Use annotations --- .../src/System/Runtime/InteropServices/ArrayMarshaller.cs | 2 -- .../Runtime/InteropServices/GeneratedMarshallingAttribute.cs | 2 -- .../src/System.Diagnostics.EventLog.csproj | 1 + .../src/System.Diagnostics.PerformanceCounter.csproj | 1 + src/libraries/System.Management/src/System.Management.csproj | 1 + 5 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/libraries/Common/src/System/Runtime/InteropServices/ArrayMarshaller.cs b/src/libraries/Common/src/System/Runtime/InteropServices/ArrayMarshaller.cs index 3828364dcb0b94..2293743aa87fe0 100644 --- a/src/libraries/Common/src/System/Runtime/InteropServices/ArrayMarshaller.cs +++ b/src/libraries/Common/src/System/Runtime/InteropServices/ArrayMarshaller.cs @@ -1,8 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -#nullable enable - // // Types in this file are used for generated p/invokes (docs/design/features/source-generator-pinvokes.md). // See the DllImportGenerator experiment in https://github.com/dotnet/runtimelab. diff --git a/src/libraries/Common/src/System/Runtime/InteropServices/GeneratedMarshallingAttribute.cs b/src/libraries/Common/src/System/Runtime/InteropServices/GeneratedMarshallingAttribute.cs index d27ed6f642322f..2fc73b41e3cb8d 100644 --- a/src/libraries/Common/src/System/Runtime/InteropServices/GeneratedMarshallingAttribute.cs +++ b/src/libraries/Common/src/System/Runtime/InteropServices/GeneratedMarshallingAttribute.cs @@ -1,8 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -#nullable enable - // // Types in this file are used for generated p/invokes (docs/design/features/source-generator-pinvokes.md). // See the DllImportGenerator experiment in https://github.com/dotnet/runtimelab. 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 90fc2965d9c0aa..c6f39b3ddf8fe4 100644 --- a/src/libraries/System.Diagnostics.EventLog/src/System.Diagnostics.EventLog.csproj +++ b/src/libraries/System.Diagnostics.EventLog/src/System.Diagnostics.EventLog.csproj @@ -7,6 +7,7 @@ CA1845: Use span-based 'string.Concat' and 'AsSpan' instead of 'Substring' CA1846: Prefer 'AsSpan' over 'Substring' when span-based overloads are available --> $(NoWarn);CA1845;CA1846 + annotations true Provides the System.Diagnostics.EventLog class, which allows the applications to use the windows event log service. 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 9652a9a7bb0849..28133feec83ed6 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. diff --git a/src/libraries/System.Management/src/System.Management.csproj b/src/libraries/System.Management/src/System.Management.csproj index aea3d01841a237..a90719285f052b 100644 --- a/src/libraries/System.Management/src/System.Management.csproj +++ b/src/libraries/System.Management/src/System.Management.csproj @@ -5,6 +5,7 @@ $(NoWarn);CA1845 + annotations true $(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent);$(NetCoreAppMinimum)-windows;$(NetCoreAppMinimum);netstandard2.0 true From abcf4d8deece64a28a46be773c76af0d5a4419bf Mon Sep 17 00:00:00 2001 From: Elinor Fung Date: Tue, 9 Nov 2021 22:42:09 -0800 Subject: [PATCH 4/4] Fix RegEnum --- .../Common/src/Interop/Windows/Advapi32/Interop.RegEnumKeyEx.cs | 2 +- .../Common/src/Interop/Windows/Advapi32/Interop.RegEnumValue.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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 05c6919b2f8449..b5b2742c213e82 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegEnumKeyEx.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegEnumKeyEx.cs @@ -16,7 +16,7 @@ internal static partial class Advapi32 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 21478308289506..bb74b7b0cf8a1e 100644 --- a/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegEnumValue.cs +++ b/src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegEnumValue.cs @@ -17,7 +17,7 @@ internal static partial class Advapi32 internal static partial int RegEnumValue( SafeRegistryHandle hKey, int dwIndex, - char[] lpValueName, + [Out] char[] lpValueName, ref int lpcbValueName, IntPtr lpReserved_MustBeZero, int[]? lpType,