Skip to content

Commit cd8d6fe

Browse files
committed
Use DllImportGenerator in System.Diagnostics.PerformanceCounter
1 parent 6d5f59b commit cd8d6fe

30 files changed

+79
-56
lines changed

eng/generators.targets

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
and '$(IsFrameworkSupportFacade)' != 'true'
3333
and '$(IsSourceProject)' == 'true'
3434
and '$(MSBuildProjectExtension)' == '.csproj'
35-
and '$(TargetFrameworkIdentifier)' == '.NETStandard'" />
35+
and ('$(TargetFrameworkIdentifier)' == '.NETStandard' or '$(TargetFrameworkIdentifier)' == '.NETFramework')" />
3636
</ItemGroup>
3737

3838
<!-- Use this complex ItemGroup-based filtering to add the ProjectReference to make sure dotnet/runtime stays compatible with NuGet Static Graph Restore. -->

src/libraries/Common/src/Interop/Windows/Advapi32/Interop.ConvertStringSecurityDescriptorToSecurityDescriptor.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ internal static partial class Interop
99
{
1010
internal static partial class Advapi32
1111
{
12-
[DllImport(Interop.Libraries.Advapi32, CharSet = CharSet.Unicode, SetLastError = true, BestFitMapping = false)]
13-
internal static extern bool ConvertStringSecurityDescriptorToSecurityDescriptor(
14-
string StringSecurityDescriptor,
15-
int StringSDRevision,
16-
out SafeLocalAllocHandle pSecurityDescriptor,
17-
IntPtr SecurityDescriptorSize);
12+
[GeneratedDllImport(Interop.Libraries.Advapi32, CharSet = CharSet.Unicode, SetLastError = true)]
13+
internal static partial bool ConvertStringSecurityDescriptorToSecurityDescriptor(
14+
string StringSecurityDescriptor,
15+
int StringSDRevision,
16+
out SafeLocalAllocHandle pSecurityDescriptor,
17+
IntPtr SecurityDescriptorSize);
1818
}
1919
}

src/libraries/Common/src/Interop/Windows/Advapi32/Interop.GetSecurityDescriptorLength.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ internal static partial class Interop
88
{
99
internal static partial class Advapi32
1010
{
11-
[DllImport(Interop.Libraries.Advapi32, EntryPoint = "GetSecurityDescriptorLength", CallingConvention = CallingConvention.Winapi,
12-
CharSet = CharSet.Unicode, ExactSpelling = true)]
13-
internal static extern /*DWORD*/ uint GetSecurityDescriptorLength(IntPtr byteArray);
11+
[GeneratedDllImport(Libraries.Advapi32, EntryPoint = "GetSecurityDescriptorLength", CharSet = CharSet.Unicode, ExactSpelling = true)]
12+
internal static partial uint GetSecurityDescriptorLength(IntPtr byteArray);
1413
}
1514
}

src/libraries/Common/src/Interop/Windows/Advapi32/Interop.LsaNtStatusToWinError.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ internal static partial class Interop
88
{
99
internal static partial class Advapi32
1010
{
11-
[DllImport(Interop.Libraries.Advapi32, SetLastError = false)]
12-
internal static extern uint LsaNtStatusToWinError(uint status);
11+
[GeneratedDllImport(Interop.Libraries.Advapi32, SetLastError = false)]
12+
internal static partial uint LsaNtStatusToWinError(uint status);
1313
}
1414
}

src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegCloseKey.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ internal static partial class Interop
88
{
99
internal static partial class Advapi32
1010
{
11-
[DllImport(Libraries.Advapi32)]
12-
internal static extern int RegCloseKey(IntPtr hKey);
11+
[GeneratedDllImport(Libraries.Advapi32)]
12+
internal static partial int RegCloseKey(IntPtr hKey);
1313
}
1414
}

