Skip to content

Commit 20f0b6e

Browse files
authored
Replace DllImport with LibraryImport in SMA 8 (PowerShell#18599)
1 parent 5b4a34f commit 20f0b6e

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright (c) Microsoft Corporation.
2+
// Licensed under the MIT License.
3+
4+
#nullable enable
5+
6+
#if !UNIX
7+
using System.Runtime.InteropServices;
8+
9+
internal static partial class Interop
10+
{
11+
internal static partial class Windows
12+
{
13+
[LibraryImport("api-ms-win-core-processthreads-l1-1-0.dll")]
14+
internal static partial uint GetCurrentThreadId();
15+
}
16+
}
17+
#endif

src/System.Management.Automation/utils/PsUtils.cs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -105,16 +105,10 @@ internal static uint GetNativeThreadId()
105105
#if UNIX
106106
return Platform.NonWindowsGetThreadId();
107107
#else
108-
return NativeMethods.GetCurrentThreadId();
108+
return Interop.Windows.GetCurrentThreadId();
109109
#endif
110110
}
111111

112-
private static class NativeMethods
113-
{
114-
[DllImport(PinvokeDllNames.GetCurrentThreadIdDllName)]
115-
internal static extern uint GetCurrentThreadId();
116-
}
117-
118112
#region ASTUtils
119113

120114
/// <summary>

0 commit comments

Comments
 (0)