Skip to content

Commit

Permalink
Replace DllImport with LibraryImport in SMA 8 (PowerShell#18599)
Browse files Browse the repository at this point in the history
  • Loading branch information
iSazonov authored Nov 23, 2022
1 parent 5b4a34f commit 20f0b6e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

#nullable enable

#if !UNIX
using System.Runtime.InteropServices;

internal static partial class Interop
{
internal static partial class Windows
{
[LibraryImport("api-ms-win-core-processthreads-l1-1-0.dll")]
internal static partial uint GetCurrentThreadId();
}
}
#endif
8 changes: 1 addition & 7 deletions src/System.Management.Automation/utils/PsUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,16 +105,10 @@ internal static uint GetNativeThreadId()
#if UNIX
return Platform.NonWindowsGetThreadId();
#else
return NativeMethods.GetCurrentThreadId();
return Interop.Windows.GetCurrentThreadId();
#endif
}

private static class NativeMethods
{
[DllImport(PinvokeDllNames.GetCurrentThreadIdDllName)]
internal static extern uint GetCurrentThreadId();
}

#region ASTUtils

/// <summary>
Expand Down

0 comments on commit 20f0b6e

Please sign in to comment.