mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
Replace DllImport with LibraryImport in SMA 6 (#18581)
This commit is contained in:
@@ -280,7 +280,7 @@ namespace System.Management.Automation
|
||||
{
|
||||
for (int i = 0; i < argCount; i++)
|
||||
{
|
||||
VariantClear(variantArgArray + s_variantSize * i);
|
||||
Interop.Windows.VariantClear(variantArgArray + s_variantSize * i);
|
||||
}
|
||||
|
||||
Marshal.FreeCoTaskMem(variantArgArray);
|
||||
@@ -297,7 +297,7 @@ namespace System.Management.Automation
|
||||
{
|
||||
for (int i = 0; i < refCount; i++)
|
||||
{
|
||||
VariantClear(tmpVariants + s_variantSize * i);
|
||||
Interop.Windows.VariantClear(tmpVariants + s_variantSize * i);
|
||||
}
|
||||
|
||||
Marshal.FreeCoTaskMem(tmpVariants);
|
||||
@@ -305,13 +305,6 @@ namespace System.Management.Automation
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clear variables of type VARIANTARG (or VARIANT) before the memory containing the VARIANTARG is freed.
|
||||
/// </summary>
|
||||
/// <param name="pVariant"></param>
|
||||
[DllImport("oleaut32.dll")]
|
||||
internal static extern void VariantClear(IntPtr pVariant);
|
||||
|
||||
/// <summary>
|
||||
/// We have to declare 'bstrSource', 'bstrDescription' and 'bstrHelpFile' as pointers because
|
||||
/// CLR marshalling layer would try to free those BSTRs by default and that is not correct.
|
||||
|
||||
@@ -276,9 +276,6 @@ namespace System.Management.Automation.InteropServices
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport("oleaut32.dll")]
|
||||
internal static extern void VariantClear(IntPtr variant);
|
||||
|
||||
/// <summary>
|
||||
/// Release any unmanaged memory associated with the Variant
|
||||
/// </summary>
|
||||
@@ -306,7 +303,7 @@ namespace System.Management.Automation.InteropServices
|
||||
{
|
||||
fixed (void* pThis = &this)
|
||||
{
|
||||
VariantClear((IntPtr)pThis);
|
||||
Interop.Windows.VariantClear((nint)pThis);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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("oleaut32.dll")]
|
||||
internal static partial void VariantClear(nint pVariant);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
Reference in New Issue
Block a user