src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegEnumKeyEx.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ internal static partial class Interop
1212
{
1313
internal static partial class Advapi32
1414
{
15-
[DllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, BestFitMapping = false, EntryPoint = "RegEnumKeyExW", ExactSpelling = true)]
16-
internal static extern int RegEnumKeyEx(
15+
[GeneratedDllImport(Libraries.Advapi32, EntryPoint = "RegEnumKeyExW", CharSet = CharSet.Unicode, ExactSpelling = true)]
16+
internal static partial int RegEnumKeyEx(
1717
SafeRegistryHandle hKey,
1818
int dwIndex,
1919
char[] lpName,

src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegEnumValue.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ internal static partial class Interop
1313
{
1414
internal static partial class Advapi32
1515
{
16-
[DllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, BestFitMapping = false, EntryPoint = "RegEnumValueW", ExactSpelling = true)]
17-
internal static extern int RegEnumValue(
16+
[GeneratedDllImport(Libraries.Advapi32, EntryPoint = "RegEnumValueW", CharSet = CharSet.Unicode, ExactSpelling = true)]
17+
internal static partial int RegEnumValue(
1818
SafeRegistryHandle hKey,
1919
int dwIndex,
2020
char[] lpValueName,

src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegQueryInfoKey.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ internal static partial class Interop
1414
{
1515
internal static partial class Advapi32
1616
{
17-
[DllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, BestFitMapping = false, EntryPoint = "RegQueryInfoKeyW")]
18-
internal static extern int RegQueryInfoKey(
17+
[GeneratedDllImport(Libraries.Advapi32, EntryPoint = "RegQueryInfoKeyW", CharSet = CharSet.Unicode, ExactSpelling = true)]
18+
internal static partial int RegQueryInfoKey(
1919
SafeRegistryHandle hKey,
2020
[Out] char[]? lpClass,
2121
int[]? lpcbClass,

src/libraries/Common/src/Interop/Windows/Advapi32/Interop.RegQueryValueEx.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,35 +13,35 @@ internal static partial class Interop
1313
{
1414
internal static partial class Advapi32
1515
{
16-
[DllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, BestFitMapping = false, EntryPoint = "RegQueryValueExW", ExactSpelling = true)]
17-
internal static extern int RegQueryValueEx(
16+
[GeneratedDllImport(Libraries.Advapi32, EntryPoint = "RegQueryValueExW", CharSet = CharSet.Unicode, ExactSpelling = true)]
17+
internal static partial int RegQueryValueEx(
1818
SafeRegistryHandle hKey,
1919
string? lpValueName,
2020
int[]? lpReserved,
2121
ref int lpType,
22-
[Out] byte[]? lpData,
22+
byte[]? lpData,
2323
ref int lpcbData);
2424

25-
[DllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, BestFitMapping = false, EntryPoint = "RegQueryValueExW", ExactSpelling = true)]
26-
internal static extern int RegQueryValueEx(
25+
[GeneratedDllImport(Libraries.Advapi32, EntryPoint = "RegQueryValueExW", CharSet = CharSet.Unicode, ExactSpelling = true)]
26+
internal static partial int RegQueryValueEx(
2727
SafeRegistryHandle hKey,
2828
string? lpValueName,
2929
int[]? lpReserved,
3030
ref int lpType,
3131
ref int lpData,
3232
ref int lpcbData);
3333

34-
[DllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, BestFitMapping = false, EntryPoint = "RegQueryValueExW", ExactSpelling = true)]
35-
internal static extern int RegQueryValueEx(
34+
[GeneratedDllImport(Libraries.Advapi32, EntryPoint = "RegQueryValueExW", CharSet = CharSet.Unicode, ExactSpelling = true)]
35+
internal static partial int RegQueryValueEx(
3636
SafeRegistryHandle hKey,
3737
string? lpValueName,
3838
int[]? lpReserved,
3939
ref int lpType,
4040
ref long lpData,
4141
ref int lpcbData);
4242

43-
[DllImport(Libraries.Advapi32, CharSet = CharSet.Unicode, BestFitMapping = false, EntryPoint = "RegQueryValueExW", ExactSpelling = true)]
44-
internal static extern int RegQueryValueEx(
43+
[GeneratedDllImport(Libraries.Advapi32, EntryPoint = "RegQueryValueExW", CharSet = CharSet.Unicode, ExactSpelling = true)]
44+
internal static partial int RegQueryValueEx(
4545
SafeRegistryHandle hKey,
4646
string? lpValueName,
4747
int[]? lpReserved,

src/libraries/Common/src/Interop/Windows/Kernel32/Interop.FreeLibrary.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ internal static partial class Interop
88
{
99
internal static partial class Kernel32
1010
{
11-
[DllImport(Libraries.Kernel32, ExactSpelling = true, SetLastError = true)]
12-
internal static extern bool FreeLibrary(IntPtr hModule);
11+
[GeneratedDllImport(Libraries.Kernel32, ExactSpelling = true, SetLastError = true)]
12+
internal static partial bool FreeLibrary(IntPtr hModule);
1313
}
1414
}

0 commit comments

Comments
 (0)